✨ Disable Proxy Filtering

This commit is contained in:
刘嘉伟 committed 2026-03-11 17:02:30 +08:00
1 parent 00cdea5af4
commit 46b28788a0
5 files changed
+55 -1

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ func (fs *Service) genCommonCfgs(id *string) (*v1.ClientCommonConfig, error) {
}
func (fs *Service) genProxyCfgs(serverId *string) ([]v1.ProxyConfigurer, error) {
proxies, err := fs.proxyRepo.FindByServerID(*serverId)
proxies, err := fs.proxyRepo.FindEnabledByServerID(*serverId)
if err != nil {
fs.app.Logger().Error("genProxyCfgs", "err", err)
return nil, err
+1
View File
@@ -9,4 +9,5 @@ type Repository interface {
UpdateBootStatusByServerID(serverID string, status ProxyBootStatus) error
ResetAllBootStatus() error
FindByServerID(serverID string) ([]Proxy, error)
FindEnabledByServerID(serverID string) ([]Proxy, error)
}
@@ -151,3 +151,23 @@ func (r *ProxyRepository) FindByServerID(serverID string) ([]proxy.Proxy, error)
return proxies, nil
}
func (r *ProxyRepository) FindEnabledByServerID(serverID string) ([]proxy.Proxy, error) {
var proxies []proxy.Proxy
err := r.app.DB().
Select("fh_proxies.*").
From("fh_proxies").
Where(dbx.And(
dbx.HashExp{"serverId": serverID},
dbx.HashExp{"status": string(proxy.ProxyStatusEnabled)},
)).
All(&proxies)
if err != nil {
r.app.Logger().Error("Failed to find enabled proxies by server id", "serverID", serverID, "error", err)
return nil, err
}
return proxies, nil
}
+25
View File
@@ -84,4 +84,29 @@ func (h *FrpcHandler) RegisterHandlers(e *core.ServeEvent) {
}
return e.JSON(200, map[string]string{"message": "frpc terminated"})
}))
e.Router.POST("/api/frpc/reload", requireAuth(func(e *core.RequestEvent) error {
data := struct {
ID string `json:"id"`
}{}
if err := e.BindBody(&data); err != nil {
return e.JSON(400, map[string]string{"error": "invalid request body"})
}
id := data.ID
if id == "" {
return e.JSON(400, map[string]string{"error": "id is required"})
}
if !validID.MatchString(id) {
return e.JSON(400, map[string]string{"error": "invalid id format"})
}
// Only reload if the server is currently running
if !h.service.IsServerRunning(id) {
return e.JSON(200, map[string]string{"message": "server not running, skipped"})
}
err := h.service.ReloadFrpc(&id)
if err != nil {
return e.JSON(500, map[string]string{"error": err.Error()})
}
return e.JSON(200, map[string]string{"message": "frpc reloaded"})
}))
}
+8
View File
@@ -1,5 +1,6 @@
import { useState, useEffect, useCallback } from "react";
import pb from "../../lib/pocketbase";
import { apiPost } from "../../lib/api";
import { toast } from "sonner";
export interface Proxy {
@@ -67,10 +68,15 @@ export function useProxies() {
}, [fetchProxies]);
const deleteProxy = async (id: string) => {
const proxy = proxies.find((p) => p.id === id);
try {
await pb.collection("fh_proxies").delete(id);
await fetchProxies();
toast.success("Proxy deleted successfully");
// Reload frp config if we know which server this proxy belonged to
if (proxy?.serverId) {
await apiPost("/api/frpc/reload", { id: proxy.serverId });
}
} catch (err) {
toast.error(err instanceof Error ? err.message : "Failed to delete proxy");
}
@@ -84,6 +90,8 @@ export function useProxies() {
);
try {
await pb.collection("fh_proxies").update(proxy.id, { status: newStatus });
// Reload frp config so the change takes effect immediately
await apiPost("/api/frpc/reload", { id: proxy.serverId });
} catch (err) {
// Rollback on failure
setProxies((prev) =>