mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-26 00:02:34 +01:00
Plugins can now access the client IP. Useful for logging and ACLs.
This commit is contained in:
parent
5e252372d5
commit
fee0a42dec
@ -128,7 +128,8 @@ func (proxy *Proxy) tcpListener(listenAddr *net.TCPAddr) error {
|
||||
if err != nil || len(packet) < MinDNSPacketSize {
|
||||
return
|
||||
}
|
||||
proxy.processIncomingQuery(proxy.serversInfo.getOne(), "tcp", "tcp", packet, nil, clientPc)
|
||||
clientAddr := clientPc.RemoteAddr()
|
||||
proxy.processIncomingQuery(proxy.serversInfo.getOne(), "tcp", "tcp", packet, &clientAddr, clientPc)
|
||||
}()
|
||||
}
|
||||
}()
|
||||
@ -176,7 +177,7 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
||||
if len(query) < MinDNSPacketSize || serverInfo == nil {
|
||||
return
|
||||
}
|
||||
pluginsState := NewPluginsState(proxy, clientProto)
|
||||
pluginsState := NewPluginsState(proxy, clientProto, clientAddr)
|
||||
query, _ = pluginsState.ApplyQueryPlugins(query)
|
||||
var response []byte
|
||||
var err error
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"crypto/sha512"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -26,7 +27,8 @@ type PluginsState struct {
|
||||
action PluginsAction
|
||||
originalMaxPayloadSize int
|
||||
maxPayloadSize int
|
||||
proto string
|
||||
clientProto string
|
||||
clientAddr *net.Addr
|
||||
queryPlugins *[]Plugin
|
||||
responsePlugins *[]Plugin
|
||||
synthResponse *dns.Msg
|
||||
@ -43,7 +45,7 @@ type Plugin interface {
|
||||
Eval(pluginsState *PluginsState, msg *dns.Msg) error
|
||||
}
|
||||
|
||||
func NewPluginsState(proxy *Proxy, proto string) PluginsState {
|
||||
func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr) PluginsState {
|
||||
queryPlugins := &[]Plugin{}
|
||||
if proxy.pluginBlockIPv6 {
|
||||
*queryPlugins = append(*queryPlugins, Plugin(new(PluginBlockIPv6)))
|
||||
@ -63,7 +65,8 @@ func NewPluginsState(proxy *Proxy, proto string) PluginsState {
|
||||
maxPayloadSize: MaxDNSUDPPacketSize - ResponseOverhead,
|
||||
queryPlugins: queryPlugins,
|
||||
responsePlugins: responsePlugins,
|
||||
proto: proto,
|
||||
clientProto: clientProto,
|
||||
clientAddr: clientAddr,
|
||||
cacheSize: proxy.cacheSize,
|
||||
cacheNegTTL: proxy.cacheNegTTL,
|
||||
cacheMinTTL: proxy.cacheMinTTL,
|
||||
|
Loading…
Reference in New Issue
Block a user