mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-04-02 08:58:08 +02:00
start: make http server's listening host/port compatible with IPv6 (#14)
previously, a command like this to listen on IPv6 loopback: HOST=::1 PORT=7447 go run ./basic/ would exit immediately because ::1:7447 is an invalid address. IPv6 addresses contain columns, so a simple host + port concatenation doesn't work. net.JoinHostPort is a function to do exactly that.
This commit is contained in:
parent
642710fda8
commit
932a9b62a7
3
start.go
3
start.go
@ -1,6 +1,7 @@
|
||||
package relayer
|
||||
|
||||
import (
|
||||
"net"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -72,7 +73,7 @@ func StartConf(s Settings, relay Relay) error {
|
||||
// start http server
|
||||
srv := &http.Server{
|
||||
Handler: cors.Default().Handler(Router),
|
||||
Addr: s.Host + ":" + s.Port,
|
||||
Addr: net.JoinHostPort(s.Host, s.Port),
|
||||
WriteTimeout: 2 * time.Second,
|
||||
ReadTimeout: 2 * time.Second,
|
||||
IdleTimeout: 30 * time.Second,
|
||||
|
Loading…
x
Reference in New Issue
Block a user