- 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.dnsFilter = p.DNSFilter
s.stats = p.Stats s.stats = p.Stats
s.queryLog = p.QueryLog 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.dhcpServer.SetOnLeaseChanged(s.onDHCPLeaseChanged)
s.onDHCPLeaseChanged(dhcpd.LeaseChangedAdded) s.onDHCPLeaseChanged(dhcpd.LeaseChangedAdded)
} }

View File

@ -65,7 +65,9 @@ func initDNSServer() error {
DNSFilter: Context.dnsFilter, DNSFilter: Context.dnsFilter,
Stats: Context.stats, Stats: Context.stats,
QueryLog: Context.queryLog, QueryLog: Context.queryLog,
DHCPServer: Context.dhcpServer, }
if Context.dhcpServer != nil {
p.DHCPServer = Context.dhcpServer
} }
Context.dnsServer = dnsforward.NewServer(p) Context.dnsServer = dnsforward.NewServer(p)
dnsConfig := generateServerConfig() dnsConfig := generateServerConfig()