Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

Commit

Permalink
Make HTTP server host separately configurable (concerns #30)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesEbke committed Jan 13, 2017
1 parent 29d2c6a commit 547051c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,12 @@ func initGlobalServices(c *cli.Context) error {
return nil
}

func getHTTPHost(c *cli.Context) string {
httpHost := fmt.Sprintf("%v:%v", c.String("host"), c.Int("http-port"))
if c.Int("http-port") == 80 {
httpHost = c.String("host")
}
return httpHost
}

func runServers(c *cli.Context) {
httpHost := getHTTPHost(c)
httpHost := fmt.Sprintf("%v:%v", c.String("host"), c.Int("http-port"))
smtpInHost := fmt.Sprintf("%v:%v", c.String("host"), c.Int("smtp-in-port"))

log.Println("Setting up SMTP server listening at: ", smtpInHost)
go serveSMTPRequestReceiver(smtpInHost, httpHost)
go serveSMTPRequestReceiver(smtpInHost, c.String("external-http-host"))

log.Println("Setting up HTTP server listening at: ", httpHost)
log.Panic(serveNonceConfirmer(httpHost))
Expand All @@ -118,8 +110,7 @@ func processMailAction(c *cli.Context) error {
return err
}

httpHost := getHTTPHost(c)
processMail := getIncomingMailHandler(httpHost)
processMail := getIncomingMailHandler(c.String("external-http-host"))
processMail(inputMail)

return nil
Expand Down Expand Up @@ -247,6 +238,11 @@ func RunApp(args []string) {
Value: "openpgp-validation-server@server.local",
Usage: "`MAIL_FROM` of outgoing mails. This is NOT the FROM header of the mail.",
},
cli.StringFlag{
Name: "external-http-host",
Value: "localhost:8080",
Usage: "External HTTP host for the nonce validation",
},
},
privateKeyFlags...,
)
Expand Down

0 comments on commit 547051c

Please sign in to comment.