Browse Source

chore(go): remove unused functions;

Vishal Dalwadi 6 months ago
parent
commit
945f4459df
2 changed files with 1 additions and 64 deletions
  1. 0 44
      logic/hosts.go
  2. 1 20
      logic/networks.go

+ 0 - 44
logic/hosts.go

@@ -49,16 +49,6 @@ func GetAllHosts() ([]models.Host, error) {
 	return currHosts, nil
 }
 
-// GetAllHostsAPI - get's all the hosts in an API usable format
-func GetAllHostsAPI(hosts []models.Host) []models.ApiHost {
-	apiHosts := []models.ApiHost{}
-	for i := range hosts {
-		newApiHost := hosts[i].ConvertNMHostToAPI()
-		apiHosts = append(apiHosts, *newApiHost)
-	}
-	return apiHosts[:]
-}
-
 // GetHost - gets a host from db given id
 func GetHost(hostID string) (*models.Host, error) {
 	_host := &schema.Host{
@@ -98,40 +88,6 @@ func CreateHost(h *models.Host) error {
 	return UpsertHost(h)
 }
 
-// UpdateHost - updates host data by field
-func UpdateHost(newHost, currentHost *models.Host) {
-	// unchangeable fields via API here
-	newHost.DaemonInstalled = currentHost.DaemonInstalled
-	newHost.OS = currentHost.OS
-	newHost.IPForwarding = currentHost.IPForwarding
-	newHost.HostPass = currentHost.HostPass
-	newHost.MacAddress = currentHost.MacAddress
-	newHost.Debug = currentHost.Debug
-	newHost.Nodes = currentHost.Nodes
-	newHost.PublicKey = currentHost.PublicKey
-	newHost.TrafficKeyPublic = currentHost.TrafficKeyPublic
-	// changeable fields
-	if len(newHost.Version) == 0 {
-		newHost.Version = currentHost.Version
-	}
-
-	if len(newHost.Name) == 0 {
-		newHost.Name = currentHost.Name
-	}
-
-	if newHost.MTU == 0 {
-		newHost.MTU = currentHost.MTU
-	}
-
-	if newHost.ListenPort == 0 {
-		newHost.ListenPort = currentHost.ListenPort
-	}
-
-	if newHost.PersistentKeepalive == 0 {
-		newHost.PersistentKeepalive = currentHost.PersistentKeepalive
-	}
-}
-
 // 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 {

+ 1 - 20
logic/networks.go

@@ -82,7 +82,7 @@ func DeleteNetwork(netID string, force bool, done chan struct{}) error {
 	for _, key := range keys {
 		if key.Tags[0] == netID {
 			if key.Default {
-				DeleteEnrollmentKey(key.Value, true)
+				_ = DeleteEnrollmentKey(key.Value, true)
 				break
 			}
 
@@ -329,25 +329,6 @@ func IsNetworkNameUnique(network *models.Network) (bool, error) {
 	return isunique, nil
 }
 
-// UpdateNetwork - updates a network with another network's fields
-func UpdateNetwork(currentNetwork *models.Network, newNetwork *models.Network) (bool, bool, bool, error) {
-	if err := ValidateNetwork(newNetwork, true); err != nil {
-		return false, false, false, err
-	}
-	if newNetwork.NetID == currentNetwork.NetID {
-		hasrangeupdate4 := newNetwork.AddressRange != currentNetwork.AddressRange
-		hasrangeupdate6 := newNetwork.AddressRange6 != currentNetwork.AddressRange6
-		hasholepunchupdate := newNetwork.DefaultUDPHolePunch != currentNetwork.DefaultUDPHolePunch
-		newNetwork.SetNetworkLastModified()
-
-		_network := converters.ToSchemaNetwork(*newNetwork)
-		err := _network.Update(db.WithContext(context.TODO()))
-		return hasrangeupdate4, hasrangeupdate6, hasholepunchupdate, err
-	}
-	// copy values
-	return false, false, false, errors.New("failed to update network " + newNetwork.NetID + ", cannot change netid.")
-}
-
 // GetNetwork - gets a network from database
 func GetNetwork(netID string) (models.Network, error) {
 	_network := &schema.Network{