mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-06 21:24:16 +08:00
use string rather than []byte for dns
This commit is contained in:
parent
ead3570064
commit
0abba58bfb
3 changed files with 9 additions and 7 deletions
|
@ -239,7 +239,7 @@ func GetPeerUpdate(node *models.Node) (models.PeerUpdate, error) {
|
|||
|
||||
|
||||
*/
|
||||
peerUpdate.DNS = []byte(dns)
|
||||
peerUpdate.DNS = dns
|
||||
return peerUpdate, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ type PeerUpdate struct {
|
|||
Network string `json:"network" bson:"network" yaml:"network"`
|
||||
ServerAddrs []ServerAddr `json:"serveraddrs" bson:"serveraddrs" yaml:"serveraddrs"`
|
||||
Peers []wgtypes.PeerConfig `json:"peers" bson:"peers" yaml:"peers"`
|
||||
DNS []byte `json:"dns" bson:'dns" yaml:"dns"`
|
||||
DNS string `json:"dns" bson:"dns" yaml:"dns"`
|
||||
}
|
||||
|
||||
// KeyUpdate - key update struct
|
||||
|
|
|
@ -3,6 +3,7 @@ package functions
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -197,9 +198,9 @@ func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
|
|||
}
|
||||
ncutils.Log("received peer update for node " + cfg.Node.Name + " " + cfg.Node.Network)
|
||||
//skip dns updates if this is a peer update for comms network
|
||||
if cfg.Node.NetworkSettings.IsComms == "yes" {
|
||||
return
|
||||
}
|
||||
//if cfg.Node.NetworkSettings.IsComms == "yes" {
|
||||
// return
|
||||
//}
|
||||
if cfg.Node.DNSOn == "yes" {
|
||||
if err := setHostDNS(peerUpdate.DNS, ncutils.IsWindows()); err != nil {
|
||||
ncutils.Log("error updating /etc/hosts " + err.Error())
|
||||
|
@ -213,12 +214,13 @@ func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
|
|||
}
|
||||
}
|
||||
|
||||
func setHostDNS(dns []byte, windows bool) error {
|
||||
func setHostDNS(dns string, windows bool) error {
|
||||
log.Println(dns)
|
||||
etchosts := "/etc/hosts"
|
||||
if windows {
|
||||
etchosts = "c:\\windows\\system32\\drivers\\etc\\hosts"
|
||||
}
|
||||
dnsdata := strings.NewReader(string(dns))
|
||||
dnsdata := strings.NewReader(dns)
|
||||
profile, err := parser.ParseProfile(dnsdata)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Reference in a new issue