Rename 'server' to 'listener' to better match how it is used
This commit is contained in:
1 parent
22c3ff9f60
commit
5cc24fe55e
2 files changed
+9
-7
No files matched your search
@@ -48,7 +48,9 @@ type inflightQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MDNSClient struct {
|
type MDNSClient struct {
|
||||||
server *dns.Server
|
// note unorthodox use of 'Server' class in client logic - using it to
|
||||||
|
// listen on a multicast socket and call callback whenever a message comes in.
|
||||||
|
listener *dns.Server
|
||||||
conn *net.UDPConn
|
conn *net.UDPConn
|
||||||
addr *net.UDPAddr
|
addr *net.UDPAddr
|
||||||
inflight map[string]*inflightQuery
|
inflight map[string]*inflightQuery
|
||||||
@@ -85,8 +87,8 @@ func (c *MDNSClient) Start(ifi *net.Interface) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.server = &dns.Server{Unsafe: true, PacketConn: multicast, Handler: dns.HandlerFunc(handleMDNS)}
|
c.listener = &dns.Server{Unsafe: true, PacketConn: multicast, Handler: dns.HandlerFunc(handleMDNS)}
|
||||||
go c.server.ActivateAndServe()
|
go c.listener.ActivateAndServe()
|
||||||
|
|
||||||
queryChan := make(chan *MDNSInteraction, MailboxSize)
|
queryChan := make(chan *MDNSInteraction, MailboxSize)
|
||||||
c.queryChan = queryChan
|
c.queryChan = queryChan
|
||||||
@@ -177,7 +179,7 @@ func (c *MDNSClient) queryLoop(queryChan <-chan *MDNSInteraction) {
|
|||||||
}
|
}
|
||||||
switch query.code {
|
switch query.code {
|
||||||
case CShutdown:
|
case CShutdown:
|
||||||
c.server.Shutdown()
|
c.listener.Shutdown()
|
||||||
terminate = true
|
terminate = true
|
||||||
case CSendQuery:
|
case CSendQuery:
|
||||||
c.handleSendQuery(query.payload.(mDNSQueryInfo))
|
c.handleSendQuery(query.payload.(mDNSQueryInfo))
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ func TestServerSimpleQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server := &dns.Server{Unsafe: true, PacketConn: multicast, Handler: dns.HandlerFunc(handleMDNS)}
|
listener := &dns.Server{Unsafe: true, PacketConn: multicast, Handler: dns.HandlerFunc(handleMDNS)}
|
||||||
go server.ActivateAndServe()
|
go listener.ActivateAndServe()
|
||||||
defer server.Shutdown()
|
defer listener.Shutdown()
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond) // Allow for server to get going
|
time.Sleep(100 * time.Millisecond) // Allow for server to get going
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user