mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 15:44:01 +03:00
Add domain-fronting-ip option
Allow specifying an explicit IP address for the domain fronting host instead of relying on DNS resolution. Useful when DNS resolution of the fronting hostname is blocked. The hostname from the secret is still used for SNI in TLS handshake.
This commit is contained in:
@@ -260,6 +260,7 @@ func runProxy(conf *config.Config, version string) error { //nolint: funlen
|
||||
|
||||
Secret: conf.Secret,
|
||||
DomainFrontingPort: conf.DomainFrontingPort.Get(mtglib.DefaultDomainFrontingPort),
|
||||
DomainFrontingIP: conf.DomainFrontingIP.String(),
|
||||
PreferIP: conf.PreferIP.Get(mtglib.DefaultPreferIP),
|
||||
|
||||
AllowFallbackOnUnknownDC: conf.AllowFallbackOnUnknownDC.Get(false),
|
||||
|
||||
@@ -18,6 +18,7 @@ type SimpleRun struct {
|
||||
TCPBuffer string `kong:"name='tcp-buffer',short='b',default='4KB',help='Deprecated and ignored'"` //nolint: lll
|
||||
PreferIP string `kong:"name='prefer-ip',short='i',default='prefer-ipv6',help='IP preference. By default we prefer IPv6 with fallback to IPv4.'"` //nolint: lll
|
||||
DomainFrontingPort uint64 `kong:"name='domain-fronting-port',short='p',default='443',help='A port to access for domain fronting.'"` //nolint: lll
|
||||
DomainFrontingIP string `kong:"name='domain-fronting-ip',help='An IP address to use for domain fronting instead of resolving the hostname via DNS.'"` //nolint: lll
|
||||
DOHIP net.IP `kong:"name='doh-ip',short='n',default='1.1.1.1',help='IP address of DNS-over-HTTP to use.'"` //nolint: lll
|
||||
Timeout time.Duration `kong:"name='timeout',short='t',default='10s',help='Network timeout to use'"` //nolint: lll
|
||||
Socks5Proxies []string `kong:"name='socks5-proxy',short='s',help='Socks5 proxies to use for network access.'"` //nolint: lll
|
||||
@@ -47,6 +48,12 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funle
|
||||
return fmt.Errorf("incorrect domain-fronting-port: %w", err)
|
||||
}
|
||||
|
||||
if s.DomainFrontingIP != "" {
|
||||
if err := conf.DomainFrontingIP.Set(s.DomainFrontingIP); err != nil {
|
||||
return fmt.Errorf("incorrect domain-fronting-ip: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := conf.Network.DOHIP.Set(s.DOHIP.String()); err != nil {
|
||||
return fmt.Errorf("incorrect doh-ip: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user