-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathglobals.go
More file actions
189 lines (150 loc) · 5.17 KB
/
globals.go
File metadata and controls
189 lines (150 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
File: globals.go
Version: 1.14.0
Updated: 21-Apr-2026 14:42 CEST
Description:
All package-level variables and feature-presence flags for sdproxy.
Changes:
1.14.0 - [FEAT] Added `ipVersionSupport` global flag to enforce selected
resource loading (IPv4/IPv6/Both).
1.13.0 - [FEAT] Added `forceRefreshStartup` flag to propagate the CLI override safely.
...
*/
package main
import (
"net"
"net/netip"
"sync"
)
// ---------------------------------------------------------------------------
// History Helpers
// ---------------------------------------------------------------------------
func historyDir() string {
return cfg.WebUI.HistoryDir
}
func retentionHours() int {
if cfg.WebUI.HistoryRetentionHours > 0 {
return cfg.WebUI.HistoryRetentionHours
}
return 24 // default
}
// ---------------------------------------------------------------------------
// Routing tables (populated at startup by main())
// ---------------------------------------------------------------------------
type cidrRouteEntry struct {
net netip.Prefix
route ParsedRoute
}
type macWildRoute struct {
pattern string
route ParsedRoute
}
var (
// Address-based routing
macRoutes map[string]ParsedRoute
macWildRoutes []macWildRoute
ipRoutes map[string]ParsedRoute
cidrRoutes []cidrRouteEntry
asnRoutes map[string]ParsedRoute
// String-based routing maps
clientNameRoutes map[string]ParsedRoute
sniRoutes map[string]ParsedRoute
pathRoutes map[string]ParsedRoute
domainRoutes map[string]domainRouteEntry
routeUpstreams map[string]*UpstreamGroup
)
// ---------------------------------------------------------------------------
// DDR — Discovery of Designated Resolvers (RFC 9462)
// ---------------------------------------------------------------------------
var (
ddrHostnames map[string]bool
ddrIPv4 []net.IP
ddrIPv6 []net.IP
ddrDoHPort uint16 = 443
ddrDoTPort uint16 = 853
ddrDoQPort uint16 = 853
)
// ---------------------------------------------------------------------------
// Policy maps (populated at startup)
// ---------------------------------------------------------------------------
var (
rtypePolicy map[uint16]int
domainPolicy map[string]int
)
// ---------------------------------------------------------------------------
// Policy Actions (Custom Internal RCODEs)
// ---------------------------------------------------------------------------
const (
PolicyActionDrop = -1
PolicyActionBlock = -2
)
// ---------------------------------------------------------------------------
// Route index table
// ---------------------------------------------------------------------------
var (
routeIdxByName map[string]uint8
routeIdxLocal uint8 = 0
routeIdxDefault uint8
)
// ---------------------------------------------------------------------------
// Security ACLs (Access Control Lists)
// ---------------------------------------------------------------------------
var (
dnsACLAllow []netip.Prefix
dnsACLDeny []netip.Prefix
hasDNSACL bool
webUIACLAllow []netip.Prefix
webUIACLDeny []netip.Prefix
hasWebUIACL bool
)
// ---------------------------------------------------------------------------
// Feature-presence flags
// ---------------------------------------------------------------------------
var (
hasClientRoutes bool
hasMACRoutes bool
hasMACWildRoutes bool
hasIPRoutes bool
hasCIDRRoutes bool
hasASNRoutes bool
hasClientNameRoutes bool
hasSNIRoutes bool
hasPathRoutes bool
hasDomainRoutes bool
hasRtypePolicy bool
hasDomainPolicy bool
hasClientNameUpstream bool
blockUnknownQtypes bool
hasRateLimit bool
hasRebindingProtection bool
forceRefreshStartup bool
)
// ---------------------------------------------------------------------------
// Hot-path query-level settings
// ---------------------------------------------------------------------------
var logQueries bool
var logASNDetails bool
var syntheticTTL uint32
var ipVersionSupport string // "ipv4", "ipv6", or "both"
// ---------------------------------------------------------------------------
// Obsolete/withdrawn DNS RR types
// ---------------------------------------------------------------------------
var obsoleteQtypes = map[uint16]string{
3: "MD", 4: "MF", 7: "MB", 8: "MG", 9: "MR", 10: "NULL",
11: "WKS", 14: "MINFO", 19: "X25", 20: "ISDN", 21: "RT",
22: "NSAP", 23: "NSAP-PTR", 24: "SIG", 25: "KEY", 26: "PX",
27: "GPOS", 30: "NXT", 31: "EID", 32: "NIMLOC", 34: "ATMA",
38: "A6", 40: "SINK", 99: "SPF", 100: "UINFO", 101: "UID",
102: "GID", 103: "UNSPEC", 253: "MAILB", 254: "MAILA",
}
// ---------------------------------------------------------------------------
// Bootstrap DNS servers
// ---------------------------------------------------------------------------
var globalBootstrapServers []string
// ---------------------------------------------------------------------------
// Buffer pools
// ---------------------------------------------------------------------------
var (
smallBufPool = sync.Pool{New: func() any { b := make([]byte, 4096); return &b }}
largeBufPool = sync.Pool{New: func() any { b := make([]byte, 65536); return &b }}
)