Skip to content

Commit

Permalink
fix nil deref
Browse files Browse the repository at this point in the history
  • Loading branch information
jvinnedge committed Aug 7, 2024
1 parent ced0e48 commit f31ef9c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ func main() {
}

serverUrl, err := url.Parse(*serverAddr)
if serverUrl.Scheme == "https" && err == nil {
//websocket https connection
tlsConfig.ServerName = serverUrl.Hostname()
if err != nil && serverUrl != nil {
if serverUrl.Scheme == "https" {
//websocket https connection
tlsConfig.ServerName = serverUrl.Hostname()
}
} else {
//direct connection. try to parse as host:port
host, _, err := net.SplitHostPort(*serverAddr)
Expand All @@ -120,7 +122,7 @@ func main() {

for {
var err error
if serverUrl.Scheme == "https" {
if serverUrl != nil && serverUrl.Scheme == "https" {
*serverAddr = strings.Replace(*serverAddr, "https://", "wss://", 1)
//websocket
err = wsconnect(&tlsConfig, *serverAddr, *socksProxy, *userAgent)
Expand Down

0 comments on commit f31ef9c

Please sign in to comment.