4 Commits

Author SHA1 Message Date
yo
6e9947809c Change "Invalid IP" msgs to info loglevel 2022-05-17 15:54:12 +02:00
yo
874b1c541a Duh! 2022-05-17 11:51:23 +02:00
yo
28dd17ccee Dont create pidfile if not defined 2022-05-17 11:43:36 +02:00
yo
a84e22ce61 Clean + version bump 2022-05-16 13:53:01 +02:00

View File

@ -26,7 +26,7 @@ import (
)
const (
version = "1.0.0-rc"
version = "1.0.0-rc4"
)
var (
@ -177,8 +177,6 @@ func handleConnection(connClt net.Conn, conLdap *ldap.Conn) {
if err.Error() != "EOF" && !strings.HasSuffix(err.Error(), "i/o timeout") {
logstream.Errorf("Error reading connection: %v\n", err.Error())
}
//sendResponse(connClt, err.Error(), 500)
//continue
return
}
@ -229,7 +227,12 @@ func handleConnection(connClt net.Conn, conLdap *ldap.Conn) {
// First query netCache built with ipNetworkNumber
res, err := isIPContainedInNetCache(ip)
if err != nil {
if strings.EqualFold(err.Error(), fmt.Sprintf("Invalid IP: %s", ip)) {
// We don't want those msg to pollute logs
logstream.Info(err.Error())
} else {
logstream.Error(err.Error())
}
sendResponse(connClt, err.Error(), 500)
continue
}
@ -303,7 +306,7 @@ func connectLdap() (*ldap.Conn, error) {
}
err = conLdap.Bind(*ldapUser, *ldapPass)
if err != nil {
logstream.Errorf("Error binding LDAP: ", err)
logstream.Errorf("Error binding LDAP: %s", err)
return conLdap, err
}
return conLdap, err
@ -351,7 +354,7 @@ func main() {
ldapBaseDN = fs.String("ldapDN", "", "LDAP base DN (also via LDAPDN env var)")
ldapUser = fs.String("ldapUser", "", "LDAP user DN (also via LDAPUSER env var)")
ldapPass = fs.String("ldapPass", "", "LDAP user password (also via LDAPPASS env var)")
pidFilePath = fs.String("pidfile", "/var/run/mynettcptable/mynettcptable.pid", "PID File (also via PIDFILE env var)")
pidFilePath = fs.String("pidfile", "", "PID File (also via PIDFILE env var). Creates pidfile only if defined")
refreshInterval = fs.Int("refresh", 300, "Net cache update interval in seconds")
timeout = fs.Int("timeout", 5, "timeout in seconds")
_ = fs.String("config", "", "config file (optional)")
@ -405,13 +408,13 @@ func main() {
logstream.Hooks.Add(hook)
}
if len(*pidFilePath) > 0 {
if pid, err := pidfile.Create(*pidFilePath); err != nil {
logstream.Fatal(err)
} else {
defer pid.Clear()
}
//defer logstream.Close()
}
logstream.Infof("Start listening for incoming connections on %s\n", *listen)
run()