offsite 0.0.57 → 0.0.58
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.
|
@@ -111,13 +111,20 @@ const args = {
|
|
|
111
111
|
dir: path.resolve(options.dir),
|
|
112
112
|
command,
|
|
113
113
|
name,
|
|
114
|
-
connect: connect$1
|
|
114
|
+
connect: connect$1,
|
|
115
|
+
portGiven: program.getOptionValueSource("port") === "cli"
|
|
115
116
|
};
|
|
116
117
|
const serverDir = path.join(import.meta.dirname, "..");
|
|
117
118
|
// src/storage/storage.ts
|
|
118
119
|
const home = args.dir;
|
|
119
120
|
const lockFile = path.join(home, "server.pid");
|
|
121
|
+
const savedServer = z.object({ port: z.number() }).nullable();
|
|
120
122
|
mkdirSync(home, { recursive: true });
|
|
123
|
+
function listenPort() {
|
|
124
|
+
if (args.command !== "pair" || args.portGiven) return args.port;
|
|
125
|
+
const saved = readSettings("server.json", savedServer, null);
|
|
126
|
+
return saved === null ? args.port : saved.port;
|
|
127
|
+
}
|
|
121
128
|
function lockHome() {
|
|
122
129
|
lock();
|
|
123
130
|
process.on("exit", () => unlinkSync(lockFile));
|
|
@@ -7615,7 +7622,7 @@ const browseTypes = new Map([
|
|
|
7615
7622
|
[".ttf", "font/ttf"],
|
|
7616
7623
|
[".otf", "font/otf"]
|
|
7617
7624
|
]);
|
|
7618
|
-
const port = Number(
|
|
7625
|
+
const port = Number(listenPort());
|
|
7619
7626
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
7620
7627
|
console.error(`invalid port ${args.port}`);
|
|
7621
7628
|
process.exit(1);
|
|
@@ -7693,6 +7700,7 @@ if (args.auth) setInterval(() => {
|
|
|
7693
7700
|
for (const [ticket, item] of tickets) if (item.expiresAt <= Date.now()) tickets.delete(ticket);
|
|
7694
7701
|
}, UNPAIR_CHECK);
|
|
7695
7702
|
server.listen(port, args.host, () => {
|
|
7703
|
+
writeJson("server.json", { port });
|
|
7696
7704
|
startPush(`${args.host}:${port}`);
|
|
7697
7705
|
if (args.connect === null && args.pair && (code !== null || !args.auth)) {
|
|
7698
7706
|
const links = pairingLinks(code);
|