Skip to content

Commit 5b2d49c

Browse files
committed
Improve New func of Client and ClientBundle
1 parent 6e1d331 commit 5b2d49c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

core/inbound/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func (s *Server) Run() {
5151
func (s *Server) ServeDNS(w dns.ResponseWriter, q *dns.Msg) {
5252

5353
inboundIP, _, _ := net.SplitHostPort(w.RemoteAddr().String())
54-
s.Dispatcher.PrimaryClientBundle = outbound.NewClientBundle(*q, s.Dispatcher.PrimaryDNS, inboundIP, s.Hosts, s.Cache)
55-
s.Dispatcher.AlternativeClientBundle = outbound.NewClientBundle(*q, s.Dispatcher.AlternativeDNS, inboundIP, s.Hosts, s.Cache)
54+
s.Dispatcher.PrimaryClientBundle = outbound.NewClientBundle(q, s.Dispatcher.PrimaryDNS, inboundIP, s.Hosts, s.Cache)
55+
s.Dispatcher.AlternativeClientBundle = outbound.NewClientBundle(q, s.Dispatcher.AlternativeDNS, inboundIP, s.Hosts, s.Cache)
5656

5757
log.Debug("Question: " + q.Question[0].String())
5858

core/outbound/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ type Client struct {
2626
Cache *cache.Cache
2727
}
2828

29-
func NewClient(q dns.Msg, u *DNSUpstream, ip string, h *hosts.Hosts, cache *cache.Cache) *Client {
29+
func NewClient(q *dns.Msg, u *DNSUpstream, ip string, h *hosts.Hosts, cache *cache.Cache) *Client {
3030

31-
c := &Client{QuestionMessage: q, DNSUpstream: u, InboundIP: ip, Hosts: h, Cache: cache}
31+
c := &Client{QuestionMessage: *q, DNSUpstream: u, InboundIP: ip, Hosts: h, Cache: cache}
3232

3333
c.getEDNSClientSubnetIP()
3434
return c

core/outbound/clientbundle.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ type ClientBundle struct {
2424
Cache *cache.Cache
2525
}
2626

27-
func NewClientBundle(q dns.Msg, ul []*DNSUpstream, ip string, h *hosts.Hosts, cache *cache.Cache) *ClientBundle {
27+
func NewClientBundle(q *dns.Msg, ul []*DNSUpstream, ip string, h *hosts.Hosts, cache *cache.Cache) *ClientBundle {
2828

29-
cb := &ClientBundle{QuestionMessage: q, DNSUpstreamList: ul, InboundIP: ip, Hosts: h, Cache: cache}
29+
cb := &ClientBundle{QuestionMessage: *q, DNSUpstreamList: ul, InboundIP: ip, Hosts: h, Cache: cache}
3030

3131
for _, u := range ul {
3232

33-
c := NewClient(cb.QuestionMessage, u, cb.InboundIP, cb.Hosts, cb.Cache)
33+
c := NewClient(&cb.QuestionMessage, u, cb.InboundIP, cb.Hosts, cb.Cache)
3434
cb.ClientList = append(cb.ClientList, c)
3535
}
3636

0 commit comments

Comments
 (0)