Skip to content

Commit b7704a0

Browse files
author
Frank Denis
committed
Make return value explicit
1 parent d82021b commit b7704a0

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

dnscrypt-proxy/proxy.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,10 @@ func (proxy *Proxy) clientsCountDec() {
572572
}
573573
}
574574

575-
func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string, query []byte, clientAddr *net.Addr, clientPc net.Conn, start time.Time, onlyCached bool) (response []byte) {
576-
response = nil
575+
func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string, query []byte, clientAddr *net.Addr, clientPc net.Conn, start time.Time, onlyCached bool) []byte {
576+
var response []byte = nil
577577
if len(query) < MinDNSPacketSize {
578-
return
578+
return response
579579
}
580580
pluginsState := NewPluginsState(proxy, clientProto, clientAddr, serverProto, start)
581581
serverName := "-"
@@ -587,25 +587,25 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
587587
}
588588
query, _ = pluginsState.ApplyQueryPlugins(&proxy.pluginsGlobals, query, needsEDNS0Padding)
589589
if len(query) < MinDNSPacketSize || len(query) > MaxDNSPacketSize {
590-
return
590+
return response
591591
}
592592
if pluginsState.action == PluginsActionDrop {
593593
pluginsState.returnCode = PluginsReturnCodeDrop
594594
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
595-
return
595+
return response
596596
}
597597
var err error
598598
if pluginsState.synthResponse != nil {
599599
response, err = pluginsState.synthResponse.PackBuffer(response)
600600
if err != nil {
601601
pluginsState.returnCode = PluginsReturnCodeParseError
602602
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
603-
return
603+
return response
604604
}
605605
}
606606
if onlyCached {
607607
if len(response) == 0 {
608-
return
608+
return response
609609
}
610610
serverInfo = nil
611611
}
@@ -622,7 +622,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
622622
if err != nil {
623623
pluginsState.returnCode = PluginsReturnCodeParseError
624624
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
625-
return
625+
return response
626626
}
627627
serverInfo.noticeBegin(proxy)
628628
if serverProto == "udp" {
@@ -640,7 +640,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
640640
if err != nil {
641641
pluginsState.returnCode = PluginsReturnCodeParseError
642642
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
643-
return
643+
return response
644644
}
645645
response, err = proxy.exchangeWithTCPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
646646
}
@@ -661,7 +661,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
661661
}
662662
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
663663
serverInfo.noticeFailure(proxy)
664-
return
664+
return response
665665
}
666666
} else if serverInfo.Proto == stamps.StampProtoTypeDoH {
667667
tid := TransactionID(query)
@@ -680,7 +680,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
680680
pluginsState.returnCode = PluginsReturnCodeNetworkError
681681
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
682682
serverInfo.noticeFailure(proxy)
683-
return
683+
return response
684684
}
685685
if response == nil {
686686
response = serverResponse
@@ -691,7 +691,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
691691
} else if serverInfo.Proto == stamps.StampProtoTypeODoHTarget {
692692
tid := TransactionID(query)
693693
if len(serverInfo.odohTargetConfigs) == 0 {
694-
return
694+
return response
695695
}
696696
target := serverInfo.odohTargetConfigs[rand.Intn(len(serverInfo.odohTargetConfigs))]
697697
odohQuery, err := target.encryptQuery(query)
@@ -738,7 +738,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
738738
pluginsState.returnCode = PluginsReturnCodeNetworkError
739739
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
740740
serverInfo.noticeFailure(proxy)
741-
return
741+
return response
742742
}
743743
} else {
744744
dlog.Fatal("Unsupported protocol")
@@ -747,26 +747,26 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
747747
pluginsState.returnCode = PluginsReturnCodeParseError
748748
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
749749
serverInfo.noticeFailure(proxy)
750-
return
750+
return response
751751
}
752752
response, err = pluginsState.ApplyResponsePlugins(&proxy.pluginsGlobals, response, ttl)
753753
if err != nil {
754754
pluginsState.returnCode = PluginsReturnCodeParseError
755755
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
756756
serverInfo.noticeFailure(proxy)
757-
return
757+
return response
758758
}
759759
if pluginsState.action == PluginsActionDrop {
760760
pluginsState.returnCode = PluginsReturnCodeDrop
761761
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
762-
return
762+
return response
763763
}
764764
if pluginsState.synthResponse != nil {
765765
response, err = pluginsState.synthResponse.PackBuffer(response)
766766
if err != nil {
767767
pluginsState.returnCode = PluginsReturnCodeParseError
768768
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
769-
return
769+
return response
770770
}
771771
}
772772
if rcode := Rcode(response); rcode == dns.RcodeServerFailure { // SERVFAIL
@@ -790,15 +790,15 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
790790
if serverInfo != nil {
791791
serverInfo.noticeFailure(proxy)
792792
}
793-
return
793+
return response
794794
}
795795
if clientProto == "udp" {
796796
if len(response) > pluginsState.maxUnencryptedUDPSafePayloadSize {
797797
response, err = TruncatedResponse(response)
798798
if err != nil {
799799
pluginsState.returnCode = PluginsReturnCodeParseError
800800
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
801-
return
801+
return response
802802
}
803803
}
804804
clientPc.(net.PacketConn).WriteTo(response, *clientAddr)
@@ -815,7 +815,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
815815
if serverInfo != nil {
816816
serverInfo.noticeFailure(proxy)
817817
}
818-
return
818+
return response
819819
}
820820
if clientPc != nil {
821821
clientPc.Write(response)

0 commit comments

Comments
 (0)