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{}) {
switch *s.cfg.ParentType {
case "kcp":
fallthrough
case "tls":
fallthrough
case "tcp":
case "kcp", "tls", "tcp":
if *s.cfg.ParentType == "tls" {
var _conn tls.Conn
_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
lbAddr := ""
switch *s.cfg.ParentType {
case "kcp":
fallthrough
case "tcp":
fallthrough
case "tls":
case "kcp", "tcp", "tls":
lbAddr, err = s.OutToTCP(&inConn)
default:
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
lbAddr := ""
switch *s.cfg.ParentType {
case "kcp":
fallthrough
case "tcp":
fallthrough
case "tls":
case "kcp", "tcp", "tls":
err = s.OutToTCP(&inConn)
case "udp":
s.OutToUDP(&inConn)

View File

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