mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 21:34:02 +03:00
Make auto updating optional
This commit is contained in:
@@ -48,6 +48,11 @@ concurrency = 8192
|
|||||||
# Only ipv4 connectivity is used
|
# Only ipv4 connectivity is used
|
||||||
prefer-ip = "prefer-ipv6"
|
prefer-ip = "prefer-ipv6"
|
||||||
|
|
||||||
|
# If this setting is set, then mtg will try to get proxy updates from Telegram
|
||||||
|
# Usually this is completely fine to have it disabled, because mtg has a list
|
||||||
|
# of some core proxies hardcoded.
|
||||||
|
auto-update = false
|
||||||
|
|
||||||
# FakeTLS uses domain fronting protection. So it needs to know a port to
|
# FakeTLS uses domain fronting protection. So it needs to know a port to
|
||||||
# access.
|
# access.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ func runProxy(conf *config.Config, version string) error { //nolint: funlen
|
|||||||
DomainFrontingIP: conf.GetDomainFrontingIP(nil),
|
DomainFrontingIP: conf.GetDomainFrontingIP(nil),
|
||||||
DomainFrontingProxyProtocol: conf.GetDomainFrontingProxyProtocol(false),
|
DomainFrontingProxyProtocol: conf.GetDomainFrontingProxyProtocol(false),
|
||||||
PreferIP: conf.PreferIP.Get(mtglib.DefaultPreferIP),
|
PreferIP: conf.PreferIP.Get(mtglib.DefaultPreferIP),
|
||||||
|
AutoUpdate: conf.AutoUpdate.Get(false),
|
||||||
|
|
||||||
AllowFallbackOnUnknownDC: conf.AllowFallbackOnUnknownDC.Get(false),
|
AllowFallbackOnUnknownDC: conf.AllowFallbackOnUnknownDC.Get(false),
|
||||||
TolerateTimeSkewness: conf.TolerateTimeSkewness.Value,
|
TolerateTimeSkewness: conf.TolerateTimeSkewness.Value,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ type Config struct {
|
|||||||
BindTo TypeHostPort `json:"bindTo"`
|
BindTo TypeHostPort `json:"bindTo"`
|
||||||
ProxyProtocolListener TypeBool `json:"proxyProtocolListener"`
|
ProxyProtocolListener TypeBool `json:"proxyProtocolListener"`
|
||||||
PreferIP TypePreferIP `json:"preferIp"`
|
PreferIP TypePreferIP `json:"preferIp"`
|
||||||
|
AutoUpdate TypeBool `json:"autoUpdate"`
|
||||||
DomainFrontingPort TypePort `json:"domainFrontingPort"`
|
DomainFrontingPort TypePort `json:"domainFrontingPort"`
|
||||||
DomainFrontingIP TypeIP `json:"domainFrontingIp"`
|
DomainFrontingIP TypeIP `json:"domainFrontingIp"`
|
||||||
DomainFrontingProxyProtocol TypeBool `json:"domainFrontingProxyProtocol"`
|
DomainFrontingProxyProtocol TypeBool `json:"domainFrontingProxyProtocol"`
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type tomlConfig struct {
|
|||||||
BindTo string `toml:"bind-to" json:"bindTo"`
|
BindTo string `toml:"bind-to" json:"bindTo"`
|
||||||
ProxyProtocolListener bool `toml:"proxy-protocol-listener" json:"proxyProtocolListener"`
|
ProxyProtocolListener bool `toml:"proxy-protocol-listener" json:"proxyProtocolListener"`
|
||||||
PreferIP string `toml:"prefer-ip" json:"preferIp,omitempty"`
|
PreferIP string `toml:"prefer-ip" json:"preferIp,omitempty"`
|
||||||
|
AutoUpdate bool `toml:"auto-update" json:"autoUpdate,omitempty"`
|
||||||
DomainFrontingPort uint `toml:"domain-fronting-port" json:"domainFrontingPort,omitempty"`
|
DomainFrontingPort uint `toml:"domain-fronting-port" json:"domainFrontingPort,omitempty"`
|
||||||
DomainFrontingIP string `toml:"domain-fronting-ip" json:"domainFrontingIp,omitempty"`
|
DomainFrontingIP string `toml:"domain-fronting-ip" json:"domainFrontingIp,omitempty"`
|
||||||
DomainFrontingProxyProtocol bool `toml:"domain-fronting-proxy-protocol" json:"domainFrontingProxyProtocol,omitempty"`
|
DomainFrontingProxyProtocol bool `toml:"domain-fronting-proxy-protocol" json:"domainFrontingProxyProtocol,omitempty"`
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ var defaultDCAddrSet = dcAddrSet{
|
|||||||
5: {
|
5: {
|
||||||
{Network: "tcp4", Address: "149.154.171.5:443"},
|
{Network: "tcp4", Address: "149.154.171.5:443"},
|
||||||
},
|
},
|
||||||
|
203: {
|
||||||
|
{Network: "tcp4", Address: "91.105.192.100:443"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
v6: map[int][]Addr{
|
v6: map[int][]Addr{
|
||||||
1: {
|
1: {
|
||||||
@@ -74,5 +77,8 @@ var defaultDCAddrSet = dcAddrSet{
|
|||||||
5: {
|
5: {
|
||||||
{Network: "tcp6", Address: "[2001:b28:f23f:f005::a]:443"},
|
{Network: "tcp6", Address: "[2001:b28:f23f:f005::a]:443"},
|
||||||
},
|
},
|
||||||
|
203: {
|
||||||
|
{Network: "tcp6", Address: "[2a0a:f280:0203:000a:5000:0000:0000:0100]:443"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ func (suite *ViewTestSuite) TestGetV4() {
|
|||||||
},
|
},
|
||||||
203: {
|
203: {
|
||||||
{Network: "tcp4", Address: "127.0.0.2:443"},
|
{Network: "tcp4", Address: "127.0.0.2:443"},
|
||||||
|
{Network: "tcp4", Address: "91.105.192.100:443"},
|
||||||
},
|
},
|
||||||
2: {
|
2: {
|
||||||
{Network: "tcp4", Address: "149.154.167.51:443"},
|
{Network: "tcp4", Address: "149.154.167.51:443"},
|
||||||
@@ -60,6 +61,7 @@ func (suite *ViewTestSuite) TestGetV6() {
|
|||||||
111: {},
|
111: {},
|
||||||
203: {
|
203: {
|
||||||
{Network: "tcp6", Address: "xxx"},
|
{Network: "tcp6", Address: "xxx"},
|
||||||
|
{Network: "tcp6", Address: "[2a0a:f280:0203:000a:5000:0000:0000:0100]:443"},
|
||||||
},
|
},
|
||||||
1: {
|
1: {
|
||||||
{Network: "tcp6", Address: "[2001:b28:f23d:f001::a]:443"},
|
{Network: "tcp6", Address: "[2001:b28:f23d:f001::a]:443"},
|
||||||
|
|||||||
+4
-2
@@ -346,8 +346,10 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {
|
|||||||
domainFrontingProxyProtocol: opts.DomainFrontingProxyProtocol,
|
domainFrontingProxyProtocol: opts.DomainFrontingProxyProtocol,
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv4, "tcp4")
|
if opts.AutoUpdate {
|
||||||
proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv6, "tcp6")
|
proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv4, "tcp4")
|
||||||
|
proxy.configUpdater.Run(ctx, dc.PublicConfigUpdateURLv6, "tcp6")
|
||||||
|
}
|
||||||
|
|
||||||
pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
|
pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
|
||||||
func(arg any) {
|
func(arg any) {
|
||||||
|
|||||||
@@ -85,6 +85,12 @@ type ProxyOpts struct {
|
|||||||
// This is an optional setting.
|
// This is an optional setting.
|
||||||
PreferIP string
|
PreferIP string
|
||||||
|
|
||||||
|
// AutoUpdate defines if it is required to auto update proxy list from
|
||||||
|
// Telegram instead of relying on a hardcoded list.
|
||||||
|
//
|
||||||
|
// This is an optional setting.
|
||||||
|
AutoUpdate bool
|
||||||
|
|
||||||
// DomainFrontingPort is a port we use to connect to a fronting domain.
|
// DomainFrontingPort is a port we use to connect to a fronting domain.
|
||||||
//
|
//
|
||||||
// This is required because secret does not specify a port. It specifies a
|
// This is required because secret does not specify a port. It specifies a
|
||||||
|
|||||||
Reference in New Issue
Block a user