diff --git a/listener/shadowsocks/tcp.go b/listener/shadowsocks/tcp.go index d767b8ab..b540a632 100644 --- a/listener/shadowsocks/tcp.go +++ b/listener/shadowsocks/tcp.go @@ -22,7 +22,7 @@ type Listener struct { var _listener *Listener func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) { - addr, cipher, password, err := parseSSURL(config) + addr, cipher, password, err := ParseSSURL(config) if err != nil { return nil, err } diff --git a/listener/shadowsocks/utils.go b/listener/shadowsocks/utils.go index f1710c94..2e9fd003 100644 --- a/listener/shadowsocks/utils.go +++ b/listener/shadowsocks/utils.go @@ -44,7 +44,7 @@ func (c *packet) InAddr() net.Addr { return c.pc.LocalAddr() } -func parseSSURL(s string) (addr, cipher, password string, err error) { +func ParseSSURL(s string) (addr, cipher, password string, err error) { u, err := url.Parse(s) if err != nil { return diff --git a/listener/sing_shadowsocks/server.go b/listener/sing_shadowsocks/server.go index 7bb9bb54..ba61ea36 100644 --- a/listener/sing_shadowsocks/server.go +++ b/listener/sing_shadowsocks/server.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "net" - "net/url" "strings" "github.com/Dreamacro/clash/adapter/inbound" @@ -34,7 +33,7 @@ type Listener struct { var _listener *Listener func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (C.AdvanceListener, error) { - addr, cipher, password, err := parseSSURL(config) + addr, cipher, password, err := embedSS.ParseSSURL(config) if err != nil { return nil, err } @@ -159,17 +158,3 @@ func HandleShadowSocks(conn net.Conn, in chan<- C.ConnContext) bool { } return embedSS.HandleShadowSocks(conn, in) } - -func parseSSURL(s string) (addr, cipher, password string, err error) { - u, err := url.Parse(s) - if err != nil { - return - } - - addr = u.Host - if u.User != nil { - cipher = u.User.Username() - password, _ = u.User.Password() - } - return -}