Commit f7aba437 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

fix: suppress warning that local IP could not be determined when local IP is not used

parent 4f091dfa
......@@ -13,6 +13,10 @@ import (
"github.com/sietseringers/viper"
)
var (
localIP, localIPErr = server.LocalIP()
)
var serverCmd = &cobra.Command{
Use: "server",
Short: "IRMA server for verifying and issuing attributes",
......@@ -67,13 +71,9 @@ func setFlags(cmd *cobra.Command, production bool) error {
flags.SortFlags = false
var defaulturl string
var err error
if !production {
defaulturl, err = server.LocalIP()
if err != nil {
logger.Warn("Could not determine local IP address: ", err.Error())
} else {
defaulturl = "http://" + defaulturl + ":port"
if localIP != "" {
defaulturl = "http://" + localIP + ":port"
}
}
......@@ -146,6 +146,10 @@ func setFlags(cmd *cobra.Command, production bool) error {
}
func configureServer(cmd *cobra.Command) (*requestorserver.Configuration, error) {
if localIPErr != nil {
logger.Warn("Could not determine local IP address: ", localIPErr.Error())
}
readConfig(cmd, "irmaserver", "irma server", []string{".", "/etc/irmaserver/", "$HOME/.irmaserver"},
map[string]interface{}{
"no-auth": false,
......
......@@ -238,6 +238,10 @@ func configureSession(cmd *cobra.Command) (irma.RequestorRequest, *irma.Configur
logger.Level = server.Verbosity(verbosity)
irma.SetLogger(logger)
if localIPErr != nil {
logger.Warn("Could not determine local IP address: ", localIPErr.Error())
}
return configureRequest(cmd)
}
......@@ -246,12 +250,8 @@ func init() {
logger.Formatter = &prefixed.TextFormatter{FullTimestamp: true}
var err error
defaulturl, err = server.LocalIP()
if err != nil {
logger.Warn("Could not determine local IP address: ", err.Error())
} else {
defaulturl = "http://" + defaulturl + ":port"
if localIP != "" {
defaulturl = "http://" + localIP + ":port"
}
flags := sessionCmd.Flags()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment