mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 02:14:40 +01:00
Base on clientProto value explicitly to dereference clientAddr (#2393)
There are variants local_doh and trampoline for internal flow.
This commit is contained in:
parent
d381af5510
commit
9b2c674744
6 changed files with 44 additions and 20 deletions
|
@ -119,10 +119,14 @@ func (plugin *PluginAllowedIP) Eval(pluginsState *PluginsState, msg *dns.Msg) er
|
||||||
if plugin.logger != nil {
|
if plugin.logger != nil {
|
||||||
qName := pluginsState.qName
|
qName := pluginsState.qName
|
||||||
var clientIPStr string
|
var clientIPStr string
|
||||||
if pluginsState.clientProto == "udp" {
|
switch pluginsState.clientProto {
|
||||||
|
case "udp":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
||||||
} else {
|
case "tcp", "local_doh":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
||||||
|
default:
|
||||||
|
// Ignore internal flow.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
var line string
|
var line string
|
||||||
if plugin.format == "tsv" {
|
if plugin.format == "tsv" {
|
||||||
|
|
|
@ -96,10 +96,14 @@ func (plugin *PluginAllowName) Eval(pluginsState *PluginsState, msg *dns.Msg) er
|
||||||
pluginsState.sessionData["whitelisted"] = true
|
pluginsState.sessionData["whitelisted"] = true
|
||||||
if plugin.logger != nil {
|
if plugin.logger != nil {
|
||||||
var clientIPStr string
|
var clientIPStr string
|
||||||
if pluginsState.clientProto == "udp" {
|
switch pluginsState.clientProto {
|
||||||
|
case "udp":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
||||||
} else {
|
case "tcp", "local_doh":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
||||||
|
default:
|
||||||
|
// Ignore internal flow.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
var line string
|
var line string
|
||||||
if plugin.format == "tsv" {
|
if plugin.format == "tsv" {
|
||||||
|
|
|
@ -123,10 +123,14 @@ func (plugin *PluginBlockIP) Eval(pluginsState *PluginsState, msg *dns.Msg) erro
|
||||||
if plugin.logger != nil {
|
if plugin.logger != nil {
|
||||||
qName := pluginsState.qName
|
qName := pluginsState.qName
|
||||||
var clientIPStr string
|
var clientIPStr string
|
||||||
if pluginsState.clientProto == "udp" {
|
switch pluginsState.clientProto {
|
||||||
|
case "udp":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
||||||
} else {
|
case "tcp", "local_doh":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
||||||
|
default:
|
||||||
|
// Ignore internal flow.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
var line string
|
var line string
|
||||||
if plugin.format == "tsv" {
|
if plugin.format == "tsv" {
|
||||||
|
|
|
@ -44,10 +44,14 @@ func (blockedNames *BlockedNames) check(pluginsState *PluginsState, qName string
|
||||||
pluginsState.returnCode = PluginsReturnCodeReject
|
pluginsState.returnCode = PluginsReturnCodeReject
|
||||||
if blockedNames.logger != nil {
|
if blockedNames.logger != nil {
|
||||||
var clientIPStr string
|
var clientIPStr string
|
||||||
if pluginsState.clientProto == "udp" {
|
switch pluginsState.clientProto {
|
||||||
|
case "udp":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
||||||
} else {
|
case "tcp", "local_doh":
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
||||||
|
default:
|
||||||
|
// Ignore internal flow.
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
var line string
|
var line string
|
||||||
if blockedNames.format == "tsv" {
|
if blockedNames.format == "tsv" {
|
||||||
|
|
|
@ -43,17 +43,21 @@ func (plugin *PluginNxLog) Eval(pluginsState *PluginsState, msg *dns.Msg) error
|
||||||
if msg.Rcode != dns.RcodeNameError {
|
if msg.Rcode != dns.RcodeNameError {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
var clientIPStr string
|
||||||
|
switch pluginsState.clientProto {
|
||||||
|
case "udp":
|
||||||
|
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
||||||
|
case "tcp", "local_doh":
|
||||||
|
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
||||||
|
default:
|
||||||
|
// Ignore internal flow.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
question := msg.Question[0]
|
question := msg.Question[0]
|
||||||
qType, ok := dns.TypeToString[question.Qtype]
|
qType, ok := dns.TypeToString[question.Qtype]
|
||||||
if !ok {
|
if !ok {
|
||||||
qType = string(qType)
|
qType = string(qType)
|
||||||
}
|
}
|
||||||
var clientIPStr string
|
|
||||||
if pluginsState.clientProto == "udp" {
|
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
|
||||||
} else {
|
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
|
||||||
}
|
|
||||||
qName := pluginsState.qName
|
qName := pluginsState.qName
|
||||||
|
|
||||||
var line string
|
var line string
|
||||||
|
|
|
@ -43,6 +43,16 @@ func (plugin *PluginQueryLog) Reload() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) error {
|
func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) error {
|
||||||
|
var clientIPStr string
|
||||||
|
switch pluginsState.clientProto {
|
||||||
|
case "udp":
|
||||||
|
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
||||||
|
case "tcp", "local_doh":
|
||||||
|
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
||||||
|
default:
|
||||||
|
// Ignore internal flow.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
question := msg.Question[0]
|
question := msg.Question[0]
|
||||||
qType, ok := dns.TypeToString[question.Qtype]
|
qType, ok := dns.TypeToString[question.Qtype]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -55,12 +65,6 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var clientIPStr string
|
|
||||||
if pluginsState.clientProto == "udp" {
|
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.UDPAddr).IP.String()
|
|
||||||
} else {
|
|
||||||
clientIPStr = (*pluginsState.clientAddr).(*net.TCPAddr).IP.String()
|
|
||||||
}
|
|
||||||
qName := pluginsState.qName
|
qName := pluginsState.qName
|
||||||
|
|
||||||
if pluginsState.cacheHit {
|
if pluginsState.cacheHit {
|
||||||
|
|
Loading…
Add table
Reference in a new issue