Skip to main content

Proxy Management

Proxies attach per-client. Add / remove from the global pool, then redistribute across spawned clients with distributeProxies(limit). Default kind is SOCKS5 — keys are either "ip:port" (no auth) or "ip:port:user:pass" (with auth).

addProxy("ip:port") -- no auth
addProxy("ip:port:user:pass") -- with auth
removeProxy("ip:port")
getProxies()
distributeProxies(3) -- redistribute, max 3 clients per proxy

Proxy shape

getProxies() returns a 1-indexed list of these. Read-only from Lua's perspective; use setProxyEnabled / setProxyMaxBots to mutate.

FieldTypeNotes
keystringLookup key. Same shape as the string passed to addProxy() — 4-segment when auth is set, 2-segment otherwise.
infoProxyInfoEndpoint half (ip / port / user). Pull info.user to display without exposing the password.
passstring?Auth password. nil for unauthenticated proxies. Don't log this — it round-trips through the Lua API in plaintext.
enabledbooleanWhether the registry will route bots through this proxy.
maxBotsnumberMax bots that can claim this proxy at once. 0 = unbounded.
max_botsnumberSnake-case alias of maxBots. Both expose the same value.

ProxyInfo shape

The info field of a Proxy — host/port/user pulled out so they can be inspected without bringing the password along.

FieldTypeNotes
ipstringHostname or IPv4 address of the proxy server.
portnumberTCP port. SOCKS5 default is 1080.
userstring?Auth username. nil for unauthenticated proxies.

Globals

addProxy(key)

FieldType
Signature(key: string) → boolean
Returnstrue on success
Common errorsraises on a malformed key ("expected 'ip:port' or 'ip:port:user:pass'", "invalid port")
Asyncno

Defaults the kind to SOCKS5.

addProxy("1.2.3.4:1080")
addProxy("1.2.3.4:1080:alice:hunter2")

removeProxy(key)

FieldType
Signature(key: string) → boolean
Returnsbooleantrue if the key matched an existing entry, false otherwise
Common errorsraises on a malformed key
Asyncno
removeProxy("1.2.3.4:1080:alice:hunter2")

getProxies()

FieldType
Signature() → {Proxy}
Returns{Proxy} — 1-indexed list of every registered proxy
Asyncno
for i, proxy in ipairs(getProxies()) do
print(proxy.key, proxy.enabled, proxy.maxBots)
print(" ", proxy.info.ip, proxy.info.port, proxy.info.user)
end

distributeProxies(limit)

FieldType
Signature(limit: number) → number
Returnsnumber — count of bots that got assigned a proxy
Asyncyes — yields while reading the bot list and updating per-bot proxy assignments

Round-robins every enabled proxy across the bot list, honoring limit as the per-proxy bot cap (also persisted onto each proxy's maxBots field). Pass 0 to clear every bot's proxy and zero the caps.

local n = distributeProxies(3)
print("assigned", n, "bots")

setProxyEnabled(key, enabled)

FieldType
Signature(key: string, enabled: boolean) → boolean
Returnsbooleantrue if the key matched an existing entry, false otherwise
Common errorsraises on a malformed key
Asyncno

Toggle whether the registry routes bots through key.

setProxyEnabled("1.2.3.4:1080", false) -- disable without removing

setProxyMaxBots(key, n)

FieldType
Signature(key: string, n: number) → boolean
Returnsbooleantrue if the key matched an existing entry, false otherwise
Common errorsraises on a malformed key
Asyncno

Set the per-proxy bot cap on key.

setProxyMaxBots("1.2.3.4:1080:alice:hunter2", 5) -- cap to 5 clients on this proxy

Iterate the live pool

for i, proxy in pairs(getProxies()) do
proxy.key -- "ip:port" or "ip:port:user:pass"
proxy.info.ip
proxy.info.port
proxy.info.user
proxy.pass
proxy.enabled -- skipped during distribution when false
proxy.maxBots -- per-proxy cap (0 = unlimited)
end