add multiple error checks
This commit is contained in:
parent
61a1637650
commit
96d15771e2
|
@ -708,7 +708,11 @@ func cdLocal() {
|
|||
dlog.Warnf("Unable to determine the executable directory: [%s] -- You will need to specify absolute paths in the configuration file", err)
|
||||
return
|
||||
}
|
||||
os.Chdir(filepath.Dir(exeFileName))
|
||||
|
||||
err = os.Chdir(filepath.Dir(exeFileName))
|
||||
if err != nil {
|
||||
dlog.Warnf("Unable to change working directory: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func isIPAndPort(addrStr string) error {
|
||||
|
|
|
@ -226,8 +226,14 @@ func _dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress stri
|
|||
return nil, 0, err
|
||||
}
|
||||
defer pc.Close()
|
||||
pc.SetDeadline(time.Now().Add(proxy.timeout))
|
||||
pc.Write(binQuery)
|
||||
err = pc.SetDeadline(time.Now().Add(proxy.timeout))
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
_, err = pc.Write(binQuery)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
packet = make([]byte, MaxDNSPacketSize)
|
||||
length, err := pc.Read(packet)
|
||||
if err != nil {
|
||||
|
@ -261,12 +267,18 @@ func _dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress stri
|
|||
return nil, 0, err
|
||||
}
|
||||
defer pc.Close()
|
||||
pc.SetDeadline(time.Now().Add(proxy.timeout))
|
||||
err = pc.SetDeadline(time.Now().Add(proxy.timeout))
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
binQuery, err = PrefixWithSize(binQuery)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
pc.Write(binQuery)
|
||||
_, err = pc.Write(binQuery)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
packet, err = ReadPrefixed(&pc)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
|
|
|
@ -126,7 +126,9 @@ func (app *App) AppMain() {
|
|||
}
|
||||
app.quit = make(chan struct{})
|
||||
app.wg.Add(1)
|
||||
pidfile.Write()
|
||||
if err := pidfile.Write(); err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
app.proxy.StartProxy()
|
||||
<-app.quit
|
||||
dlog.Notice("Quit signal received...")
|
||||
|
|
|
@ -151,7 +151,10 @@ func (plugin *PluginBlockIP) Eval(pluginsState *PluginsState, msg *dns.Msg) erro
|
|||
if plugin.logger == nil {
|
||||
return errors.New("Log file not initialized")
|
||||
}
|
||||
plugin.logger.Write([]byte(line))
|
||||
_, err := plugin.logger.Write([]byte(line))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -66,7 +66,10 @@ func (blockedNames *BlockedNames) check(pluginsState *PluginsState, qName string
|
|||
if blockedNames.logger == nil {
|
||||
return false, errors.New("Log file not initialized")
|
||||
}
|
||||
blockedNames.logger.Write([]byte(line))
|
||||
_, err := blockedNames.logger.Write([]byte(line))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
@ -84,7 +84,10 @@ func (plugin *PluginCloak) Init(proxy *Proxy) error {
|
|||
cloakedNames[line] = cloakedName
|
||||
}
|
||||
for line, cloakedName := range cloakedNames {
|
||||
plugin.patternMatcher.Add(line, cloakedName, cloakedName.lineNo)
|
||||
err = plugin.patternMatcher.Add(line, cloakedName, cloakedName.lineNo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@ func ServiceManagerStartNotify() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mgr.Disconnect()
|
||||
|
||||
if err = mgr.Disconnect(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue