Skip to content

Commit

Permalink
Fix #157
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Apr 26, 2024
1 parent b90e37d commit fa32f93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 2 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,7 @@ func main() {

}

log.Println("connect back: ", connectBackAddress)

server.Run(listenAddress, dataDir, connectBackAddress, tlscert, tlskey, insecure, webserver, tls, openproxy, timeout)
}
23 changes: 7 additions & 16 deletions internal/server/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ func buildAndServe() http.HandlerFunc {
}

if linkExtension != "" {
log.Println("ext: ", linkExtension)

host, port := getHostnameAndPort(DefaultConnectBack)
host, port, err := net.SplitHostPort(DefaultConnectBack)
if err != nil {
host = DefaultConnectBack
port = "80"

log.Println("no port specified in external_address:", DefaultConnectBack, " defaulting to: ", DefaultConnectBack+":80")
}

output, err := shellscripts.MakeTemplate(shellscripts.Args{
OS: f.Goos,
Expand Down Expand Up @@ -144,17 +149,3 @@ func buildAndServe() http.HandlerFunc {
}
}
}

func getHostnameAndPort(address string) (host, port string) {
for i := len(address) - 1; i > 0; i-- {
if address[i] == ':' {
host = address[:i]
if i < len(address) {
port = address[i+1:]
}
return
}
}

return
}

0 comments on commit fa32f93

Please sign in to comment.