v0.5.7 : Ajout flag -version, correction filtre cn=
This commit is contained in:
parent
b0d006b39b
commit
dfc26b821c
16
main.go
16
main.go
@ -22,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gVersion = "0.5.6"
|
gVersion = "0.5.8"
|
||||||
|
|
||||||
gRoLdap *MyLdap
|
gRoLdap *MyLdap
|
||||||
)
|
)
|
||||||
@ -263,6 +263,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
// json format is the default
|
// json format is the default
|
||||||
format := c.DefaultQuery("format", "json")
|
format := c.DefaultQuery("format", "json")
|
||||||
@ -298,6 +299,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, "ALL")
|
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, "ALL")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -334,6 +336,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
res, err := searchByCn(ldapCon, ou, cn, class, attr)
|
res, err := searchByCn(ldapCon, ou, cn, class, attr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -365,6 +368,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, attr)
|
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, attr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -405,6 +409,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
// Unmarshall json body to a map
|
// Unmarshall json body to a map
|
||||||
if c.Request.Header.Get("Content-Type") == "application/json" {
|
if c.Request.Header.Get("Content-Type") == "application/json" {
|
||||||
@ -468,6 +473,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
// Unmarshall json body to a map
|
// Unmarshall json body to a map
|
||||||
if c.Request.Header.Get("Content-Type") == "application/json" {
|
if c.Request.Header.Get("Content-Type") == "application/json" {
|
||||||
@ -521,6 +527,7 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer ldapCon.Conn.Close()
|
||||||
|
|
||||||
// Unmarshall json body to a map
|
// Unmarshall json body to a map
|
||||||
if c.Request.Header.Get("Content-Type") == "application/json" {
|
if c.Request.Header.Get("Content-Type") == "application/json" {
|
||||||
@ -570,6 +577,7 @@ func main() {
|
|||||||
var tlsCert string
|
var tlsCert string
|
||||||
var doTls bool
|
var doTls bool
|
||||||
var debug bool
|
var debug bool
|
||||||
|
var showversion bool
|
||||||
|
|
||||||
flag.StringVar(&confFile, "config", "", "Path to the config file (optional)")
|
flag.StringVar(&confFile, "config", "", "Path to the config file (optional)")
|
||||||
flag.StringVar(&listen, "listen-addr", "0.0.0.0:8080", "listen address for server")
|
flag.StringVar(&listen, "listen-addr", "0.0.0.0:8080", "listen address for server")
|
||||||
@ -582,9 +590,15 @@ func main() {
|
|||||||
flag.StringVar(&tlsPrivKey, "ssl-private-key", "", "SSL Private key")
|
flag.StringVar(&tlsPrivKey, "ssl-private-key", "", "SSL Private key")
|
||||||
flag.StringVar(&tlsCert, "ssl-certificate", "", "SSL certificate (PEM format)")
|
flag.StringVar(&tlsCert, "ssl-certificate", "", "SSL certificate (PEM format)")
|
||||||
flag.BoolVar(&debug, "debug", false, "Set log level to debug")
|
flag.BoolVar(&debug, "debug", false, "Set log level to debug")
|
||||||
|
flag.BoolVar(&showversion, "version", false, "Show version then exit")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if showversion {
|
||||||
|
fmt.Printf("GlApi v%s\n", gVersion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(confFile) > 0 {
|
if len(confFile) > 0 {
|
||||||
viper.SetConfigFile(confFile)
|
viper.SetConfigFile(confFile)
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user