merge conflicts resolved

This commit is contained in:
Abhishek Kondur
2023-04-25 11:12:22 +04:00
39 changed files with 285 additions and 119 deletions

View File

@@ -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
})
}