feat: 新增 GRE 隧道协议,管理端口调整为 18080

- backend: 新增 GRE 隧道实现(ip tunnel 点对点互联),binmgr 支持 iproute2
- backend: api/identity 调整,各协议 service(gre/ikev2/ipsec/l2tp/openvpn)统一改动
- backend: OpenVPN 认证辅助与用户口令同步逻辑完善
- frontend: 协议图标/向导/编辑器支持 GRE,VPN 用户页重构(234 行)
- frontend: 新增 RouteListInput 路由列表输入组件,Dashboard/Layout 优化
- i18n: 中英文文案同步更新
- test: 新增 binmgr/common/gre 单测,openvpn 测试补充
- docs: README 补充 GRE 说明,默认监听端口 8080 → 18080
- chore: .gitignore 增加 opsx-vpn.previous(构建备份二进制)
This commit is contained in:
opsx committed 2026-10-20 20:58:58 +08:00
1 parent c7f59f2cbf
commit ef7eb378d2
28 files changed
+1363 -439

No files matched your search

+23 -20
View File
@@ -381,34 +381,32 @@ func InstallHint(protocol string) map[string]interface{} {
"pacman": "pacman -S --noconfirm wireguard-tools",
},
"openvpn": {
"apt-get": "apt-get install -y openvpn",
"yum": fmt.Sprintf("yum install -y epel-release && sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https://download.example/pub/epel|baseurl=%s|g' /etc/yum.repos.d/epel*.repo 2>/dev/null; yum install -y openvpn", epelMirror),
"dnf": fmt.Sprintf("dnf install -y epel-release && sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https://download.example/pub/epel|baseurl=%s|g' /etc/yum.repos.d/epel*.repo 2>/dev/null; dnf install -y openvpn", epelMirror),
"apk": "apk add openvpn",
"pacman": "pacman -S --noconfirm openvpn",
"apt-get": "apt-get install -y openvpn easy-rsa",
"yum": fmt.Sprintf("yum install -y epel-release && sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https://download.example/pub/epel|baseurl=%s|g' /etc/yum.repos.d/epel*.repo 2>/dev/null; yum install -y openvpn easy-rsa", epelMirror),
"dnf": fmt.Sprintf("dnf install -y epel-release && sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https://download.example/pub/epel|baseurl=%s|g' /etc/yum.repos.d/epel*.repo 2>/dev/null; dnf install -y openvpn easy-rsa", epelMirror),
"apk": "apk add openvpn easy-rsa",
"pacman": "pacman -S --noconfirm openvpn easy-rsa",
},
"strongswan": {
"apt-get": "apt-get install -y strongswan strongswan-swanctl",
"yum": fmt.Sprintf("yum install -y epel-release && sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https://download.example/pub/epel|baseurl=%s|g' /etc/yum.repos.d/epel*.repo 2>/dev/null; yum install -y strongswan", epelMirror),
"dnf": fmt.Sprintf("dnf install -y epel-release && sed -i 's|^metalink=|#metalink=|g; s|^#baseurl=https://download.example/pub/epel|baseurl=%s|g' /etc/yum.repos.d/epel*.repo 2>/dev/null; dnf install -y strongswan", epelMirror),
"yum": "yum install -y strongswan",
"dnf": "dnf install -y strongswan",
"apk": "apk add strongswan",
"pacman": "pacman -S --noconfirm strongswan",
},
}
// L2TP 额外需要 xl2tpd
if protocol == "l2tp" || protocol == "strongswan" {
// 追加 xl2tpd 包(L2TP 协议必需)
// L2TP 额外需要 xl2tpd。TencentOS 4 的 EPOL 没有该包,需回退到官方源码编译。
if protocol == "l2tp" {
for pm, cmd := range hints["strongswan"] {
if pm == "apt-get" {
switch pm {
case "apt-get":
hints["strongswan"][pm] = cmd + " xl2tpd"
} else {
hints["strongswan"][pm] = strings.Replace(cmd, "strongswan\"", "strongswan xl2tpd\"", 1)
if !strings.Contains(cmd, "xl2tpd") {
hints["strongswan"][pm] = cmd + " && " + map[string]string{
"yum": "yum install -y xl2tpd", "dnf": "dnf install -y xl2tpd",
"apk": "apk add xl2tpd", "pacman": "pacman -S --noconfirm xl2tpd",
}[pm]
}
case "yum", "dnf":
hints["strongswan"][pm] = cmd + " && " + xl2tpdInstallCommand(pm)
default:
hints["strongswan"][pm] = cmd + " && " + map[string]string{
"apk": "apk add xl2tpd", "pacman": "pacman -S --noconfirm xl2tpd",
}[pm]
}
}
}
@@ -442,6 +440,11 @@ func InstallHint(protocol string) map[string]interface{} {
}
}
func xl2tpdInstallCommand(pm string) string {
pkg := pm
return fmt.Sprintf(`if %s list --available xl2tpd >/dev/null 2>&1; then %s install -y xl2tpd; else %s install -y gcc make libpcap-devel git && workdir=$(mktemp -d) && git clone --depth 1 https://github.com/xelerance/xl2tpd.git "$workdir/xl2tpd" && make -C "$workdir/xl2tpd" && install -m 0755 "$workdir/xl2tpd/xl2tpd" /usr/local/sbin/xl2tpd && rm -rf "$workdir"; fi`, pkg, pkg, pkg)
}
// ---- 一键包管理器安装 ----
// InstallViaPackageManager 通过系统包管理器一键安装协议依赖。
@@ -494,7 +497,7 @@ type BinaryStatus struct {
Name string `json:"name"`
Installed bool `json:"installed"`
Path string `json:"path"`
Source string `json:"source"` // managed / system / undeployed
Source string `json:"source"` // managed / system / undeployed
Version string `json:"version"`
CanDeploy bool `json:"can_deploy"` // 是否支持平台下载(仅 frp)
InstallCmd string `json:"install_cmd"` // 包管理器安装命令(非 frp)
+17
View File
@@ -0,0 +1,17 @@
package binmgr
import (
"strings"
"testing"
)
func TestInstallHintL2TPDnfFallback(t *testing.T) {
hint := InstallHint("l2tp")
commands, _ := hint["all_commands"].(map[string]string)
cmd := commands["dnf"]
for _, want := range []string{"dnf install -y strongswan", "xelerance/xl2tpd", "libpcap-devel"} {
if !strings.Contains(cmd, want) {
t.Fatalf("L2TP dnf install command missing %q: %s", want, cmd)
}
}
}