- windows: install: fix crash due to empty DHCP server pointer

#2036

Squashed commit of the following:

commit 5c70d28b241d1a98e034f6798dade073b1b42511
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Aug 24 18:42:21 2020 +0300

    - windows: install: fix crash due to empty DHCP server pointer

    We should not assign a Go interface value, otherwise `==nil` check doesn't work.
This commit is contained in:
Simon Zolin 2020-08-24 20:06:53 +03:00
parent eb3999a261
commit cb6ca3b0c4
2 changed files with 8 additions and 6 deletions

View file

@ -82,9 +82,9 @@ func NewServer(p DNSCreateParams) *Server {
s.dnsFilter = p.DNSFilter
s.stats = p.Stats
s.queryLog = p.QueryLog
s.dhcpServer = p.DHCPServer
if s.dhcpServer != nil {
if p.DHCPServer != nil {
s.dhcpServer = p.DHCPServer
s.dhcpServer.SetOnLeaseChanged(s.onDHCPLeaseChanged)
s.onDHCPLeaseChanged(dhcpd.LeaseChangedAdded)
}

View file

@ -62,10 +62,12 @@ func initDNSServer() error {
Context.dnsFilter = dnsfilter.New(&filterConf, nil)
p := dnsforward.DNSCreateParams{
DNSFilter: Context.dnsFilter,
Stats: Context.stats,
QueryLog: Context.queryLog,
DHCPServer: Context.dhcpServer,
DNSFilter: Context.dnsFilter,
Stats: Context.stats,
QueryLog: Context.queryLog,
}
if Context.dhcpServer != nil {
p.DHCPServer = Context.dhcpServer
}
Context.dnsServer = dnsforward.NewServer(p)
dnsConfig := generateServerConfig()