Apply inbounds on nodes via Xray with Reality settings and client sync.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -117,6 +117,7 @@ func (s *Server) clientsCreate(w http.ResponseWriter, r *http.Request) {
|
||||
formErr("Не удалось создать (возможно username занят)")
|
||||
return
|
||||
}
|
||||
s.syncNodesForInbounds(inboundIDs)
|
||||
http.Redirect(w, r, "/admin/clients/"+c.ID.String()+"?ok=created", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
@@ -187,11 +188,16 @@ func (s *Server) clientUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/admin/clients/"+id.String()+"?err=username", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
oldIDs, _ := db.ListClientInboundIDs(s.DB, id)
|
||||
if err := db.UpdateClient(s.DB, c, parseInboundIDs(r)); err != nil {
|
||||
log.Printf("update client: %v", err)
|
||||
http.Redirect(w, r, "/admin/clients/"+id.String()+"?err=save", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
newIDs := parseInboundIDs(r)
|
||||
merged := append([]uuid.UUID{}, oldIDs...)
|
||||
merged = append(merged, newIDs...)
|
||||
s.syncNodesForInbounds(merged)
|
||||
http.Redirect(w, r, "/admin/clients/"+id.String()+"?ok=saved", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
@@ -211,6 +217,7 @@ func (s *Server) clientToggle(w http.ResponseWriter, r *http.Request) {
|
||||
next = models.ClientStatusActive
|
||||
}
|
||||
_ = db.SetClientStatus(s.DB, id, next)
|
||||
s.syncNodesForInbounds(c.InboundIDs)
|
||||
http.Redirect(w, r, "/admin/clients/"+id.String()+"?ok=status", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
@@ -220,6 +227,12 @@ func (s *Server) clientDelete(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "invalid id", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
c, _ := db.GetClient(s.DB, id)
|
||||
var inboundIDs []uuid.UUID
|
||||
if c != nil {
|
||||
inboundIDs = c.InboundIDs
|
||||
}
|
||||
_ = db.DeleteClient(s.DB, id)
|
||||
s.syncNodesForInbounds(inboundIDs)
|
||||
http.Redirect(w, r, "/admin/clients?ok=deleted", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user