From fd213dd450096d37b9075d713bcc0f885cc69899 Mon Sep 17 00:00:00 2001 From: Philippe Beaulieu Date: Thu, 9 Apr 2020 09:18:50 -0400 Subject: [PATCH] added AllowedHosts configuration --- README.md | 3 ++- mailrelay.json | 1 + main.go | 13 +++++++------ server.go | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6b481f6..7fc0bdb 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ On local PC (192.168.1.54) create file `/etc/mailrelay.json` with contents: "smtp_username": "username@fastmail.com", "smtp_password": "secretAppPassword", "local_listen_ip": "0.0.0.0", - "local_listen_port": 2525 + "local_listen_port": 2525, + "allowed_hosts": ["*"] } ``` diff --git a/mailrelay.json b/mailrelay.json index 8f01bad..b2e82a0 100644 --- a/mailrelay.json +++ b/mailrelay.json @@ -5,4 +5,5 @@ "smtp_password": "secret_app_password", "local_listen_port": 2525, "local_listen_ip": "0.0.0.0" + "allowed_hosts": ["*"] } diff --git a/main.go b/main.go index 168c8a7..1d3d71e 100644 --- a/main.go +++ b/main.go @@ -15,12 +15,13 @@ type loggerLevels struct { } type mailRelayConfig struct { - SMTPServer string `json:"smtp_server"` - SMTPPort int `json:"smtp_port"` - SMTPUsername string `json:"smtp_username"` - SMTPPassword string `json:"smtp_password"` - LocalListenIP string `json:"local_listen_ip"` - LocalListenPort int `json:"local_listen_port"` + SMTPServer string `json:"smtp_server"` + SMTPPort int `json:"smtp_port"` + SMTPUsername string `json:"smtp_username"` + SMTPPassword string `json:"smtp_password"` + LocalListenIP string `json:"local_listen_ip"` + LocalListenPort int `json:"local_listen_port"` + AllowedHosts []string `json:"allowed_hosts"` } // Logger provides application logging. diff --git a/server.go b/server.go index 69beb58..e57af0e 100644 --- a/server.go +++ b/server.go @@ -14,7 +14,7 @@ func Start(appConfig *mailRelayConfig) (err error) { listen := fmt.Sprintf("%s:%d", appConfig.LocalListenIP, appConfig.LocalListenPort) - cfg := &guerrilla.AppConfig{LogFile: log.OutputStdout.String(), AllowedHosts: []string{"warpmail.net"}} + cfg := &guerrilla.AppConfig{LogFile: log.OutputStdout.String(), AllowedHosts: appConfig.AllowedHosts} sc := guerrilla.ServerConfig{ ListenInterface: listen, IsEnabled: true,