feature(server): allow to bind specific addresses (#263)

The main use case for ooniprobe is to bind 127.0.0.1 only.
This commit is contained in:
Simone Basso
2017-07-31 10:31:07 +02:00
committed by Bo-Yi Wu
parent 00ff0248a2
commit a714d03e2c
5 changed files with 14 additions and 6 deletions

View File

@@ -36,13 +36,13 @@ func RunHTTPServer() (err error) {
}
err = gracehttp.Serve(&http.Server{
Addr: ":" + PushConf.Core.Port,
Addr: PushConf.Core.Address + ":" + PushConf.Core.Port,
Handler: routerEngine(),
TLSConfig: config,
})
} else {
err = gracehttp.Serve(&http.Server{
Addr: ":" + PushConf.Core.Port,
Addr: PushConf.Core.Address + ":" + PushConf.Core.Port,
Handler: routerEngine(),
})
}

View File

@@ -17,9 +17,9 @@ func RunHTTPServer() (err error) {
s := autoTLSServer()
err = s.ListenAndServeTLS("", "")
} else if PushConf.Core.SSL && PushConf.Core.CertPath != "" && PushConf.Core.KeyPath != "" {
err = http.ListenAndServeTLS(":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath, routerEngine())
err = http.ListenAndServeTLS(PushConf.Core.Address+":"+PushConf.Core.Port, PushConf.Core.CertPath, PushConf.Core.KeyPath, routerEngine())
} else {
err = http.ListenAndServe(":"+PushConf.Core.Port, routerEngine())
err = http.ListenAndServe(PushConf.Core.Address+":"+PushConf.Core.Port, routerEngine())
}
return