maxpool 1.24.37 → 1.24.38
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 +1 -1
- package/src/index.js +15 -9
- package/src/server.js +10 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1732,20 +1732,22 @@ async function poolCommand() {
|
|
|
1732
1732
|
console.error(' e.g. maxpool pool shared maxpool.tail-scale.ts.net:3456 mp-personal-key');
|
|
1733
1733
|
process.exit(1);
|
|
1734
1734
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1735
|
+
// atomicConfigUpdate, not load→save: a running local pool may rotate an OAuth
|
|
1736
|
+
// token in the same instant, and a whole-file save would undo that refresh.
|
|
1737
|
+
await atomicConfigUpdate(c => {
|
|
1738
|
+
c.client = { ...(c.client || {}), mode: 'shared', sharedHost: host, sharedKey: key };
|
|
1739
|
+
});
|
|
1739
1740
|
console.log(`This machine now points at the SHARED pool: http://${host}`);
|
|
1740
1741
|
console.log('Apply it in your shells (or restart terminals):');
|
|
1741
1742
|
console.log(` export ANTHROPIC_BASE_URL=http://${host}`);
|
|
1742
1743
|
console.log(` export ANTHROPIC_API_KEY=${key}`);
|
|
1743
1744
|
console.log('rc-gate users: also set RC_GATE_MAXPOOL_HOST/PORT/KEY in the LaunchAgent and restart it.');
|
|
1744
1745
|
} else if (sub === 'local') {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1746
|
+
await atomicConfigUpdate(c => {
|
|
1747
|
+
c.client = { ...(c.client || {}), mode: 'local' };
|
|
1748
|
+
delete c.client.sharedHost;
|
|
1749
|
+
delete c.client.sharedKey;
|
|
1750
|
+
});
|
|
1749
1751
|
console.log(`This machine points at its OWN local pool: http://${config.proxy.host || '127.0.0.1'}:${config.proxy.port}`);
|
|
1750
1752
|
console.log('Unset ANTHROPIC_BASE_URL/ANTHROPIC_API_KEY (or re-export the local ones) and restart terminals.');
|
|
1751
1753
|
} else if (sub === 'status') {
|
|
@@ -1774,15 +1776,19 @@ async function runCommand() {
|
|
|
1774
1776
|
// which the proxy accepts from localhost. Not setting ANTHROPIC_API_KEY
|
|
1775
1777
|
// lets Claude Code stay in subscription mode (full model access).
|
|
1776
1778
|
// Use spawnSync so the Node process blocks entirely — behaves like execvp.
|
|
1779
|
+
const shared = config.client?.mode === 'shared' && !!config.client?.sharedHost;
|
|
1777
1780
|
const result = spawnSync('claude', claudeArgs, {
|
|
1778
1781
|
stdio: 'inherit',
|
|
1779
1782
|
env: {
|
|
1780
1783
|
...process.env,
|
|
1781
1784
|
// Follows the `pool shared` switch like envCommand (client.mode 'shared'
|
|
1782
1785
|
// redirects run-subcommand traffic at the team pool).
|
|
1783
|
-
ANTHROPIC_BASE_URL:
|
|
1786
|
+
ANTHROPIC_BASE_URL: shared
|
|
1784
1787
|
? `http://${config.client.sharedHost}`
|
|
1785
1788
|
: `http://${config.proxy.host || '127.0.0.1'}:${config.proxy.port}`,
|
|
1789
|
+
// A shared pool trusts no address, so it needs the person's key; the local
|
|
1790
|
+
// pool keeps today's keyless subscription-mode behavior.
|
|
1791
|
+
...(shared && config.client.sharedKey ? { ANTHROPIC_API_KEY: config.client.sharedKey } : {}),
|
|
1786
1792
|
},
|
|
1787
1793
|
});
|
|
1788
1794
|
|
package/src/server.js
CHANGED
|
@@ -168,6 +168,9 @@ export function createProxyServer(accountManager, config, hooks = {}) {
|
|
|
168
168
|
? config.proxy.clients.filter(c => c && typeof c.key === 'string' && c.key)
|
|
169
169
|
: [];
|
|
170
170
|
const clientByKey = new Map(clientList.map(c => [c.key, c.name]));
|
|
171
|
+
// '0.0.0.0' stays in the trusted set for backward compatibility (a solo user who
|
|
172
|
+
// binds every interface keeps keyless local use); it is warned about at startup
|
|
173
|
+
// because it also exposes the pool to the network. Shared pools set `clients`.
|
|
171
174
|
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1', '0.0.0.0']);
|
|
172
175
|
const hostIsLoopback = (config.proxy?.host == null) || LOOPBACK_HOSTS.has(String(config.proxy.host).toLowerCase());
|
|
173
176
|
const strictClients = clientByKey.size > 0 || !hostIsLoopback;
|
|
@@ -186,6 +189,8 @@ export function createProxyServer(accountManager, config, hooks = {}) {
|
|
|
186
189
|
if (strictClients) {
|
|
187
190
|
const who = clientByKey.size > 0 ? `${clientByKey.size} named client${clientByKey.size > 1 ? 's' : ''}` : 'non-loopback listen host';
|
|
188
191
|
appendEventLog(`[Maxpool] Strict client auth ON (${who}; loopback bypass removed)`);
|
|
192
|
+
} else if (String(config.proxy?.host) === '0.0.0.0') {
|
|
193
|
+
appendEventLog('[Maxpool] WARNING: listening on every interface (0.0.0.0) with local callers trusted keyless — set proxy.clients to require a key from everyone');
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
if (logDir) {
|
|
@@ -269,8 +274,10 @@ export function createProxyServer(accountManager, config, hooks = {}) {
|
|
|
269
274
|
rejectUnauthorized();
|
|
270
275
|
return;
|
|
271
276
|
}
|
|
272
|
-
|
|
273
|
-
|
|
277
|
+
// In strict mode the legacy single key is still accepted; label it so its
|
|
278
|
+
// traffic is attributed and logged rather than anonymous.
|
|
279
|
+
req.callerName = caller.name || (strictClients ? 'legacy-key' : null);
|
|
280
|
+
accountManager.countRequest?.(req.callerName);
|
|
274
281
|
|
|
275
282
|
// Let client token refresh requests pass through to upstream untouched.
|
|
276
283
|
// The proxy manages its own tokens via ensureTokenFresh(); intercepting
|
|
@@ -304,6 +311,7 @@ export function createProxyServer(accountManager, config, hooks = {}) {
|
|
|
304
311
|
path: req.url,
|
|
305
312
|
account: ctx.account,
|
|
306
313
|
status: ctx.status,
|
|
314
|
+
caller: req.callerName || null,
|
|
307
315
|
});
|
|
308
316
|
}
|
|
309
317
|
return;
|