Skip to content

Commit

Permalink
chore: rename listen addr config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Nov 4, 2021
1 parent 06ef3f7 commit 2455bbb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ You can specify configuration options either via a config file (`config.yml`) or
|---------------------------|---------------------------|--------------|---------------------------------------------------------------------|
| `env` | `MW_ENV` | `dev` | Whether to use development- or production settings |
| `mail.domain` | `MW_MAIL_DOMAIN` | - | Default domain for sending mails |
| `web.listen_v4` | `MW_WEB_LISTEN_V4` | `127.0.0.1:3000` | IP and port for the web server to listen on |
| `web.listen_addr` | `MW_WEB_LISTEN_ADDR`| `127.0.0.1:3000` | IP and port for the web server to listen on (can be IPv4 or IPv6) |
| `web.cors_origin` | - | [`http://localhost:5000`] | List of URLs which to accept CORS requests for |
| `web.public_url` | `MW_PUBLIC_URL` | `http://localhost:3000` | The URL under which your MailWhale server is available from the public internet |
| `smtp.host` | `MW_SMTP_HOST` | - | SMTP relay host name or IP |
Expand Down
12 changes: 9 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ type smtpConfig struct {
}

type webConfig struct {
ListenV4 string `yaml:"listen_v4" default:"127.0.0.1:3000" env:"MW_WEB_LISTEN_V4"`
ListenV4 string `yaml:"listen_v4" env:"MW_WEB_LISTEN_V4"` // deprecated, use ListenAddr
ListenAddr string `yaml:"listen_addr" default:"127.0.0.1:3000" env:"MW_WEB_LISTEN_ADDR"`
CorsOrigins []string `yaml:"cors_origins" env:"MW_WEB_CORS_ORIGINS"`
PublicUrl string `yaml:"public_url" default:"http://localhost:3000" env:"MW_WEB_PUBLIC_URL"`
}
Expand Down Expand Up @@ -82,9 +83,14 @@ func Load() *Config {

config.Version = readVersion()

if config.Web.ListenV4 == "" {
logbuch.Fatal("config option 'listen4' must be specified")
if config.Web.ListenV4 != "" {
config.Web.ListenAddr = config.Web.ListenV4 // for backwards-compatbility
}

if config.Web.ListenAddr == "" {
logbuch.Fatal("config option 'listen_addr' must be specified")
}

if !config.Mail.SystemSender().Valid() {
logbuch.Fatal("system sender address is invalid")
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ func listen(handler http.Handler, config *conf.Config) {

s4 = &http.Server{
Handler: handler,
Addr: config.Web.ListenV4,
Addr: config.Web.ListenAddr,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
}

go func() {
logbuch.Info("web server started, listening on %s", config.Web.ListenV4)
logbuch.Info("web server started, listening on %s", config.Web.ListenAddr)
if err := s4.ListenAndServe(); err != nil {
logbuch.Fatal("failed to start web server: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.2
0.11.3

0 comments on commit 2455bbb

Please sign in to comment.