feat(ldap): add ldap protocol support (#50)

Co-authored-by: tardc <[email protected]>
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2022-01-07 22:47:02 +08:00
committed by GitHub
co-authored by tardc E99p1ant
parent 06ae3d0555
commit fc505b0733
46 changed files with 1356 additions and 135 deletions
+2 -2
View File
@@ -191,10 +191,10 @@ func (s *Server) Run() {
}
}()
for s.Enable {
for {
tcpConn, err := listener.Accept()
if err != nil {
if !strings.Contains(err.Error(), net.ErrClosed.Error()) {
if !errors.Is(err, net.ErrClosed) {
log.Warn("RMI accept connection error: %v", err)
} else {
break
+3 -13
View File
@@ -93,10 +93,7 @@ func ListRules(c *gin.Context) {
}
db := database.DB.Model(&rmiRule)
if rmiRule.Name != "" {
db.Where("name = ?", rmiRule.Name)
}
db.Count(&count)
db.Where(&rmiRule).Count(&count)
page, err := strconv.Atoi(c.Query("page"))
if err != nil {
@@ -130,10 +127,7 @@ func ListRules(c *gin.Context) {
// UpsertRules creates or updates rmi rule from user submit
func UpsertRules(c *gin.Context) {
var (
rmiRule Rule
update bool
)
var rmiRule Rule
if err := c.ShouldBind(&rmiRule); err != nil {
c.JSON(400, gin.H{
@@ -144,10 +138,6 @@ func UpsertRules(c *gin.Context) {
return
}
if rmiRule.ID != 0 {
update = true
}
if err := rmiRule.CreateOrUpdate(); err != nil {
c.JSON(400, gin.H{
"status": "failed",
@@ -157,7 +147,7 @@ func UpsertRules(c *gin.Context) {
return
}
if update {
if rmiRule.ID != 0 {
log.Trace("RMI rule[id:%d] has been updated", rmiRule.ID)
} else {
log.Trace("RMI rule[id:%d] has been created", rmiRule.ID)