Feature: per-instance public_host for .ovpn
When creating/editing an instance, add '公网地址' (public_host) field. This is the domain/IP clients will use to reach the OpenVPN server. When downloading a .ovpn, this field is used first, falling back to: 1. ?host= query parameter (one-time override) 2. Request Host header 3. 'vpn.example.com' default This eliminates the need to manually edit .ovpn files after download when the server's public address differs from its internal IP. Backend changes: model.Instance: add PublicHost string field service.GenerateOVPN: priority PublicHost > remoteHost > default service.UpdateInstance: PublicHost persisted (already via JSON tag) Frontend changes: Instances.vue: new '公网地址' input in create/edit dialog Instances.vue: new column in list table (shows '未配置' when empty) Users.vue: hint text updated to '可选: 覆盖实例公网地址' E2E verified: public_host='vpn.yunwei.blog' → .ovpn has 'remote vpn.yunwei.blog 1194' public_host='' + host=X → .ovpn has 'remote X 1194' public_host set + no host → public_host wins
This commit is contained in:
@@ -41,6 +41,7 @@ type Instance struct {
|
||||
AccessMode AccessMode `json:"access_mode"` // open | whitelist
|
||||
AllowNetworks []string `json:"allow_networks"` // 实例级白名单 CIDR 列表
|
||||
AuthMode AuthMode `json:"auth_mode"` // cert | cert+password
|
||||
PublicHost string `json:"public_host"` // 公网域名/IP,生成 .ovpn 时优先用它;空则用下载时前端传入的 host
|
||||
Status string `json:"status"` // running/stopped/error
|
||||
PID int `json:"pid"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
|
||||
Reference in New Issue
Block a user