Skip to content

Commit

Permalink
Issue #265: Catch and log listener errors
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Apr 24, 2017
1 parent 89a59a8 commit 5a23cb1
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,26 @@ func startServers(cfg *config.Config) {

switch l.Proto {
case "http", "https":
h := newHTTPProxy(cfg)
go proxy.ListenAndServeHTTP(l, h, tlscfg)
go func() {
h := newHTTPProxy(cfg)
if err := proxy.ListenAndServeHTTP(l, h, tlscfg); err != nil {
exit.Fatal("[FATAL] ", err)
}
}()
case "tcp":
h := &tcp.Proxy{cfg.Proxy.DialTimeout, lookupHostFn(cfg)}
go proxy.ListenAndServeTCP(l, h, tlscfg)
go func() {
h := &tcp.Proxy{cfg.Proxy.DialTimeout, lookupHostFn(cfg)}
if err := proxy.ListenAndServeTCP(l, h, tlscfg); err != nil {
exit.Fatal("[FATAL] ", err)
}
}()
case "tcp+sni":
h := &tcp.SNIProxy{cfg.Proxy.DialTimeout, lookupHostFn(cfg)}
go proxy.ListenAndServeTCP(l, h, tlscfg)
go func() {
h := &tcp.SNIProxy{cfg.Proxy.DialTimeout, lookupHostFn(cfg)}
if err := proxy.ListenAndServeTCP(l, h, tlscfg); err != nil {
exit.Fatal("[FATAL] ", err)
}
}()
default:
exit.Fatal("[FATAL] Invalid protocol ", l.Proto)
}
Expand Down

0 comments on commit 5a23cb1

Please sign in to comment.