mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 02:14:40 +01:00
Add some missing error checks (#2420)
I found these with the 'errcheck' tool (via 'golangci-lint'). I aimed to apply reasonable judgement when deciding which errors actually need handling, and how to handle them.
This commit is contained in:
parent
cef4b041d7
commit
b46775ae0c
3 changed files with 16 additions and 5 deletions
|
@ -861,7 +861,9 @@ func (config *Config) loadSources(proxy *Proxy) error {
|
|||
}
|
||||
proxy.registeredServers = append(proxy.registeredServers, RegisteredServer{name: serverName, stamp: stamp})
|
||||
}
|
||||
proxy.updateRegisteredServers()
|
||||
if err := proxy.updateRegisteredServers(); err != nil {
|
||||
return err
|
||||
}
|
||||
rs1 := proxy.registeredServers
|
||||
rs2 := proxy.serversInfo.registeredServers
|
||||
rand.Shuffle(len(rs1), func(i, j int) {
|
||||
|
|
|
@ -27,8 +27,11 @@ type App struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
TimezoneSetup()
|
||||
tzErr := TimezoneSetup()
|
||||
dlog.Init("dnscrypt-proxy", dlog.SeverityNotice, "DAEMON")
|
||||
if tzErr != nil {
|
||||
dlog.Errorf("Timezone setup failed: %v", tzErr)
|
||||
}
|
||||
runtime.MemProfileRate = 0
|
||||
|
||||
seed := make([]byte, 8)
|
||||
|
@ -141,7 +144,9 @@ func (app *App) AppMain() {
|
|||
}
|
||||
|
||||
func (app *App) Stop(service service.Service) error {
|
||||
PidFileRemove()
|
||||
if err := PidFileRemove(); err != nil {
|
||||
dlog.Warnf("Failed to remove the PID file: %v", err)
|
||||
}
|
||||
dlog.Notice("Stopped.")
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -615,7 +615,9 @@ func dohTestPacket(msgID uint16) []byte {
|
|||
msg.SetEdns0(uint16(MaxDNSPacketSize), false)
|
||||
ext := new(dns.EDNS0_PADDING)
|
||||
ext.Padding = make([]byte, 16)
|
||||
crypto_rand.Read(ext.Padding)
|
||||
if _, err := crypto_rand.Read(ext.Padding); err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
edns0 := msg.IsEdns0()
|
||||
edns0.Option = append(edns0.Option, ext)
|
||||
body, err := msg.Pack()
|
||||
|
@ -638,7 +640,9 @@ func dohNXTestPacket(msgID uint16) []byte {
|
|||
msg.SetEdns0(uint16(MaxDNSPacketSize), false)
|
||||
ext := new(dns.EDNS0_PADDING)
|
||||
ext.Padding = make([]byte, 16)
|
||||
crypto_rand.Read(ext.Padding)
|
||||
if _, err := crypto_rand.Read(ext.Padding); err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
edns0 := msg.IsEdns0()
|
||||
edns0.Option = append(edns0.Option, ext)
|
||||
body, err := msg.Pack()
|
||||
|
|
Loading…
Add table
Reference in a new issue