mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-06-07 00:46:58 +03:00
add: default allowed-ips for new clients creations
This commit is contained in:
parent
026bca5078
commit
c9a7bdf018
5 changed files with 7 additions and 2 deletions
|
@ -98,7 +98,7 @@ func WireGuardClients(db store.IStore) echo.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Render(http.StatusOK, "clients.html", map[string]interface{}{
|
return c.Render(http.StatusOK, "clients.html", map[string]interface{}{
|
||||||
"baseData": model.BaseData{Active: "", CurrentUser: currentUser(c)},
|
"baseData": model.BaseData{Active: "", CurrentUser: currentUser(c), AllowedIPs: util.AllowedIPs},
|
||||||
"clientDataList": clientDataList,
|
"clientDataList": clientDataList,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
3
main.go
3
main.go
|
@ -36,6 +36,7 @@ var (
|
||||||
flagEmailFromName string = "WireGuard UI"
|
flagEmailFromName string = "WireGuard UI"
|
||||||
flagSessionSecret string
|
flagSessionSecret string
|
||||||
flagClientMTU int
|
flagClientMTU int
|
||||||
|
flagAllowedIPs string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -63,6 +64,7 @@ func init() {
|
||||||
flag.StringVar(&flagEmailFromName, "email-from-name", util.LookupEnvOrString("EMAIL_FROM_NAME", flagEmailFromName), "'From' email name.")
|
flag.StringVar(&flagEmailFromName, "email-from-name", util.LookupEnvOrString("EMAIL_FROM_NAME", flagEmailFromName), "'From' email name.")
|
||||||
flag.StringVar(&flagSessionSecret, "session-secret", util.LookupEnvOrString("SESSION_SECRET", flagSessionSecret), "The key used to encrypt session cookies.")
|
flag.StringVar(&flagSessionSecret, "session-secret", util.LookupEnvOrString("SESSION_SECRET", flagSessionSecret), "The key used to encrypt session cookies.")
|
||||||
flag.IntVar(&flagClientMTU, "client-mtu", util.LookupEnvOrInt("CLIENT_MTU", flagClientMTU), "Client default MTU")
|
flag.IntVar(&flagClientMTU, "client-mtu", util.LookupEnvOrInt("CLIENT_MTU", flagClientMTU), "Client default MTU")
|
||||||
|
flag.StringVar(&flagAllowedIPs, "allowed-ips", util.LookupEnvOrString("ALLOWED_IPS", flagAllowedIPs), "List of default allowed IPs for the client")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// update runtime config
|
// update runtime config
|
||||||
|
@ -79,6 +81,7 @@ func init() {
|
||||||
util.EmailFromName = flagEmailFromName
|
util.EmailFromName = flagEmailFromName
|
||||||
util.SessionSecret = []byte(flagSessionSecret)
|
util.SessionSecret = []byte(flagSessionSecret)
|
||||||
util.ClientMTU = flagClientMTU
|
util.ClientMTU = flagClientMTU
|
||||||
|
util.AllowedIPs = flagAllowedIPs
|
||||||
|
|
||||||
// print app information
|
// print app information
|
||||||
fmt.Println("Wireguard UI")
|
fmt.Println("Wireguard UI")
|
||||||
|
|
|
@ -10,4 +10,5 @@ type Interface struct {
|
||||||
type BaseData struct {
|
type BaseData struct {
|
||||||
Active string
|
Active string
|
||||||
CurrentUser string
|
CurrentUser string
|
||||||
|
AllowedIPs string
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@
|
||||||
</i>
|
</i>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" data-role="tagsinput" class="form-control" id="client_allowed_ips"
|
<input type="text" data-role="tagsinput" class="form-control" id="client_allowed_ips"
|
||||||
value="0.0.0.0/0">
|
value="{{if .baseData.AllowedIPs}} {{.baseData.AllowedIPs}} {{else}} 0.0.0.0/0 {{end}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="client_extra_allowed_ips" class="control-label">Extra Allowed IPs
|
<label for="client_extra_allowed_ips" class="control-label">Extra Allowed IPs
|
||||||
|
|
|
@ -17,6 +17,7 @@ var (
|
||||||
EmailContent string
|
EmailContent string
|
||||||
SessionSecret []byte
|
SessionSecret []byte
|
||||||
ClientMTU int
|
ClientMTU int
|
||||||
|
AllowedIPs string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue