mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Propagate DNS setting to configuration
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
|
||||
"github.com/9seconds/mtg/v2/mtglib"
|
||||
)
|
||||
@@ -56,6 +57,7 @@ type Config struct {
|
||||
Idle TypeDuration `json:"idle"`
|
||||
} `json:"timeout"`
|
||||
DOHIP TypeIP `json:"dohIp"`
|
||||
DNS TypeDNSURI `json:"dns"`
|
||||
Proxies []TypeProxyURL `json:"proxies"`
|
||||
} `json:"network"`
|
||||
Stats struct {
|
||||
@@ -76,6 +78,16 @@ type Config struct {
|
||||
} `json:"stats"`
|
||||
}
|
||||
|
||||
func (c *Config) GetDNS() *url.URL {
|
||||
var dohURL *url.URL
|
||||
|
||||
if dohIP := c.Network.DOHIP.Get(nil); dohIP != nil {
|
||||
dohURL, _ = url.Parse("https://" + dohIP.String())
|
||||
}
|
||||
|
||||
return c.Network.DNS.Get(dohURL)
|
||||
}
|
||||
|
||||
func (c *Config) GetDomainFrontingPort(defaultValue uint) uint {
|
||||
if port := c.DomainFronting.Port.Get(0); port != 0 {
|
||||
return port
|
||||
|
||||
Reference in New Issue
Block a user