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