Fix DHT and tracker stats display
This commit is contained in:
parent
42fad7c9fd
commit
4f4c817276
@ -3326,7 +3326,7 @@ func RegisterRoutes(r *mux.Router, cfg *config.Config, storage *storage.Backend)
|
|||||||
publicRoutes.HandleFunc("/profile/{pubkey}", gateway.ProfileHandler).Methods("GET")
|
publicRoutes.HandleFunc("/profile/{pubkey}", gateway.ProfileHandler).Methods("GET")
|
||||||
|
|
||||||
// System stats endpoint (public)
|
// System stats endpoint (public)
|
||||||
r.HandleFunc("/stats", systemStatsHandler(storage, trackerInstance)).Methods("GET")
|
r.HandleFunc("/stats", systemStatsHandler(gateway, storage, trackerInstance)).Methods("GET")
|
||||||
|
|
||||||
// Branding configuration endpoint (public)
|
// Branding configuration endpoint (public)
|
||||||
r.HandleFunc("/branding", brandingHandler(cfg)).Methods("GET")
|
r.HandleFunc("/branding", brandingHandler(cfg)).Methods("GET")
|
||||||
@ -3939,7 +3939,7 @@ func brandingHandler(cfg *config.Config) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func systemStatsHandler(storage *storage.Backend, trackerInstance *tracker.Tracker) http.HandlerFunc {
|
func systemStatsHandler(gateway *Gateway, storage *storage.Backend, trackerInstance *tracker.Tracker) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
@ -4013,8 +4013,8 @@ func systemStatsHandler(storage *storage.Backend, trackerInstance *tracker.Track
|
|||||||
},
|
},
|
||||||
"dht": map[string]interface{}{
|
"dht": map[string]interface{}{
|
||||||
"status": "healthy",
|
"status": "healthy",
|
||||||
"port": 6882,
|
"port": 6883, // Fixed port number
|
||||||
"peers": 0, // Would need DHT integration
|
"peers": 0, // Will be updated below if DHT available
|
||||||
"torrents": torrentFiles,
|
"torrents": torrentFiles,
|
||||||
},
|
},
|
||||||
"system": map[string]interface{}{
|
"system": map[string]interface{}{
|
||||||
@ -4027,6 +4027,17 @@ func systemStatsHandler(storage *storage.Backend, trackerInstance *tracker.Track
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update DHT stats with real data if DHT is enabled
|
||||||
|
if gateway.config.IsServiceEnabled("dht") && gateway.dhtBootstrap != nil {
|
||||||
|
dhtStats := gateway.dhtBootstrap.GetDHTStats()
|
||||||
|
if dhtMap, exists := stats["dht"].(map[string]interface{}); exists {
|
||||||
|
// Update peers count with routing table size
|
||||||
|
if routingTableSize, hasRouting := dhtStats["routing_table_size"]; hasRouting {
|
||||||
|
dhtMap["peers"] = routingTableSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add tracker stats if enabled
|
// Add tracker stats if enabled
|
||||||
if trackerInstance != nil {
|
if trackerInstance != nil {
|
||||||
trackerStats := trackerInstance.GetStats()
|
trackerStats := trackerInstance.GetStats()
|
||||||
|
@ -260,6 +260,50 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="stats-section">
|
||||||
|
<h3>🌐 DHT Network</h3>
|
||||||
|
<div class="service-grid">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Status</div>
|
||||||
|
<div class="stat-value status-indicator" id="dht-status">🔴</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Routing Table</div>
|
||||||
|
<div class="stat-value" id="dht-peers">--</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Announced Torrents</div>
|
||||||
|
<div class="stat-value" id="dht-torrents">--</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="stats-section">
|
||||||
|
<h3>📊 Tracker Stats</h3>
|
||||||
|
<div class="service-grid">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Status</div>
|
||||||
|
<div class="stat-value status-indicator" id="tracker-status">🔴</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Torrents</div>
|
||||||
|
<div class="stat-value" id="tracker-torrents">--</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Total Peers</div>
|
||||||
|
<div class="stat-value" id="tracker-peers">--</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Seeders</div>
|
||||||
|
<div class="stat-value" id="tracker-seeders">--</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-header">Leechers</div>
|
||||||
|
<div class="stat-value" id="tracker-leechers">--</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="stats-section">
|
<div class="stats-section">
|
||||||
<h3>📱 WebTorrent Integration</h3>
|
<h3>📱 WebTorrent Integration</h3>
|
||||||
<div class="service-grid">
|
<div class="service-grid">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user