Skip to content

Commit 312dbba

Browse files
author
renzhn
committed
remove tunnel allowed port function
1 parent 254a6ee commit 312dbba

File tree

4 files changed

+0
-70
lines changed

4 files changed

+0
-70
lines changed

config.go

-28
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,12 @@ const (
2727
loadBalanceLatency
2828
)
2929

30-
// allow the same tunnel ports as polipo
31-
var defaultTunnelAllowedPort = []string{
32-
"22", "80", "443", // ssh, http, https
33-
"873", // rsync
34-
"143", "220", "585", "993", // imap, imap3, imap4-ssl, imaps
35-
"109", "110", "473", "995", // pop2, pop3, hybrid-pop, pop3s
36-
"5222", "5269", // jabber-client, jabber-server
37-
"2401", "3690", "9418", // cvspserver, svn, git
38-
}
39-
4030
type Config struct {
4131
RcFile string // config file
4232
LogFile string // path for log file
4333
JudgeByIP bool
4434
LoadBalance LoadBalanceMode // select load balance mode
4535

46-
TunnelAllowedPort map[string]bool // allowed ports to create tunnel
47-
4836
SshServer []string
4937

5038
// authenticate client
@@ -88,11 +76,6 @@ func initConfig(rcFile string) {
8876
config.JudgeByIP = true
8977

9078
config.AuthTimeout = 2 * time.Hour
91-
92-
config.TunnelAllowedPort = make(map[string]bool)
93-
for _, port := range defaultTunnelAllowedPort {
94-
config.TunnelAllowedPort[port] = true
95-
}
9679
}
9780

9881
// Whether command line options specifies listen addr
@@ -370,17 +353,6 @@ func (p configParser) ParseAddrInPAC(val string) {
370353
}
371354
}
372355

373-
func (p configParser) ParseTunnelAllowedPort(val string) {
374-
arr := strings.Split(val, ",")
375-
for _, s := range arr {
376-
s = strings.TrimSpace(s)
377-
if _, err := strconv.Atoi(s); err != nil {
378-
Fatal("tunnel allowed ports", err)
379-
}
380-
config.TunnelAllowedPort[s] = true
381-
}
382-
}
383-
384356
func (p configParser) ParseSocksParent(val string) {
385357
var pp proxyParser
386358
pp.ProxySocks5(val)

config_test.go

-30
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,6 @@ func TestParseListen(t *testing.T) {
2323
}
2424
}
2525

26-
func TestTunnelAllowedPort(t *testing.T) {
27-
initConfig("")
28-
parser := configParser{}
29-
parser.ParseTunnelAllowedPort("1, 2, 3, 4, 5")
30-
parser.ParseTunnelAllowedPort("6")
31-
parser.ParseTunnelAllowedPort("7")
32-
parser.ParseTunnelAllowedPort("8")
33-
34-
testData := []struct {
35-
port string
36-
allowed bool
37-
}{
38-
{"80", true}, // default allowd ports
39-
{"443", true},
40-
{"1", true},
41-
{"3", true},
42-
{"5", true},
43-
{"7", true},
44-
{"8080", false},
45-
{"8388", false},
46-
}
47-
48-
for _, td := range testData {
49-
allowed := config.TunnelAllowedPort[td.port]
50-
if allowed != td.allowed {
51-
t.Errorf("port %s allowed %v, got %v\n", td.port, td.allowed, allowed)
52-
}
53-
}
54-
}
55-
5626
func TestParseProxy(t *testing.T) {
5727
pool, ok := parentProxy.(*backupParentPool)
5828
if !ok {

doc/sample-config/rc-full

-6
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ listen = http://127.0.0.1:4411
125125
# 最多允许使用多少个 CPU 核
126126
#core = 2
127127

128-
# 允许建立隧道连接的端口,多个端口用逗号分隔,可重复多次
129-
# 默认总是允许下列服务的端口: ssh, http, https, rsync, imap, pop, jabber, cvs, git, svn
130-
# 如需允许其他端口,请用该选项添加
131-
# 限制隧道连接的端口可以防止将运行 meow 的服务器上只监听本机 ip 的服务暴露给外部
132-
#tunnelAllowedPort = 80, 443
133-
134128
# 修改 direct/proxy 文件路径,如不指定,默认在配置文件所在目录下
135129
#directFile = <dir to rc file>/direct
136130
#proxyFile = <dir to rc file>/proxy

proxy.go

-6
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,6 @@ func (c *clientConn) serve() {
404404
authed = true
405405
}
406406

407-
if r.isConnect && !config.TunnelAllowedPort[r.URL.Port] {
408-
sendErrorPage(c, statusForbidden, "Forbidden tunnel port",
409-
genErrMsg(&r, nil, "Please contact proxy admin."))
410-
return
411-
}
412-
413407
if r.ExpectContinue {
414408
sendErrorPage(c, statusExpectFailed, "Expect header not supported",
415409
"Please contact meow's developer if you see this.")

0 commit comments

Comments
 (0)