diff --git a/model/vo/client.go b/model/vo/client.go index 8cf0b25..5c497da 100644 --- a/model/vo/client.go +++ b/model/vo/client.go @@ -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"` diff --git a/repository/client.go b/repository/client.go index d9e5eac..c5f1c83 100644 --- a/repository/client.go +++ b/repository/client.go @@ -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 diff --git a/template/wg.client.conf b/template/wg.client.conf new file mode 100644 index 0000000..298518f --- /dev/null +++ b/template/wg.client.conf @@ -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 }} diff --git a/template/wg.conf b/template/wg.conf index 6a00e3b..88c1ad3 100644 --- a/template/wg.conf +++ b/template/wg.conf @@ -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 }}