Skip to content

Commit

Permalink
Merge pull request #100 from jvinnedge/master
Browse files Browse the repository at this point in the history
fix nil deref on latest agent
  • Loading branch information
nicocha30 authored Aug 8, 2024
2 parents ced0e48 + c402549 commit 46c6413
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 46c6413

Please sign in to comment.