Skip to content

Commit

Permalink
proxy: exit glider when it fails to listen (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadoo committed Dec 11, 2021
1 parent 3c431ee commit b502b12
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion proxy/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewHTTPServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *HTTP) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[http] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[http] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/kcp/kcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func NewKCPServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *KCP) ListenAndServe() {
l, err := kcp.ListenWithOptions(s.addr, s.block, s.dataShards, s.parityShards)
if err != nil {
log.F("[kcp] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[kcp] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/mixed/mixed.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (m *Mixed) ListenAndServe() {

l, err := net.Listen("tcp", m.addr)
if err != nil {
log.F("[mixed] failed to listen on %s: %v", m.addr, err)
log.Fatalf("[mixed] failed to listen on %s: %v", m.addr, err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion proxy/pxyproto/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewPxyProtoServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *PxyProtoServer) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[pxyproto] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[pxyproto] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/redir/redir_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewRedir6Server(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *RedirProxy) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[redir] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[redir] failed to listen on %s: %v", s.addr, err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion proxy/smux/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewSmuxServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *SmuxServer) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[smux] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[smux] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
4 changes: 2 additions & 2 deletions proxy/socks5/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *Socks5) ListenAndServe() {
func (s *Socks5) ListenAndServeTCP() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[socks5] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[socks5] failed to listen on %s: %v", s.addr, err)
return
}

Expand Down Expand Up @@ -99,7 +99,7 @@ func (s *Socks5) Serve(c net.Conn) {
func (s *Socks5) ListenAndServeUDP() {
lc, err := net.ListenPacket("udp", s.addr)
if err != nil {
log.F("[socks5] failed to listen on UDP %s: %v", s.addr, err)
log.Fatalf("[socks5] failed to listen on UDP %s: %v", s.addr, err)
return
}
defer lc.Close()
Expand Down
4 changes: 2 additions & 2 deletions proxy/ss/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *SS) ListenAndServe() {
func (s *SS) ListenAndServeTCP() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[ss] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[ss] failed to listen on %s: %v", s.addr, err)
return
}

Expand Down Expand Up @@ -89,7 +89,7 @@ func (s *SS) Serve(c net.Conn) {
func (s *SS) ListenAndServeUDP() {
lc, err := net.ListenPacket("udp", s.addr)
if err != nil {
log.F("[ss] failed to listen on UDP %s: %v", s.addr, err)
log.Fatalf("[ss] failed to listen on UDP %s: %v", s.addr, err)
return
}
defer lc.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewTCPServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *TCP) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[tcp] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[tcp] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func NewTLSServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *TLS) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[tls] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[tls] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/tproxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *TProxy) Serve(c net.Conn) {
func (s *TProxy) ListenAndServeUDP() {
laddr, err := net.ResolveUDPAddr("udp", s.addr)
if err != nil {
log.F("[tproxyu] failed to resolve addr %s: %v", s.addr, err)
log.Fatalf("[tproxyu] failed to resolve addr %s: %v", s.addr, err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion proxy/trojan/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewTrojanServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *Trojan) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[trojan] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[trojan] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/udp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewUDPServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *UDP) ListenAndServe() {
c, err := net.ListenPacket("udp", s.addr)
if err != nil {
log.F("[udp] failed to listen on UDP %s: %v", s.addr, err)
log.Fatalf("[udp] failed to listen on UDP %s: %v", s.addr, err)
return
}
defer c.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/unix/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *Unix) ListenAndServeTCP() {
os.Remove(s.addr)
l, err := net.Listen("unix", s.addr)
if err != nil {
log.F("[unix] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[unix] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/vless/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewVLessServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *VLess) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[vless] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[vless] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down
2 changes: 1 addition & 1 deletion proxy/ws/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewWSSServer(s string, p proxy.Proxy) (proxy.Server, error) {
func (s *WS) ListenAndServe() {
l, err := net.Listen("tcp", s.addr)
if err != nil {
log.F("[ws] failed to listen on %s: %v", s.addr, err)
log.Fatalf("[ws] failed to listen on %s: %v", s.addr, err)
return
}
defer l.Close()
Expand Down

0 comments on commit b502b12

Please sign in to comment.