parent
cb022ece82
commit
a726a40dc5
|
@ -73,6 +73,7 @@ type Config struct {
|
|||
NetprobeTimeout int `toml:"netprobe_timeout"`
|
||||
OfflineMode bool `toml:"offline_mode"`
|
||||
HTTPProxyURL string `toml:"http_proxy"`
|
||||
RefusedCodeInResponses bool `toml:"refused_code_in_responses"`
|
||||
}
|
||||
|
||||
func newConfig() Config {
|
||||
|
@ -108,6 +109,7 @@ func newConfig() Config {
|
|||
NetprobeAddress: "9.9.9.9:53",
|
||||
NetprobeTimeout: 60,
|
||||
OfflineMode: false,
|
||||
RefusedCodeInResponses: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,6 +280,7 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error {
|
|||
|
||||
proxy.xTransport.rebuildTransport()
|
||||
|
||||
proxy.refusedCodeInResponses = config.RefusedCodeInResponses
|
||||
proxy.timeout = time.Duration(config.Timeout) * time.Millisecond
|
||||
proxy.maxClients = config.MaxClients
|
||||
proxy.mainProto = "udp"
|
||||
|
|
|
@ -31,12 +31,16 @@ func EmptyResponseFromMessage(srcMsg *dns.Msg) (*dns.Msg, error) {
|
|||
return dstMsg, nil
|
||||
}
|
||||
|
||||
func RefusedResponseFromMessage(srcMsg *dns.Msg) (*dns.Msg, error) {
|
||||
func RefusedResponseFromMessage(srcMsg *dns.Msg, refusedCode bool) (*dns.Msg, error) {
|
||||
dstMsg, err := EmptyResponseFromMessage(srcMsg)
|
||||
if err != nil {
|
||||
return dstMsg, err
|
||||
}
|
||||
if refusedCode {
|
||||
dstMsg.Rcode = dns.RcodeRefused
|
||||
} else {
|
||||
dstMsg.Rcode = dns.RcodeSuccess
|
||||
}
|
||||
return dstMsg, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ type PluginsGlobals struct {
|
|||
queryPlugins *[]Plugin
|
||||
responsePlugins *[]Plugin
|
||||
loggingPlugins *[]Plugin
|
||||
refusedCodeInResponses bool
|
||||
}
|
||||
|
||||
type PluginsReturnCode int
|
||||
|
@ -127,6 +128,7 @@ func InitPluginsGlobals(pluginsGlobals *PluginsGlobals, proxy *Proxy) error {
|
|||
(*pluginsGlobals).queryPlugins = queryPlugins
|
||||
(*pluginsGlobals).responsePlugins = responsePlugins
|
||||
(*pluginsGlobals).loggingPlugins = loggingPlugins
|
||||
(*pluginsGlobals).refusedCodeInResponses = proxy.refusedCodeInResponses
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -175,7 +177,7 @@ func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGloba
|
|||
return packet, ret
|
||||
}
|
||||
if pluginsState.action == PluginsActionReject {
|
||||
synth, err := RefusedResponseFromMessage(&msg)
|
||||
synth, err := RefusedResponseFromMessage(&msg, pluginsGlobals.refusedCodeInResponses)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -223,7 +225,7 @@ func (pluginsState *PluginsState) ApplyResponsePlugins(pluginsGlobals *PluginsGl
|
|||
return packet, ret
|
||||
}
|
||||
if pluginsState.action == PluginsActionReject {
|
||||
synth, err := RefusedResponseFromMessage(&msg)
|
||||
synth, err := RefusedResponseFromMessage(&msg, pluginsGlobals.refusedCodeInResponses)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ type Proxy struct {
|
|||
logMaxSize int
|
||||
logMaxAge int
|
||||
logMaxBackups int
|
||||
refusedCodeInResponses bool
|
||||
}
|
||||
|
||||
func (proxy *Proxy) StartProxy() {
|
||||
|
|
Loading…
Reference in New Issue