exec go fix

Kim committed Mar 3, 2026 at 13:40 UTC 2221daab2e3401cac6c484c2eab44e656c077f9b
4 files changed +14 -15
cmd/relay-server/admin.go
+9 -9
@@ -242,7 +242,7 @@ func (a *Admin) HandleAdminRequest(w http.ResponseWriter, r *http.Request, serv
242 case route == "leases/banned" && r.Method == http.MethodGet:
243 writeJSON(w, serv.GetLeaseManager().GetBannedLeases())
244 case route == "stats" && r.Method == http.MethodGet:
245 - writeJSON(w, map[string]interface{}{
245 + writeJSON(w, map[string]any{
246 "leases_count": len(serv.GetLeaseManager().GetAllLeaseEntries()),
247 "uptime": "TODO",
248 })
@@ -273,7 +273,7 @@ func (a *Admin) handleLogin(w http.ResponseWriter, r *http.Request) {
273 if a.authManager.IsIPLocked(clientIP) {
274 remaining := a.authManager.GetLockRemainingSeconds(clientIP)
275 w.WriteHeader(http.StatusTooManyRequests)
276 - writeJSON(w, map[string]interface{}{
276 + writeJSON(w, map[string]any{
277 "success": false,
278 "error": "Too many failed attempts. Please try again later.",
279 "locked": true,
@@ -295,7 +295,7 @@ func (a *Admin) handleLogin(w http.ResponseWriter, r *http.Request) {
295 nowLocked := a.authManager.RecordFailedLogin(clientIP)
296 log.Warn().Str("ip", clientIP).Bool("now_locked", nowLocked).Msg("[Admin] Failed login attempt")
297
298 - response := map[string]interface{}{
298 + response := map[string]any{
299 "success": false,
300 "error": "Invalid key",
301 "locked": nowLocked,
@@ -324,7 +324,7 @@ func (a *Admin) handleLogin(w http.ResponseWriter, r *http.Request) {
324 })
325
326 log.Info().Str("ip", clientIP).Msg("[Admin] Successful login")
327 - writeJSON(w, map[string]interface{}{
327 + writeJSON(w, map[string]any{
328 "success": true,
329 })
330 }
@@ -348,7 +348,7 @@ func (a *Admin) handleLogout(w http.ResponseWriter, r *http.Request) {
348 MaxAge: -1, // Delete cookie
349 })
350
351 - writeJSON(w, map[string]interface{}{
351 + writeJSON(w, map[string]any{
352 "success": true,
353 })
354 }
@@ -360,7 +360,7 @@ func (a *Admin) handleAuthStatus(w http.ResponseWriter, r *http.Request) {
360 // Check if secret key is configured
361 authEnabled := a.authManager != nil && a.authManager.HasSecretKey()
362
363 - writeJSON(w, map[string]interface{}{
363 + writeJSON(w, map[string]any{
364 "authenticated": authenticated,
365 "auth_enabled": authEnabled,
366 })
@@ -394,7 +394,7 @@ func (a *Admin) handleLeaseBanRequest(w http.ResponseWriter, r *http.Request, se
394 }
395
396 func (a *Admin) handleGetSettings(w http.ResponseWriter) {
397 - writeJSON(w, map[string]interface{}{
397 + writeJSON(w, map[string]any{
398 "approval_mode": a.approveManager.GetApprovalMode(),
399 "approved_leases": a.approveManager.GetApprovedLeases(),
400 "denied_leases": a.approveManager.GetDeniedLeases(),
@@ -404,7 +404,7 @@ func (a *Admin) handleGetSettings(w http.ResponseWriter) {
404 func (a *Admin) handleApprovalModeRequest(w http.ResponseWriter, r *http.Request, serv *portal.RelayServer) {
405 switch r.Method {
406 case http.MethodGet:
407 - writeJSON(w, map[string]interface{}{
407 + writeJSON(w, map[string]any{
408 "approval_mode": a.approveManager.GetApprovalMode(),
409 })
410 case http.MethodPost:
@@ -423,7 +423,7 @@ func (a *Admin) handleApprovalModeRequest(w http.ResponseWriter, r *http.Request
423 a.approveManager.SetApprovalMode(mode)
424 a.SaveSettings(serv)
425 log.Info().Str("mode", string(mode)).Msg("[Admin] Approval mode changed")
426 - writeJSON(w, map[string]interface{}{
426 + writeJSON(w, map[string]any{
427 "approval_mode": mode,
428 })
429 default:
cmd/relay-server/manager/bps_manager.go
+2 -3
@@ -3,6 +3,7 @@ package manager
3 import (
4 "errors"
5 "io"
6 + "maps"
7 "net"
8 "sync"
9 "sync/atomic"
@@ -57,9 +58,7 @@ func (m *BPSManager) GetAllBPSLimits() map[string]int64 {
58 m.mu.Lock()
59 defer m.mu.Unlock()
60 result := make(map[string]int64, len(m.bpsLimits))
60 - for k, v := range m.bpsLimits {
61 - result[k] = v
62 - }
61 + maps.Copy(result, m.bpsLimits)
62 return result
63 }
64
cmd/relay-server/manager/ip_manager.go
+2 -2
@@ -122,8 +122,8 @@ func ExtractClientIP(r *http.Request) string {
122 // Check X-Forwarded-For header first (for proxied requests)
123 if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
124 // X-Forwarded-For can contain multiple IPs, take the first one
125 - if idx := strings.Index(xff, ","); idx != -1 {
126 - return strings.TrimSpace(xff[:idx])
125 + if before, _, ok := strings.Cut(xff, ","); ok {
126 + return strings.TrimSpace(before)
127 }
128 return strings.TrimSpace(xff)
129 }
portal/reverse_hub.go
+1 -1
@@ -177,7 +177,7 @@ func (h *ReverseHub) Offer(leaseID string, conn *ReverseConn) bool {
177 return false
178 }
179
180 - for i := 0; i < QueueSize+1; i++ {
180 + for range QueueSize + 1 {
181 select {
182 case pool <- conn:
183 return true