Merge pull request #140 from Quasilyte/quasilyte/emptyFallthrough

services: simplify switch statements with case clause lists
This commit is contained in:
snail007
2018-09-14 11:37:25 +08:00
committed by GitHub
4 changed files with 4 additions and 18 deletions

View File

@ -462,11 +462,7 @@ func (s *Socks) proxyTCP(inConn *net.Conn, serverConn *socks.ServerConn) {
} }
func (s *Socks) GetParentConn(parentAddress string, serverConn *socks.ServerConn) (outConn net.Conn, err interface{}) { func (s *Socks) GetParentConn(parentAddress string, serverConn *socks.ServerConn) (outConn net.Conn, err interface{}) {
switch *s.cfg.ParentType { switch *s.cfg.ParentType {
case "kcp": case "kcp", "tls", "tcp":
fallthrough
case "tls":
fallthrough
case "tcp":
if *s.cfg.ParentType == "tls" { if *s.cfg.ParentType == "tls" {
var _conn tls.Conn var _conn tls.Conn
_conn, err = utils.TlsConnectHost(parentAddress, *s.cfg.Timeout, s.cfg.CertBytes, s.cfg.KeyBytes, s.cfg.CaCertBytes) _conn, err = utils.TlsConnectHost(parentAddress, *s.cfg.Timeout, s.cfg.CertBytes, s.cfg.KeyBytes, s.cfg.CaCertBytes)

View File

@ -273,11 +273,7 @@ func (s *SPS) callback(inConn net.Conn) {
var err error var err error
lbAddr := "" lbAddr := ""
switch *s.cfg.ParentType { switch *s.cfg.ParentType {
case "kcp": case "kcp", "tcp", "tls":
fallthrough
case "tcp":
fallthrough
case "tls":
lbAddr, err = s.OutToTCP(&inConn) lbAddr, err = s.OutToTCP(&inConn)
default: default:
err = fmt.Errorf("unkown parent type %s", *s.cfg.ParentType) err = fmt.Errorf("unkown parent type %s", *s.cfg.ParentType)

View File

@ -160,11 +160,7 @@ func (s *TCP) callback(inConn net.Conn) {
var err error var err error
lbAddr := "" lbAddr := ""
switch *s.cfg.ParentType { switch *s.cfg.ParentType {
case "kcp": case "kcp", "tcp", "tls":
fallthrough
case "tcp":
fallthrough
case "tls":
err = s.OutToTCP(&inConn) err = s.OutToTCP(&inConn)
case "udp": case "udp":
s.OutToUDP(&inConn) s.OutToUDP(&inConn)

View File

@ -141,9 +141,7 @@ func (s *UDP) callback(listener *net.UDPConn, packet []byte, localAddr, srcAddr
} }
}() }()
switch *s.cfg.ParentType { switch *s.cfg.ParentType {
case "tcp": case "tcp", "tls":
fallthrough
case "tls":
s.OutToTCP(packet, localAddr, srcAddr) s.OutToTCP(packet, localAddr, srcAddr)
case "udp": case "udp":
s.OutToUDP(packet, localAddr, srcAddr) s.OutToUDP(packet, localAddr, srcAddr)