mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 01:07:41 +08:00
merge conflicts resolved
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"github.com/devilcove/httpclient"
|
||||
@@ -106,6 +107,7 @@ func CreateHost(h *models.Host) error {
|
||||
return err
|
||||
}
|
||||
h.HostPass = string(hash)
|
||||
h.AutoUpdate = servercfg.AutoUpdateEnabled()
|
||||
// if another server has already updated proxyenabled, leave it alone
|
||||
if !h.ProxyEnabledSet {
|
||||
log.Println("checking default proxy", servercfg.GetServerConfig().DefaultProxyMode)
|
||||
@@ -160,6 +162,10 @@ func UpdateHost(newHost, currentHost *models.Host) {
|
||||
// UpdateHostFromClient - used for updating host on server with update recieved from client
|
||||
func UpdateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool) {
|
||||
|
||||
if newHost.PublicKey != currHost.PublicKey {
|
||||
currHost.PublicKey = newHost.PublicKey
|
||||
sendPeerUpdate = true
|
||||
}
|
||||
if newHost.ListenPort != 0 && currHost.ListenPort != newHost.ListenPort {
|
||||
currHost.ListenPort = newHost.ListenPort
|
||||
sendPeerUpdate = true
|
||||
@@ -490,3 +496,10 @@ func DeRegisterHostWithTurn(hostID string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SortApiHosts - Sorts slice of ApiHosts by their ID alphabetically with numbers first
|
||||
func SortApiHosts(unsortedHosts []models.ApiHost) {
|
||||
sort.Slice(unsortedHosts, func(i, j int) bool {
|
||||
return unsortedHosts[i].ID < unsortedHosts[j].ID
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user