feat: 新增 IPv6 双栈支持

- 协议: InitMessage 增加 ip6/prefix6/server_ip6 字段(omitempty,向后兼容)
- TUN: Device 接口新增 ConfigureIPv6, macOS 用 ifconfig inet6, Linux 用 ip -6 addr add
- 路由: full 模式自动添加 ::/1+8000::/1, v6 服务器旁路 /128, resolveHosts 双栈解析
- 会话: setupTUN 解析 v6 字段并配置 TUN+路由, connectOnce 传 v6 给 stats/日志
- 统计: SetConnected(ip,ip6), Snapshot.AssignedIP6
- DB: connection_logs 增加 assigned_ip6 列 + migrateV3 幂等迁移
- UI: 状态卡片新增独立 IPv6 行, 始终可见(未获取显示 IPv6: —)
- 文档: 同步 client-development.md 至服务端 IPv6 版本
This commit is contained in:
2026-07-07 12:24:20 +08:00
parent e867c8e248
commit 8f6daf9f49
18 changed files with 478 additions and 148 deletions
+24 -23
View File
@@ -28,21 +28,21 @@ const (
// ServerProfile is a saved VPN server configuration.
type ServerProfile struct {
ID int64 `json:"id"`
Name string `json:"name"`
Protocol string `json:"protocol"` // "wss" (default) or "ws"
Host string `json:"host"` // hostname for SNI, e.g. vpn.example.com
ServerIPs string `json:"server_ips"` // comma-separated CDN IPs, first used by default
Port int `json:"port"` // default 443
Path string `json:"path"` // default "/ws"
Username string `json:"username"`
AuthMode AuthMode `json:"auth_mode"`
ID int64 `json:"id"`
Name string `json:"name"`
Protocol string `json:"protocol"` // "wss" (default) or "ws"
Host string `json:"host"` // hostname for SNI, e.g. vpn.example.com
ServerIPs string `json:"server_ips"` // comma-separated CDN IPs, first used by default
Port int `json:"port"` // default 443
Path string `json:"path"` // default "/ws"
Username string `json:"username"`
AuthMode AuthMode `json:"auth_mode"`
RoutingMode RoutingMode `json:"routing_mode"`
CustomCIDRs string `json:"custom_cidrs"` // comma-separated, for RoutingCustom
MTUOverride int `json:"mtu_override"` // 0 = use server MTU
AutoConnect bool `json:"auto_connect"`
CreatedAt time.Time `json:"created_at"`
LastConnectedAt *time.Time `json:"last_connected_at"`
CustomCIDRs string `json:"custom_cidrs"` // comma-separated, for RoutingCustom
MTUOverride int `json:"mtu_override"` // 0 = use server MTU
AutoConnect bool `json:"auto_connect"`
CreatedAt time.Time `json:"created_at"`
LastConnectedAt *time.Time `json:"last_connected_at"`
}
// BuildServerURL constructs the WebSocket URL from the profile fields.
@@ -108,13 +108,14 @@ const (
// ConnectionLog records a single VPN session.
type ConnectionLog struct {
ID int64 `json:"id"`
ProfileID int64 `json:"profile_id"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at"`
AssignedIP string `json:"assigned_ip"`
RxBytes int64 `json:"rx_bytes"`
TxBytes int64 `json:"tx_bytes"`
Status ConnectionStatus `json:"status"`
ErrorMsg string `json:"error_msg"`
ID int64 `json:"id"`
ProfileID int64 `json:"profile_id"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at"`
AssignedIP string `json:"assigned_ip"`
AssignedIP6 string `json:"assigned_ip6"`
RxBytes int64 `json:"rx_bytes"`
TxBytes int64 `json:"tx_bytes"`
Status ConnectionStatus `json:"status"`
ErrorMsg string `json:"error_msg"`
}