mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-30 08:16:37 +08:00
增加协议屏蔽支持
This commit is contained in:
Executable
BIN
Binary file not shown.
+1
-5
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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 排除字符串
|
||||
|
||||
Reference in New Issue
Block a user