Will exit on port binding failure (#1635)

pull/1640/head
Glenn Wilkinson 2019-10-29 02:38:59 +00:00 committed by Jordan Wright
parent 3227437f52
commit 28252bcb56
2 changed files with 6 additions and 8 deletions

View File

@ -82,19 +82,18 @@ func WithContactAddress(addr string) PhishingServerOption {
}
// Start launches the phishing server, listening on the configured address.
func (ps *PhishingServer) Start() error {
func (ps *PhishingServer) Start() {
if ps.config.UseTLS {
err := util.CheckAndCreateSSL(ps.config.CertPath, ps.config.KeyPath)
if err != nil {
log.Fatal(err)
return err
}
log.Infof("Starting phishing server at https://%s", ps.config.ListenURL)
return ps.server.ListenAndServeTLS(ps.config.CertPath, ps.config.KeyPath)
log.Fatal(ps.server.ListenAndServeTLS(ps.config.CertPath, ps.config.KeyPath))
}
// If TLS isn't configured, just listen on HTTP
log.Infof("Starting phishing server at http://%s", ps.config.ListenURL)
return ps.server.ListenAndServe()
log.Fatal(ps.server.ListenAndServe())
}
// Shutdown attempts to gracefully shutdown the server.

View File

@ -65,7 +65,7 @@ func NewAdminServer(config config.AdminServer, options ...AdminServerOption) *Ad
}
// Start launches the admin server, listening on the configured address.
func (as *AdminServer) Start() error {
func (as *AdminServer) Start() {
if as.worker != nil {
go as.worker.Start()
}
@ -73,14 +73,13 @@ func (as *AdminServer) Start() error {
err := util.CheckAndCreateSSL(as.config.CertPath, as.config.KeyPath)
if err != nil {
log.Fatal(err)
return err
}
log.Infof("Starting admin server at https://%s", as.config.ListenURL)
return as.server.ListenAndServeTLS(as.config.CertPath, as.config.KeyPath)
log.Fatal(as.server.ListenAndServeTLS(as.config.CertPath, as.config.KeyPath))
}
// If TLS isn't configured, just listen on HTTP
log.Infof("Starting admin server at http://%s", as.config.ListenURL)
return as.server.ListenAndServe()
log.Fatal(as.server.ListenAndServe())
}
// Shutdown attempts to gracefully shutdown the server.