feat: add local remote address toggle (#472)

This commit is contained in:
sagit
2026-04-26 16:30:05 +08:00
committed by GitHub
parent 3f374df724
commit 799bb66fe5
5 changed files with 416 additions and 2 deletions
@@ -50,6 +50,7 @@ type Handler struct {
}
const monitorTunnelQualityEnabledConfigKey = "monitor_tunnel_quality_enabled"
const allowLocalRemoteAddrConfigKey = "allow_local_remote_addr"
type loginRequest struct {
Username string `json:"username"`
@@ -1041,6 +1042,19 @@ func (h *Handler) isTunnelQualityMonitoringEnabled() bool {
return strings.TrimSpace(strings.ToLower(cfg.Value)) != "false"
}
func (h *Handler) allowLocalRemoteAddr() bool {
if h == nil || h.repo == nil {
return false
}
cfg, err := h.repo.GetConfigByName(allowLocalRemoteAddrConfigKey)
if err != nil || cfg == nil {
return false
}
return strings.TrimSpace(strings.ToLower(cfg.Value)) == "true"
}
func (h *Handler) userPackage(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
response.WriteJSON(w, response.ErrDefault("请求失败"))