🆕新增客户端配置文件模板

This commit is contained in:
coward 2024-03-13 17:30:39 +08:00
parent 7c48551989
commit 91a1e61334
4 changed files with 16 additions and 3 deletions

View File

@ -11,8 +11,8 @@ type Client struct {
Email string `json:"email"`
SubnetRange string `json:"subnetRange"`
IpAllocation string `json:"ipAllocation"`
AllowedIPS string `json:"allowedIPS"`
ExtraAllowedIPS string `json:"extraAllowedIPS"`
AllowedIps string `json:"allowedIPS"`
ExtraAllowedIps string `json:"extraAllowedIPS"`
Endpoint string `json:"endpoint"`
UseServerDNS int `json:"useServerDNS"`
EnableAfterCreation int `json:"enableAfterCreation"`

View File

@ -96,6 +96,7 @@ func (r clientRepo) Save(p param.SaveClient, adminId string) (client *entity.Cli
return
}
keys := template_data.Keys{
PrivateKey: privateKey.String(),
PublicKey: publicKey,
PresharedKey: presharedKey.String(),
}
@ -114,6 +115,7 @@ func (r clientRepo) Save(p param.SaveClient, adminId string) (client *entity.Cli
EnableAfterCreation: p.EnabledAfterCreation,
Keys: string(keysStr),
UserId: adminId,
Enabled: true,
}
err = r.Model(&entity.Client{}).Create(ent).Error

11
template/wg.client.conf Normal file
View File

@ -0,0 +1,11 @@
[Interface]
PrivateKey = {{ .PrivateKey|html }}
Address = {{ .IpAllocation|html }}
MTU = {{ .MTU }}
[Peer]
PublicKey = {{ .PublicKey|html }}
PresharedKey = {{ .PresharedKey|html }}
AllowedIPs = {{ .AllowedIPS|html }}
Endpoint = {{ .Endpoint|html }}:{{ .ListenPort|html }}
PersistentKeepalive = {{ .PersistentKeepalive|html }}

View File

@ -20,5 +20,5 @@ PublicKey = {{ .PublicKey|html }}
PresharedKey = {{ .PresharedKey|html }}
AllowedIPs = {{ .AllowedIPS|html }}
PersistentKeepalive = {{ .PersistentKeepalive|html }}
Endpoint = {{ .Endpoint|html }}
{{ if .Endpoint }}Endpoint = {{ .Endpoint|html }}{{ end }}
{{ end }}{{ end }}