Repack structures to save some memory

This commit is contained in:
Frank Denis 2020-11-14 14:46:59 +01:00
parent e6fdb08d3d
commit 4fa643ef4d
4 changed files with 164 additions and 163 deletions

View File

@ -28,80 +28,80 @@ const (
)
type Config struct {
LogLevel int `toml:"log_level"`
LogFile *string `toml:"log_file"`
LogFileLatest bool `toml:"log_file_latest"`
UseSyslog bool `toml:"use_syslog"`
ServerNames []string `toml:"server_names"`
DisabledServerNames []string `toml:"disabled_server_names"`
ListenAddresses []string `toml:"listen_addresses"`
LocalDoH LocalDoHConfig `toml:"local_doh"`
Daemonize bool
UserName string `toml:"user_name"`
ForceTCP bool `toml:"force_tcp"`
Timeout int `toml:"timeout"`
KeepAlive int `toml:"keepalive"`
Proxy string `toml:"proxy"`
CertRefreshDelay int `toml:"cert_refresh_delay"`
CertIgnoreTimestamp bool `toml:"cert_ignore_timestamp"`
EphemeralKeys bool `toml:"dnscrypt_ephemeral_keys"`
LBStrategy string `toml:"lb_strategy"`
LBEstimator bool `toml:"lb_estimator"`
BlockIPv6 bool `toml:"block_ipv6"`
BlockUnqualified bool `toml:"block_unqualified"`
BlockUndelegated bool `toml:"block_undelegated"`
LocalDoH LocalDoHConfig
QueryLog QueryLogConfig
AllowedName AllowedNameConfig
DNS64 DNS64Config
BlockIP BlockIPConfig
BlockName BlockNameConfig
BlockNameLegacy BlockNameConfigLegacy
BlockIPLegacy BlockIPConfigLegacy
WhitelistNameLegacy WhitelistNameConfigLegacy
BrokenImplementations BrokenImplementationsConfig
NxLog NxLogConfig
AnonymizedDNS AnonymizedDNSConfig
DoHClientX509Auth DoHClientX509AuthConfig
DoHClientX509AuthLegacy DoHClientX509AuthConfig
ListenAddresses []string
DisabledServerNames []string
QueryMeta []string
ServerNames []string
FallbackResolvers []string
TLSCipherSuite []uint16
EDNSClientSubnet []string
SourcesConfig map[string]SourceConfig
AllWeeklyRanges map[string]WeeklyRangesStr
StaticsConfig map[string]StaticConfig
LogFile *string
UserName string
CloakFile string
ForwardFile string
FallbackResolver string
HTTPProxyURL string
NetprobeAddress string
Proxy string
LBStrategy string
BlockedQueryResponse string
CaptivePortalFile string
LogMaxBackups int
LogMaxAge int
CertRefreshDelay int
LogMaxSize int
LogLevel int
CacheSize int
NetprobeTimeout int
Timeout int
KeepAlive int
MaxClients uint32
CloakTTL uint32
RejectTTL uint32
CacheMinTTL uint32
CacheNegMaxTTL uint32
CacheNegTTL uint32
CacheNegMinTTL uint32
CacheMaxTTL uint32
SourceIPv6 bool
SourceIPv4 bool
SourceDoH bool
IgnoreSystemDNS bool
SourceDNSCrypt bool
SourceRequireNoFilter bool
SourceRequireNoLog bool
SourceRequireDNSSEC bool
TLSDisableSessionTickets bool
Cache bool
CacheSize int `toml:"cache_size"`
CacheNegTTL uint32 `toml:"cache_neg_ttl"`
CacheNegMinTTL uint32 `toml:"cache_neg_min_ttl"`
CacheNegMaxTTL uint32 `toml:"cache_neg_max_ttl"`
CacheMinTTL uint32 `toml:"cache_min_ttl"`
CacheMaxTTL uint32 `toml:"cache_max_ttl"`
RejectTTL uint32 `toml:"reject_ttl"`
CloakTTL uint32 `toml:"cloak_ttl"`
QueryLog QueryLogConfig `toml:"query_log"`
NxLog NxLogConfig `toml:"nx_log"`
BlockName BlockNameConfig `toml:"blocked_names"`
BlockNameLegacy BlockNameConfigLegacy `toml:"blacklist"`
WhitelistNameLegacy WhitelistNameConfigLegacy `toml:"whitelist"`
AllowedName AllowedNameConfig `toml:"allowed_names"`
BlockIP BlockIPConfig `toml:"blocked_ips"`
BlockIPLegacy BlockIPConfigLegacy `toml:"ip_blacklist"`
ForwardFile string `toml:"forwarding_rules"`
CloakFile string `toml:"cloaking_rules"`
CaptivePortalFile string `toml:"captive_portal_handler"`
StaticsConfig map[string]StaticConfig `toml:"static"`
SourcesConfig map[string]SourceConfig `toml:"sources"`
BrokenImplementations BrokenImplementationsConfig `toml:"broken_implementations"`
SourceRequireDNSSEC bool `toml:"require_dnssec"`
SourceRequireNoLog bool `toml:"require_nolog"`
SourceRequireNoFilter bool `toml:"require_nofilter"`
SourceDNSCrypt bool `toml:"dnscrypt_servers"`
SourceDoH bool `toml:"doh_servers"`
SourceIPv4 bool `toml:"ipv4_servers"`
SourceIPv6 bool `toml:"ipv6_servers"`
MaxClients uint32 `toml:"max_clients"`
FallbackResolver string `toml:"fallback_resolver"`
FallbackResolvers []string `toml:"fallback_resolvers"`
IgnoreSystemDNS bool `toml:"ignore_system_dns"`
AllWeeklyRanges map[string]WeeklyRangesStr `toml:"schedules"`
LogMaxSize int `toml:"log_files_max_size"`
LogMaxAge int `toml:"log_files_max_age"`
LogMaxBackups int `toml:"log_files_max_backups"`
TLSDisableSessionTickets bool `toml:"tls_disable_session_tickets"`
TLSCipherSuite []uint16 `toml:"tls_cipher_suite"`
NetprobeAddress string `toml:"netprobe_address"`
NetprobeTimeout int `toml:"netprobe_timeout"`
OfflineMode bool `toml:"offline_mode"`
HTTPProxyURL string `toml:"http_proxy"`
RefusedCodeInResponses bool `toml:"refused_code_in_responses"`
BlockedQueryResponse string `toml:"blocked_query_response"`
QueryMeta []string `toml:"query_meta"`
AnonymizedDNS AnonymizedDNSConfig `toml:"anonymized_dns"`
DoHClientX509Auth DoHClientX509AuthConfig `toml:"doh_client_x509_auth"`
DoHClientX509AuthLegacy DoHClientX509AuthConfig `toml:"tls_client_auth"`
DNS64 DNS64Config `toml:"dns64"`
EDNSClientSubnet []string `toml:"edns_client_subnet"`
BlockUndelegated bool
BlockUnqualified bool
BlockIPv6 bool
LBEstimator bool
RefusedCodeInResponses bool
EphemeralKeys bool
CertIgnoreTimestamp bool
ForceTCP bool
Daemonize bool
UseSyslog bool
LogFileLatest bool
OfflineMode bool
}
func newConfig() Config {

View File

@ -64,30 +64,30 @@ var PluginsReturnCodeToString = map[PluginsReturnCode]string{
}
type PluginsState struct {
sessionData map[string]interface{}
action PluginsAction
maxUnencryptedUDPSafePayloadSize int
originalMaxPayloadSize int
maxPayloadSize int
clientProto string
clientAddr *net.Addr
synthResponse *dns.Msg
dnssec bool
cacheSize int
cacheNegMinTTL uint32
cacheNegMaxTTL uint32
cacheMinTTL uint32
cacheMaxTTL uint32
rejectTTL uint32
questionMsg *dns.Msg
qName string
requestStart time.Time
requestEnd time.Time
cacheHit bool
returnCode PluginsReturnCode
clientProto string
serverName string
serverProto string
qName string
clientAddr *net.Addr
synthResponse *dns.Msg
questionMsg *dns.Msg
sessionData map[string]interface{}
action PluginsAction
timeout time.Duration
returnCode PluginsReturnCode
maxPayloadSize int
cacheSize int
originalMaxPayloadSize int
maxUnencryptedUDPSafePayloadSize int
rejectTTL uint32
cacheMaxTTL uint32
cacheNegMaxTTL uint32
cacheNegMinTTL uint32
cacheMinTTL uint32
cacheHit bool
dnssec bool
}
func (proxy *Proxy) InitPluginsGlobals() error {

View File

@ -17,77 +17,77 @@ import (
)
type Proxy struct {
udpListeners []*net.UDPConn
tcpListeners []*net.TCPListener
localDoHListeners []*net.TCPListener
userName string
child bool
proxyPublicKey [32]byte
proxySecretKey [32]byte
ephemeralKeys bool
questionSizeEstimator QuestionSizeEstimator
pluginsGlobals PluginsGlobals
serversInfo ServersInfo
timeout time.Duration
certRefreshDelay time.Duration
certRefreshDelayAfterFailure time.Duration
certIgnoreTimestamp bool
mainProto string
questionSizeEstimator QuestionSizeEstimator
registeredServers []RegisteredServer
dns64Resolvers []string
dns64Prefixes []string
serversBlockingFragments []string
ednsClientSubnets []*net.IPNet
queryLogIgnoredQtypes []string
localDoHListeners []*net.TCPListener
queryMeta []string
udpListeners []*net.UDPConn
sources []*Source
tcpListeners []*net.TCPListener
registeredRelays []RegisteredServer
listenAddresses []string
localDoHListenAddresses []string
localDoHPath string
xTransport *XTransport
dohCreds *map[string]DOHClientCreds
allWeeklyRanges *map[string]WeeklyRanges
routes *map[string][]string
nxLogFormat string
localDoHCertFile string
localDoHCertKeyFile string
daemonize bool
registeredServers []RegisteredServer
registeredRelays []RegisteredServer
pluginBlockIPv6 bool
pluginBlockUnqualified bool
pluginBlockUndelegated bool
cache bool
cacheSize int
cacheNegMinTTL uint32
cacheNegMaxTTL uint32
cacheMinTTL uint32
cacheMaxTTL uint32
rejectTTL uint32
cloakTTL uint32
queryLogFile string
queryLogFormat string
queryLogIgnoredQtypes []string
nxLogFile string
nxLogFormat string
blockNameFile string
whitelistNameFile string
blockNameLogFile string
whitelistNameLogFile string
blockNameFormat string
whitelistNameFormat string
blockIPFile string
blockIPLogFile string
blockIPFormat string
forwardFile string
cloakFile string
captivePortalFile string
pluginsGlobals PluginsGlobals
sources []*Source
localDoHPath string
mainProto string
cloakFile string
forwardFile string
blockIPFormat string
blockIPLogFile string
queryLogFormat string
blockIPFile string
whitelistNameFormat string
whitelistNameLogFile string
blockNameLogFile string
whitelistNameFile string
blockNameFile string
queryLogFile string
blockedQueryResponse string
userName string
nxLogFile string
blockNameFormat string
proxySecretKey [32]byte
proxyPublicKey [32]byte
certRefreshDelayAfterFailure time.Duration
timeout time.Duration
certRefreshDelay time.Duration
cacheSize int
logMaxBackups int
logMaxAge int
logMaxSize int
cacheNegMinTTL uint32
rejectTTL uint32
cacheMaxTTL uint32
clientsCount uint32
maxClients uint32
xTransport *XTransport
allWeeklyRanges *map[string]WeeklyRanges
logMaxSize int
logMaxAge int
logMaxBackups int
blockedQueryResponse string
queryMeta []string
routes *map[string][]string
serversBlockingFragments []string
cacheMinTTL uint32
cacheNegMaxTTL uint32
cloakTTL uint32
cache bool
pluginBlockIPv6 bool
ephemeralKeys bool
pluginBlockUnqualified bool
showCerts bool
dohCreds *map[string]DOHClientCreds
certIgnoreTimestamp bool
skipAnonIncompatbibleResolvers bool
anonDirectCertFallback bool
dns64Prefixes []string
dns64Resolvers []string
ednsClientSubnets []*net.IPNet
pluginBlockUndelegated bool
child bool
daemonize bool
}
func (proxy *Proxy) registerUDPListener(conn *net.UDPConn) {

View File

@ -16,6 +16,7 @@ import (
"github.com/VividCortex/ewma"
"github.com/jedisct1/dlog"
"github.com/jedisct1/go-dnsstamps"
stamps "github.com/jedisct1/go-dnsstamps"
"github.com/miekg/dns"
"golang.org/x/crypto/ed25519"
@ -42,25 +43,25 @@ type DOHClientCreds struct {
}
type ServerInfo struct {
Proto stamps.StampProtoType
MagicQuery [8]byte
ServerPk [32]byte
SharedKey [32]byte
CryptoConstruction CryptoConstruction
DOHClientCreds DOHClientCreds
lastActionTS time.Time
rtt ewma.MovingAverage
Name string
Timeout time.Duration
URL *url.URL
HostName string
UDPAddr *net.UDPAddr
TCPAddr *net.TCPAddr
RelayUDPAddr *net.UDPAddr
URL *url.URL
RelayTCPAddr *net.TCPAddr
knownBugs ServerBugs
lastActionTS time.Time
rtt ewma.MovingAverage
initialRtt int
Timeout time.Duration
CryptoConstruction CryptoConstruction
ServerPk [32]byte
SharedKey [32]byte
MagicQuery [8]byte
knownBugs ServerBugs
Proto dnsstamps.StampProtoType
useGet bool
DOHClientCreds DOHClientCreds
}
type LBStrategy interface {