增加协议屏蔽支持

This commit is contained in:
qaq
2025-08-17 21:45:48 +08:00
parent cdfad3f224
commit 51e4f590f5
5 changed files with 14 additions and 14 deletions
Executable
BIN
View File
Binary file not shown.
+1 -5
View File
@@ -140,11 +140,7 @@ func main() {
defer wsReporter.Stop()
service.SetHTTPReportURL(config.Addr, config.Secret)
p := &program{
configReporter: func() {
service.StartConfigReporter()
},
}
p := &program{}
if err := svc.Run(p); err != nil {
logger.Default().Fatal(err)
}
+11 -6
View File
@@ -15,12 +15,14 @@ import (
xmetrics "github.com/go-gost/x/metrics"
metrics "github.com/go-gost/x/metrics/service"
"github.com/go-gost/x/registry"
xservice "github.com/go-gost/x/service"
"github.com/judwhite/go-svc"
"net/http"
"os"
"os/signal"
"strings"
"syscall"
"time"
)
type program struct {
@@ -29,7 +31,6 @@ type program struct {
srvProfiling *http.Server
cancel context.CancelFunc
configReporter func() // 配置上报器启动函数
}
func (p *program) Init(env svc.Environment) error {
@@ -65,11 +66,6 @@ func (p *program) Start() error {
return err
}
// 配置加载完成后启动配置上报器
if p.configReporter != nil {
go p.configReporter()
}
if err := p.run(cfg); err != nil {
return err
}
@@ -78,6 +74,15 @@ func (p *program) Start() error {
p.cancel = cancel
go p.reload(ctx)
go func() {
select {
case <-time.After(10 * time.Second):
xservice.StartConfigReporter(ctx)
case <-ctx.Done():
return
}
}()
return nil
}
+1 -2
View File
@@ -189,8 +189,7 @@ func sendConfigReport(ctx context.Context) (bool, error) {
}
// StartConfigReporter 启动配置定时上报器(每10分钟上报一次)
func StartConfigReporter() {
ctx, _ := context.WithCancel(context.Background())
func StartConfigReporter(ctx context.Context) {
if configReportURL == "" {
fmt.Printf("⚠️ 配置上报URL未设置,跳过定时上报\n")
return
+1 -1
View File
@@ -266,7 +266,7 @@ block_protocol() {
[[ "$block_socks5" == "y" ]] && echo " - SOCKS5 已屏蔽" || echo " - SOCKS5 未屏蔽"
# 生成 rules.yaml 文件
local file="rules.yaml"
local file="/etc/gost/rules.yaml"
> "$file"
# 构造 IP 排除字符串