mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
fix(macos): reject invalid gateway ports before tunnel setup (#128260)
This commit is contained in:
committed by
GitHub
parent
1d54ce376e
commit
bf91e00d36
@@ -122,12 +122,12 @@ enum GatewayEnvironment {
|
||||
{
|
||||
if let raw = environment["OPENCLAW_GATEWAY_PORT"] {
|
||||
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if let parsed = Int(trimmed), parsed > 0 { return parsed }
|
||||
if let parsed = Int(trimmed), (1...65535).contains(parsed) { return parsed }
|
||||
}
|
||||
if let configPort, configPort > 0 {
|
||||
if let configPort, (1...65535).contains(configPort) {
|
||||
return configPort
|
||||
}
|
||||
return storedPort > 0 ? storedPort : profile.defaultGatewayPort
|
||||
return (1...65535).contains(storedPort) ? storedPort : profile.defaultGatewayPort
|
||||
}
|
||||
|
||||
static func expectedGatewayVersion() -> Semver? {
|
||||
|
||||
@@ -124,6 +124,21 @@ struct GatewayEnvironmentTests {
|
||||
configPort: nil,
|
||||
storedPort: 23001,
|
||||
profile: work) == 23001)
|
||||
#expect(GatewayEnvironment.resolvedGatewayPort(
|
||||
environment: ["OPENCLAW_GATEWAY_PORT": "65536"],
|
||||
configPort: 22001,
|
||||
storedPort: 23001,
|
||||
profile: work) == 22001)
|
||||
#expect(GatewayEnvironment.resolvedGatewayPort(
|
||||
environment: [:],
|
||||
configPort: 65536,
|
||||
storedPort: 23001,
|
||||
profile: work) == 23001)
|
||||
#expect(GatewayEnvironment.resolvedGatewayPort(
|
||||
environment: [:],
|
||||
configPort: nil,
|
||||
storedPort: 65536,
|
||||
profile: work) == work.defaultGatewayPort)
|
||||
#expect(AppProfile(environment: [:]).defaultGatewayPort == 18789)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user