This commit is contained in:
wh1te909 2022-06-26 15:34:00 -07:00
parent aed33b9a95
commit 8d2511129c
8 changed files with 29 additions and 13 deletions

View file

@ -66,6 +66,9 @@ type Agent struct {
Platform string
GoArch string
ServiceConfig *service.Config
NatsServer string
NatsProxyPath string
NatsProxyPort string
}
const (
@ -139,6 +142,17 @@ func New(logger *logrus.Logger, version string) *Agent {
},
}
var natsProxyPath, natsProxyPort string
if ac.NatsProxyPath == "" {
natsProxyPath = "natsws"
}
if ac.NatsProxyPort == "" {
natsProxyPort = "443"
}
natsServer := fmt.Sprintf("wss://%s:%s", ac.APIURL, natsProxyPort)
return &Agent{
Hostname: info.Hostname,
BaseURL: ac.BaseURL,
@ -163,6 +177,9 @@ func New(logger *logrus.Logger, version string) *Agent {
Platform: runtime.GOOS,
GoArch: runtime.GOARCH,
ServiceConfig: svcConf,
NatsServer: natsServer,
NatsProxyPath: natsProxyPath,
NatsProxyPort: natsProxyPort,
}
}
@ -359,6 +376,7 @@ func (a *Agent) setupNatsOptions() []nats.Option {
opts = append(opts, nats.RetryOnFailedConnect(true))
opts = append(opts, nats.MaxReconnects(-1))
opts = append(opts, nats.ReconnectBufSize(-1))
opts = append(opts, nats.ProxyPath("natsws"))
return opts
}