Show subscription inbounds as Remnawave-style host cards.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user