diff options
author | Nick Thomas <nick@bytemark.co.uk> | 2016-05-05 15:16:32 +0300 |
---|---|---|
committer | Nick Thomas <me@ur.gs> | 2016-09-09 01:56:37 +0300 |
commit | 33fca0976f95eac7ddce424080db9e381ec7388e (patch) | |
tree | b0879a1eba1b3be67ec867d1b8a3027b5f0e2168 /app.go | |
parent | 62b22d776ebf3115e0ed2ae46191f40ae71fc0a7 (diff) |
Allow -listen-http, -listen-https and -listen-proxy to be given more than once
Per issue #13, sometimes you want to listen on more than one port for each type
of listener. This commit adds support for that.
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -85,39 +85,40 @@ func (a *theApp) UpdateDomains(domains domains) { func (a *theApp) Run() { var wg sync.WaitGroup - if a.ListenHTTP != 0 { + // Listen for HTTP + for _, fd := range a.ListenHTTP { wg.Add(1) - go func() { + go func(fd uintptr) { defer wg.Done() - err := listenAndServe(a.ListenHTTP, a.ServeHTTP, a.HTTP2, nil) + err := listenAndServe(fd, a.ServeHTTP, a.HTTP2, nil) if err != nil { log.Fatal(err) } - }() + }(fd) } // Listen for HTTPS - if a.ListenHTTPS != 0 { + for _, fd := range a.ListenHTTPS { wg.Add(1) - go func() { + go func(fd uintptr) { defer wg.Done() - err := listenAndServeTLS(a.ListenHTTPS, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS, a.HTTP2) + err := listenAndServeTLS(fd, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS, a.HTTP2) if err != nil { log.Fatal(err) } - }() + }(fd) } // Listen for HTTP proxy requests - if a.ListenProxy != 0 { + for _, fd := range a.ListenProxy { wg.Add(1) - go func() { + go func(fd uintptr) { defer wg.Done() - err := listenAndServe(a.ListenProxy, a.ServeProxy, a.HTTP2, nil) + err := listenAndServe(fd, a.ServeProxy, a.HTTP2, nil) if err != nil { log.Fatal(err) } - }() + }(fd) } go watchDomains(a.Domain, a.UpdateDomains, time.Second) |