From ea4e505c792d4a3d45f3d1851726bf3bd5ae2ea9 Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Wed, 22 Jun 2022 23:10:12 +0800 Subject: [PATCH] fix: simple-obfs didn't work in some cases --- service/pkg/plugin/simpleobfs/simpleobfs.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/service/pkg/plugin/simpleobfs/simpleobfs.go b/service/pkg/plugin/simpleobfs/simpleobfs.go index ae51678a..1322cd30 100644 --- a/service/pkg/plugin/simpleobfs/simpleobfs.go +++ b/service/pkg/plugin/simpleobfs/simpleobfs.go @@ -89,14 +89,11 @@ func (s *SimpleObfs) dial(network, addr string) (c net.Conn, err error) { } switch s.obfstype { case HTTP: - rs := strings.Split(s.addr, ":") - var port string - if len(rs) == 1 { + _, port, _ := net.SplitHostPort(s.addr) + if port == "" { port = "80" - } else { - port = rs[1] } - c = NewHTTPObfs(rc, rs[0], port, s.path) + c = NewHTTPObfs(rc, s.host, port, s.path) case TLS: c = NewTLSObfs(rc, s.host) }