Use more things from the config file
This commit is contained in:
parent
2822a9781b
commit
b86e7f268e
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/binary"
|
||||
"errors"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CryptoConstruction uint16
|
||||
|
@ -22,9 +21,6 @@ var (
|
|||
MaxDNSPacketSize = 4096
|
||||
MaxDNSUDPPacketSize = 1252
|
||||
InitialMinQuestionSize = 256
|
||||
TimeoutMin = 1 * time.Second
|
||||
TimeoutMax = 5 * time.Second
|
||||
CertRefreshDelay = 30 * time.Minute
|
||||
)
|
||||
|
||||
func PrefixWithSize(packet []byte) ([]byte, error) {
|
||||
|
|
|
@ -58,7 +58,7 @@ func (proxy *Proxy) StartProxy() {
|
|||
}
|
||||
}
|
||||
for {
|
||||
time.Sleep(CertRefreshDelay)
|
||||
time.Sleep(proxy.certRefreshDelay)
|
||||
proxy.serversInfo.refresh(proxy)
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,11 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, serverProto str
|
|||
if len(query) < MinDNSPacketSize {
|
||||
return
|
||||
}
|
||||
pluginsState := NewPluginsState()
|
||||
clientProto := "udp"
|
||||
if clientAddr == nil {
|
||||
clientProto = "tcp"
|
||||
}
|
||||
pluginsState := NewPluginsState(clientProto)
|
||||
query, _ = pluginsState.ApplyQueryPlugins(query)
|
||||
encryptedQuery, clientNonce, err := proxy.Encrypt(serverInfo, query, serverProto)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,11 +29,11 @@ type Plugin interface {
|
|||
Eval(pluginsState *PluginsState, msg *dns.Msg) error
|
||||
}
|
||||
|
||||
func NewPluginsState() PluginsState {
|
||||
func NewPluginsState(proto string) PluginsState {
|
||||
queryPlugins := &[]Plugin{Plugin(new(PluginGetSetPayloadSize))}
|
||||
responsePlugins := &[]Plugin{}
|
||||
return PluginsState{action: PluginsActionForward, maxPayloadSize: MaxDNSUDPPacketSize - ResponseOverhead,
|
||||
queryPlugins: queryPlugins, responsePlugins: responsePlugins}
|
||||
queryPlugins: queryPlugins, responsePlugins: responsePlugins, proto: proto}
|
||||
}
|
||||
|
||||
func (pluginsState *PluginsState) ApplyQueryPlugins(packet []byte) ([]byte, error) {
|
||||
|
|
|
@ -107,7 +107,7 @@ func (serversInfo *ServersInfo) fetchServerInfo(proxy *Proxy, name string, stamp
|
|||
SharedKey: certInfo.SharedKey,
|
||||
CryptoConstruction: certInfo.CryptoConstruction,
|
||||
Name: name,
|
||||
Timeout: TimeoutMin,
|
||||
Timeout: proxy.timeout,
|
||||
UDPAddr: remoteUDPAddr,
|
||||
TCPAddr: remoteTCPAddr,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue