mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-07 02:06:38 +08:00
修复agent时携带错误的屏蔽协议数据,编辑转发时无法使用原分配端口
This commit is contained in:
@@ -2,7 +2,7 @@ name: Build and Push Images Based on Version
|
|||||||
|
|
||||||
# 在这里定义统一版本号
|
# 在这里定义统一版本号
|
||||||
env:
|
env:
|
||||||
VERSION: "2.0.4-beta"
|
VERSION: "2.0.5-beta"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
image: bqlpfy/springboot-backend:2.0.4-beta
|
image: bqlpfy/springboot-backend:2.0.5-beta
|
||||||
container_name: springboot-backend
|
container_name: springboot-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -25,7 +25,7 @@ services:
|
|||||||
start_period: 60s
|
start_period: 60s
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: bqlpfy/vite-frontend:2.0.4-beta
|
image: bqlpfy/vite-frontend:2.0.5-beta
|
||||||
container_name: vite-frontend
|
container_name: vite-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
image: bqlpfy/springboot-backend:2.0.4-beta
|
image: bqlpfy/springboot-backend:2.0.5-beta
|
||||||
container_name: springboot-backend
|
container_name: springboot-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -25,7 +25,7 @@ services:
|
|||||||
start_period: 60s
|
start_period: 60s
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: bqlpfy/vite-frontend:2.0.4-beta
|
image: bqlpfy/vite-frontend:2.0.5-beta
|
||||||
container_name: vite-frontend
|
container_name: vite-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ func main() {
|
|||||||
log := xlogger.NewLogger()
|
log := xlogger.NewLogger()
|
||||||
logger.SetDefault(log)
|
logger.SetDefault(log)
|
||||||
|
|
||||||
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, config.Http, config.Tls, config.Socks, "2.0.0")
|
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, config.Http, config.Tls, config.Socks, "2.0.1")
|
||||||
defer wsReporter.Stop()
|
defer wsReporter.Stop()
|
||||||
service.SetHTTPReportURL(config.Addr, config.Secret)
|
service.SetHTTPReportURL(config.Addr, config.Secret)
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ type TcpPingResponse struct {
|
|||||||
|
|
||||||
type WebSocketReporter struct {
|
type WebSocketReporter struct {
|
||||||
url string
|
url string
|
||||||
|
addr string // 保存服务器地址
|
||||||
|
secret string // 保存密钥
|
||||||
|
version string // 保存版本号
|
||||||
conn *websocket.Conn
|
conn *websocket.Conn
|
||||||
reconnectTime time.Duration
|
reconnectTime time.Duration
|
||||||
pingInterval time.Duration
|
pingInterval time.Duration
|
||||||
@@ -195,7 +198,25 @@ func (w *WebSocketReporter) connect() error {
|
|||||||
w.connecting = false
|
w.connecting = false
|
||||||
}()
|
}()
|
||||||
|
|
||||||
u, err := url.Parse(w.url)
|
// 重新读取 config.json 获取最新的协议配置
|
||||||
|
type LocalConfig struct {
|
||||||
|
Addr string `json:"addr"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
Http int `json:"http"`
|
||||||
|
Tls int `json:"tls"`
|
||||||
|
Socks int `json:"socks"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg LocalConfig
|
||||||
|
if b, err := os.ReadFile("config.json"); err == nil {
|
||||||
|
json.Unmarshal(b, &cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用最新的配置重新构建 URL
|
||||||
|
currentURL := "ws://" + w.addr + "/system-info?type=1&secret=" + w.secret + "&version=" + w.version +
|
||||||
|
"&http=" + strconv.Itoa(cfg.Http) + "&tls=" + strconv.Itoa(cfg.Tls) + "&socks=" + strconv.Itoa(cfg.Socks)
|
||||||
|
|
||||||
|
u, err := url.Parse(currentURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("解析URL失败: %v", err)
|
return fmt.Errorf("解析URL失败: %v", err)
|
||||||
}
|
}
|
||||||
@@ -225,7 +246,7 @@ func (w *WebSocketReporter) connect() error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Printf("✅ WebSocket连接建立成功\n")
|
fmt.Printf("✅ WebSocket连接建立成功 (http=%d, tls=%d, socks=%d)\n", cfg.Http, cfg.Tls, cfg.Socks)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1021,12 +1042,16 @@ func getMemoryInfo() MemoryInfo {
|
|||||||
// StartWebSocketReporterWithConfig 使用配置字段启动WebSocket报告器
|
// StartWebSocketReporterWithConfig 使用配置字段启动WebSocket报告器
|
||||||
func StartWebSocketReporterWithConfig(addr string, secret string, http int, tls int, socks int, version string) *WebSocketReporter {
|
func StartWebSocketReporterWithConfig(addr string, secret string, http int, tls int, socks int, version string) *WebSocketReporter {
|
||||||
|
|
||||||
// 构建包含本机IP的WebSocket URL
|
// 构建初始 WebSocket URL
|
||||||
fullURL := "ws://" + addr + "/system-info?type=1&secret=" + secret + "&version=" + version + "&http=" + strconv.Itoa(http) + "&tls=" + strconv.Itoa(tls) + "&socks=" + strconv.Itoa(socks)
|
fullURL := "ws://" + addr + "/system-info?type=1&secret=" + secret + "&version=" + version + "&http=" + strconv.Itoa(http) + "&tls=" + strconv.Itoa(tls) + "&socks=" + strconv.Itoa(socks)
|
||||||
|
|
||||||
fmt.Printf("🔗 WebSocket连接URL: %s\n", fullURL)
|
fmt.Printf("🔗 WebSocket连接URL: %s\n", fullURL)
|
||||||
|
|
||||||
reporter := NewWebSocketReporter(fullURL, secret)
|
reporter := NewWebSocketReporter(fullURL, secret)
|
||||||
|
// 保存 addr, secret, version 供重连时使用
|
||||||
|
reporter.addr = addr
|
||||||
|
reporter.secret = secret
|
||||||
|
reporter.version = version
|
||||||
reporter.Start()
|
reporter.Start()
|
||||||
return reporter
|
return reporter
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ get_architecture() {
|
|||||||
# 构建下载地址
|
# 构建下载地址
|
||||||
build_download_url() {
|
build_download_url() {
|
||||||
local ARCH=$(get_architecture)
|
local ARCH=$(get_architecture)
|
||||||
echo "https://github.com/bqlpfy/flux-panel/releases/download/2.0.4-beta/gost-${ARCH}"
|
echo "https://github.com/bqlpfy/flux-panel/releases/download/2.0.5-beta/gost-${ARCH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 下载地址
|
# 下载地址
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ export LC_ALL=C
|
|||||||
|
|
||||||
|
|
||||||
# 全局下载地址配置
|
# 全局下载地址配置
|
||||||
DOCKER_COMPOSEV4_URL="https://github.com/bqlpfy/flux-panel/releases/download/2.0.4-beta/docker-compose-v4.yml"
|
DOCKER_COMPOSEV4_URL="https://github.com/bqlpfy/flux-panel/releases/download/2.0.5-beta/docker-compose-v4.yml"
|
||||||
DOCKER_COMPOSEV6_URL="https://github.com/bqlpfy/flux-panel/releases/download/2.0.4-beta/docker-compose-v6.yml"
|
DOCKER_COMPOSEV6_URL="https://github.com/bqlpfy/flux-panel/releases/download/2.0.5-beta/docker-compose-v6.yml"
|
||||||
|
|
||||||
COUNTRY=$(curl -s https://ipinfo.io/country)
|
COUNTRY=$(curl -s https://ipinfo.io/country)
|
||||||
if [ "$COUNTRY" = "CN" ]; then
|
if [ "$COUNTRY" = "CN" ]; then
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> impl
|
|||||||
forward.setUpdatedTime(System.currentTimeMillis());
|
forward.setUpdatedTime(System.currentTimeMillis());
|
||||||
List<JSONObject> success = new ArrayList<>();
|
List<JSONObject> success = new ArrayList<>();
|
||||||
List<ChainTunnel> chainTunnels = chainTunnelService.list(new QueryWrapper<ChainTunnel>().eq("tunnel_id", tunnel.getId()).eq("chain_type", 1));
|
List<ChainTunnel> chainTunnels = chainTunnelService.list(new QueryWrapper<ChainTunnel>().eq("tunnel_id", tunnel.getId()).eq("chain_type", 1));
|
||||||
chainTunnels = get_port(chainTunnels, forwardDto.getInPort());
|
chainTunnels = get_port(chainTunnels, forwardDto.getInPort(), 0L);
|
||||||
this.save(forward);
|
this.save(forward);
|
||||||
|
|
||||||
for (ChainTunnel chainTunnel : chainTunnels) {
|
for (ChainTunnel chainTunnel : chainTunnels) {
|
||||||
@@ -251,7 +251,12 @@ public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> impl
|
|||||||
|
|
||||||
|
|
||||||
List<ChainTunnel> chainTunnels = chainTunnelService.list(new QueryWrapper<ChainTunnel>().eq("tunnel_id", tunnel.getId()).eq("chain_type", 1));
|
List<ChainTunnel> chainTunnels = chainTunnelService.list(new QueryWrapper<ChainTunnel>().eq("tunnel_id", tunnel.getId()).eq("chain_type", 1));
|
||||||
chainTunnels = get_port(chainTunnels, forwardUpdateDto.getInPort());
|
|
||||||
|
// 自己占用的应该不算
|
||||||
|
chainTunnels = get_port(chainTunnels, forwardUpdateDto.getInPort(), existForward.getId());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (ChainTunnel chainTunnel : chainTunnels) {
|
for (ChainTunnel chainTunnel : chainTunnels) {
|
||||||
String serviceName = buildServiceName(existForward.getId(), existForward.getUserId(), userTunnel);
|
String serviceName = buildServiceName(existForward.getId(), existForward.getUserId(), userTunnel);
|
||||||
Integer limiter = permissionResult.getLimiter();
|
Integer limiter = permissionResult.getLimiter();
|
||||||
@@ -940,12 +945,12 @@ public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<ChainTunnel> get_port(List<ChainTunnel> chainTunnelList, Integer in_port) {
|
public List<ChainTunnel> get_port(List<ChainTunnel> chainTunnelList, Integer in_port, Long forward_id) {
|
||||||
List<List<Integer>> list = new ArrayList<>();
|
List<List<Integer>> list = new ArrayList<>();
|
||||||
|
|
||||||
// 获取每个节点的端口列表
|
// 获取每个节点的端口列表
|
||||||
for (ChainTunnel tunnel : chainTunnelList) {
|
for (ChainTunnel tunnel : chainTunnelList) {
|
||||||
List<Integer> nodePort = getNodePort(tunnel.getNodeId());
|
List<Integer> nodePort = getNodePort(tunnel.getNodeId(), forward_id);
|
||||||
if (nodePort.isEmpty()) {
|
if (nodePort.isEmpty()) {
|
||||||
throw new RuntimeException("暂无可用端口");
|
throw new RuntimeException("暂无可用端口");
|
||||||
}
|
}
|
||||||
@@ -968,7 +973,7 @@ public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ========== 未指定 in_port 查找最小的共同端口 ==========
|
// ========== 未指定 in_port 查找最小的共同端口 ==========
|
||||||
Set<Integer> intersection = new HashSet<>(list.get(0));
|
Set<Integer> intersection = new HashSet<>(list.getFirst());
|
||||||
for (int i = 1; i < list.size(); i++) {
|
for (int i = 1; i < list.size(); i++) {
|
||||||
intersection.retainAll(list.get(i));
|
intersection.retainAll(list.get(i));
|
||||||
}
|
}
|
||||||
@@ -995,7 +1000,7 @@ public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> impl
|
|||||||
return chainTunnelList;
|
return chainTunnelList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getNodePort(Long nodeId) {
|
public List<Integer> getNodePort(Long nodeId, Long forward_id) {
|
||||||
|
|
||||||
Node node = nodeService.getById(nodeId);
|
Node node = nodeService.getById(nodeId);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
@@ -1012,7 +1017,7 @@ public class ForwardServiceImpl extends ServiceImpl<ForwardMapper, Forward> impl
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
|
||||||
List<ForwardPort> list = forwardPortService.list(new QueryWrapper<ForwardPort>().eq("node_id", nodeId));
|
List<ForwardPort> list = forwardPortService.list(new QueryWrapper<ForwardPort>().eq("node_id", nodeId).ne("forward_id", forward_id));
|
||||||
Set<Integer> forwardUsedPorts = new HashSet<>();
|
Set<Integer> forwardUsedPorts = new HashSet<>();
|
||||||
for (ForwardPort forwardPort : list) {
|
for (ForwardPort forwardPort : list) {
|
||||||
forwardUsedPorts.add(forwardPort.getPort());
|
forwardUsedPorts.add(forwardPort.getPort());
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements No
|
|||||||
ViteConfig viteConfig = viteConfigService.getOne(new QueryWrapper<ViteConfig>().eq("name", "ip"));
|
ViteConfig viteConfig = viteConfigService.getOne(new QueryWrapper<ViteConfig>().eq("name", "ip"));
|
||||||
if (viteConfig == null) return R.err("请先前往网站配置中设置ip");
|
if (viteConfig == null) return R.err("请先前往网站配置中设置ip");
|
||||||
StringBuilder command = new StringBuilder();
|
StringBuilder command = new StringBuilder();
|
||||||
command.append("curl -L https://github.com/bqlpfy/flux-panel/releases/download/2.0.4-beta/install.sh")
|
command.append("curl -L https://github.com/bqlpfy/flux-panel/releases/download/2.0.5-beta/install.sh")
|
||||||
.append(" -o ./install.sh && chmod +x ./install.sh && ");
|
.append(" -o ./install.sh && chmod +x ./install.sh && ");
|
||||||
String processedServerAddr = GostUtil.processServerAddress(viteConfig.getValue());
|
String processedServerAddr = GostUtil.processServerAddress(viteConfig.getValue());
|
||||||
command.append("./install.sh")
|
command.append("./install.sh")
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export type SiteConfig = typeof siteConfig;
|
|||||||
|
|
||||||
// 缓存相关常量
|
// 缓存相关常量
|
||||||
const CACHE_PREFIX = 'vite_config_';
|
const CACHE_PREFIX = 'vite_config_';
|
||||||
const VERSION = "2.0.4-beta";
|
const VERSION = "2.0.5-beta";
|
||||||
const APP_VERSION = "1.0.3";
|
const APP_VERSION = "1.0.3";
|
||||||
|
|
||||||
const getInitialConfig = () => {
|
const getInitialConfig = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user