Show subscription inbounds as Remnawave-style host cards.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-29 04:56:45 +03:00
co-authored by Cursor
parent c0e78ce949
commit c41bae9852
8 changed files with 493 additions and 72 deletions
+17 -31
View File
@@ -132,7 +132,7 @@ func (s *Server) clientView(w http.ResponseWriter, r *http.Request) {
return
}
inbounds, _ := db.ListAllInbounds(s.DB)
links, _ := db.ClientSubscriptionLinks(s.DB, c)
info, _ := db.BuildSubscriptionInfo(s.DB, c)
scheme := "https"
if r.TLS == nil {
if xf := r.Header.Get("X-Forwarded-Proto"); xf != "" {
@@ -142,16 +142,23 @@ func (s *Server) clientView(w http.ResponseWriter, r *http.Request) {
}
}
subURL := scheme + "://" + r.Host + "/sub/" + c.SubToken
var links []string
var hosts []models.SubHost
if info != nil {
links = info.Links
hosts = info.Hosts
}
s.render(w, "client_view.html", pageData{
"Title": c.Username,
"UserName": s.Auth.CurrentName(r),
"Active": "clients",
"Client": c,
"Inbounds": inbounds,
"Links": links,
"SubURL": subURL,
"Flash": r.URL.Query().Get("ok"),
"Error": r.URL.Query().Get("err"),
"Title": c.Username,
"UserName": s.Auth.CurrentName(r),
"Active": "clients",
"Client": c,
"Inbounds": inbounds,
"Links": links,
"Hosts": hosts,
"SubURL": subURL,
"Flash": r.URL.Query().Get("ok"),
"Error": r.URL.Query().Get("err"),
})
}
@@ -216,24 +223,3 @@ func (s *Server) clientDelete(w http.ResponseWriter, r *http.Request) {
_ = db.DeleteClient(s.DB, id)
http.Redirect(w, r, "/admin/clients?ok=deleted", http.StatusSeeOther)
}
func (s *Server) subscriptionGet(w http.ResponseWriter, r *http.Request) {
token := mux.Vars(r)["token"]
c, err := db.GetClientBySubToken(s.DB, token)
if err != nil || c == nil || !c.IsActive() {
http.Error(w, "not found", http.StatusNotFound)
return
}
links, err := db.ClientSubscriptionLinks(s.DB, c)
if err != nil {
http.Error(w, "error", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("Profile-Title", c.Username)
if len(links) == 0 {
_, _ = w.Write([]byte("# no active inbounds / online nodes\n"))
return
}
_, _ = w.Write([]byte(strings.Join(links, "\n") + "\n"))
}