mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 16:25:39 +00:00
Add option -no-ecs
This commit is contained in:
@@ -39,16 +39,18 @@ type Client struct {
|
||||
upstream string
|
||||
bootstrap string
|
||||
timeout uint
|
||||
noECS bool
|
||||
udpServer *dns.Server
|
||||
tcpServer *dns.Server
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
func NewClient(addr, upstream, bootstrap string, timeout uint) (c *Client, err error) {
|
||||
func NewClient(addr, upstream, bootstrap string, timeout uint, noECS bool) (c *Client, err error) {
|
||||
c = &Client {
|
||||
addr: addr,
|
||||
upstream: upstream,
|
||||
timeout: timeout,
|
||||
noECS: noECS,
|
||||
}
|
||||
c.udpServer = &dns.Server {
|
||||
Addr: addr,
|
||||
@@ -224,6 +226,9 @@ var (
|
||||
|
||||
func (c *Client) findClientIP(w dns.ResponseWriter, r *dns.Msg) (ednsClientAddress net.IP, ednsClientNetmask uint8) {
|
||||
ednsClientNetmask = 255
|
||||
if c.noECS {
|
||||
return net.IPv4(0, 0, 0, 0), 0
|
||||
}
|
||||
if opt := r.IsEdns0(); opt != nil {
|
||||
for _, option := range opt.Option {
|
||||
if option.Option() == dns.EDNS0SUBNET {
|
||||
|
||||
@@ -28,9 +28,10 @@ func main() {
|
||||
upstream := flag.String("upstream", "https://dns.google.com/resolve", "HTTP path for upstream resolver")
|
||||
bootstrap := flag.String("bootstrap", "", "The bootstrap DNS server to resolve the address of the upstream resolver")
|
||||
timeout := flag.Uint("timeout", 10, "Timeout for upstream request")
|
||||
noECS := flag.Bool("no-ecs", false, "Disable EDNS0-Client-Subnet, do not send client's IP address")
|
||||
flag.Parse()
|
||||
|
||||
client, err := NewClient(*addr, *upstream, *bootstrap, *timeout)
|
||||
client, err := NewClient(*addr, *upstream, *bootstrap, *timeout, *noECS)
|
||||
if err != nil { log.Fatalln(err) }
|
||||
_ = client.Start()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user