浏览代码

Make auto updating optional

tags/v2.1.12^2^2
9seconds 2 个月前
父节点
当前提交
189dce07c6

+ 5
- 0
example.config.toml 查看文件

@@ -48,6 +48,11 @@ concurrency = 8192
48 48
 #     Only ipv4 connectivity is used
49 49
 prefer-ip = "prefer-ipv6"
50 50
 
51
+# If this setting is set, then mtg will try to get proxy updates from Telegram
52
+# Usually this is completely fine to have it disabled, because mtg has a list
53
+# of some core proxies hardcoded.
54
+auto-update = false
55
+
51 56
 # FakeTLS uses domain fronting protection. So it needs to know a port to
52 57
 # access.
53 58
 #

+ 1
- 0
internal/cli/run_proxy.go 查看文件

@@ -255,6 +255,7 @@ func runProxy(conf *config.Config, version string) error { //nolint: funlen
255 255
 		DomainFrontingIP:            conf.GetDomainFrontingIP(nil),
256 256
 		DomainFrontingProxyProtocol: conf.GetDomainFrontingProxyProtocol(false),
257 257
 		PreferIP:                    conf.PreferIP.Get(mtglib.DefaultPreferIP),
258
+		AutoUpdate:                  conf.AutoUpdate.Get(false),
258 259
 
259 260
 		AllowFallbackOnUnknownDC: conf.AllowFallbackOnUnknownDC.Get(false),
260 261
 		TolerateTimeSkewness:     conf.TolerateTimeSkewness.Value,

+ 1
- 0
internal/config/config.go 查看文件

@@ -28,6 +28,7 @@ type Config struct {
28 28
 	BindTo                      TypeHostPort    `json:"bindTo"`
29 29
 	ProxyProtocolListener       TypeBool        `json:"proxyProtocolListener"`
30 30
 	PreferIP                    TypePreferIP    `json:"preferIp"`
31
+	AutoUpdate                  TypeBool        `json:"autoUpdate"`
31 32
 	DomainFrontingPort          TypePort        `json:"domainFrontingPort"`
32 33
 	DomainFrontingIP            TypeIP          `json:"domainFrontingIp"`
33 34
 	DomainFrontingProxyProtocol TypeBool        `json:"domainFrontingProxyProtocol"`

+ 1
- 0
internal/config/parse.go 查看文件

@@ -15,6 +15,7 @@ type tomlConfig struct {
15 15
 	BindTo                      string `toml:"bind-to" json:"bindTo"`
16 16
 	ProxyProtocolListener       bool   `toml:"proxy-protocol-listener" json:"proxyProtocolListener"`
17 17
 	PreferIP                    string `toml:"prefer-ip" json:"preferIp,omitempty"`
18
+	AutoUpdate                  bool   `toml:"auto-update" json:"autoUpdate,omitempty"`
18 19
 	DomainFrontingPort          uint   `toml:"domain-fronting-port" json:"domainFrontingPort,omitempty"`
19 20
 	DomainFrontingIP            string `toml:"domain-fronting-ip" json:"domainFrontingIp,omitempty"`
20 21
 	DomainFrontingProxyProtocol bool   `toml:"domain-fronting-proxy-protocol" json:"domainFrontingProxyProtocol,omitempty"`

+ 6
- 0
mtglib/internal/dc/init.go 查看文件

@@ -57,6 +57,9 @@ var defaultDCAddrSet = dcAddrSet{
57 57
 		5: {
58 58
 			{Network: "tcp4", Address: "149.154.171.5:443"},
59 59
 		},
60
+		203: {
61
+			{Network: "tcp4", Address: "91.105.192.100:443"},
62
+		},
60 63
 	},
61 64
 	v6: map[int][]Addr{
62 65
 		1: {
@@ -74,5 +77,8 @@ var defaultDCAddrSet = dcAddrSet{
74 77
 		5: {
75 78
 			{Network: "tcp6", Address: "[2001:b28:f23f:f005::a]:443"},
76 79
 		},
80
+		203: {
81
+			{Network: "tcp6", Address: "[2a0a:f280:0203:000a:5000:0000:0000:0100]:443"},
82
+		},
77 83
 	},
78 84
 }

+ 2
- 0
mtglib/internal/dc/view_test.go 查看文件

@@ -41,6 +41,7 @@ func (suite *ViewTestSuite) TestGetV4() {
41 41
 		},
42 42
 		203: {
43 43
 			{Network: "tcp4", Address: "127.0.0.2:443"},
44
+			{Network: "tcp4", Address: "91.105.192.100:443"},
44 45
 		},
45 46
 		2: {
46 47
 			{Network: "tcp4", Address: "149.154.167.51:443"},
@@ -60,6 +61,7 @@ func (suite *ViewTestSuite) TestGetV6() {
60 61
 		111: {},
61 62
 		203: {
62 63
 			{Network: "tcp6", Address: "xxx"},
64
+			{Network: "tcp6", Address: "[2a0a:f280:0203:000a:5000:0000:0000:0100]:443"},
63 65
 		},
64 66
 		1: {
65 67
 			{Network: "tcp6", Address: "[2001:b28:f23d:f001::a]:443"},

+ 4
- 2
mtglib/proxy.go 查看文件

@@ -346,8 +346,10 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {
346 346
 		domainFrontingProxyProtocol: opts.DomainFrontingProxyProtocol,
347 347
 	}
348 348
 
349
-	proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv4, "tcp4")
350
-	proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv6, "tcp6")
349
+	if opts.AutoUpdate {
350
+		proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv4, "tcp4")
351
+		proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv6, "tcp6")
352
+	}
351 353
 
352 354
 	pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
353 355
 		func(arg any) {

+ 6
- 0
mtglib/proxy_opts.go 查看文件

@@ -85,6 +85,12 @@ type ProxyOpts struct {
85 85
 	// This is an optional setting.
86 86
 	PreferIP string
87 87
 
88
+	// AutoUpdate defines if it is required to auto update proxy list from
89
+	// Telegram instead of relying on a hardcoded list.
90
+	//
91
+	// This is an optional setting.
92
+	AutoUpdate bool
93
+
88 94
 	// DomainFrontingPort is a port we use to connect to a fronting domain.
89 95
 	//
90 96
 	// This is required because secret does not specify a port. It specifies a

正在加载...
取消
保存