mirror of
https://github.com/axllent/mailpit.git
synced 2025-04-27 12:32:22 +02:00
Display service listening IPs as 0.0.0.0 when set to default [::]
This commit is contained in:
parent
efc9c10f83
commit
84d3384120
@ -64,13 +64,12 @@ func Listen() {
|
|||||||
isReady.Store(true)
|
isReady.Store(true)
|
||||||
|
|
||||||
if config.UITLSCert != "" && config.UITLSKey != "" {
|
if config.UITLSCert != "" && config.UITLSKey != "" {
|
||||||
logger.Log().Infof("[http] starting secure server on https://%s%s", config.HTTPListen, config.Webroot)
|
logger.Log().Infof("[http] starting secure server on https://%s%s", logger.CleanIP(config.HTTPListen), config.Webroot)
|
||||||
logger.Log().Fatal(http.ListenAndServeTLS(config.HTTPListen, config.UITLSCert, config.UITLSKey, nil))
|
logger.Log().Fatal(http.ListenAndServeTLS(config.HTTPListen, config.UITLSCert, config.UITLSKey, nil))
|
||||||
} else {
|
} else {
|
||||||
logger.Log().Infof("[http] starting server on http://%s%s", config.HTTPListen, config.Webroot)
|
logger.Log().Infof("[http] starting server on http://%s%s", logger.CleanIP(config.HTTPListen), config.Webroot)
|
||||||
logger.Log().Fatal(http.ListenAndServe(config.HTTPListen, nil))
|
logger.Log().Fatal(http.ListenAndServe(config.HTTPListen, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultRoutes() *mux.Router {
|
func defaultRoutes() *mux.Router {
|
||||||
|
@ -71,7 +71,7 @@ func Listen() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Log().Infof("[smtp] starting on %s", config.SMTPListen)
|
logger.Log().Infof("[smtp] starting on %s", logger.CleanIP(config.SMTPListen))
|
||||||
|
|
||||||
return listenAndServe(config.SMTPListen, mailHandler, authHandler)
|
return listenAndServe(config.SMTPListen, mailHandler, authHandler)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Package logger handles the logging
|
||||||
package logger
|
package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/axllent/mailpit/config"
|
"github.com/axllent/mailpit/config"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -45,3 +47,14 @@ func PrettyPrint(i interface{}) {
|
|||||||
s, _ := json.MarshalIndent(i, "", "\t")
|
s, _ := json.MarshalIndent(i, "", "\t")
|
||||||
fmt.Println(string(s))
|
fmt.Println(string(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CleanIP returns a human-readable IP for the logging interface
|
||||||
|
// when starting services. It translates [::]:<port> to "localhost:<port>"
|
||||||
|
func CleanIP(s string) string {
|
||||||
|
re := regexp.MustCompile(`^\[\:\:\]\:\d+`)
|
||||||
|
if re.MatchString(s) {
|
||||||
|
return "0.0.0.0:" + s[5:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user