Skip to content

Commit 7bd1f7a

Browse files
committed
Replace proxy.mainProto with proxy.xTransport.mainProto everywhere
Having both was confusing and unnecessary
1 parent 4236aee commit 7bd1f7a

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

dnscrypt-proxy/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
383383
// Configure server parameters
384384
configureServerParams(proxy, &config)
385385

386-
// Configure XTransport (needs proxy.mainProto to be set)
386+
// Configure XTransport (may override mainProto if proxy is configured)
387387
if err := configureXTransport(proxy, &config); err != nil {
388388
return err
389389
}

dnscrypt-proxy/config_loader.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func configureLogging(proxy *Proxy, flags *ConfigFlags, config *Config) {
6666
func configureXTransport(proxy *Proxy, config *Config) error {
6767
proxy.xTransport.tlsDisableSessionTickets = config.TLSDisableSessionTickets
6868
proxy.xTransport.tlsCipherSuite = config.TLSCipherSuite
69-
proxy.xTransport.mainProto = proxy.mainProto
7069
proxy.xTransport.http3 = config.HTTP3
7170
proxy.xTransport.http3Probe = config.HTTP3Probe
7271

@@ -120,7 +119,6 @@ func configureXTransport(proxy *Proxy, config *Config) error {
120119
return fmt.Errorf("Unable to use the proxy: [%v]", err)
121120
}
122121
proxy.xTransport.proxyDialer = &proxyDialer
123-
proxy.mainProto = "tcp"
124122
proxy.xTransport.mainProto = "tcp"
125123
}
126124

@@ -174,9 +172,9 @@ func configureServerParams(proxy *Proxy, config *Config) {
174172
dlog.Warnf("timeout_load_reduction must be between 0.0 and 1.0, using default 0.75")
175173
proxy.timeoutLoadReduction = 0.75
176174
}
177-
proxy.mainProto = "udp"
175+
proxy.xTransport.mainProto = "udp"
178176
if config.ForceTCP {
179-
proxy.mainProto = "tcp"
177+
proxy.xTransport.mainProto = "tcp"
180178
}
181179

182180
// Configure certificate refresh parameters

dnscrypt-proxy/local-doh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (handler localDoHHandler) ServeHTTP(writer http.ResponseWriter, request *ht
6767
writer.WriteHeader(400)
6868
return
6969
}
70-
response := proxy.processIncomingQuery("local_doh", proxy.mainProto, packet, &xClientAddr, nil, start, false)
70+
response := proxy.processIncomingQuery("local_doh", proxy.xTransport.mainProto, packet, &xClientAddr, nil, start, false)
7171
if len(response) == 0 {
7272
writer.WriteHeader(500)
7373
return

dnscrypt-proxy/plugin_dns64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
100100
}
101101
respPacket := plugin.proxy.processIncomingQuery(
102102
"trampoline",
103-
plugin.proxy.mainProto,
103+
plugin.proxy.xTransport.mainProto,
104104
msgAPacket,
105105
nil,
106106
nil,

dnscrypt-proxy/proxy.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type Proxy struct {
4949
localDoHCertKeyFile string
5050
captivePortalMapFile string
5151
localDoHPath string
52-
mainProto string
5352
cloakFile string
5453
forwardFile string
5554
blockIPFormat string
@@ -449,7 +448,7 @@ func (proxy *Proxy) udpListener(clientPc *net.UDPConn) {
449448
dlog.Debugf("Number of goroutines: %d", runtime.NumGoroutine())
450449
proxy.processIncomingQuery(
451450
"udp",
452-
proxy.mainProto,
451+
proxy.xTransport.mainProto,
453452
packet,
454453
&clientAddr,
455454
clientPc,
@@ -460,7 +459,7 @@ func (proxy *Proxy) udpListener(clientPc *net.UDPConn) {
460459
}
461460
go func() {
462461
defer proxy.clientsCountDec()
463-
proxy.processIncomingQuery("udp", proxy.mainProto, packet, &clientAddr, clientPc, time.Now(), false)
462+
proxy.processIncomingQuery("udp", proxy.xTransport.mainProto, packet, &clientAddr, clientPc, time.Now(), false)
464463
}()
465464
}
466465
}

dnscrypt-proxy/serversInfo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ func fetchDNSCryptServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp
721721
certInfo, rtt, fragmentsBlocked, err := FetchCurrentDNSCryptCert(
722722
proxy,
723723
&name,
724-
proxy.mainProto,
724+
proxy.xTransport.mainProto,
725725
stamp.ServerPk,
726726
stamp.ServerAddrStr,
727727
stamp.ProviderName,
@@ -757,7 +757,7 @@ func fetchDNSCryptServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp
757757
query := plainNXTestPacket(0xcafe)
758758
msg, _, _, err := DNSExchange(
759759
proxy,
760-
proxy.mainProto,
760+
proxy.xTransport.mainProto,
761761
&query,
762762
stamp.ServerAddrStr,
763763
dnscryptRelay,

0 commit comments

Comments
 (0)