Skip to content

Commit

Permalink
Improve New func of Client and ClientBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn1m committed May 20, 2017
1 parent 6e1d331 commit 5b2d49c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/inbound/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (s *Server) Run() {
func (s *Server) ServeDNS(w dns.ResponseWriter, q *dns.Msg) {

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

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

Expand Down
4 changes: 2 additions & 2 deletions core/outbound/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type Client struct {
Cache *cache.Cache
}

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

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

c.getEDNSClientSubnetIP()
return c
Expand Down
6 changes: 3 additions & 3 deletions core/outbound/clientbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ type ClientBundle struct {
Cache *cache.Cache
}

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

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

for _, u := range ul {

c := NewClient(cb.QuestionMessage, u, cb.InboundIP, cb.Hosts, cb.Cache)
c := NewClient(&cb.QuestionMessage, u, cb.InboundIP, cb.Hosts, cb.Cache)
cb.ClientList = append(cb.ClientList, c)
}

Expand Down

0 comments on commit 5b2d49c

Please sign in to comment.