mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-09-21 09:57:17 +03:00
More checks on the response
This commit is contained in:
parent
7dde2f4a37
commit
d2f6c69a2c
@ -215,7 +215,7 @@ func (serversInfo *ServersInfo) fetchDoHServerInfo(proxy *Proxy, name string, st
|
||||
return ServerInfo{}, err
|
||||
}
|
||||
body := ioutil.NopCloser(bytes.NewReader([]byte{
|
||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
0xca, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
}))
|
||||
req := &http.Request{
|
||||
Method: "POST",
|
||||
@ -243,7 +243,8 @@ func (serversInfo *ServersInfo) fetchDoHServerInfo(proxy *Proxy, name string, st
|
||||
if err != nil {
|
||||
return ServerInfo{}, err
|
||||
}
|
||||
if len(respBody) < MinDNSPacketSize || len(respBody) > MaxDNSPacketSize {
|
||||
if len(respBody) < MinDNSPacketSize || len(respBody) > MaxDNSPacketSize ||
|
||||
respBody[0] != 0xca || respBody[1] != 0xfe || respBody[4] != 0x00 || respBody[5] != 0x01 {
|
||||
return ServerInfo{}, errors.New("Webserver returned an unexpected response")
|
||||
}
|
||||
dlog.Noticef("[%s] OK (DoH) - rtt: %dms", name, rtt.Nanoseconds()/1000000)
|
||||
|
Loading…
Reference in New Issue
Block a user