Use more things from the config file

This commit is contained in:
Frank Denis 2018-01-10 12:09:59 +01:00
parent 2822a9781b
commit b86e7f268e
4 changed files with 9 additions and 9 deletions

View File

@ -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) {

View File

@ -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 {

View File

@ -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) {

View File

@ -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,
}