add: default allowed-ips for new clients creations
This commit is contained in:
		
							parent
							
								
									026bca5078
								
							
						
					
					
						commit
						c9a7bdf018
					
				|  | @ -98,7 +98,7 @@ func WireGuardClients(db store.IStore) echo.HandlerFunc { | |||
| 		} | ||||
| 
 | ||||
| 		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, | ||||
| 		}) | ||||
| 	} | ||||
|  |  | |||
							
								
								
									
										3
									
								
								main.go
								
								
								
								
							
							
						
						
									
										3
									
								
								main.go
								
								
								
								
							|  | @ -36,6 +36,7 @@ var ( | |||
| 	flagEmailFromName  string = "WireGuard UI" | ||||
| 	flagSessionSecret  string | ||||
| 	flagClientMTU      int | ||||
| 	flagAllowedIPs     string | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
|  | @ -63,6 +64,7 @@ func init() { | |||
| 	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.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() | ||||
| 
 | ||||
| 	// update runtime config
 | ||||
|  | @ -79,6 +81,7 @@ func init() { | |||
| 	util.EmailFromName = flagEmailFromName | ||||
| 	util.SessionSecret = []byte(flagSessionSecret) | ||||
| 	util.ClientMTU = flagClientMTU | ||||
| 	util.AllowedIPs = flagAllowedIPs | ||||
| 
 | ||||
| 	// print app information
 | ||||
| 	fmt.Println("Wireguard UI") | ||||
|  |  | |||
|  | @ -10,4 +10,5 @@ type Interface struct { | |||
| type BaseData struct { | ||||
| 	Active      string | ||||
| 	CurrentUser string | ||||
| 	AllowedIPs  string | ||||
| } | ||||
|  |  | |||
|  | @ -175,7 +175,7 @@ | |||
|                                     </i> | ||||
|                                 </label> | ||||
|                                 <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 class="form-group"> | ||||
|                                 <label for="client_extra_allowed_ips" class="control-label">Extra Allowed IPs | ||||
|  |  | |||
|  | @ -17,6 +17,7 @@ var ( | |||
| 	EmailContent   string | ||||
| 	SessionSecret  []byte | ||||
| 	ClientMTU      int | ||||
| 	AllowedIPs     string | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue