mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-26 00:02:34 +01:00
Pass the client protocol around, don't infer it from clientAddr
This commit is contained in:
parent
d63c47b779
commit
5e252372d5
@ -101,7 +101,7 @@ func (proxy *Proxy) udpListener(listenAddr *net.UDPAddr) error {
|
|||||||
}
|
}
|
||||||
packet := buffer[:length]
|
packet := buffer[:length]
|
||||||
go func() {
|
go func() {
|
||||||
proxy.processIncomingQuery(proxy.serversInfo.getOne(), proxy.mainProto, packet, &clientAddr, clientPc)
|
proxy.processIncomingQuery(proxy.serversInfo.getOne(), "udp", proxy.mainProto, packet, &clientAddr, clientPc)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -128,7 +128,7 @@ func (proxy *Proxy) tcpListener(listenAddr *net.TCPAddr) error {
|
|||||||
if err != nil || len(packet) < MinDNSPacketSize {
|
if err != nil || len(packet) < MinDNSPacketSize {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
proxy.processIncomingQuery(proxy.serversInfo.getOne(), "tcp", packet, nil, clientPc)
|
proxy.processIncomingQuery(proxy.serversInfo.getOne(), "tcp", "tcp", packet, nil, clientPc)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -172,14 +172,10 @@ func (proxy *Proxy) exchangeWithTCPServer(serverInfo *ServerInfo, encryptedQuery
|
|||||||
return proxy.Decrypt(serverInfo, encryptedResponse, clientNonce)
|
return proxy.Decrypt(serverInfo, encryptedResponse, clientNonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, serverProto string, query []byte, clientAddr *net.Addr, clientPc net.Conn) {
|
func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto string, serverProto string, query []byte, clientAddr *net.Addr, clientPc net.Conn) {
|
||||||
if len(query) < MinDNSPacketSize || serverInfo == nil {
|
if len(query) < MinDNSPacketSize || serverInfo == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
clientProto := "udp"
|
|
||||||
if clientAddr == nil {
|
|
||||||
clientProto = "tcp"
|
|
||||||
}
|
|
||||||
pluginsState := NewPluginsState(proxy, clientProto)
|
pluginsState := NewPluginsState(proxy, clientProto)
|
||||||
query, _ = pluginsState.ApplyQueryPlugins(query)
|
query, _ = pluginsState.ApplyQueryPlugins(query)
|
||||||
var response []byte
|
var response []byte
|
||||||
@ -209,7 +205,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, serverProto str
|
|||||||
}
|
}
|
||||||
response, _ = pluginsState.ApplyResponsePlugins(response)
|
response, _ = pluginsState.ApplyResponsePlugins(response)
|
||||||
}
|
}
|
||||||
if clientAddr != nil {
|
if clientProto == "udp" {
|
||||||
if len(response) > MaxDNSUDPPacketSize {
|
if len(response) > MaxDNSUDPPacketSize {
|
||||||
response, err = TruncatedResponse(response)
|
response, err = TruncatedResponse(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user