Skip to content

Commit 358a236

Browse files
committed
ncm: add more return values
1 parent 5ab7f4d commit 358a236

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

model/network_client_model.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,15 @@ type AuthNetworkClientError struct {
122122

123123
type ProxyConfigResult struct {
124124
KeepaliveSeconds int `json:"keepalive_seconds"`
125-
HttpsProxyUrl string `json:"https_proxy_url"`
126125
SocksProxyUrl string `json:"socks_proxy_url"`
126+
HttpProxyUrl string `json:"http_proxy_url"`
127+
HttpsProxyUrl string `json:"https_proxy_url"`
127128
AuthToken string `json:"auth_token"`
128129
InstanceId server.Id `json:"instance_id"`
130+
ProxyHost string `json:"proxy_host"`
131+
HttpProxyPort int `json:"http_proxy_port"`
132+
HttpsProxyPort int `json:"https_proxy_port"`
133+
SocksProxyPort int `json:"socks_proxy_port"`
129134
}
130135

131136
type ProxyAuthResult struct {
@@ -274,34 +279,46 @@ func AuthNetworkClient(
274279

275280
// FIXME pull the current avaiable far edges and use least recently used with a threshold
276281
socksProxyPort := 8080
282+
httpProxyPort := 8081
277283
httpsProxyPort := 8082
278284

279-
host := fmt.Sprintf("%s.%s", "cosmic", server.RequireDomain())
285+
proxyHost := fmt.Sprintf("%s.%s", "cosmic", server.RequireDomain())
286+
287+
socksProxyUrl := fmt.Sprintf("socks5h://%s:%d", proxyHost, socksProxyPort)
288+
289+
httpProxyUrl = fmt.Sprintf(
290+
"http://%s:%d",
291+
proxyHost,
292+
httpProxyPort,
293+
)
280294

281295
var httpsProxyUrl string
282296
if authClient.ProxyConfig.HttpsRequireAuth {
283297
// use the encoded proxy id for the url, since the signed proxy id will be passed in auth
284298
httpsProxyUrl = fmt.Sprintf(
285299
"https://%s:%d",
286-
host,
300+
proxyHost,
287301
httpsProxyPort,
288302
)
289303
} else {
290304
httpsProxyUrl = fmt.Sprintf(
291305
"https://%s.%s:%d",
292306
strings.ToLower(signedProxyId),
293-
host,
307+
proxyHost,
294308
httpsProxyPort,
295309
)
296310
}
297311

298-
socksProxyUrl := fmt.Sprintf("socks5h://%s:%d", host, socksProxyPort)
299-
300312
authClientResult.ProxyConfigResult = &ProxyConfigResult{
301-
HttpsProxyUrl: httpsProxyUrl,
302-
SocksProxyUrl: socksProxyUrl,
303-
AuthToken: strings.ToLower(signedProxyId),
304-
InstanceId: proxyDeviceConfig.InstanceId,
313+
SocksProxyUrl: socksProxyUrl,
314+
HttpProxyUrl: httpProxyUrl,
315+
HttpsProxyUrl: httpsProxyUrl,
316+
AuthToken: strings.ToLower(signedProxyId),
317+
InstanceId: proxyDeviceConfig.InstanceId,
318+
ProxyHost: proxyHost,
319+
SocksProxyPort: socksProxyPort,
320+
HttpProxyPort: httpProxyPort,
321+
HttpsProxyPort: httpsProxyPort,
305322
}
306323
} else {
307324
authClientResult.Error = &AuthNetworkClientError{

0 commit comments

Comments
 (0)