Skip to content

Commit

Permalink
添加 10.0.0.0 到 10.255.255.255(Class A)
Browse files Browse the repository at this point in the history
172.16.0.0 到 172.31.255.255(Class B)
192.168.0.0 到 192.168.255.255(Class C)
127.0.0.0 到 127.255.255.255(回环地址)
100.64.0.0 到 100.127.255.255(共享地址空间)http 监听
  • Loading branch information
qist committed Dec 2, 2024
1 parent d79f865 commit 879918e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24.11.22
24.12.02
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/robfig/cron/v3 v3.0.1
github.com/shirou/gopsutil/v3 v3.24.5
github.com/xtls/xray-core v1.8.25-0.20241121054707-513f18bf531e
github.com/xtls/xray-core v1.8.25-0.20241201231301-03d7d07c5b77
go.uber.org/atomic v1.11.0
golang.org/x/crypto v0.29.0
golang.org/x/text v0.20.0
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
Expand All @@ -163,8 +164,8 @@ github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1Y
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg=
github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE=
github.com/xtls/xray-core v1.8.25-0.20241121054707-513f18bf531e h1:J5sTv0Sw+BonaI+rBh4Jkw9BfBqDjfAts81/HbIaqNg=
github.com/xtls/xray-core v1.8.25-0.20241121054707-513f18bf531e/go.mod h1:wByClH1yrH8I611sREjG62gxbP5hFtdAWYJfydQF/zI=
github.com/xtls/xray-core v1.8.25-0.20241201231301-03d7d07c5b77 h1:4s1Q/Wb7Iwuzwgkoe1d48hSmexwlUOn+XJQ7sOuWSDQ=
github.com/xtls/xray-core v1.8.25-0.20241201231301-03d7d07c5b77/go.mod h1:BCeSy6P4xz8vSk46ziVkg0iby82W2Mmqvz2ub5kfYrc=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func showSetting(show bool) {
if err != nil {
fmt.Println("get current port fialed,error info:", err)
}
listen, err := settingService.GetListen()
if err != nil {
fmt.Println("get current listen fialed,error info:", err)
}
webBasePath, err := settingService.GetBasePath()
if err != nil {
fmt.Println("get webBasePath failed, error info:", err)
Expand Down Expand Up @@ -128,6 +132,7 @@ func showSetting(show bool) {
fmt.Println("登录用户名:", username)
fmt.Println("登录密码:", userpasswd)
fmt.Println("登录端口:", port)
fmt.Println("监听地址:", listen)
if webBasePath != "" {
fmt.Println("Web 路径:", webBasePath)
} else {
Expand Down
17 changes: 16 additions & 1 deletion web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,12 @@ func (s *Server) Start() (err error) {
}
if certFile == "" || keyFile == "" {
// If any of the files are empty, override `listen` to use "127.0.0.1"
listen = "127.0.0.1"
if !isInternalIP(listen) {
// If not internal, fallback to "127.0.0.1"
listen = "127.0.0.1"
}
}

listenAddr := net.JoinHostPort(listen, strconv.Itoa(port))
listener, err := net.Listen("tcp", listenAddr)
if err != nil {
Expand Down Expand Up @@ -489,3 +493,14 @@ func (s *Server) GetCtx() context.Context {
func (s *Server) GetCron() *cron.Cron {
return s.cron
}

func isInternalIP(ip string) bool {
if strings.HasPrefix(ip, "127.") || // Loopback
strings.HasPrefix(ip, "10.") || // Class A
strings.HasPrefix(ip, "192.168.") || // Class C
(ip >= "172.16.0.0" && ip <= "172.31.255.255") || // Class B
(ip >= "100.64.0.0" && ip <= "100.127.255.255") { // Shared Address Space
return true
}
return false
}

0 comments on commit 879918e

Please sign in to comment.