sliftutils 1.4.8 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -86,14 +86,20 @@ type RemoteConfig = { url: string; password: string };
|
|
|
86
86
|
function remoteConfigKey() { return getFileAPIKey() + ":remote"; }
|
|
87
87
|
function loadRemoteConfig(): RemoteConfig | undefined {
|
|
88
88
|
try {
|
|
89
|
-
const
|
|
89
|
+
const key = remoteConfigKey();
|
|
90
|
+
const s = localStorage.getItem(key);
|
|
91
|
+
console.log("[remotecfg] load", JSON.stringify(key), "->", s);
|
|
90
92
|
if (!s) return undefined;
|
|
91
93
|
const c = JSON.parse(s);
|
|
92
94
|
if (c && typeof c.url === "string" && typeof c.password === "string") return c;
|
|
93
|
-
} catch {
|
|
95
|
+
} catch (e) { console.warn("[remotecfg] load error", e); }
|
|
94
96
|
return undefined;
|
|
95
97
|
}
|
|
96
|
-
function saveRemoteConfig(c: RemoteConfig) {
|
|
98
|
+
function saveRemoteConfig(c: RemoteConfig) {
|
|
99
|
+
const key = remoteConfigKey();
|
|
100
|
+
localStorage.setItem(key, JSON.stringify(c));
|
|
101
|
+
console.log("[remotecfg] saved", JSON.stringify(key), "readback ->", localStorage.getItem(key));
|
|
102
|
+
}
|
|
97
103
|
|
|
98
104
|
// The server is always HTTPS on the filehoster's default port, so the user only needs to type the host
|
|
99
105
|
// (e.g. "65.109.93.113"). We strip any scheme/path they include and default the port if omitted.
|
|
@@ -427,14 +427,18 @@ export async function runFileHoster(): Promise<void> {
|
|
|
427
427
|
let externalIP: string | undefined;
|
|
428
428
|
try { externalIP = (await getExternalIP()).trim(); } catch { /* offline / unreachable */ }
|
|
429
429
|
|
|
430
|
+
// What the user types into the app: just the host, plus ":port" only if it's not the default. No
|
|
431
|
+
// scheme — the app always uses https.
|
|
432
|
+
const host = externalIP || "localhost";
|
|
433
|
+
const appAddress = host + (info.port === 8787 ? "" : ":" + info.port);
|
|
434
|
+
const certUrl = "https://" + host + ":" + info.port;
|
|
430
435
|
console.log("");
|
|
431
436
|
console.log(" Serving: " + path.resolve(root));
|
|
432
437
|
console.log(" Password: " + info.password);
|
|
433
|
-
console.log("
|
|
434
|
-
if (externalIP) console.log(" Public: https://" + externalIP + ":" + info.port + " (once port-forwarding succeeds)");
|
|
438
|
+
console.log(" Address: " + appAddress + " <- in the app, choose \"Connect to a server\" and enter this");
|
|
435
439
|
console.log("");
|
|
436
|
-
console.log("
|
|
437
|
-
console.log("
|
|
440
|
+
console.log(" First time only: open " + certUrl + " in a browser once and accept the");
|
|
441
|
+
console.log(" self-signed certificate warning, then connect from the app.");
|
|
438
442
|
console.log("");
|
|
439
443
|
|
|
440
444
|
// Keep the UPnP port mapping alive — leases expire ~hourly, so refresh well within that. No-op on
|