Add endpoint field to client
This commit is contained in:
		
							parent
							
								
									0bf6dae5cf
								
							
						
					
					
						commit
						ca42b4aeab
					
				| 
						 | 
					@ -624,6 +624,7 @@ func UpdateClient(db store.IStore) echo.HandlerFunc {
 | 
				
			||||||
		client.AllocatedIPs = _client.AllocatedIPs
 | 
							client.AllocatedIPs = _client.AllocatedIPs
 | 
				
			||||||
		client.AllowedIPs = _client.AllowedIPs
 | 
							client.AllowedIPs = _client.AllowedIPs
 | 
				
			||||||
		client.ExtraAllowedIPs = _client.ExtraAllowedIPs
 | 
							client.ExtraAllowedIPs = _client.ExtraAllowedIPs
 | 
				
			||||||
 | 
							client.Endpoint = _client.Endpoint
 | 
				
			||||||
		client.PublicKey = _client.PublicKey
 | 
							client.PublicKey = _client.PublicKey
 | 
				
			||||||
		client.PresharedKey = _client.PresharedKey
 | 
							client.PresharedKey = _client.PresharedKey
 | 
				
			||||||
		client.UpdatedAt = time.Now().UTC()
 | 
							client.UpdatedAt = time.Now().UTC()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ type Client struct {
 | 
				
			||||||
	AllocatedIPs    []string  `json:"allocated_ips"`
 | 
						AllocatedIPs    []string  `json:"allocated_ips"`
 | 
				
			||||||
	AllowedIPs      []string  `json:"allowed_ips"`
 | 
						AllowedIPs      []string  `json:"allowed_ips"`
 | 
				
			||||||
	ExtraAllowedIPs []string  `json:"extra_allowed_ips"`
 | 
						ExtraAllowedIPs []string  `json:"extra_allowed_ips"`
 | 
				
			||||||
 | 
						Endpoint        string    `json:"endpoint"`
 | 
				
			||||||
	UseServerDNS    bool      `json:"use_server_dns"`
 | 
						UseServerDNS    bool      `json:"use_server_dns"`
 | 
				
			||||||
	Enabled         bool      `json:"enabled"`
 | 
						Enabled         bool      `json:"enabled"`
 | 
				
			||||||
	CreatedAt       time.Time `json:"created_at"`
 | 
						CreatedAt       time.Time `json:"created_at"`
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -235,6 +235,10 @@
 | 
				
			||||||
                                </label>
 | 
					                                </label>
 | 
				
			||||||
                                <input type="text" data-role="tagsinput" class="form-control" id="client_extra_allowed_ips" value="{{ StringsJoin .client_defaults.ExtraAllowedIps "," }}">
 | 
					                                <input type="text" data-role="tagsinput" class="form-control" id="client_extra_allowed_ips" value="{{ StringsJoin .client_defaults.ExtraAllowedIps "," }}">
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
 | 
					                            <div class="form-group">
 | 
				
			||||||
 | 
					                                <label for="client_endpoint" class="control-label">Endpoint</label>
 | 
				
			||||||
 | 
					                                <input type="text" class="form-control" id="client_endpoint" name="client_endpoint">
 | 
				
			||||||
 | 
					                            </div>
 | 
				
			||||||
                            <div class="form-group">
 | 
					                            <div class="form-group">
 | 
				
			||||||
                                <div class="icheck-primary d-inline">
 | 
					                                <div class="icheck-primary d-inline">
 | 
				
			||||||
                                    <input type="checkbox" id="use_server_dns" {{ if .client_defaults.UseServerDNS }}checked{{ end }}>
 | 
					                                    <input type="checkbox" id="use_server_dns" {{ if .client_defaults.UseServerDNS }}checked{{ end }}>
 | 
				
			||||||
| 
						 | 
					@ -416,6 +420,7 @@
 | 
				
			||||||
            const email = $("#client_email").val();
 | 
					            const email = $("#client_email").val();
 | 
				
			||||||
            const allocated_ips = $("#client_allocated_ips").val().split(",");
 | 
					            const allocated_ips = $("#client_allocated_ips").val().split(",");
 | 
				
			||||||
            const allowed_ips = $("#client_allowed_ips").val().split(",");
 | 
					            const allowed_ips = $("#client_allowed_ips").val().split(",");
 | 
				
			||||||
 | 
					            const endpoint = $("#client_endpoint").val();
 | 
				
			||||||
            let use_server_dns = false;
 | 
					            let use_server_dns = false;
 | 
				
			||||||
            let extra_allowed_ips = [];
 | 
					            let extra_allowed_ips = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -437,7 +442,7 @@
 | 
				
			||||||
            const preshared_key = $("#client_preshared_key").val();
 | 
					            const preshared_key = $("#client_preshared_key").val();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const data = {"name": name, "email": email, "allocated_ips": allocated_ips, "allowed_ips": allowed_ips,
 | 
					            const data = {"name": name, "email": email, "allocated_ips": allocated_ips, "allowed_ips": allowed_ips,
 | 
				
			||||||
                "extra_allowed_ips": extra_allowed_ips, "use_server_dns": use_server_dns, "enabled": enabled,
 | 
					                "extra_allowed_ips": extra_allowed_ips, "endpoint": endpoint, "use_server_dns": use_server_dns, "enabled": enabled,
 | 
				
			||||||
                "public_key": public_key, "preshared_key": preshared_key};
 | 
					                "public_key": public_key, "preshared_key": preshared_key};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $.ajax({
 | 
					            $.ajax({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -113,6 +113,10 @@ Clients
 | 
				
			||||||
                        <input type="text" data-role="tagsinput" class="form-control"
 | 
					                        <input type="text" data-role="tagsinput" class="form-control"
 | 
				
			||||||
                               id="_client_extra_allowed_ips">
 | 
					                               id="_client_extra_allowed_ips">
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
 | 
					                    <div class="form-group">
 | 
				
			||||||
 | 
					                        <label for="_client_endpoint" class="control-label">Endpoint</label>
 | 
				
			||||||
 | 
					                        <input type="text" class="form-control" id="_client_endpoint" name="client_endpoint">
 | 
				
			||||||
 | 
					                    </div>
 | 
				
			||||||
                    <div class="form-group">
 | 
					                    <div class="form-group">
 | 
				
			||||||
                        <div class="icheck-primary d-inline">
 | 
					                        <div class="icheck-primary d-inline">
 | 
				
			||||||
                            <input type="checkbox" id="_use_server_dns">
 | 
					                            <input type="checkbox" id="_use_server_dns">
 | 
				
			||||||
| 
						 | 
					@ -477,6 +481,8 @@ Clients
 | 
				
			||||||
                            modal.find("#_client_extra_allowed_ips").addTag(obj);
 | 
					                            modal.find("#_client_extra_allowed_ips").addTag(obj);
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        modal.find("#_client_endpoint").val(client.endpoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        modal.find("#_use_server_dns").prop("checked", client.use_server_dns);
 | 
					                        modal.find("#_use_server_dns").prop("checked", client.use_server_dns);
 | 
				
			||||||
                        modal.find("#_enabled").prop("checked", client.enabled);
 | 
					                        modal.find("#_enabled").prop("checked", client.enabled);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -564,6 +570,8 @@ Clients
 | 
				
			||||||
                extra_allowed_ips = $("#_client_extra_allowed_ips").val().split(",");
 | 
					                extra_allowed_ips = $("#_client_extra_allowed_ips").val().split(",");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const endpoint = $("#_client_endpoint").val();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($("#_use_server_dns").is(':checked')){
 | 
					            if ($("#_use_server_dns").is(':checked')){
 | 
				
			||||||
                use_server_dns = true;
 | 
					                use_server_dns = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -575,7 +583,8 @@ Clients
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const data = {"id": client_id, "name": name, "email": email, "allocated_ips": allocated_ips,
 | 
					            const data = {"id": client_id, "name": name, "email": email, "allocated_ips": allocated_ips,
 | 
				
			||||||
                "allowed_ips": allowed_ips, "extra_allowed_ips": extra_allowed_ips, "use_server_dns": use_server_dns, "enabled": enabled, "public_key": public_key, "preshared_key": preshared_key};
 | 
					                "allowed_ips": allowed_ips, "extra_allowed_ips": extra_allowed_ips, "endpoint": endpoint,
 | 
				
			||||||
 | 
					                "use_server_dns": use_server_dns, "enabled": enabled, "public_key": public_key, "preshared_key": preshared_key};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $.ajax({
 | 
					            $.ajax({
 | 
				
			||||||
                cache: false,
 | 
					                cache: false,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,7 @@ Table = {{ .globalSettings.Table }}
 | 
				
			||||||
# Update at:    {{ .Client.UpdatedAt }}
 | 
					# Update at:    {{ .Client.UpdatedAt }}
 | 
				
			||||||
[Peer]
 | 
					[Peer]
 | 
				
			||||||
PublicKey = {{ .Client.PublicKey }}
 | 
					PublicKey = {{ .Client.PublicKey }}
 | 
				
			||||||
{{if .Client.PresharedKey }}PresharedKey = {{ .Client.PresharedKey }}
 | 
					{{if .Client.PresharedKey }}PresharedKey = {{ .Client.PresharedKey }}{{end}}
 | 
				
			||||||
{{end}}AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
 | 
					AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}{{end}}
 | 
				
			||||||
{{end}}{{end}}
 | 
					{{if .Client.Endpoint }}Endpoint = {{ .Client.Endpoint }}{{end}}
 | 
				
			||||||
 | 
					{{end}}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue