🆕新增客户端配置文件模板
This commit is contained in:
parent
7c48551989
commit
91a1e61334
@ -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"`
|
||||
|
@ -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
11
template/wg.client.conf
Normal 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 }}
|
@ -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 }}
|
||||
|
Loading…
Reference in New Issue
Block a user