Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90e0af59c3 | |||
| b7a6689b9b | |||
| ab597c221b | |||
| 558519f048 |
@@ -6,5 +6,5 @@ ldapPass here_lies_the_password
|
|||||||
# "domain" sera ajoute a relayName pour former le FQDN
|
# "domain" sera ajoute a relayName pour former le FQDN
|
||||||
domain example.org
|
domain example.org
|
||||||
# Le nom de l'attribut LDAP contenant le relais a retourner
|
# Le nom de l'attribut LDAP contenant le relais a retourner
|
||||||
lapAttr relayName
|
ldapAttr relayName
|
||||||
|
|
||||||
|
|||||||
+18
-2
@@ -33,7 +33,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "0.9.8"
|
version = "0.9.9"
|
||||||
// Match le nom de domaine, soit les 2 dernieres chaines separees par un point.
|
// Match le nom de domaine, soit les 2 dernieres chaines separees par un point.
|
||||||
// Peut aussi terminer par un point (Ex: srv.domaine.com. => domaine.com)
|
// Peut aussi terminer par un point (Ex: srv.domaine.com. => domaine.com)
|
||||||
DomainRegexpFormat = `([0-9A-Za-z\-]*)\.([0-9A-Za-z\-]*)(?:\.)?$`
|
DomainRegexpFormat = `([0-9A-Za-z\-]*)\.([0-9A-Za-z\-]*)(?:\.)?$`
|
||||||
@@ -55,12 +55,14 @@ var (
|
|||||||
timeout *int
|
timeout *int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// attempt is useless now. It was introduced to break after N attempts, but this is not implemented. Should it be?
|
||||||
func ldapSearch(searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult, error) {
|
func ldapSearch(searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult, error) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
result, err := conLdap.Search(searchReq)
|
result, err := conLdap.Search(searchReq)
|
||||||
mutex.Unlock()
|
mutex.Unlock()
|
||||||
// Let's just manage connection errors here
|
// Let's just manage connection errors here
|
||||||
if err != nil && strings.HasSuffix(err.Error(), "ldap: connection closed") {
|
if err != nil {
|
||||||
|
if strings.HasSuffix(err.Error(), "ldap: connection closed") {
|
||||||
logstream.Err("LDAP connection closed, retrying")
|
logstream.Err("LDAP connection closed, retrying")
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
conLdap.Close()
|
conLdap.Close()
|
||||||
@@ -72,6 +74,20 @@ func ldapSearch(searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult,
|
|||||||
attempt = attempt + 1
|
attempt = attempt + 1
|
||||||
return ldapSearch(searchReq, attempt)
|
return ldapSearch(searchReq, attempt)
|
||||||
}
|
}
|
||||||
|
} else if err == ldap.ErrNilConnection {
|
||||||
|
logstream.Err("LDAP connection is nil, reconnecting")
|
||||||
|
mutex.Lock()
|
||||||
|
// conLdap is nil so this would be a sigsegv/panic
|
||||||
|
//conLdap.Close()
|
||||||
|
conLdap, err = connectLdap()
|
||||||
|
mutex.Unlock()
|
||||||
|
if err != nil {
|
||||||
|
return result, err
|
||||||
|
} else {
|
||||||
|
attempt = attempt + 1
|
||||||
|
return ldapSearch(searchReq, attempt)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, err
|
return result, err
|
||||||
|
|||||||
Reference in New Issue
Block a user