From 7861e9e1e561d1d58ea139e2b1f1b03d46467c15 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Tue, 4 May 2021 03:01:03 +0000 Subject: [PATCH 01/14] installer updates --- config/environments/dev.yaml | 2 +- functions/helpers.go | 8 +- .../netclient-install.sh | 0 .../netmaker-install-clientmode.sh | 0 scripts/netmaker-install-local.sh | 100 ++++++++++++++++++ .../netmaker-server.sh | 0 scripts/uninstall-netclient.sh | 12 +++ scripts/uninstall-netmaker.sh | 25 +++++ 8 files changed, 144 insertions(+), 3 deletions(-) rename netclient-install.sh => scripts/netclient-install.sh (100%) rename netmaker-install-clientmode.sh => scripts/netmaker-install-clientmode.sh (100%) create mode 100755 scripts/netmaker-install-local.sh rename netmaker-server.sh => scripts/netmaker-server.sh (100%) create mode 100755 scripts/uninstall-netclient.sh create mode 100755 scripts/uninstall-netmaker.sh diff --git a/config/environments/dev.yaml b/config/environments/dev.yaml index 1143af15..fab0035a 100644 --- a/config/environments/dev.yaml +++ b/config/environments/dev.yaml @@ -12,6 +12,6 @@ server: mongoconn: user: "mongoadmin" pass: "mongopass" - host: "localhost" + host: "127.0.0.1" port: "27017" opts: '/?authSource=admin' diff --git a/functions/helpers.go b/functions/helpers.go index 7a9f89a9..afd112ab 100644 --- a/functions/helpers.go +++ b/functions/helpers.go @@ -131,7 +131,7 @@ func NetworkExists(name string) (bool, error) { if err == mongo.ErrNoDocuments { return false, nil } - fmt.Println("ERROR RETRIEVING GROUP!") + fmt.Println("Error Retrieving Group: " + name) fmt.Println(err) } return true, err @@ -530,7 +530,11 @@ func UniqueAddress6(networkName string) (string, error) { var network models.Network network, err := GetParentNetwork(networkName) - if !*network.IsDualStack { + if err != nil { + fmt.Println("Network Not Found") + return "", err + } + if network.IsDualStack == nil || *network.IsDualStack == false { return "", nil } diff --git a/netclient-install.sh b/scripts/netclient-install.sh similarity index 100% rename from netclient-install.sh rename to scripts/netclient-install.sh diff --git a/netmaker-install-clientmode.sh b/scripts/netmaker-install-clientmode.sh similarity index 100% rename from netmaker-install-clientmode.sh rename to scripts/netmaker-install-clientmode.sh diff --git a/scripts/netmaker-install-local.sh b/scripts/netmaker-install-local.sh new file mode 100755 index 00000000..a9257fa6 --- /dev/null +++ b/scripts/netmaker-install-local.sh @@ -0,0 +1,100 @@ +#!/bin/sh +set -x + +[ -z "$SERVER_DOMAIN" ] && echo "Need to set SERVER_DOMAIN (format: 1.2.3.4 or mybackend.com)" && exit 1; + + +install() { + +docker volume create mongovol && docker run -d --name mongodb -v mongovol:/data/db -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=mongopass mongo + +echo "Giving Mongo Time to Start" +sleep 10 +echo "Installing Netmaker API" + +mkdir -p /etc/netmaker/config/environments +cp ../netmaker /etc/netmaker/netmaker +chmod +x /etc/netmaker/netmaker + + +cat >/etc/netmaker/config/environments/dev.yaml</etc/netmaker/config/Corefile</etc/systemd/system/netmaker.service< Date: Tue, 4 May 2021 21:36:55 +0000 Subject: [PATCH 02/14] dns server setup --- Dockerfile | 16 +++-- controllers/dnsHttpController.go | 2 +- docker-compose.yml | 43 ++++++++++++-- functions/helpers.go | 7 --- functions/local.go | 53 +++++++++++++++++ main.go | 42 +++---------- netclient/functions/common.go | 6 +- netclient/functions/local.go | 48 +++++++-------- netclient/main.go | 3 +- scripts/netmaker-install-local.sh | 5 +- scripts/uninstall-netmaker.sh | 1 + serverctl/serverctl.go | 97 ++++++++++++++++++++++++++++--- 12 files changed, 232 insertions(+), 91 deletions(-) create mode 100644 functions/local.go diff --git a/Dockerfile b/Dockerfile index 99f1ebbb..746b6364 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ #first stage - builder -FROM golang:1.14-stretch as builder +FROM golang:latest as builder COPY . /app @@ -10,22 +10,28 @@ ENV GO111MODULE=auto RUN CGO_ENABLED=0 GOOS=linux go build -o app main.go +WORKDIR /app/netclient + +ENV GO111MODULE=auto + +RUN CGO_ENABLED=0 GOOS=linux go build -o netclient main.go #second stage -FROM alpine:latest +FROM debian:latest + +RUN apt-get update && apt-get -y install systemd procps WORKDIR /root/ -RUN apk add --no-cache tzdata - COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /app . COPY --from=builder /app/config config +COPY --from=builder /app/netclient netclient EXPOSE 8081 EXPOSE 50051 -CMD ["./app", "--clientmode=off"] +CMD ["./app"] diff --git a/controllers/dnsHttpController.go b/controllers/dnsHttpController.go index 3f8ebcb3..59b5bf67 100644 --- a/controllers/dnsHttpController.go +++ b/controllers/dnsHttpController.go @@ -441,7 +441,7 @@ func WriteHosts() error { } } } - err = hostfile.SaveAs("./config/netmaker.hosts") + err = hostfile.SaveAs("./config/dnsconfig/netmaker.hosts") return err } diff --git a/docker-compose.yml b/docker-compose.yml index 84c481d3..ea79912e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,8 @@ -version: "3.3" +version: "3.4" +volumes: + dnsconfig: + driver: local services: mongodb: image: mongo:4.2 @@ -13,24 +16,54 @@ services: MONGO_INITDB_ROOT_USERNAME: mongoadmin MONGO_INITDB_ROOT_PASSWORD: mongopass netmaker: + privileged: true container_name: netmaker + build: netmaker depends_on: - mongodb - image: gravitl/netmaker:v0.2 + image: gravitl/netmaker:v0.3 ports: - "8081:8081" - "50051:50051" + volumes: + - ./:/local + - /etc/netclient:/etc/netclient + - dnsconfig:/root/config/dnsconfig + - /usr/bin/wg:/usr/bin/wg:ro + - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket + - /run/systemd/system:/run/systemd/system + - /etc/systemd/system:/etc/systemd/system + - /sys/fs/cgroup:/sys/fs/cgroup environment: - MONGO_HOST: mongodb + MONGO_HOST: "127.0.0.1" + SERVER_DOMAIN: "3.236.149.180" + cap_add: + - NET_ADMIN + - SYS_MODULE restart: always + network_mode: host netmaker-ui: container_name: netmaker-ui depends_on: - netmaker - image: gravitl/netmaker-ui:v0.2 + image: gravitl/netmaker-ui:v0.3 + links: + - "netmaker:api" ports: - "80:80" environment: - BACKEND_URL: "http://localhost:8081" + BACKEND_URL: "http://3.236.149.180:8081" + coredns: + depends_on: + - netmaker + image: coredns/coredns + command: -conf /root/dnsconfig/Corefile + container_name: coredns + restart: always + ports: + - "53:53/udp" + volumes: + - dnsconfig:/root/dnsconfig volumes: mongovol: {} + dnsconfig: {} diff --git a/functions/helpers.go b/functions/helpers.go index afd112ab..a2860730 100644 --- a/functions/helpers.go +++ b/functions/helpers.go @@ -49,11 +49,6 @@ func CreateServerToken(netID string) (string, error) { privAddr = network.LocalRange } - fmt.Println("Token details:") - fmt.Println(" grpc address + port: " + address) - fmt.Println(" network: " + netID) - fmt.Println(" private range: " + privAddr) - accessstringdec := address + "|" + netID + "|" + accesskey.Value + "|" + privAddr accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec)) @@ -131,8 +126,6 @@ func NetworkExists(name string) (bool, error) { if err == mongo.ErrNoDocuments { return false, nil } - fmt.Println("Error Retrieving Group: " + name) - fmt.Println(err) } return true, err } diff --git a/functions/local.go b/functions/local.go new file mode 100644 index 00000000..ed18502a --- /dev/null +++ b/functions/local.go @@ -0,0 +1,53 @@ +package functions + +import ( + "fmt" + "path/filepath" + "log" + "os" + "io/ioutil" +) + + +func FileExists(f string) bool { + info, err := os.Stat(f) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} + +func ConfigureDNS() error { + dir, err := filepath.Abs(filepath.Dir(os.Args[0])) + if err != nil { + return err + } + _, err = os.Stat(dir + "/config/dnsconfig") + if os.IsNotExist(err) { + os.Mkdir(dir +"/config/dnsconfig", 744) + } else if err != nil { + fmt.Println("couldnt find or create /config/dnsconfig") + return err + } + + if !FileExists(dir + "/config/dnsconfig/Corefile") { + + corefile := `. { + hosts /root/dnsconfig/netmaker.hosts { + fallthrough + } + forward . 8.8.8.8 8.8.4.4 + log +} +` + corebytes := []byte(corefile) + + err = ioutil.WriteFile(dir + "/config/dnsconfig/Corefile", corebytes, 0644) + if err != nil { + log.Println(err) + log.Println("") + return err + } + } + return err +} diff --git a/main.go b/main.go index 44c65c61..98bd186d 100644 --- a/main.go +++ b/main.go @@ -15,10 +15,7 @@ import ( "go.mongodb.org/mongo-driver/bson" "fmt" "time" - "net/http" "strings" - "errors" - "io/ioutil" "os" "os/exec" "net" @@ -39,10 +36,12 @@ var PortGRPC string func main() { + var dnsmode string var clientmode string var defaultnet string flag.StringVar(&clientmode, "clientmode", "on", "Have a client on the server") flag.StringVar(&defaultnet, "defaultnet", "on", "Create a default network") + flag.StringVar(&dnsmode, "dnsmode", "on", "Add DNS settings") flag.Parse() if clientmode == "on" { @@ -77,6 +76,12 @@ func main() { } } } + if dnsmode == "on" { + err := functions.ConfigureDNS() + if err != nil { + fmt.Printf("Error setting DNS: %v", err) + } + } var waitnetwork sync.WaitGroup if config.Config.Server.AgentBackend { @@ -116,7 +121,7 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { PortGRPC = grpcport if os.Getenv("BACKEND_URL") == "" { if config.Config.Server.Host == "" { - ServerGRPC, _ = getPublicIP() + ServerGRPC, _ = serverctl.GetPublicIP() } else { ServerGRPC = config.Config.Server.Host } @@ -281,35 +286,6 @@ func createDefaultNetwork() (bool, error) { } - -func getPublicIP() (string, error) { - - iplist := []string{"https://ifconfig.me", "http://api.ipify.org", "http://ipinfo.io/ip"} - endpoint := "" - var err error - for _, ipserver := range iplist { - resp, err := http.Get(ipserver) - if err != nil { - continue - } - defer resp.Body.Close() - if resp.StatusCode == http.StatusOK { - bodyBytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - continue - } - endpoint = string(bodyBytes) - break - } - - } - if err == nil && endpoint == "" { - err = errors.New("Public Address Not Found.") - } - return endpoint, err -} - - func authServerUnaryInterceptor() grpc.ServerOption { return grpc.UnaryInterceptor(controller.AuthServerUnaryInterceptor) } diff --git a/netclient/functions/common.go b/netclient/functions/common.go index 70783809..38c1ac4b 100644 --- a/netclient/functions/common.go +++ b/netclient/functions/common.go @@ -72,7 +72,7 @@ func GetFreePort(rangestart int32) (int32, error){ return portno, err } -func Install(accesskey string, password string, server string, network string, noauto bool, accesstoken string, inputname string) error { +func Install(accesskey string, password string, server string, network string, noauto bool, accesstoken string, inputname string, pubip string) error { tserver := "" tnetwork := "" @@ -252,6 +252,9 @@ func Install(accesskey string, password string, server string, network string, n } fmt.Println(" Local Address: " + localaddress) + if pubip != "" && pubip != "nopubip" { + endpoint = pubip + } else { if nodecfg.Endpoint == "" { if islocal && localaddress != "" { endpoint = localaddress @@ -269,6 +272,7 @@ func Install(accesskey string, password string, server string, network string, n endpoint = nodecfg.Endpoint fmt.Println("Endpoint set in config. Setting to address: " + endpoint) } + } fmt.Println(" Endpoint: " + endpoint) diff --git a/netclient/functions/local.go b/netclient/functions/local.go index c2962655..e16de7d9 100644 --- a/netclient/functions/local.go +++ b/netclient/functions/local.go @@ -118,40 +118,32 @@ WantedBy=timers.target return err } } - sysExec, err := exec.LookPath("systemctl") + //sysExec, err := exec.LookPath("systemctl") - cmdSysEnableService := &exec.Cmd { + cmdSysEnableService := exec.Command("systemctl", "enable", "netclient@.service")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "enable", "netclient@.service" }, Stdout: os.Stdout, Stderr: os.Stdout, - } - /* - cmdSysStartService := &exec.Cmd { - Path: sysExec, - Args: []string{ sysExec, "start", "netclient@.service"}, - Stdout: os.Stdout, - Stderr: os.Stdout, - } - */ - cmdSysDaemonReload := &exec.Cmd { + }*/ + cmdSysDaemonReload := exec.Command("systemctl", "daemon-reload")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "daemon-reload"}, Stdout: os.Stdout, Stderr: os.Stdout, - } - cmdSysEnableTimer := &exec.Cmd { + }*/ + cmdSysEnableTimer := exec.Command("systemctl", "enable", "netclient-"+network+".timer")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "enable", "netclient-"+network+".timer" }, Stdout: os.Stdout, Stderr: os.Stdout, - } - cmdSysStartTimer := &exec.Cmd { + }*/ + cmdSysStartTimer := exec.Command("systemctl", "start", "netclient-"+network+".timer")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "start", "netclient-"+network+".timer"}, Stdout: os.Stdout, Stderr: os.Stdout, - } + }*/ err = cmdSysEnableService.Run() if err != nil { @@ -191,7 +183,7 @@ func isOnlyService(network string) (bool, error) { } func RemoveSystemDServices(network string) error { - sysExec, err := exec.LookPath("systemctl") + //sysExec, err := exec.LookPath("systemctl") fullremove, err := isOnlyService(network) @@ -199,36 +191,36 @@ func RemoveSystemDServices(network string) error { fmt.Println(err) } - cmdSysDisableService := &exec.Cmd { + cmdSysDisableService := exec.Command("systemctl","disable","netclient@.service")/* &exec.Cmd { Path: sysExec, Args: []string{ sysExec, "disable", "netclient@.service"}, Stdout: os.Stdout, Stderr: os.Stdout, - } - cmdSysDaemonReload := &exec.Cmd { + }*/ + cmdSysDaemonReload := exec.Command("systemctl","daemon-reload")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "daemon-reload"}, Stdout: os.Stdout, Stderr: os.Stdout, - } - cmdSysResetFailed := &exec.Cmd { + }*/ + cmdSysResetFailed := exec.Command("systemctl","reset-failed")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "reset-failed"}, Stdout: os.Stdout, Stderr: os.Stdout, - } - cmdSysStopTimer := &exec.Cmd { + }*/ + cmdSysStopTimer := exec.Command("systemctl", "stop", "netclient-"+network+".timer")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "stop", "netclient-"+network+".timer" }, Stdout: os.Stdout, Stderr: os.Stdout, - } - cmdSysDisableTimer := &exec.Cmd { + }*/ + cmdSysDisableTimer := exec.Command("systemctl", "disable", "netclient-"+network+".timer")/*&exec.Cmd { Path: sysExec, Args: []string{ sysExec, "disable", "netclient-"+network+".timer"}, Stdout: os.Stdout, Stderr: os.Stdout, - } + }*/ //err = cmdSysStopService.Run() if err != nil { diff --git a/netclient/main.go b/netclient/main.go index 86247f09..f90cfee9 100644 --- a/netclient/main.go +++ b/netclient/main.go @@ -39,6 +39,7 @@ func main() { tname := flag.String("name", "noname", "give the node a name at runtime") tserver := flag.String("s", "localhost:50051", "The location (including port) of the remote gRPC server.") tnetwork := flag.String("n", "nonetwork", "The node network you are attempting to join.") + tpublicip := flag.String("ip4", "nopubip", "The node network you are attempting to join.") tnoauto := flag.Bool("na", false, "No auto mode. If true, netmclient will not be installed as a system service and you will have to retrieve updates manually via checkin command.") tnoforward := flag.Bool("nf", false, "No Forward mode. If true, netclient will not check for IP forwarding. This may break functionality") command := flag.String("c", "required", "The command to run") @@ -108,7 +109,7 @@ func main() { } fmt.Println("Beginning agent installation.") - err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname) + err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname, *tpublicip) if err != nil { fmt.Println("Error encountered while installing.") if !strings.Contains(err.Error(), "ALREADY_INSTALLED") { diff --git a/scripts/netmaker-install-local.sh b/scripts/netmaker-install-local.sh index a9257fa6..3a8952de 100755 --- a/scripts/netmaker-install-local.sh +++ b/scripts/netmaker-install-local.sh @@ -13,6 +13,7 @@ sleep 10 echo "Installing Netmaker API" mkdir -p /etc/netmaker/config/environments +mkdir -p /etc/netmaker/config/dnsconfig cp ../netmaker /etc/netmaker/netmaker chmod +x /etc/netmaker/netmaker @@ -37,7 +38,7 @@ mongoconn: opts: '/?authSource=admin' EOL -cat >/etc/netmaker/config/Corefile</etc/netmaker/config/dnsconfig/Corefile< Date: Wed, 5 May 2021 00:44:23 +0000 Subject: [PATCH 03/14] dns working --- controllers/dnsHttpController.go | 67 +++++++++++++++++--------------- functions/local.go | 8 ++-- main.go | 6 +-- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/controllers/dnsHttpController.go b/controllers/dnsHttpController.go index 59b5bf67..f5fd258b 100644 --- a/controllers/dnsHttpController.go +++ b/controllers/dnsHttpController.go @@ -173,6 +173,40 @@ func GetCustomDNS(network string) ([]models.DNSEntry, error){ return dns, err } +func SetDNS() error { + hostfile := txeh.Hosts{} + var corefilestring string + networks, err := functions.ListNetworks() + if err != nil { + return err + } + + for _, net := range networks { + corefilestring = corefilestring + net.NetID + " " + dns, err := GetDNS(net.NetID) + if err != nil { + return err + } + for _, entry := range dns { + hostfile.AddHost(entry.Address, entry.Name+"."+entry.Network) + if err != nil { + return err + } + } + } + if corefilestring == "" { + corefilestring = "example.com" + } + + err = hostfile.SaveAs("./config/dnsconfig/netmaker.hosts") + if err != nil { + return err + } + err = functions.SetCorefile(corefilestring) + + return err +} + func GetDNSEntryNum(domain string, network string) (int, error){ num := 0 @@ -406,45 +440,16 @@ func pushDNS(w http.ResponseWriter, r *http.Request) { // Set header w.Header().Set("Content-Type", "application/json") - err := WriteHosts() + err := SetDNS() if err != nil { returnErrorResponse(w, r, formatError(err, "internal")) return } + json.NewEncoder(w).Encode("DNS Pushed to CoreDNS") } - -func WriteHosts() error { - //hostfile, err := txeh.NewHostsDefault() - hostfile := txeh.Hosts{} - /* - if err != nil { - return err - } - */ - networks, err := functions.ListNetworks() - if err != nil { - return err - } - - for _, net := range networks { - dns, err := GetDNS(net.NetID) - if err != nil { - return err - } - for _, entry := range dns { - hostfile.AddHost(entry.Address, entry.Name+"."+entry.Network) - if err != nil { - return err - } - } - } - err = hostfile.SaveAs("./config/dnsconfig/netmaker.hosts") - return err -} - func ValidateDNSCreate(entry models.DNSEntry) error { v := validator.New() diff --git a/functions/local.go b/functions/local.go index ed18502a..bbc18eb1 100644 --- a/functions/local.go +++ b/functions/local.go @@ -17,7 +17,7 @@ func FileExists(f string) bool { return !info.IsDir() } -func ConfigureDNS() error { +func SetCorefile(domains string) error { dir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { return err @@ -30,10 +30,9 @@ func ConfigureDNS() error { return err } - if !FileExists(dir + "/config/dnsconfig/Corefile") { - - corefile := `. { + corefile := domains + ` { hosts /root/dnsconfig/netmaker.hosts { + reload 15s fallthrough } forward . 8.8.8.8 8.8.4.4 @@ -48,6 +47,5 @@ func ConfigureDNS() error { log.Println("") return err } - } return err } diff --git a/main.go b/main.go index 98bd186d..38ecce02 100644 --- a/main.go +++ b/main.go @@ -77,7 +77,7 @@ func main() { } } if dnsmode == "on" { - err := functions.ConfigureDNS() + err := controller.SetDNS() if err != nil { fmt.Printf("Error setting DNS: %v", err) } @@ -119,14 +119,14 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { grpcport = ":" + os.Getenv("GRPC_PORT") } PortGRPC = grpcport - if os.Getenv("BACKEND_URL") == "" { + if os.Getenv("SERVER_DOMAIN") == "" { if config.Config.Server.Host == "" { ServerGRPC, _ = serverctl.GetPublicIP() } else { ServerGRPC = config.Config.Server.Host } } else { - ServerGRPC = os.Getenv("BACKEND_URL") + ServerGRPC = os.Getenv("SERVER_DOMAIN") } fmt.Println("GRPC Server set to: " + ServerGRPC) fmt.Println("GRPC Port set to: " + PortGRPC) From 46a81c97670df4d326a6f3896cd71646c7a58a1c Mon Sep 17 00:00:00 2001 From: afeiszli Date: Wed, 5 May 2021 20:42:17 +0000 Subject: [PATCH 04/14] refactoring logic in main --- config/config.go | 1 - config/environments/dev.yaml | 31 ++--- controllers/userHttpController.go | 33 +++-- docker-compose.yml | 1 - main.go | 199 ++++++------------------------ mongoconn/mongoconn.go | 45 +------ netclient/config/config.go | 6 - netclient/functions/common.go | 2 +- serverctl/getconf.go | 159 ++++++++++++++++++++++++ serverctl/serverctl.go | 168 +++++++++++++++++++++---- 10 files changed, 380 insertions(+), 265 deletions(-) create mode 100644 serverctl/getconf.go diff --git a/config/config.go b/config/config.go index a827e627..9623aca4 100644 --- a/config/config.go +++ b/config/config.go @@ -44,7 +44,6 @@ type ServerConfig struct { AgentBackend bool `yaml:"agentbackend"` DefaultNetName string `yaml:"defaultnetname"` DefaultNetRange string `yaml:"defaultnetrange"` - CreateDefault bool `yaml:"createdefault"` } type MongoConnConfig struct { diff --git a/config/environments/dev.yaml b/config/environments/dev.yaml index fab0035a..a2cfcb5a 100644 --- a/config/environments/dev.yaml +++ b/config/environments/dev.yaml @@ -1,17 +1,18 @@ server: - host: "localhost" - apiport: "8081" - grpcport: "50051" - masterkey: "secretkey" - allowedorigin: "*" - restbackend: true - agentbackend: true - defaultnetname: "default" - defaultnetrange: "10.10.10.0/24" - createdefault: true + apihost: "" # defaults to 127.0.0.1 or remote ip (SERVER_HOST) if DisableRemoteIPCheck is not set to true. SERVER_API_HOST if set + apiport: "" # defaults to 8081 or HTTP_PORT (if set) + grpchost: "" # defaults to 127.0.0.1 or remote ip (SERVER_HOST) if DisableRemoteIPCheck is not set to true. SERVER_GRPC_HOST if set. + grpcport: "" # defaults to 50051 or GRPC_PORT (if set) + masterkey: "" # defaults to 'secretkey' or MASTER_KEY (if set) + allowedorigin: "" # defaults to '*' or CORS_ALLOWED_ORIGIN (if set) + restbackend: "" # defaults to "on" or REST_BACKEND (if set) + agentbackend: "" # defaults to "on" or AGENT_BACKEND (if set) + clientmode: "" # defaults to "on" or CLIENT_MODE (if set) + dnsmode: "" # defaults to "on" or DNS_MODE (if set) + disableremoteipcheck: "" # defaults to "false" or DISABLE_REMOTE_IP_CHECK (if set) mongoconn: - user: "mongoadmin" - pass: "mongopass" - host: "127.0.0.1" - port: "27017" - opts: '/?authSource=admin' + user: "" # defaults to "mongoadmin" or MONGO_ADMIN (if set) + pass: "" # defaults to "mongopass" or MONGO_PASS (if set) + host: "" # defaults to 127.0.0.1 or MONGO_HOST (if set) + port: "" # defaults to 27017 or MONGO_PORT (if set) + opts: '' # defaults to '/?authSource=admin' or MONGO_OPTS (if set) diff --git a/controllers/userHttpController.go b/controllers/userHttpController.go index cc180220..8bb8da6e 100644 --- a/controllers/userHttpController.go +++ b/controllers/userHttpController.go @@ -156,10 +156,7 @@ func authorizeUser(next http.Handler) http.HandlerFunc { username, _, err := functions.VerifyUserToken(authToken) if err != nil { - errorResponse = models.ErrorResponse{ - Code: http.StatusUnauthorized, Message: "W1R3: Error Verifying Auth Token.", - } - returnErrorResponse(w, r, errorResponse) + returnErrorResponse(w, r, formatError(err, "internal")) return } @@ -240,8 +237,8 @@ func getUser(w http.ResponseWriter, r *http.Request) { user, err := GetUser(params["username"]) if err != nil { - mongoconn.GetError(err, w) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } json.NewEncoder(w).Encode(user) @@ -304,14 +301,14 @@ func createAdmin(w http.ResponseWriter, r *http.Request) { err = ValidateUser("create", admin) if err != nil { - json.NewEncoder(w).Encode(err) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } admin, err = CreateUser(admin) if err != nil { - json.NewEncoder(w).Encode(err) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } json.NewEncoder(w).Encode(admin) @@ -379,8 +376,8 @@ func updateUser(w http.ResponseWriter, r *http.Request) { //start here user, err := GetUser(params["username"]) if err != nil { - json.NewEncoder(w).Encode(err) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } var userchange models.User @@ -388,8 +385,8 @@ func updateUser(w http.ResponseWriter, r *http.Request) { // we decode our body request params err = json.NewDecoder(r.Body).Decode(&userchange) if err != nil { - json.NewEncoder(w).Encode(err) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } userchange.IsAdmin = true @@ -397,15 +394,15 @@ func updateUser(w http.ResponseWriter, r *http.Request) { err = ValidateUser("update", userchange) if err != nil { - json.NewEncoder(w).Encode(err) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } user, err = UpdateUser(userchange, user) if err != nil { - json.NewEncoder(w).Encode(err) - return + returnErrorResponse(w, r, formatError(err, "internal")) + return } json.NewEncoder(w).Encode(user) diff --git a/docker-compose.yml b/docker-compose.yml index ea79912e..bbe39e3b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,6 @@ services: - /sys/fs/cgroup:/sys/fs/cgroup environment: MONGO_HOST: "127.0.0.1" - SERVER_DOMAIN: "3.236.149.180" cap_add: - NET_ADMIN - SYS_MODULE diff --git a/main.go b/main.go index 38ecce02..dcb0ac77 100644 --- a/main.go +++ b/main.go @@ -29,72 +29,63 @@ import ( "google.golang.org/grpc" ) -var ServerGRPC string -var PortGRPC string - //Start MongoDB Connection and start API Request Handler func main() { + //Client Mode Prereq Check + if serverctl.IsClientMode() { + cmd := exec.Command("id", "-u") + output, err := cmd.Output() - var dnsmode string - var clientmode string - var defaultnet string - flag.StringVar(&clientmode, "clientmode", "on", "Have a client on the server") - flag.StringVar(&defaultnet, "defaultnet", "on", "Create a default network") - flag.StringVar(&dnsmode, "dnsmode", "on", "Add DNS settings") - flag.Parse() - if clientmode == "on" { - - cmd := exec.Command("id", "-u") - output, err := cmd.Output() - - if err != nil { - log.Fatal(err) - } - i, err := strconv.Atoi(string(output[:len(output)-1])) - if err != nil { - log.Fatal(err) - } - - if i != 0 { - log.Fatal("To run in client mode requires root privileges. Either turn off client mode with the --clientmode=off flag, or run with sudo.") - } + if err != nil { + fmt.Println("Error running 'id -u' for prereq check. Please investigate or disable client mode.") + log.Fatal(err) + } + i, err := strconv.Atoi(string(output[:len(output)-1])) + if err != nil { + fmt.Println("Error retrieving uid from 'id -u' for prereq check. Please investigate or disable client mode.") + log.Fatal(err) + } + if i != 0 { + log.Fatal("To run in client mode requires root privileges. Either disable client mode or run with sudo.") + } } - log.Println("Server starting...") + //Start Mongodb mongoconn.ConnectDatabase() installserver := false - if !(defaultnet == "off") { - if config.Config.Server.CreateDefault { - created, err := createDefaultNetwork() - if err != nil { - fmt.Printf("Error creating default network: %v", err) - } - if created && clientmode != "off" { - installserver = true - } + + //Create the default network (default: 10.10.10.0/24) + created, err := serverctl.CreateDefaultNetwork() + if err != nil { + fmt.Printf("Error creating default network: %v", err) } + + if created && serverctl.IsClientMode() { + installserver = true } - if dnsmode == "on" { - err := controller.SetDNS() - if err != nil { - fmt.Printf("Error setting DNS: %v", err) - } - } + + //NOTE: Removed Check and Logic for DNS Mode + //Reasoning. DNS Logic is very small on server. Can run with little/no impact. Just sets a tiny config file. + //Real work is done by CoreDNS + //We can just not run CoreDNS. On Agent side is only necessary check for IsDNSMode, which we will pass. + var waitnetwork sync.WaitGroup - if config.Config.Server.AgentBackend { + //Run Agent Server + if serverctl.IsAgentBackend() { waitnetwork.Add(1) go runGRPC(&waitnetwork, installserver) } - if config.Config.Server.RestBackend { + //Run Rest Server + if serverctl.IsRestBackend() { waitnetwork.Add(1) controller.HandleRESTRequests(&waitnetwork) } - if !config.Config.Server.RestBackend && !config.Config.Server.AgentBackend { - fmt.Println("Oops! No Server Mode selected. Nothing being served.") + if !serverctl.IsAgentBackend() && !serverctl.IsRestBackend { + fmt.Println("Oops! No Server Mode selected. Nothing is being served! Set either Agent mode (AGENT_BACKEND) or Rest mode (REST_BACKEND) to 'true'.") } waitnetwork.Wait() fmt.Println("Exiting now.") @@ -110,36 +101,7 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { // Pipe flags to one another (log.LstdFLags = log.Ldate | log.Ltime) log.SetFlags(log.LstdFlags | log.Lshortfile) - // Start our listener, 50051 is the default gRPC port - grpcport := ":50051" - if config.Config.Server.GrpcPort != "" { - grpcport = ":" + config.Config.Server.GrpcPort - } - if os.Getenv("GRPC_PORT") != "" { - grpcport = ":" + os.Getenv("GRPC_PORT") - } - PortGRPC = grpcport - if os.Getenv("SERVER_DOMAIN") == "" { - if config.Config.Server.Host == "" { - ServerGRPC, _ = serverctl.GetPublicIP() - } else { - ServerGRPC = config.Config.Server.Host - } - } else { - ServerGRPC = os.Getenv("SERVER_DOMAIN") - } - fmt.Println("GRPC Server set to: " + ServerGRPC) - fmt.Println("GRPC Port set to: " + PortGRPC) - var gconf models.GlobalConfig - gconf.ServerGRPC = ServerGRPC - gconf.PortGRPC = PortGRPC - gconf.Name = "netmaker" - err := setGlobalConfig(gconf) - - if err != nil && err != mongo.ErrNoDocuments{ - log.Fatalf("Unable to set global config: %v", err) - } - + grpcport := serverctl.GetGRPCPort() listener, err := net.Listen("tcp", grpcport) // Handle errors if any @@ -168,8 +130,8 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { fmt.Println("Agent Server succesfully started on port " + grpcport + " (gRPC)") if installserver { - fmt.Println("Adding server to " + config.Config.Server.DefaultNetName) - success, err := serverctl.AddNetwork(config.Config.Server.DefaultNetName) + fmt.Println("Adding server to default network") + success, err := serverctl.AddNetwork("default") if err != nil { fmt.Printf("Error adding to default network: %v", err) fmt.Println("") @@ -184,8 +146,6 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { } fmt.Println("Setup complete. You are ready to begin using netmaker.") - - // Right way to stop the server using a SHUTDOWN HOOK // Create a channel to receive OS signals c := make(chan os.Signal) @@ -207,84 +167,6 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { mongoconn.Client.Disconnect(context.TODO()) fmt.Println("MongoDB connection closed.") } -func setGlobalConfig(globalconf models.GlobalConfig) (error) { - - collection := mongoconn.Client.Database("netmaker").Collection("config") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - - create, _, err := functions.GetGlobalConfig() - if create { - _, err := collection.InsertOne(ctx, globalconf) - defer cancel() - if err != nil { - if err == mongo.ErrNoDocuments || strings.Contains(err.Error(), "no documents in result"){ - return nil - } else { - return err - } - } - } else { - filter := bson.M{"name": "netmaker"} - update := bson.D{ - {"$set", bson.D{ - {"servergrpc", globalconf.ServerGRPC}, - {"portgrpc", globalconf.PortGRPC}, - }}, - } - err := collection.FindOneAndUpdate(ctx, filter, update).Decode(&globalconf) - if err == mongo.ErrNoDocuments { - //if err == mongo.ErrNoDocuments || strings.Contains(err.Error(), "no documents in result"){ - return nil - } - } - return err -} - -func createDefaultNetwork() (bool, error) { - - iscreated := false - exists, err := functions.NetworkExists(config.Config.Server.DefaultNetName) - - if exists || err != nil { - fmt.Println("Default network already exists") - fmt.Println("Skipping default network create") - return iscreated, err - } else { - - var network models.Network - - network.NetID = config.Config.Server.DefaultNetName - network.AddressRange = config.Config.Server.DefaultNetRange - network.DisplayName = config.Config.Server.DefaultNetName - network.SetDefaults() - network.SetNodesLastModified() - network.SetNetworkLastModified() - network.KeyUpdateTimeStamp = time.Now().Unix() - priv := false - network.IsLocal = &priv - network.KeyUpdateTimeStamp = time.Now().Unix() - allow := true - network.AllowManualSignUp = &allow - - fmt.Println("Creating default network.") - - - collection := mongoconn.Client.Database("netmaker").Collection("networks") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - - - // insert our network into the network table - _, err = collection.InsertOne(ctx, network) - defer cancel() - - } - if err == nil { - iscreated = true - } - return iscreated, err - - -} func authServerUnaryInterceptor() grpc.ServerOption { return grpc.UnaryInterceptor(controller.AuthServerUnaryInterceptor) @@ -292,4 +174,3 @@ func authServerUnaryInterceptor() grpc.ServerOption { func authServerStreamInterceptor() grpc.ServerOption { return grpc.StreamInterceptor(controller.AuthServerStreamInterceptor) } - diff --git a/mongoconn/mongoconn.go b/mongoconn/mongoconn.go index 649c5df5..f4108828 100644 --- a/mongoconn/mongoconn.go +++ b/mongoconn/mongoconn.go @@ -2,10 +2,8 @@ package mongoconn import ( "context" - "encoding/json" "log" "os" - "net/http" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "github.com/gravitl/netmaker/config" @@ -67,7 +65,6 @@ func setVars() { //TODO: are we even using this besides at startup? Is it truely necessary? //TODO: Use config file instead of os.Getenv func ConnectDatabase() { - log.Println("Database connecting...") // Set client options setVars() @@ -80,9 +77,11 @@ func ConnectDatabase() { opts ) // Connect to MongoDB + log.Println("Connecting to MongoDB at " + host + ":" + port + "...") client, err := mongo.Connect(context.TODO(), clientOptions) Client = client if err != nil { + log.Println("Error encountered connecting to MongoDB. Terminating.") log.Fatal(err) } @@ -90,36 +89,14 @@ func ConnectDatabase() { err = Client.Ping(context.TODO(), nil) if err != nil { + log.Println("Error encountered pinging MongoDB. Terminating.") log.Fatal(err) } NodeDB = Client.Database("netmaker").Collection("nodes") NetworkDB = Client.Database("netmaker").Collection("networks") - log.Println("Database Connected.") -} - -//TODO: IDK if we're using ConnectDB any more.... I think we're just using Client.Database -//Review and see if this is necessary -// ConnectDB : This is helper function to connect mongoDB -func ConnectDB(db string, targetCollection string) *mongo.Collection { - - // Set client options - //clientOptions := options.Client().ApplyURI("mongodb://mongoadmin:mongopassword@localhost:27017/?authSource=admin") - clientOptions := options.Client().ApplyURI("mongodb://" + os.Getenv("MONGO_USER") + ":" + - os.Getenv("MONGO_PASS") + "@" + os.Getenv("MONGO_HOST") + ":" + os.Getenv("MONGO_PORT") + os.Getenv("MONGO_OPTS") ) - - // Connect to MongoDB - client, err := mongo.Connect(context.TODO(), clientOptions) - - if err != nil { - log.Fatal(err) - } - - //collection := client.Database("go_rest_api").Collection("wg") - collection := client.Database(db).Collection(targetCollection) - - return collection + log.Println("MongoDB Connected.") } // ErrorResponse : This is error model. @@ -127,17 +104,3 @@ type ErrorResponse struct { StatusCode int `json:"status"` ErrorMessage string `json:"message"` } - -// GetError : This is helper function to prepare error model. -func GetError(err error, w http.ResponseWriter) { - - var response = ErrorResponse{ - ErrorMessage: err.Error(), - StatusCode: http.StatusInternalServerError, - } - - message, _ := json.Marshal(response) - - w.WriteHeader(response.StatusCode) - w.Write(message) -} diff --git a/netclient/config/config.go b/netclient/config/config.go index a0da4b02..48b60170 100644 --- a/netclient/config/config.go +++ b/netclient/config/config.go @@ -234,9 +234,3 @@ func ReadConfig(network string) (*ClientConfig, error) { } return &cfg, err } -/* -func init() { - Config = readConfig() -} -*/ - diff --git a/netclient/functions/common.go b/netclient/functions/common.go index 38c1ac4b..7861583c 100644 --- a/netclient/functions/common.go +++ b/netclient/functions/common.go @@ -518,7 +518,7 @@ func getLocalIP(localrange string) (string, error) { func getPublicIP() (string, error) { - iplist := []string{"https://ifconfig.me", "http://api.ipify.org", "http://ipinfo.io/ip"} + iplist := []string{"http://ip.client.gravitl.com","https://ifconfig.me", "http://api.ipify.org", "http://ipinfo.io/ip"} endpoint := "" var err error for _, ipserver := range iplist { diff --git a/serverctl/getconf.go b/serverctl/getconf.go new file mode 100644 index 00000000..5c6fc184 --- /dev/null +++ b/serverctl/getconf.go @@ -0,0 +1,159 @@ +package serverctl + +func SetHost() error { + remoteip, err := GetPublicIP() + if err != nil { + return err + } + os.Setenv("SERVER_HOST", remoteip) +} +func GetAPIHost() string { + serverhost := 127.0.0.1 + if os.Getenv("SERVER_HTTP_HOST") != "" { + serverhost = os.Getenv("SERVER_HTTP_HOST") + } else if config.Config.Server.APIHost != "" { + serverhost = config.Config.Server.APIHost + } else if os.Getenv("SERVER_HOST") != "" { + serverhost = os.Getenv("SERVER_HOST") + } + return serverhost +} +func GetAPIPort() string { + apiport := "8081" + if os.Getenv("API_PORT") != "" { + apiport = os.Getenv("API_PORT") + } else if config.Config.Server.APIPort != "" { + apiport = config.Config.Server.APIPort + } + return apiport +} +func GetGRPCHost() string { + serverhost := 127.0.0.1 + if os.Getenv("SERVER_GRPC_HOST") != "" { + serverhost = os.Getenv("SERVER_GRPC_HOST") + } else if config.Config.Server.GRPCHost != "" { + serverhost = config.Config.Server.GRPCHost + } else if os.Getenv("SERVER_HOST") != "" { + serverhost = os.Getenv("SERVER_HOST") + } + return serverhost +} +func GetGRPCPort() string { + grpcport := "50051" + if os.Getenv("GRPC_PORT") != "" { + grpcport = os.Getenv("GRPC_PORT") + } else if config.Config.Server.GRPCPort != "" { + grpcport = config.Config.Server.GRPCPort + } + return grpcport +} +func GetMasterKey() string { + key := "secretkey" + if os.Getenv("MASTER_KEY") != "" { + key = os.Getenv("MASTER_KEY") + } else if config.Config.Server.MasterKey != "" { + key = config.Config.Server.MasterKey + } + return key +} +func GetAllowedOrigin() string { + allowedorigin := "*" + if os.Getenv("CORS_ALLOWED_ORIGIN") != "" { + allowedorigin = os.Getenv("CORS_ALLOWED_ORIGIN") + } else if config.Config.Server.AllowedOrigin != "" { + allowedorigin = config.Config.Server.AllowedOrigin + } + return allowedorigin +} +func IsRestBackend() bool { + isrest := true + if os.Getenv("REST_BACKEND") != "" { + if os.Getenv("REST_BACKEND") == "off" + isrest = false + } + } else if config.Config.Server.RestBackend != "" { + if config.Config.Server.RestBackend == "off" { + isrest = false + } + } + return isrest +} +func IsAgentBackend() bool { + isagent := true + if os.Getenv("AGENT_BACKEND") != "" { + if os.Getenv("AGENT_BACKEND") == "off" + isagent = false + } + } else if config.Config.Server.AgentBackend != "" { + if config.Config.Server.AgentBackend == "off" { + isagent = false + } + } + return isagent +} +func IsClientMode() bool { + isclient := true + if os.Getenv("CLIENT_MODE") != "" { + if os.Getenv("CLIENT_MODE") == "off" + isclient = false + } + } else if config.Config.Server.ClientMode != "" { + if config.Config.Server.ClientMode == "off" { + isclient = false + } + } + return isclient +} +func IsDNSMode() bool { + isdns := true + if os.Getenv("DNS_MODE") != "" { + if os.Getenv("DNS_MODE") == "off" + isdns = false + } + } else if config.Config.Server.DNSMode != "" { + if config.Config.Server.DNSMode == "off" { + isdns = false + } + } + return isdns +} +func DisableRemoteIPCheck() bool { + disabled := false + if os.Getenv("DISABLE_REMOTE_IP_CHECK") != "" { + if os.Getenv("DISABLE_REMOTE_IP_CHECK") == "on" + disabled = true + } + } else if config.Config.Server.DisableRemoteIpCheck != "" { + if config.Config.Server.DisableRemoteIpCheck == "on" { + disabled= true + } + } + return disabled +} +func GetPublicIP() (string, error) { + + endpoint := "" + var err error + + iplist := []string{"http://ip.server.gravitl.com", "https://ifconfig.me", "http://api.ipify.org", "http://ipinfo.io/ip"} + for _, ipserver := range iplist { + resp, err := http.Get(ipserver) + if err != nil { + continue + } + defer resp.Body.Close() + if resp.StatusCode == http.StatusOK { + bodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + continue + } + endpoint = string(bodyBytes) + break + } + + } + if err == nil && endpoint == "" { + err = errors.New("Public Address Not Found.") + } + return endpoint, err +} diff --git a/serverctl/serverctl.go b/serverctl/serverctl.go index 61d8a6a1..df4bd1be 100644 --- a/serverctl/serverctl.go +++ b/serverctl/serverctl.go @@ -11,37 +11,159 @@ import ( "os/exec" ) -func GetPublicIP() (string, error) { +func CreateDefaultNetwork() (bool, error) { - endpoint := "" - var err error + fmt.Println("Creating default network...") - if os.Getenv("SERVER_DOMAIN") != "" { - endpoint = os.Getenv("SERVER_DOMAIN") + iscreated := false + exists, err := functions.NetworkExists(config.Config.Server.DefaultNetName) + + if exists || err != nil { + fmt.Println("Default network already exists. Skipping...") + return iscreated, err } else { - iplist := []string{"https://ifconfig.me", "http://api.ipify.org", "http://ipinfo.io/ip"} - for _, ipserver := range iplist { - resp, err := http.Get(ipserver) - if err != nil { - continue - } - defer resp.Body.Close() - if resp.StatusCode == http.StatusOK { - bodyBytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - continue - } - endpoint = string(bodyBytes) - break - } + var network models.Network + + network.NetID = "default" + network.AddressRange = "10.10.10.0/24" + network.DisplayName = "default" + network.SetDefaults() + network.SetNodesLastModified() + network.SetNetworkLastModified() + network.KeyUpdateTimeStamp = time.Now().Unix() + priv := false + network.IsLocal = &priv + network.KeyUpdateTimeStamp = time.Now().Unix() + allow := true + network.AllowManualSignUp = &allow + + fmt.Println("Creating default network.") + + collection := mongoconn.Client.Database("netmaker").Collection("networks") + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + + // insert our network into the network table + _, err = collection.InsertOne(ctx, network) + defer cancel() } - if err == nil && endpoint == "" { - err = errors.New("Public Address Not Found.") + if err == nil { + iscreated = true } + return iscreated, err + + +} + +func GetHTTPPort() (string, error) { + +} + +func GetGRPCPort() (string, error) { + +} + +func GetServerDomain() (string, error) { + +} + +func modConfig(node *nodepb.Node) error{ + network := node.Nodenetwork + if network == "" { + return errors.New("No Network Provided") } - return endpoint, err + modconfig, err := config.ReadConfig(network) + if err != nil { + return err + } + nodecfg := modconfig.Node + if node.Name != ""{ + nodecfg.Name = node.Name + } + if node.Interface != ""{ + nodecfg.Interface = node.Interface + } + if node.Nodenetwork != ""{ + nodecfg.Network = node.Nodenetwork + } + if node.Macaddress != ""{ + nodecfg.MacAddress = node.Macaddress + } + if node.Localaddress != ""{ + nodecfg.LocalAddress = node.Localaddress + } + if node.Postup != ""{ + nodecfg.PostUp = node.Postup + } + if node.Postdown != ""{ + nodecfg.PostDown = node.Postdown + } + if node.Listenport != 0{ + nodecfg.Port = node.Listenport + } + if node.Keepalive != 0{ + nodecfg.KeepAlive = node.Keepalive + } + if node.Publickey != ""{ + nodecfg.PublicKey = node.Publickey + } + if node.Endpoint != ""{ + nodecfg.Endpoint = node.Endpoint + } + if node.Password != ""{ + nodecfg.Password = node.Password + } + if node.Address != ""{ + nodecfg.WGAddress = node.Address + } + if node.Postchanges != "" { + nodecfg.PostChanges = node.Postchanges + } + if node.Localrange != "" && node.Islocal { + nodecfg.IsLocal = true + nodecfg.LocalRange = node.Localrange + } + modconfig.Node = nodecfg + err = config.Write(modconfig, network) + return err +} + +func SetGlobalConfig(globalconf models.GlobalConfig) (error) { + + if err != nil && err != mongo.ErrNoDocuments{ + log.Fatalf("Unable to set global config: %v", err) + } + + collection := mongoconn.Client.Database("netmaker").Collection("config") + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + + create, _, err := functions.GetGlobalConfig() + if create { + _, err := collection.InsertOne(ctx, globalconf) + defer cancel() + if err != nil { + if err == mongo.ErrNoDocuments || strings.Contains(err.Error(), "no documents in result"){ + return nil + } else { + return err + } + } + } else { + filter := bson.M{"name": "netmaker"} + update := bson.D{ + {"$set", bson.D{ + {"servergrpc", globalconf.ServerGRPC}, + {"portgrpc", globalconf.PortGRPC}, + }}, + } + err := collection.FindOneAndUpdate(ctx, filter, update).Decode(&globalconf) + if err == mongo.ErrNoDocuments { + //if err == mongo.ErrNoDocuments || strings.Contains(err.Error(), "no documents in result"){ + return nil + } + } + return err } func DownloadNetclient() error { From de3d81db3af27e77e02ee5aaba053ff9532c92ec Mon Sep 17 00:00:00 2001 From: afeiszli Date: Wed, 5 May 2021 22:03:37 +0000 Subject: [PATCH 05/14] configs mostly working. Need to add in public dns default check. --- config/config.go | 27 ++-- controllers/controller.go | 9 +- controllers/networkHttpController.go | 5 +- controllers/serverHttpController.go | 17 ++- functions/jwt.go | 7 +- main.go | 23 ++-- mongoconn/mongoconn.go | 51 +------- servercfg/mongoconf.go | 53 ++++++++ .../getconf.go => servercfg/serverconf.go | 60 +++++++-- serverctl/serverctl.go | 121 +----------------- 10 files changed, 163 insertions(+), 210 deletions(-) create mode 100644 servercfg/mongoconf.go rename serverctl/getconf.go => servercfg/serverconf.go (78%) diff --git a/config/config.go b/config/config.go index 9623aca4..847b8e43 100644 --- a/config/config.go +++ b/config/config.go @@ -15,7 +15,7 @@ import ( //setting dev by default func getEnv() string { - env := os.Getenv("APP_ENV") + env := os.Getenv("NETMAKER_ENV") if len(env) == 0 { return "dev" @@ -35,15 +35,17 @@ type EnvironmentConfig struct { // ServerConfig : type ServerConfig struct { - Host string `yaml:"host"` - ApiPort string `yaml:"apiport"` - GrpcPort string `yaml:"grpcport"` + APIHost string `yaml:"apihost"` + APIPort string `yaml:"apiport"` + GRPCHost string `yaml:"grpchost"` + GRPCPort string `yaml:"grpcport"` MasterKey string `yaml:"masterkey"` AllowedOrigin string `yaml:"allowedorigin"` - RestBackend bool `yaml:"restbackend"` - AgentBackend bool `yaml:"agentbackend"` - DefaultNetName string `yaml:"defaultnetname"` - DefaultNetRange string `yaml:"defaultnetrange"` + RestBackend string `yaml:"restbackend"` + AgentBackend string `yaml:"agentbackend"` + ClientMode string `yaml:"clientmode"` + DNSMode string `yaml:"dnsmode"` + DisableRemoteIPCheck string `yaml:"disableremoteipcheck"` } type MongoConnConfig struct { @@ -59,13 +61,16 @@ type MongoConnConfig struct { func readConfig() *EnvironmentConfig { file := fmt.Sprintf("config/environments/%s.yaml", getEnv()) f, err := os.Open(file) + var cfg EnvironmentConfig if err != nil { - log.Fatal(err) - os.Exit(2) + //log.Fatal(err) + //os.Exit(2) + log.Println("Unable to open config file at config/environments/" + getEnv()) + log.Println("Will proceed with defaults or enironment variables (no config file).") + return &cfg } defer f.Close() - var cfg EnvironmentConfig decoder := yaml.NewDecoder(f) err = decoder.Decode(&cfg) if err != nil { diff --git a/controllers/controller.go b/controllers/controller.go index 9a7d11d9..a4a7dcc4 100644 --- a/controllers/controller.go +++ b/controllers/controller.go @@ -2,6 +2,7 @@ package controller import ( "github.com/gravitl/netmaker/mongoconn" + "github.com/gravitl/netmaker/servercfg" "os/signal" "os" "fmt" @@ -10,7 +11,6 @@ import ( "github.com/gorilla/mux" "github.com/gorilla/handlers" "sync" - "github.com/gravitl/netmaker/config" ) @@ -22,7 +22,7 @@ func HandleRESTRequests(wg *sync.WaitGroup) { // Currently allowed dev origin is all. Should change in prod // should consider analyzing the allowed methods further headersOk := handlers.AllowedHeaders([]string{"Access-Control-Allow-Origin", "X-Requested-With", "Content-Type", "authorization"}) - originsOk := handlers.AllowedOrigins([]string{config.Config.Server.AllowedOrigin}) + originsOk := handlers.AllowedOrigins([]string{servercfg.GetAllowedOrigin()}) methodsOk := handlers.AllowedMethods([]string{"GET", "PUT", "POST", "DELETE"}) nodeHandlers(r) @@ -32,10 +32,7 @@ func HandleRESTRequests(wg *sync.WaitGroup) { fileHandlers(r) serverHandlers(r) - port := config.Config.Server.ApiPort - if os.Getenv("API_PORT") != "" { - port = os.Getenv("API_PORT") - } + port := servercfg.GetAPIPort() srv := &http.Server{Addr: ":" + port, Handler: handlers.CORS(originsOk, headersOk, methodsOk)(r)} go func(){ diff --git a/controllers/networkHttpController.go b/controllers/networkHttpController.go index cc669b56..7d48bfa8 100644 --- a/controllers/networkHttpController.go +++ b/controllers/networkHttpController.go @@ -9,9 +9,8 @@ import ( "net/http" "strings" "time" - "os" "github.com/gorilla/mux" - "github.com/gravitl/netmaker/config" + "github.com/gravitl/netmaker/servercfg" "github.com/gravitl/netmaker/functions" "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/mongoconn" @@ -83,7 +82,7 @@ func securityCheck(next http.Handler) http.HandlerFunc { //Consider a more secure way of setting master key func authenticateMaster(tokenString string) bool { - if tokenString == config.Config.Server.MasterKey || (tokenString == os.Getenv("MASTER_KEY") && tokenString != "") { + if tokenString == servercfg.GetMasterKey() { return true } return false diff --git a/controllers/serverHttpController.go b/controllers/serverHttpController.go index c384fd8d..320a0f1a 100644 --- a/controllers/serverHttpController.go +++ b/controllers/serverHttpController.go @@ -3,7 +3,7 @@ package controller import ( "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/serverctl" - "github.com/gravitl/netmaker/config" + "github.com/gravitl/netmaker/servercfg" "encoding/json" "strings" "net/http" @@ -12,6 +12,7 @@ import ( func serverHandlers(r *mux.Router) { r.HandleFunc("/api/server/addnetwork/{network}", securityCheckServer(http.HandlerFunc(addNetwork))).Methods("POST") + r.HandleFunc("/api/server/getconfig", securityCheckServer(http.HandlerFunc(getConfig))).Methods("GET") r.HandleFunc("/api/server/removenetwork/{network}", securityCheckServer(http.HandlerFunc(removeNetwork))).Methods("DELETE") } @@ -49,7 +50,7 @@ func securityCheckServer(next http.Handler) http.HandlerFunc { } //Consider a more secure way of setting master key func authenticateMasterServer(tokenString string) bool { - if tokenString == config.Config.Server.MasterKey { + if tokenString == servercfg.GetMasterKey() { return true } return false @@ -72,6 +73,18 @@ func removeNetwork(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode("Server removed from network " + params["network"]) } +func getConfig(w http.ResponseWriter, r *http.Request) { + // Set header + w.Header().Set("Content-Type", "application/json") + + // get params + + scfg := servercfg.GetConfig() + + w.WriteHeader(http.StatusOK) + json.NewEncoder(w).Encode(scfg) +} + func addNetwork(w http.ResponseWriter, r *http.Request) { // Set header w.Header().Set("Content-Type", "application/json") diff --git a/functions/jwt.go b/functions/jwt.go index 49699f58..5beee30c 100644 --- a/functions/jwt.go +++ b/functions/jwt.go @@ -2,9 +2,8 @@ package functions import ( "time" - "os" - "github.com/gravitl/netmaker/config" "github.com/gravitl/netmaker/models" + "github.com/gravitl/netmaker/servercfg" "github.com/dgrijalva/jwt-go" ) @@ -51,7 +50,7 @@ func CreateUserJWT(username string, isadmin bool) (response string, err error) { func VerifyUserToken(tokenString string) (username string, isadmin bool, err error) { claims := &models.UserClaims{} - if tokenString == config.Config.Server.MasterKey || (tokenString == os.Getenv("MASTER_KEY") && tokenString != "") { + if tokenString == servercfg.GetMasterKey() { return "masteradministrator", true, nil } @@ -71,7 +70,7 @@ func VerifyToken(tokenString string) (macaddress string, network string, err err //this may be a stupid way of serving up a master key //TODO: look into a different method. Encryption? - if tokenString == config.Config.Server.MasterKey || (tokenString == os.Getenv("MASTER_KEY") && tokenString != "") { + if tokenString == servercfg.GetMasterKey() { return "mastermac", "", nil } diff --git a/main.go b/main.go index dcb0ac77..4ac3d401 100644 --- a/main.go +++ b/main.go @@ -5,17 +5,11 @@ package main import ( "log" - "flag" - "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/controllers" + "github.com/gravitl/netmaker/servercfg" "github.com/gravitl/netmaker/serverctl" - "github.com/gravitl/netmaker/functions" "github.com/gravitl/netmaker/mongoconn" - "github.com/gravitl/netmaker/config" - "go.mongodb.org/mongo-driver/bson" "fmt" - "time" - "strings" "os" "os/exec" "net" @@ -23,7 +17,6 @@ import ( "strconv" "sync" "os/signal" - "go.mongodb.org/mongo-driver/mongo" service "github.com/gravitl/netmaker/controllers" nodepb "github.com/gravitl/netmaker/grpc" "google.golang.org/grpc" @@ -33,7 +26,7 @@ import ( func main() { //Client Mode Prereq Check - if serverctl.IsClientMode() { + if servercfg.IsClientMode() { cmd := exec.Command("id", "-u") output, err := cmd.Output() @@ -62,7 +55,7 @@ func main() { fmt.Printf("Error creating default network: %v", err) } - if created && serverctl.IsClientMode() { + if created && servercfg.IsClientMode() { installserver = true } @@ -74,17 +67,17 @@ func main() { var waitnetwork sync.WaitGroup //Run Agent Server - if serverctl.IsAgentBackend() { + if servercfg.IsAgentBackend() { waitnetwork.Add(1) go runGRPC(&waitnetwork, installserver) } //Run Rest Server - if serverctl.IsRestBackend() { + if servercfg.IsRestBackend() { waitnetwork.Add(1) controller.HandleRESTRequests(&waitnetwork) } - if !serverctl.IsAgentBackend() && !serverctl.IsRestBackend { + if !servercfg.IsAgentBackend() && !servercfg.IsRestBackend() { fmt.Println("Oops! No Server Mode selected. Nothing is being served! Set either Agent mode (AGENT_BACKEND) or Rest mode (REST_BACKEND) to 'true'.") } waitnetwork.Wait() @@ -101,9 +94,9 @@ func runGRPC(wg *sync.WaitGroup, installserver bool) { // Pipe flags to one another (log.LstdFLags = log.Ldate | log.Ltime) log.SetFlags(log.LstdFlags | log.Lshortfile) - grpcport := serverctl.GetGRPCPort() + grpcport := servercfg.GetGRPCPort() - listener, err := net.Listen("tcp", grpcport) + listener, err := net.Listen("tcp", ":"+grpcport) // Handle errors if any if err != nil { log.Fatalf("Unable to listen on port" + grpcport + ": %v", err) diff --git a/mongoconn/mongoconn.go b/mongoconn/mongoconn.go index f4108828..352f7597 100644 --- a/mongoconn/mongoconn.go +++ b/mongoconn/mongoconn.go @@ -3,10 +3,9 @@ package mongoconn import ( "context" "log" - "os" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "github.com/gravitl/netmaker/config" + "github.com/gravitl/netmaker/servercfg" ) var Client *mongo.Client @@ -19,51 +18,13 @@ var port string var opts string func setVars() { - - //defaults - user = "admin" - pass = "password" - host = "localhost" - port = "27017" - opts = "/?authSource=admin" - - //override with settings from config file - if config.Config.MongoConn.User != "" { - user = config.Config.MongoConn.User - } - if config.Config.MongoConn.Pass != "" { - pass = config.Config.MongoConn.Pass - } - if config.Config.MongoConn.Host != "" { - host = config.Config.MongoConn.Host - } - if config.Config.MongoConn.Port != "" { - port = config.Config.MongoConn.Port - } - if config.Config.MongoConn.Opts != "" { - opts = config.Config.MongoConn.Opts - } - - //override with settings from env - if os.Getenv("MONGO_USER") != "" { - user = os.Getenv("MONGO_USER") - } - if os.Getenv("MONGO_PASS") != "" { - pass = os.Getenv("MONGO_PASS") - } - if os.Getenv("MONGO_HOST") != "" { - host = os.Getenv("MONGO_HOST") - } - if os.Getenv("MONGO_PORT") != "" { - port = os.Getenv("MONGO_PORT") - } - if os.Getenv("MONGO_OPTS") != "" { - opts = os.Getenv("MONGO_OPTS") - } + user = servercfg.GetMongoUser() + pass = servercfg.GetMongoPass() + host = servercfg.GetMongoHost() + port = servercfg.GetMongoPort() + opts = servercfg.GetMongoOpts() } -//TODO: are we even using this besides at startup? Is it truely necessary? -//TODO: Use config file instead of os.Getenv func ConnectDatabase() { // Set client options diff --git a/servercfg/mongoconf.go b/servercfg/mongoconf.go new file mode 100644 index 00000000..89fecbe2 --- /dev/null +++ b/servercfg/mongoconf.go @@ -0,0 +1,53 @@ +package servercfg + +import ( + "github.com/gravitl/netmaker/config" + "os" +) + +func GetMongoUser() string { + user := "mongoadmin" + if os.Getenv("MONGO_ADMIN") != "" { + user = os.Getenv("MONGO_ADMIN") + } else if config.Config.MongoConn.User != "" { + user = config.Config.MongoConn.User + } + return user +} +func GetMongoPass() string { + pass := "mongopass" + if os.Getenv("MONGO_PASS") != "" { + pass = os.Getenv("MONGO_PASS") + } else if config.Config.MongoConn.Pass != "" { + pass = config.Config.MongoConn.Pass + } + return pass +} +func GetMongoHost() string { + host := "127.0.0.1" + if os.Getenv("MONGO_HOST") != "" { + host = os.Getenv("MONGO_HOST") + } else if config.Config.MongoConn.Host != "" { + host = config.Config.MongoConn.Host + } + return host +} +func GetMongoPort() string { + port := "27017" + if os.Getenv("MONGO_PORT") != "" { + port = os.Getenv("MONGO_PORT") + } else if config.Config.MongoConn.Port != "" { + port = config.Config.MongoConn.Port + } + return port +} +func GetMongoOpts() string { + opts := "/?authSource=admin" + if os.Getenv("MONGO_OPTS") != "" { + opts = os.Getenv("MONGO_OPTS") + } else if config.Config.MongoConn.Opts != "" { + opts = config.Config.MongoConn.Opts + } + return opts +} + diff --git a/serverctl/getconf.go b/servercfg/serverconf.go similarity index 78% rename from serverctl/getconf.go rename to servercfg/serverconf.go index 5c6fc184..effe638f 100644 --- a/serverctl/getconf.go +++ b/servercfg/serverconf.go @@ -1,4 +1,12 @@ -package serverctl +package servercfg + +import ( + "github.com/gravitl/netmaker/config" + "net/http" + "io/ioutil" + "os" + "errors" +) func SetHost() error { remoteip, err := GetPublicIP() @@ -6,9 +14,41 @@ func SetHost() error { return err } os.Setenv("SERVER_HOST", remoteip) + return nil } +func GetConfig() config.ServerConfig { + var cfg config.ServerConfig + cfg.APIHost = GetAPIHost() + cfg.APIPort = GetAPIPort() + cfg.GRPCHost = GetGRPCHost() + cfg.GRPCPort = GetGRPCPort() + cfg.MasterKey = "(hidden)" + cfg.AllowedOrigin = GetAllowedOrigin() + cfg.RestBackend = "off" + if IsRestBackend() { + cfg.RestBackend = "on" + } + cfg.AgentBackend = "off" + if IsAgentBackend() { + cfg.AgentBackend = "on" + } + cfg.ClientMode = "off" + if IsClientMode() { + cfg.ClientMode = "on" + } + cfg.DNSMode = "off" + if IsDNSMode() { + cfg.DNSMode = "on" + } + cfg.DisableRemoteIPCheck = "off" + if DisableRemoteIPCheck() { + cfg.DisableRemoteIPCheck = "on" + } + return cfg +} + func GetAPIHost() string { - serverhost := 127.0.0.1 + serverhost := "127.0.0.1" if os.Getenv("SERVER_HTTP_HOST") != "" { serverhost = os.Getenv("SERVER_HTTP_HOST") } else if config.Config.Server.APIHost != "" { @@ -28,7 +68,7 @@ func GetAPIPort() string { return apiport } func GetGRPCHost() string { - serverhost := 127.0.0.1 + serverhost := "127.0.0.1" if os.Getenv("SERVER_GRPC_HOST") != "" { serverhost = os.Getenv("SERVER_GRPC_HOST") } else if config.Config.Server.GRPCHost != "" { @@ -68,7 +108,7 @@ func GetAllowedOrigin() string { func IsRestBackend() bool { isrest := true if os.Getenv("REST_BACKEND") != "" { - if os.Getenv("REST_BACKEND") == "off" + if os.Getenv("REST_BACKEND") == "off" { isrest = false } } else if config.Config.Server.RestBackend != "" { @@ -81,7 +121,7 @@ func IsRestBackend() bool { func IsAgentBackend() bool { isagent := true if os.Getenv("AGENT_BACKEND") != "" { - if os.Getenv("AGENT_BACKEND") == "off" + if os.Getenv("AGENT_BACKEND") == "off" { isagent = false } } else if config.Config.Server.AgentBackend != "" { @@ -94,7 +134,7 @@ func IsAgentBackend() bool { func IsClientMode() bool { isclient := true if os.Getenv("CLIENT_MODE") != "" { - if os.Getenv("CLIENT_MODE") == "off" + if os.Getenv("CLIENT_MODE") == "off" { isclient = false } } else if config.Config.Server.ClientMode != "" { @@ -107,7 +147,7 @@ func IsClientMode() bool { func IsDNSMode() bool { isdns := true if os.Getenv("DNS_MODE") != "" { - if os.Getenv("DNS_MODE") == "off" + if os.Getenv("DNS_MODE") == "off" { isdns = false } } else if config.Config.Server.DNSMode != "" { @@ -120,11 +160,11 @@ func IsDNSMode() bool { func DisableRemoteIPCheck() bool { disabled := false if os.Getenv("DISABLE_REMOTE_IP_CHECK") != "" { - if os.Getenv("DISABLE_REMOTE_IP_CHECK") == "on" + if os.Getenv("DISABLE_REMOTE_IP_CHECK") == "on" { disabled = true } - } else if config.Config.Server.DisableRemoteIpCheck != "" { - if config.Config.Server.DisableRemoteIpCheck == "on" { + } else if config.Config.Server.DisableRemoteIPCheck != "" { + if config.Config.Server.DisableRemoteIPCheck == "on" { disabled= true } } diff --git a/serverctl/serverctl.go b/serverctl/serverctl.go index df4bd1be..7a4cd6e4 100644 --- a/serverctl/serverctl.go +++ b/serverctl/serverctl.go @@ -2,10 +2,13 @@ package serverctl import ( "fmt" - "net/http" - "io/ioutil" "github.com/gravitl/netmaker/functions" + "github.com/gravitl/netmaker/models" + "github.com/gravitl/netmaker/mongoconn" + "github.com/gravitl/netmaker/servercfg" "io" + "time" + "context" "errors" "os" "os/exec" @@ -16,7 +19,7 @@ func CreateDefaultNetwork() (bool, error) { fmt.Println("Creating default network...") iscreated := false - exists, err := functions.NetworkExists(config.Config.Server.DefaultNetName) + exists, err := functions.NetworkExists("default") if exists || err != nil { fmt.Println("Default network already exists. Skipping...") @@ -56,116 +59,6 @@ func CreateDefaultNetwork() (bool, error) { } -func GetHTTPPort() (string, error) { - -} - -func GetGRPCPort() (string, error) { - -} - -func GetServerDomain() (string, error) { - -} - -func modConfig(node *nodepb.Node) error{ - network := node.Nodenetwork - if network == "" { - return errors.New("No Network Provided") - } - modconfig, err := config.ReadConfig(network) - if err != nil { - return err - } - nodecfg := modconfig.Node - if node.Name != ""{ - nodecfg.Name = node.Name - } - if node.Interface != ""{ - nodecfg.Interface = node.Interface - } - if node.Nodenetwork != ""{ - nodecfg.Network = node.Nodenetwork - } - if node.Macaddress != ""{ - nodecfg.MacAddress = node.Macaddress - } - if node.Localaddress != ""{ - nodecfg.LocalAddress = node.Localaddress - } - if node.Postup != ""{ - nodecfg.PostUp = node.Postup - } - if node.Postdown != ""{ - nodecfg.PostDown = node.Postdown - } - if node.Listenport != 0{ - nodecfg.Port = node.Listenport - } - if node.Keepalive != 0{ - nodecfg.KeepAlive = node.Keepalive - } - if node.Publickey != ""{ - nodecfg.PublicKey = node.Publickey - } - if node.Endpoint != ""{ - nodecfg.Endpoint = node.Endpoint - } - if node.Password != ""{ - nodecfg.Password = node.Password - } - if node.Address != ""{ - nodecfg.WGAddress = node.Address - } - if node.Postchanges != "" { - nodecfg.PostChanges = node.Postchanges - } - if node.Localrange != "" && node.Islocal { - nodecfg.IsLocal = true - nodecfg.LocalRange = node.Localrange - } - modconfig.Node = nodecfg - err = config.Write(modconfig, network) - return err -} - -func SetGlobalConfig(globalconf models.GlobalConfig) (error) { - - if err != nil && err != mongo.ErrNoDocuments{ - log.Fatalf("Unable to set global config: %v", err) - } - - collection := mongoconn.Client.Database("netmaker").Collection("config") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - - create, _, err := functions.GetGlobalConfig() - if create { - _, err := collection.InsertOne(ctx, globalconf) - defer cancel() - if err != nil { - if err == mongo.ErrNoDocuments || strings.Contains(err.Error(), "no documents in result"){ - return nil - } else { - return err - } - } - } else { - filter := bson.M{"name": "netmaker"} - update := bson.D{ - {"$set", bson.D{ - {"servergrpc", globalconf.ServerGRPC}, - {"portgrpc", globalconf.PortGRPC}, - }}, - } - err := collection.FindOneAndUpdate(ctx, filter, update).Decode(&globalconf) - if err == mongo.ErrNoDocuments { - //if err == mongo.ErrNoDocuments || strings.Contains(err.Error(), "no documents in result"){ - return nil - } - } - return err -} - func DownloadNetclient() error { /* // Get the data @@ -247,7 +140,7 @@ func RemoveNetwork(network string) (bool, error) { } func AddNetwork(network string) (bool, error) { - pubip, err := GetPublicIP() + pubip, err := servercfg.GetPublicIP() if err != nil { fmt.Println("could not get public IP.") return false, err From 4ddd83aefb37855c3bcebbe0cc2584c27af14e00 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 00:41:28 +0000 Subject: [PATCH 06/14] new config fully functional --- controllers/networkHttpController.go | 3 +-- functions/helpers.go | 36 ++-------------------------- main.go | 14 +++++++++++ test/api_test.go | 14 ----------- 4 files changed, 17 insertions(+), 50 deletions(-) diff --git a/controllers/networkHttpController.go b/controllers/networkHttpController.go index 7d48bfa8..c1c82bff 100644 --- a/controllers/networkHttpController.go +++ b/controllers/networkHttpController.go @@ -592,7 +592,6 @@ func createAccessKey(w http.ResponseWriter, r *http.Request) { if accesskey.Uses == 0 { accesskey.Uses = 1 } - _, gconf, err := functions.GetGlobalConfig() if err != nil { returnErrorResponse(w, r, formatError(err, "internal")) return @@ -604,7 +603,7 @@ func createAccessKey(w http.ResponseWriter, r *http.Request) { } netID := params["networkname"] - address := gconf.ServerGRPC + gconf.PortGRPC + address := servercfg.GetGRPCHost() + ":" + servercfg.GetGRPCPort() accessstringdec := address + "|" + netID + "|" + accesskey.Value + "|" + privAddr accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec)) diff --git a/functions/helpers.go b/functions/helpers.go index a2860730..d05b0305 100644 --- a/functions/helpers.go +++ b/functions/helpers.go @@ -16,6 +16,7 @@ import ( "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/mongoconn" + "github.com/gravitl/netmaker/servercfg" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" @@ -38,11 +39,7 @@ func CreateServerToken(netID string) (string, error) { accesskey.Name = GenKeyName() accesskey.Value = GenKey() accesskey.Uses = 1 - _, gconf, errG := GetGlobalConfig() - if errG != nil { - return "", errG - } - address := "localhost" + gconf.PortGRPC + address := "127.0.0.1:" + servercfg.GetGRPCPort() privAddr := "" if *network.IsLocal { @@ -556,35 +553,6 @@ func UniqueAddress6(networkName string) (string, error) { return "W1R3: NO UNIQUE ADDRESSES AVAILABLE", err1 } -//pretty simple get -func GetGlobalConfig() (bool, models.GlobalConfig, error) { - - create := false - - filter := bson.M{} - - var globalconf models.GlobalConfig - - collection := mongoconn.Client.Database("netmaker").Collection("config") - - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - - err := collection.FindOne(ctx, filter).Decode(&globalconf) - - defer cancel() - - if err == mongo.ErrNoDocuments { - fmt.Println("Global config does not exist. Need to create.") - create = true - return create, globalconf, err - } else if err != nil { - fmt.Println(err) - fmt.Println("Could not get global config") - return create, globalconf, err - } - return create, globalconf, err -} - //generate an access key value func GenKey() string { diff --git a/main.go b/main.go index 4ac3d401..b4621cf7 100644 --- a/main.go +++ b/main.go @@ -68,12 +68,26 @@ func main() { //Run Agent Server if servercfg.IsAgentBackend() { + if !(servercfg.DisableRemoteIPCheck()) && servercfg.GetGRPCHost() == "127.0.0.1" { + err := servercfg.SetHost() + if err != nil { + fmt.Println("Unable to Set host. Exiting.") + log.Fatal(err) + } + } waitnetwork.Add(1) go runGRPC(&waitnetwork, installserver) } //Run Rest Server if servercfg.IsRestBackend() { + if !servercfg.DisableRemoteIPCheck() && servercfg.GetAPIHost() == "127.0.0.1" { + err := servercfg.SetHost() + if err != nil { + fmt.Println("Unable to Set host. Exiting.") + log.Fatal(err) + } + } waitnetwork.Add(1) controller.HandleRESTRequests(&waitnetwork) } diff --git a/test/api_test.go b/test/api_test.go index 647db459..6d169ec7 100644 --- a/test/api_test.go +++ b/test/api_test.go @@ -46,20 +46,6 @@ func TestMain(m *testing.M) { var waitgroup sync.WaitGroup waitgroup.Add(1) go controller.HandleRESTRequests(&waitgroup) - var gconf models.GlobalConfig - gconf.ServerGRPC = "localhost:8081" - gconf.PortGRPC = "50051" - //err := SetGlobalConfig(gconf) - collection := mongoconn.Client.Database("netmaker").Collection("config") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - //create, _, err := functions.GetGlobalConfig() - _, err := collection.InsertOne(ctx, gconf) - if err != nil { - panic("could not create config store") - } - - //wait for http server to start time.Sleep(time.Second * 1) os.Exit(m.Run()) } From 1fd30c0a71b34acee1283ceb9ed11a7654f39c20 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Wed, 5 May 2021 20:51:59 -0400 Subject: [PATCH 07/14] saving netclient changes --- functions/helpers.go | 1 + grpc/node.proto | 3 +- netclient/config/config.go | 2 ++ netclient/functions/common.go | 16 +++++++++- netclient/functions/local.go | 22 +++++++++++++ netclient/main.go | 5 +-- netmaker-install-v3.sh | 60 +++++++++++++++++++++++++++++++++++ 7 files changed, 105 insertions(+), 4 deletions(-) create mode 100755 netmaker-install-v3.sh diff --git a/functions/helpers.go b/functions/helpers.go index 7a9f89a9..13ea21eb 100644 --- a/functions/helpers.go +++ b/functions/helpers.go @@ -530,6 +530,7 @@ func UniqueAddress6(networkName string) (string, error) { var network models.Network network, err := GetParentNetwork(networkName) + dualstack := *network.IsDualStack if !*network.IsDualStack { return "", nil } diff --git a/grpc/node.proto b/grpc/node.proto index 2218cffd..a50f53b2 100644 --- a/grpc/node.proto +++ b/grpc/node.proto @@ -44,7 +44,8 @@ message Node { string postchanges = 21; string allowedips = 22; bool islocal = 23; - string localrange = 24; + bool dnsoff = 24; + string localrange = 25; } message CheckInResponse { diff --git a/netclient/config/config.go b/netclient/config/config.go index a0da4b02..dc5a0612 100644 --- a/netclient/config/config.go +++ b/netclient/config/config.go @@ -31,7 +31,9 @@ type NodeConfig struct { MacAddress string `yaml:"macaddress"` LocalAddress string `yaml:"localaddress"` WGAddress string `yaml:"wgaddress"` + WGAddress6 string `yaml:"wgaddress6"` RoamingOff bool `yaml:"roamingoff"` + DNSOff bool `yaml:"dnsoff"` IsLocal bool `yaml:"islocal"` AllowedIPs string `yaml:"allowedips"` LocalRange string `yaml:"localrange"` diff --git a/netclient/functions/common.go b/netclient/functions/common.go index 70783809..5aa2f46b 100644 --- a/netclient/functions/common.go +++ b/netclient/functions/common.go @@ -72,7 +72,7 @@ func GetFreePort(rangestart int32) (int32, error){ return portno, err } -func Install(accesskey string, password string, server string, network string, noauto bool, accesstoken string, inputname string) error { +func Install(accesskey string, password string, server string, network string, noauto bool, accesstoken string, inputname string, dnsoff bool) error { tserver := "" tnetwork := "" @@ -143,6 +143,8 @@ func Install(accesskey string, password string, server string, network string, n servercfg := cfg.Server fmt.Println("SERVER SETTINGS:") + nodecfg.DNSOff = dnsoff + if server == "" { if servercfg.Address == "" && tserver == "" { log.Fatal("no server provided") @@ -588,6 +590,9 @@ func modConfig(node *nodepb.Node) error{ if node.Address != ""{ nodecfg.WGAddress = node.Address } + if node.Address != ""{ + nodecfg.WGAddress = node.Address + } if node.Postchanges != "" { nodecfg.PostChanges = node.Postchanges } @@ -952,6 +957,15 @@ func CheckIn(network string) error { setupcheck := true ipchange := false + if !nodecfg.DNSOff { + vals := strings.Split(servercfg.Address, ":") + server := vals[0] + err = SetDNS(server) + if err != nil { + fmt.Printf("Error encountered setting dns: %v", err) + } + } + if !nodecfg.RoamingOff { if !nodecfg.IsLocal { fmt.Println("Checking to see if public addresses have changed") diff --git a/netclient/functions/local.go b/netclient/functions/local.go index c2962655..69011344 100644 --- a/netclient/functions/local.go +++ b/netclient/functions/local.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "path/filepath" "io" + "strings" "log" "os" "os/exec" @@ -20,6 +21,27 @@ func FileExists(f string) bool { return !info.IsDir() } +func SetDNS(nameserver string) error { + bytes, err := ioutil.ReadFile("/etc/resolv.conf") + if err != nil { + return err + } + resolvstring := string(bytes) + // //check whether s contains substring text + hasdns := strings.Contains(resolvstring, nameserver) + if hasdns { + return nil + } + resolv, err := os.OpenFile("/etc/resolv.conf",os.O_APPEND|os.O_WRONLY, 0644) + if err != nil { + return err + } + defer resolv.Close() + _, err = resolv.WriteString("nameserver " + nameserver + "\n") + + return err +} + func ConfigureSystemD(network string) error { /* path, err := os.Getwd() diff --git a/netclient/main.go b/netclient/main.go index 86247f09..cc466f1b 100644 --- a/netclient/main.go +++ b/netclient/main.go @@ -39,7 +39,8 @@ func main() { tname := flag.String("name", "noname", "give the node a name at runtime") tserver := flag.String("s", "localhost:50051", "The location (including port) of the remote gRPC server.") tnetwork := flag.String("n", "nonetwork", "The node network you are attempting to join.") - tnoauto := flag.Bool("na", false, "No auto mode. If true, netmclient will not be installed as a system service and you will have to retrieve updates manually via checkin command.") + tnoauto := flag.Bool("na", false, "No auto mode. If true, netclient will not be installed as a system service and you will have to retrieve updates manually via checkin command.") + tdnsoff := flag.Bool("dnsoff", false, "No dns mode. If true, netclient will not alter system dns.") tnoforward := flag.Bool("nf", false, "No Forward mode. If true, netclient will not check for IP forwarding. This may break functionality") command := flag.String("c", "required", "The command to run") @@ -108,7 +109,7 @@ func main() { } fmt.Println("Beginning agent installation.") - err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname) + err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname, *tdnsoff) if err != nil { fmt.Println("Error encountered while installing.") if !strings.Contains(err.Error(), "ALREADY_INSTALLED") { diff --git a/netmaker-install-v3.sh b/netmaker-install-v3.sh new file mode 100755 index 00000000..158000e0 --- /dev/null +++ b/netmaker-install-v3.sh @@ -0,0 +1,60 @@ +#!/bin/sh +set -e + +[ -z "$SERVER_DOMAIN" ] && echo "Need to set SERVER_DOMAIN (format: 1.2.3.4 or mybackend.com)" && exit 1; + + +docker volume create mongovol && docker run -d --name mongodb -v mongovol:/data/db --network host -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=mongopass mongo --bind_ip 0.0.0.0 + +mkdir -p /etc/netmaker/config/environments +wget -O /etc/netmaker/netmaker https://github.com/gravitl/netmaker/releases/download/latest/netmaker +chmod +x /etc/netmaker/netmaker + + +cat >/etc/netmaker/config/environments/dev.yaml</etc/netmaker/config/Corefile</etc/systemd/system/netmaker.service< Date: Thu, 6 May 2021 11:41:11 +0000 Subject: [PATCH 08/14] added ipv6 responses --- controllers/nodeGrpcController.go | 11 + docker-compose.nodns.yml | 66 + docker-compose.yml | 2 - go.mod | 1 + grpc/node.pb.go | 2049 ++++++++++++++++++----------- grpc/node.proto | 3 + models/structs.go | 1 + 7 files changed, 1378 insertions(+), 755 deletions(-) create mode 100644 docker-compose.nodns.yml diff --git a/controllers/nodeGrpcController.go b/controllers/nodeGrpcController.go index 33056da2..e3786878 100644 --- a/controllers/nodeGrpcController.go +++ b/controllers/nodeGrpcController.go @@ -7,6 +7,7 @@ import ( nodepb "github.com/gravitl/netmaker/grpc" "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/functions" + "github.com/gravitl/netmaker/servercfg" "go.mongodb.org/mongo-driver/mongo" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -40,6 +41,7 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe Macaddress: node.MacAddress, Name: node.Name, Address: node.Address, + Address6: node.Address6, Endpoint: node.Endpoint, Password: node.Password, Nodenetwork: node.Network, @@ -48,6 +50,7 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe Postdown: node.PostDown, Postup: node.PostUp, Checkininterval: node.CheckInInterval, + Dnsoff: servercfg.IsDNSMode(), Ispending: node.IsPending, Publickey: node.PublicKey, Listenport: node.ListenPort, @@ -71,6 +74,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo LocalAddress: data.GetLocaladdress(), Name: data.GetName(), Address: data.GetAddress(), + Address6: data.GetAddress6(), AccessKey: data.GetAccesskey(), Endpoint: data.GetEndpoint(), PersistentKeepalive: data.GetKeepalive(), @@ -132,10 +136,12 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo Localaddress: node.LocalAddress, Name: node.Name, Address: node.Address, + Address6: node.Address6, Endpoint: node.Endpoint, Password: node.Password, Interface: node.Interface, Nodenetwork: node.Network, + Dnsoff: servercfg.IsDNSMode(), Ispending: node.IsPending, Publickey: node.PublicKey, Listenport: node.ListenPort, @@ -162,6 +168,7 @@ func (s *NodeServiceServer) CheckIn(ctx context.Context, req *nodepb.CheckInReq) // ID: primitive.NilObjectID, MacAddress: data.GetMacaddress(), Address: data.GetAddress(), + Address6: data.GetAddress6(), Endpoint: data.GetEndpoint(), Network: data.GetNodenetwork(), Password: data.GetPassword(), @@ -207,6 +214,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo MacAddress: data.GetMacaddress(), Name: data.GetName(), Address: data.GetAddress(), + Address6: data.GetAddress6(), LocalAddress: data.GetLocaladdress(), Endpoint: data.GetEndpoint(), Password: data.GetPassword(), @@ -255,6 +263,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo Localaddress: newnode.LocalAddress, Name: newnode.Name, Address: newnode.Address, + Address6: newnode.Address6, Endpoint: newnode.Endpoint, Password: newnode.Password, Interface: newnode.Interface, @@ -263,6 +272,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo Nodenetwork: newnode.Network, Ispending: newnode.IsPending, Publickey: newnode.PublicKey, + Dnsoff: servercfg.IsDNSMode(), Listenport: newnode.ListenPort, Keepalive: newnode.PersistentKeepalive, Islocal: *network.IsLocal, @@ -316,6 +326,7 @@ func (s *NodeServiceServer) GetPeers(req *nodepb.GetPeersReq, stream nodepb.Node stream.Send(&nodepb.GetPeersRes{ Peers: &nodepb.PeersResponse{ Address: peers[i].Address, + Address6: peers[i].Address6, Endpoint: peers[i].Endpoint, Gatewayrange: peers[i].GatewayRange, Isgateway: peers[i].IsGateway, diff --git a/docker-compose.nodns.yml b/docker-compose.nodns.yml new file mode 100644 index 00000000..cddc195e --- /dev/null +++ b/docker-compose.nodns.yml @@ -0,0 +1,66 @@ +version: "3.4" + +volumes: + dnsconfig: + driver: local +services: + mongodb: + image: mongo:4.2 + ports: + - "27017:27017" + container_name: mongodb + volumes: + - mongovol:/data/db + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: mongoadmin + MONGO_INITDB_ROOT_PASSWORD: mongopass + netmaker: + privileged: true + container_name: netmaker + build: netmaker + depends_on: + - mongodb + image: gravitl/netmaker:v0.3 + ports: + - "8081:8081" + - "50051:50051" + volumes: + - ./:/local + - /etc/netclient:/etc/netclient + - dnsconfig:/root/config/dnsconfig + - /usr/bin/wg:/usr/bin/wg:ro + - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket + - /run/systemd/system:/run/systemd/system + - /etc/systemd/system:/etc/systemd/system + - /sys/fs/cgroup:/sys/fs/cgroup + cap_add: + - NET_ADMIN + - SYS_MODULE + restart: always + network_mode: host + netmaker-ui: + container_name: netmaker-ui + depends_on: + - netmaker + image: gravitl/netmaker-ui:v0.3 + links: + - "netmaker:api" + ports: + - "80:80" + environment: + BACKEND_URL: "http://3.236.149.180:8081" + coredns: + depends_on: + - netmaker + image: coredns/coredns + command: -conf /root/dnsconfig/Corefile + container_name: coredns + restart: always + ports: + - "53:53/udp" + volumes: + - dnsconfig:/root/dnsconfig +volumes: + mongovol: {} + dnsconfig: {} diff --git a/docker-compose.yml b/docker-compose.yml index bbe39e3b..cddc195e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,8 +34,6 @@ services: - /run/systemd/system:/run/systemd/system - /etc/systemd/system:/etc/systemd/system - /sys/fs/cgroup:/sys/fs/cgroup - environment: - MONGO_HOST: "127.0.0.1" cap_add: - NET_ADMIN - SYS_MODULE diff --git a/go.mod b/go.mod index ca20babe..93304178 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200609130330-bd2cb7843e1b google.golang.org/genproto v0.0.0-20210201151548-94839c025ad4 // indirect google.golang.org/grpc v1.35.0 + google.golang.org/protobuf v1.25.0 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c diff --git a/grpc/node.pb.go b/grpc/node.pb.go index 8a365e82..9291876d 100644 --- a/grpc/node.pb.go +++ b/grpc/node.pb.go @@ -1,1104 +1,1647 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 // source: grpc/node.proto package nodepb import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type LoginRequest struct { - Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - Network string `protobuf:"bytes,3,opt,name=network,proto3" json:"network,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + Network string `protobuf:"bytes,3,opt,name=network,proto3" json:"network,omitempty"` } -func (m *LoginRequest) Reset() { *m = LoginRequest{} } -func (m *LoginRequest) String() string { return proto.CompactTextString(m) } -func (*LoginRequest) ProtoMessage() {} +func (x *LoginRequest) Reset() { + *x = LoginRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest) ProtoMessage() {} + +func (x *LoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{0} + return file_grpc_node_proto_rawDescGZIP(), []int{0} } -func (m *LoginRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LoginRequest.Unmarshal(m, b) -} -func (m *LoginRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LoginRequest.Marshal(b, m, deterministic) -} -func (m *LoginRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_LoginRequest.Merge(m, src) -} -func (m *LoginRequest) XXX_Size() int { - return xxx_messageInfo_LoginRequest.Size(m) -} -func (m *LoginRequest) XXX_DiscardUnknown() { - xxx_messageInfo_LoginRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_LoginRequest proto.InternalMessageInfo - -func (m *LoginRequest) GetMacaddress() string { - if m != nil { - return m.Macaddress +func (x *LoginRequest) GetMacaddress() string { + if x != nil { + return x.Macaddress } return "" } -func (m *LoginRequest) GetPassword() string { - if m != nil { - return m.Password +func (x *LoginRequest) GetPassword() string { + if x != nil { + return x.Password } return "" } -func (m *LoginRequest) GetNetwork() string { - if m != nil { - return m.Network +func (x *LoginRequest) GetNetwork() string { + if x != nil { + return x.Network } return "" } type LoginResponse struct { - Accesstoken string `protobuf:"bytes,1,opt,name=accesstoken,proto3" json:"accesstoken,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Accesstoken string `protobuf:"bytes,1,opt,name=accesstoken,proto3" json:"accesstoken,omitempty"` } -func (m *LoginResponse) Reset() { *m = LoginResponse{} } -func (m *LoginResponse) String() string { return proto.CompactTextString(m) } -func (*LoginResponse) ProtoMessage() {} +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{1} + return file_grpc_node_proto_rawDescGZIP(), []int{1} } -func (m *LoginResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LoginResponse.Unmarshal(m, b) -} -func (m *LoginResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LoginResponse.Marshal(b, m, deterministic) -} -func (m *LoginResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_LoginResponse.Merge(m, src) -} -func (m *LoginResponse) XXX_Size() int { - return xxx_messageInfo_LoginResponse.Size(m) -} -func (m *LoginResponse) XXX_DiscardUnknown() { - xxx_messageInfo_LoginResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_LoginResponse proto.InternalMessageInfo - -func (m *LoginResponse) GetAccesstoken() string { - if m != nil { - return m.Accesstoken +func (x *LoginResponse) GetAccesstoken() string { + if x != nil { + return x.Accesstoken } return "" } type Node struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` - Listenport int32 `protobuf:"varint,4,opt,name=listenport,proto3" json:"listenport,omitempty"` - Publickey string `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"` - Endpoint string `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - Macaddress string `protobuf:"bytes,7,opt,name=macaddress,proto3" json:"macaddress,omitempty"` - Password string `protobuf:"bytes,8,opt,name=password,proto3" json:"password,omitempty"` - Nodenetwork string `protobuf:"bytes,9,opt,name=nodenetwork,proto3" json:"nodenetwork,omitempty"` - Ispending bool `protobuf:"varint,10,opt,name=ispending,proto3" json:"ispending,omitempty"` - Postup string `protobuf:"bytes,11,opt,name=postup,proto3" json:"postup,omitempty"` - Postdown string `protobuf:"bytes,12,opt,name=postdown,proto3" json:"postdown,omitempty"` - Keepalive int32 `protobuf:"varint,13,opt,name=keepalive,proto3" json:"keepalive,omitempty"` - Saveconfig bool `protobuf:"varint,14,opt,name=saveconfig,proto3" json:"saveconfig,omitempty"` - Accesskey string `protobuf:"bytes,15,opt,name=accesskey,proto3" json:"accesskey,omitempty"` - Interface string `protobuf:"bytes,16,opt,name=interface,proto3" json:"interface,omitempty"` - Lastcheckin string `protobuf:"bytes,17,opt,name=lastcheckin,proto3" json:"lastcheckin,omitempty"` - Lastmodified string `protobuf:"bytes,18,opt,name=lastmodified,proto3" json:"lastmodified,omitempty"` - Checkininterval int32 `protobuf:"varint,19,opt,name=checkininterval,proto3" json:"checkininterval,omitempty"` - Localaddress string `protobuf:"bytes,20,opt,name=localaddress,proto3" json:"localaddress,omitempty"` - Postchanges string `protobuf:"bytes,21,opt,name=postchanges,proto3" json:"postchanges,omitempty"` - Allowedips string `protobuf:"bytes,22,opt,name=allowedips,proto3" json:"allowedips,omitempty"` - Islocal bool `protobuf:"varint,23,opt,name=islocal,proto3" json:"islocal,omitempty"` - Dnsoff bool `protobuf:"varint,24,opt,name=dnsoff,proto3" json:"dnsoff,omitempty"` - Localrange string `protobuf:"bytes,25,opt,name=localrange,proto3" json:"localrange,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` + Address6 string `protobuf:"bytes,26,opt,name=address6,proto3" json:"address6,omitempty"` + Listenport int32 `protobuf:"varint,4,opt,name=listenport,proto3" json:"listenport,omitempty"` + Publickey string `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"` + Endpoint string `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Macaddress string `protobuf:"bytes,7,opt,name=macaddress,proto3" json:"macaddress,omitempty"` + Password string `protobuf:"bytes,8,opt,name=password,proto3" json:"password,omitempty"` + Nodenetwork string `protobuf:"bytes,9,opt,name=nodenetwork,proto3" json:"nodenetwork,omitempty"` + Ispending bool `protobuf:"varint,10,opt,name=ispending,proto3" json:"ispending,omitempty"` + Postup string `protobuf:"bytes,11,opt,name=postup,proto3" json:"postup,omitempty"` + Postdown string `protobuf:"bytes,12,opt,name=postdown,proto3" json:"postdown,omitempty"` + Keepalive int32 `protobuf:"varint,13,opt,name=keepalive,proto3" json:"keepalive,omitempty"` + Saveconfig bool `protobuf:"varint,14,opt,name=saveconfig,proto3" json:"saveconfig,omitempty"` + Accesskey string `protobuf:"bytes,15,opt,name=accesskey,proto3" json:"accesskey,omitempty"` + Interface string `protobuf:"bytes,16,opt,name=interface,proto3" json:"interface,omitempty"` + Lastcheckin string `protobuf:"bytes,17,opt,name=lastcheckin,proto3" json:"lastcheckin,omitempty"` + Lastmodified string `protobuf:"bytes,18,opt,name=lastmodified,proto3" json:"lastmodified,omitempty"` + Checkininterval int32 `protobuf:"varint,19,opt,name=checkininterval,proto3" json:"checkininterval,omitempty"` + Localaddress string `protobuf:"bytes,20,opt,name=localaddress,proto3" json:"localaddress,omitempty"` + Postchanges string `protobuf:"bytes,21,opt,name=postchanges,proto3" json:"postchanges,omitempty"` + Allowedips string `protobuf:"bytes,22,opt,name=allowedips,proto3" json:"allowedips,omitempty"` + Islocal bool `protobuf:"varint,23,opt,name=islocal,proto3" json:"islocal,omitempty"` + Isdualstack bool `protobuf:"varint,27,opt,name=isdualstack,proto3" json:"isdualstack,omitempty"` + Dnsoff bool `protobuf:"varint,24,opt,name=dnsoff,proto3" json:"dnsoff,omitempty"` + Localrange string `protobuf:"bytes,25,opt,name=localrange,proto3" json:"localrange,omitempty"` } -func (m *Node) Reset() { *m = Node{} } -func (m *Node) String() string { return proto.CompactTextString(m) } -func (*Node) ProtoMessage() {} +func (x *Node) Reset() { + *x = Node{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Node) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Node) ProtoMessage() {} + +func (x *Node) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Node.ProtoReflect.Descriptor instead. func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{2} + return file_grpc_node_proto_rawDescGZIP(), []int{2} } -func (m *Node) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Node.Unmarshal(m, b) -} -func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Node.Marshal(b, m, deterministic) -} -func (m *Node) XXX_Merge(src proto.Message) { - xxx_messageInfo_Node.Merge(m, src) -} -func (m *Node) XXX_Size() int { - return xxx_messageInfo_Node.Size(m) -} -func (m *Node) XXX_DiscardUnknown() { - xxx_messageInfo_Node.DiscardUnknown(m) -} - -var xxx_messageInfo_Node proto.InternalMessageInfo - -func (m *Node) GetId() string { - if m != nil { - return m.Id +func (x *Node) GetId() string { + if x != nil { + return x.Id } return "" } -func (m *Node) GetName() string { - if m != nil { - return m.Name +func (x *Node) GetName() string { + if x != nil { + return x.Name } return "" } -func (m *Node) GetAddress() string { - if m != nil { - return m.Address +func (x *Node) GetAddress() string { + if x != nil { + return x.Address } return "" } -func (m *Node) GetListenport() int32 { - if m != nil { - return m.Listenport +func (x *Node) GetAddress6() string { + if x != nil { + return x.Address6 + } + return "" +} + +func (x *Node) GetListenport() int32 { + if x != nil { + return x.Listenport } return 0 } -func (m *Node) GetPublickey() string { - if m != nil { - return m.Publickey +func (x *Node) GetPublickey() string { + if x != nil { + return x.Publickey } return "" } -func (m *Node) GetEndpoint() string { - if m != nil { - return m.Endpoint +func (x *Node) GetEndpoint() string { + if x != nil { + return x.Endpoint } return "" } -func (m *Node) GetMacaddress() string { - if m != nil { - return m.Macaddress +func (x *Node) GetMacaddress() string { + if x != nil { + return x.Macaddress } return "" } -func (m *Node) GetPassword() string { - if m != nil { - return m.Password +func (x *Node) GetPassword() string { + if x != nil { + return x.Password } return "" } -func (m *Node) GetNodenetwork() string { - if m != nil { - return m.Nodenetwork +func (x *Node) GetNodenetwork() string { + if x != nil { + return x.Nodenetwork } return "" } -func (m *Node) GetIspending() bool { - if m != nil { - return m.Ispending +func (x *Node) GetIspending() bool { + if x != nil { + return x.Ispending } return false } -func (m *Node) GetPostup() string { - if m != nil { - return m.Postup +func (x *Node) GetPostup() string { + if x != nil { + return x.Postup } return "" } -func (m *Node) GetPostdown() string { - if m != nil { - return m.Postdown +func (x *Node) GetPostdown() string { + if x != nil { + return x.Postdown } return "" } -func (m *Node) GetKeepalive() int32 { - if m != nil { - return m.Keepalive +func (x *Node) GetKeepalive() int32 { + if x != nil { + return x.Keepalive } return 0 } -func (m *Node) GetSaveconfig() bool { - if m != nil { - return m.Saveconfig +func (x *Node) GetSaveconfig() bool { + if x != nil { + return x.Saveconfig } return false } -func (m *Node) GetAccesskey() string { - if m != nil { - return m.Accesskey +func (x *Node) GetAccesskey() string { + if x != nil { + return x.Accesskey } return "" } -func (m *Node) GetInterface() string { - if m != nil { - return m.Interface +func (x *Node) GetInterface() string { + if x != nil { + return x.Interface } return "" } -func (m *Node) GetLastcheckin() string { - if m != nil { - return m.Lastcheckin +func (x *Node) GetLastcheckin() string { + if x != nil { + return x.Lastcheckin } return "" } -func (m *Node) GetLastmodified() string { - if m != nil { - return m.Lastmodified +func (x *Node) GetLastmodified() string { + if x != nil { + return x.Lastmodified } return "" } -func (m *Node) GetCheckininterval() int32 { - if m != nil { - return m.Checkininterval +func (x *Node) GetCheckininterval() int32 { + if x != nil { + return x.Checkininterval } return 0 } -func (m *Node) GetLocaladdress() string { - if m != nil { - return m.Localaddress +func (x *Node) GetLocaladdress() string { + if x != nil { + return x.Localaddress } return "" } -func (m *Node) GetPostchanges() string { - if m != nil { - return m.Postchanges +func (x *Node) GetPostchanges() string { + if x != nil { + return x.Postchanges } return "" } -func (m *Node) GetAllowedips() string { - if m != nil { - return m.Allowedips +func (x *Node) GetAllowedips() string { + if x != nil { + return x.Allowedips } return "" } -func (m *Node) GetIslocal() bool { - if m != nil { - return m.Islocal +func (x *Node) GetIslocal() bool { + if x != nil { + return x.Islocal } return false } -func (m *Node) GetDnsoff() bool { - if m != nil { - return m.Dnsoff +func (x *Node) GetIsdualstack() bool { + if x != nil { + return x.Isdualstack } return false } -func (m *Node) GetLocalrange() string { - if m != nil { - return m.Localrange +func (x *Node) GetDnsoff() bool { + if x != nil { + return x.Dnsoff + } + return false +} + +func (x *Node) GetLocalrange() string { + if x != nil { + return x.Localrange } return "" } type CheckInResponse struct { - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Needpeerupdate bool `protobuf:"varint,2,opt,name=needpeerupdate,proto3" json:"needpeerupdate,omitempty"` - Needconfigupdate bool `protobuf:"varint,3,opt,name=needconfigupdate,proto3" json:"needconfigupdate,omitempty"` - Nodemessage string `protobuf:"bytes,4,opt,name=nodemessage,proto3" json:"nodemessage,omitempty"` - Ispending bool `protobuf:"varint,5,opt,name=ispending,proto3" json:"ispending,omitempty"` - Needkeyupdate bool `protobuf:"varint,6,opt,name=needkeyupdate,proto3" json:"needkeyupdate,omitempty"` - Needdelete bool `protobuf:"varint,7,opt,name=needdelete,proto3" json:"needdelete,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Needpeerupdate bool `protobuf:"varint,2,opt,name=needpeerupdate,proto3" json:"needpeerupdate,omitempty"` + Needconfigupdate bool `protobuf:"varint,3,opt,name=needconfigupdate,proto3" json:"needconfigupdate,omitempty"` + Nodemessage string `protobuf:"bytes,4,opt,name=nodemessage,proto3" json:"nodemessage,omitempty"` + Ispending bool `protobuf:"varint,5,opt,name=ispending,proto3" json:"ispending,omitempty"` + Needkeyupdate bool `protobuf:"varint,6,opt,name=needkeyupdate,proto3" json:"needkeyupdate,omitempty"` + Needdelete bool `protobuf:"varint,7,opt,name=needdelete,proto3" json:"needdelete,omitempty"` } -func (m *CheckInResponse) Reset() { *m = CheckInResponse{} } -func (m *CheckInResponse) String() string { return proto.CompactTextString(m) } -func (*CheckInResponse) ProtoMessage() {} +func (x *CheckInResponse) Reset() { + *x = CheckInResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckInResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckInResponse) ProtoMessage() {} + +func (x *CheckInResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckInResponse.ProtoReflect.Descriptor instead. func (*CheckInResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{3} + return file_grpc_node_proto_rawDescGZIP(), []int{3} } -func (m *CheckInResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CheckInResponse.Unmarshal(m, b) -} -func (m *CheckInResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CheckInResponse.Marshal(b, m, deterministic) -} -func (m *CheckInResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CheckInResponse.Merge(m, src) -} -func (m *CheckInResponse) XXX_Size() int { - return xxx_messageInfo_CheckInResponse.Size(m) -} -func (m *CheckInResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CheckInResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CheckInResponse proto.InternalMessageInfo - -func (m *CheckInResponse) GetSuccess() bool { - if m != nil { - return m.Success +func (x *CheckInResponse) GetSuccess() bool { + if x != nil { + return x.Success } return false } -func (m *CheckInResponse) GetNeedpeerupdate() bool { - if m != nil { - return m.Needpeerupdate +func (x *CheckInResponse) GetNeedpeerupdate() bool { + if x != nil { + return x.Needpeerupdate } return false } -func (m *CheckInResponse) GetNeedconfigupdate() bool { - if m != nil { - return m.Needconfigupdate +func (x *CheckInResponse) GetNeedconfigupdate() bool { + if x != nil { + return x.Needconfigupdate } return false } -func (m *CheckInResponse) GetNodemessage() string { - if m != nil { - return m.Nodemessage +func (x *CheckInResponse) GetNodemessage() string { + if x != nil { + return x.Nodemessage } return "" } -func (m *CheckInResponse) GetIspending() bool { - if m != nil { - return m.Ispending +func (x *CheckInResponse) GetIspending() bool { + if x != nil { + return x.Ispending } return false } -func (m *CheckInResponse) GetNeedkeyupdate() bool { - if m != nil { - return m.Needkeyupdate +func (x *CheckInResponse) GetNeedkeyupdate() bool { + if x != nil { + return x.Needkeyupdate } return false } -func (m *CheckInResponse) GetNeeddelete() bool { - if m != nil { - return m.Needdelete +func (x *CheckInResponse) GetNeeddelete() bool { + if x != nil { + return x.Needdelete } return false } type PeersResponse struct { - Isgateway bool `protobuf:"varint,1,opt,name=isgateway,proto3" json:"isgateway,omitempty"` - Gatewayrange string `protobuf:"bytes,2,opt,name=gatewayrange,proto3" json:"gatewayrange,omitempty"` - Publickey string `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"` - Endpoint string `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` - Listenport int32 `protobuf:"varint,4,opt,name=listenport,proto3" json:"listenport,omitempty"` - Localaddress string `protobuf:"bytes,7,opt,name=localaddress,proto3" json:"localaddress,omitempty"` - Keepalive int32 `protobuf:"varint,13,opt,name=keepalive,proto3" json:"keepalive,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Isgateway bool `protobuf:"varint,1,opt,name=isgateway,proto3" json:"isgateway,omitempty"` + Gatewayrange string `protobuf:"bytes,2,opt,name=gatewayrange,proto3" json:"gatewayrange,omitempty"` + Publickey string `protobuf:"bytes,5,opt,name=publickey,proto3" json:"publickey,omitempty"` + Endpoint string `protobuf:"bytes,6,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` + Address6 string `protobuf:"bytes,8,opt,name=address6,proto3" json:"address6,omitempty"` + Listenport int32 `protobuf:"varint,4,opt,name=listenport,proto3" json:"listenport,omitempty"` + Localaddress string `protobuf:"bytes,7,opt,name=localaddress,proto3" json:"localaddress,omitempty"` + Keepalive int32 `protobuf:"varint,13,opt,name=keepalive,proto3" json:"keepalive,omitempty"` } -func (m *PeersResponse) Reset() { *m = PeersResponse{} } -func (m *PeersResponse) String() string { return proto.CompactTextString(m) } -func (*PeersResponse) ProtoMessage() {} +func (x *PeersResponse) Reset() { + *x = PeersResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeersResponse) ProtoMessage() {} + +func (x *PeersResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PeersResponse.ProtoReflect.Descriptor instead. func (*PeersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{4} + return file_grpc_node_proto_rawDescGZIP(), []int{4} } -func (m *PeersResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PeersResponse.Unmarshal(m, b) -} -func (m *PeersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PeersResponse.Marshal(b, m, deterministic) -} -func (m *PeersResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PeersResponse.Merge(m, src) -} -func (m *PeersResponse) XXX_Size() int { - return xxx_messageInfo_PeersResponse.Size(m) -} -func (m *PeersResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PeersResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_PeersResponse proto.InternalMessageInfo - -func (m *PeersResponse) GetIsgateway() bool { - if m != nil { - return m.Isgateway +func (x *PeersResponse) GetIsgateway() bool { + if x != nil { + return x.Isgateway } return false } -func (m *PeersResponse) GetGatewayrange() string { - if m != nil { - return m.Gatewayrange +func (x *PeersResponse) GetGatewayrange() string { + if x != nil { + return x.Gatewayrange } return "" } -func (m *PeersResponse) GetPublickey() string { - if m != nil { - return m.Publickey +func (x *PeersResponse) GetPublickey() string { + if x != nil { + return x.Publickey } return "" } -func (m *PeersResponse) GetEndpoint() string { - if m != nil { - return m.Endpoint +func (x *PeersResponse) GetEndpoint() string { + if x != nil { + return x.Endpoint } return "" } -func (m *PeersResponse) GetAddress() string { - if m != nil { - return m.Address +func (x *PeersResponse) GetAddress() string { + if x != nil { + return x.Address } return "" } -func (m *PeersResponse) GetListenport() int32 { - if m != nil { - return m.Listenport +func (x *PeersResponse) GetAddress6() string { + if x != nil { + return x.Address6 + } + return "" +} + +func (x *PeersResponse) GetListenport() int32 { + if x != nil { + return x.Listenport } return 0 } -func (m *PeersResponse) GetLocaladdress() string { - if m != nil { - return m.Localaddress +func (x *PeersResponse) GetLocaladdress() string { + if x != nil { + return x.Localaddress } return "" } -func (m *PeersResponse) GetKeepalive() int32 { - if m != nil { - return m.Keepalive +func (x *PeersResponse) GetKeepalive() int32 { + if x != nil { + return x.Keepalive } return 0 } type CreateNodeReq struct { - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` // Node id blank } -func (m *CreateNodeReq) Reset() { *m = CreateNodeReq{} } -func (m *CreateNodeReq) String() string { return proto.CompactTextString(m) } -func (*CreateNodeReq) ProtoMessage() {} +func (x *CreateNodeReq) Reset() { + *x = CreateNodeReq{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateNodeReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateNodeReq) ProtoMessage() {} + +func (x *CreateNodeReq) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateNodeReq.ProtoReflect.Descriptor instead. func (*CreateNodeReq) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{5} + return file_grpc_node_proto_rawDescGZIP(), []int{5} } -func (m *CreateNodeReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateNodeReq.Unmarshal(m, b) -} -func (m *CreateNodeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateNodeReq.Marshal(b, m, deterministic) -} -func (m *CreateNodeReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateNodeReq.Merge(m, src) -} -func (m *CreateNodeReq) XXX_Size() int { - return xxx_messageInfo_CreateNodeReq.Size(m) -} -func (m *CreateNodeReq) XXX_DiscardUnknown() { - xxx_messageInfo_CreateNodeReq.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateNodeReq proto.InternalMessageInfo - -func (m *CreateNodeReq) GetNode() *Node { - if m != nil { - return m.Node +func (x *CreateNodeReq) GetNode() *Node { + if x != nil { + return x.Node } return nil } type CreateNodeRes struct { - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` // Node id filled in } -func (m *CreateNodeRes) Reset() { *m = CreateNodeRes{} } -func (m *CreateNodeRes) String() string { return proto.CompactTextString(m) } -func (*CreateNodeRes) ProtoMessage() {} +func (x *CreateNodeRes) Reset() { + *x = CreateNodeRes{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateNodeRes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateNodeRes) ProtoMessage() {} + +func (x *CreateNodeRes) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateNodeRes.ProtoReflect.Descriptor instead. func (*CreateNodeRes) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{6} + return file_grpc_node_proto_rawDescGZIP(), []int{6} } -func (m *CreateNodeRes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateNodeRes.Unmarshal(m, b) -} -func (m *CreateNodeRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateNodeRes.Marshal(b, m, deterministic) -} -func (m *CreateNodeRes) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateNodeRes.Merge(m, src) -} -func (m *CreateNodeRes) XXX_Size() int { - return xxx_messageInfo_CreateNodeRes.Size(m) -} -func (m *CreateNodeRes) XXX_DiscardUnknown() { - xxx_messageInfo_CreateNodeRes.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateNodeRes proto.InternalMessageInfo - -func (m *CreateNodeRes) GetNode() *Node { - if m != nil { - return m.Node +func (x *CreateNodeRes) GetNode() *Node { + if x != nil { + return x.Node } return nil } type UpdateNodeReq struct { - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` } -func (m *UpdateNodeReq) Reset() { *m = UpdateNodeReq{} } -func (m *UpdateNodeReq) String() string { return proto.CompactTextString(m) } -func (*UpdateNodeReq) ProtoMessage() {} +func (x *UpdateNodeReq) Reset() { + *x = UpdateNodeReq{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateNodeReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateNodeReq) ProtoMessage() {} + +func (x *UpdateNodeReq) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateNodeReq.ProtoReflect.Descriptor instead. func (*UpdateNodeReq) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{7} + return file_grpc_node_proto_rawDescGZIP(), []int{7} } -func (m *UpdateNodeReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateNodeReq.Unmarshal(m, b) -} -func (m *UpdateNodeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateNodeReq.Marshal(b, m, deterministic) -} -func (m *UpdateNodeReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateNodeReq.Merge(m, src) -} -func (m *UpdateNodeReq) XXX_Size() int { - return xxx_messageInfo_UpdateNodeReq.Size(m) -} -func (m *UpdateNodeReq) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateNodeReq.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateNodeReq proto.InternalMessageInfo - -func (m *UpdateNodeReq) GetNode() *Node { - if m != nil { - return m.Node +func (x *UpdateNodeReq) GetNode() *Node { + if x != nil { + return x.Node } return nil } type UpdateNodeRes struct { - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` } -func (m *UpdateNodeRes) Reset() { *m = UpdateNodeRes{} } -func (m *UpdateNodeRes) String() string { return proto.CompactTextString(m) } -func (*UpdateNodeRes) ProtoMessage() {} +func (x *UpdateNodeRes) Reset() { + *x = UpdateNodeRes{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateNodeRes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateNodeRes) ProtoMessage() {} + +func (x *UpdateNodeRes) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateNodeRes.ProtoReflect.Descriptor instead. func (*UpdateNodeRes) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{8} + return file_grpc_node_proto_rawDescGZIP(), []int{8} } -func (m *UpdateNodeRes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateNodeRes.Unmarshal(m, b) -} -func (m *UpdateNodeRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateNodeRes.Marshal(b, m, deterministic) -} -func (m *UpdateNodeRes) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateNodeRes.Merge(m, src) -} -func (m *UpdateNodeRes) XXX_Size() int { - return xxx_messageInfo_UpdateNodeRes.Size(m) -} -func (m *UpdateNodeRes) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateNodeRes.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateNodeRes proto.InternalMessageInfo - -func (m *UpdateNodeRes) GetNode() *Node { - if m != nil { - return m.Node +func (x *UpdateNodeRes) GetNode() *Node { + if x != nil { + return x.Node } return nil } type ReadNodeReq struct { - Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` - Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` + Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` } -func (m *ReadNodeReq) Reset() { *m = ReadNodeReq{} } -func (m *ReadNodeReq) String() string { return proto.CompactTextString(m) } -func (*ReadNodeReq) ProtoMessage() {} +func (x *ReadNodeReq) Reset() { + *x = ReadNodeReq{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadNodeReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadNodeReq) ProtoMessage() {} + +func (x *ReadNodeReq) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadNodeReq.ProtoReflect.Descriptor instead. func (*ReadNodeReq) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{9} + return file_grpc_node_proto_rawDescGZIP(), []int{9} } -func (m *ReadNodeReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadNodeReq.Unmarshal(m, b) -} -func (m *ReadNodeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadNodeReq.Marshal(b, m, deterministic) -} -func (m *ReadNodeReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadNodeReq.Merge(m, src) -} -func (m *ReadNodeReq) XXX_Size() int { - return xxx_messageInfo_ReadNodeReq.Size(m) -} -func (m *ReadNodeReq) XXX_DiscardUnknown() { - xxx_messageInfo_ReadNodeReq.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadNodeReq proto.InternalMessageInfo - -func (m *ReadNodeReq) GetMacaddress() string { - if m != nil { - return m.Macaddress +func (x *ReadNodeReq) GetMacaddress() string { + if x != nil { + return x.Macaddress } return "" } -func (m *ReadNodeReq) GetNetwork() string { - if m != nil { - return m.Network +func (x *ReadNodeReq) GetNetwork() string { + if x != nil { + return x.Network } return "" } type ReadNodeRes struct { - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` } -func (m *ReadNodeRes) Reset() { *m = ReadNodeRes{} } -func (m *ReadNodeRes) String() string { return proto.CompactTextString(m) } -func (*ReadNodeRes) ProtoMessage() {} +func (x *ReadNodeRes) Reset() { + *x = ReadNodeRes{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadNodeRes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadNodeRes) ProtoMessage() {} + +func (x *ReadNodeRes) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadNodeRes.ProtoReflect.Descriptor instead. func (*ReadNodeRes) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{10} + return file_grpc_node_proto_rawDescGZIP(), []int{10} } -func (m *ReadNodeRes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadNodeRes.Unmarshal(m, b) -} -func (m *ReadNodeRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadNodeRes.Marshal(b, m, deterministic) -} -func (m *ReadNodeRes) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadNodeRes.Merge(m, src) -} -func (m *ReadNodeRes) XXX_Size() int { - return xxx_messageInfo_ReadNodeRes.Size(m) -} -func (m *ReadNodeRes) XXX_DiscardUnknown() { - xxx_messageInfo_ReadNodeRes.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadNodeRes proto.InternalMessageInfo - -func (m *ReadNodeRes) GetNode() *Node { - if m != nil { - return m.Node +func (x *ReadNodeRes) GetNode() *Node { + if x != nil { + return x.Node } return nil } type DeleteNodeReq struct { - Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` - NetworkName string `protobuf:"bytes,2,opt,name=networkName,proto3" json:"networkName,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` + NetworkName string `protobuf:"bytes,2,opt,name=networkName,proto3" json:"networkName,omitempty"` } -func (m *DeleteNodeReq) Reset() { *m = DeleteNodeReq{} } -func (m *DeleteNodeReq) String() string { return proto.CompactTextString(m) } -func (*DeleteNodeReq) ProtoMessage() {} +func (x *DeleteNodeReq) Reset() { + *x = DeleteNodeReq{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteNodeReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteNodeReq) ProtoMessage() {} + +func (x *DeleteNodeReq) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteNodeReq.ProtoReflect.Descriptor instead. func (*DeleteNodeReq) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{11} + return file_grpc_node_proto_rawDescGZIP(), []int{11} } -func (m *DeleteNodeReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteNodeReq.Unmarshal(m, b) -} -func (m *DeleteNodeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteNodeReq.Marshal(b, m, deterministic) -} -func (m *DeleteNodeReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteNodeReq.Merge(m, src) -} -func (m *DeleteNodeReq) XXX_Size() int { - return xxx_messageInfo_DeleteNodeReq.Size(m) -} -func (m *DeleteNodeReq) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteNodeReq.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteNodeReq proto.InternalMessageInfo - -func (m *DeleteNodeReq) GetMacaddress() string { - if m != nil { - return m.Macaddress +func (x *DeleteNodeReq) GetMacaddress() string { + if x != nil { + return x.Macaddress } return "" } -func (m *DeleteNodeReq) GetNetworkName() string { - if m != nil { - return m.NetworkName +func (x *DeleteNodeReq) GetNetworkName() string { + if x != nil { + return x.NetworkName } return "" } type DeleteNodeRes struct { - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` } -func (m *DeleteNodeRes) Reset() { *m = DeleteNodeRes{} } -func (m *DeleteNodeRes) String() string { return proto.CompactTextString(m) } -func (*DeleteNodeRes) ProtoMessage() {} +func (x *DeleteNodeRes) Reset() { + *x = DeleteNodeRes{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteNodeRes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteNodeRes) ProtoMessage() {} + +func (x *DeleteNodeRes) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteNodeRes.ProtoReflect.Descriptor instead. func (*DeleteNodeRes) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{12} + return file_grpc_node_proto_rawDescGZIP(), []int{12} } -func (m *DeleteNodeRes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteNodeRes.Unmarshal(m, b) -} -func (m *DeleteNodeRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteNodeRes.Marshal(b, m, deterministic) -} -func (m *DeleteNodeRes) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteNodeRes.Merge(m, src) -} -func (m *DeleteNodeRes) XXX_Size() int { - return xxx_messageInfo_DeleteNodeRes.Size(m) -} -func (m *DeleteNodeRes) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteNodeRes.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteNodeRes proto.InternalMessageInfo - -func (m *DeleteNodeRes) GetSuccess() bool { - if m != nil { - return m.Success +func (x *DeleteNodeRes) GetSuccess() bool { + if x != nil { + return x.Success } return false } type GetPeersReq struct { - Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` - Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Macaddress string `protobuf:"bytes,1,opt,name=macaddress,proto3" json:"macaddress,omitempty"` + Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` } -func (m *GetPeersReq) Reset() { *m = GetPeersReq{} } -func (m *GetPeersReq) String() string { return proto.CompactTextString(m) } -func (*GetPeersReq) ProtoMessage() {} +func (x *GetPeersReq) Reset() { + *x = GetPeersReq{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPeersReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPeersReq) ProtoMessage() {} + +func (x *GetPeersReq) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPeersReq.ProtoReflect.Descriptor instead. func (*GetPeersReq) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{13} + return file_grpc_node_proto_rawDescGZIP(), []int{13} } -func (m *GetPeersReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetPeersReq.Unmarshal(m, b) -} -func (m *GetPeersReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetPeersReq.Marshal(b, m, deterministic) -} -func (m *GetPeersReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetPeersReq.Merge(m, src) -} -func (m *GetPeersReq) XXX_Size() int { - return xxx_messageInfo_GetPeersReq.Size(m) -} -func (m *GetPeersReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetPeersReq.DiscardUnknown(m) -} - -var xxx_messageInfo_GetPeersReq proto.InternalMessageInfo - -func (m *GetPeersReq) GetMacaddress() string { - if m != nil { - return m.Macaddress +func (x *GetPeersReq) GetMacaddress() string { + if x != nil { + return x.Macaddress } return "" } -func (m *GetPeersReq) GetNetwork() string { - if m != nil { - return m.Network +func (x *GetPeersReq) GetNetwork() string { + if x != nil { + return x.Network } return "" } type GetPeersRes struct { - Peers *PeersResponse `protobuf:"bytes,1,opt,name=peers,proto3" json:"peers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Peers *PeersResponse `protobuf:"bytes,1,opt,name=peers,proto3" json:"peers,omitempty"` } -func (m *GetPeersRes) Reset() { *m = GetPeersRes{} } -func (m *GetPeersRes) String() string { return proto.CompactTextString(m) } -func (*GetPeersRes) ProtoMessage() {} +func (x *GetPeersRes) Reset() { + *x = GetPeersRes{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPeersRes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPeersRes) ProtoMessage() {} + +func (x *GetPeersRes) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPeersRes.ProtoReflect.Descriptor instead. func (*GetPeersRes) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{14} + return file_grpc_node_proto_rawDescGZIP(), []int{14} } -func (m *GetPeersRes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetPeersRes.Unmarshal(m, b) -} -func (m *GetPeersRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetPeersRes.Marshal(b, m, deterministic) -} -func (m *GetPeersRes) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetPeersRes.Merge(m, src) -} -func (m *GetPeersRes) XXX_Size() int { - return xxx_messageInfo_GetPeersRes.Size(m) -} -func (m *GetPeersRes) XXX_DiscardUnknown() { - xxx_messageInfo_GetPeersRes.DiscardUnknown(m) -} - -var xxx_messageInfo_GetPeersRes proto.InternalMessageInfo - -func (m *GetPeersRes) GetPeers() *PeersResponse { - if m != nil { - return m.Peers +func (x *GetPeersRes) GetPeers() *PeersResponse { + if x != nil { + return x.Peers } return nil } type CheckInReq struct { - Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Node *Node `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` // bool postchanges = 2; } -func (m *CheckInReq) Reset() { *m = CheckInReq{} } -func (m *CheckInReq) String() string { return proto.CompactTextString(m) } -func (*CheckInReq) ProtoMessage() {} +func (x *CheckInReq) Reset() { + *x = CheckInReq{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckInReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckInReq) ProtoMessage() {} + +func (x *CheckInReq) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckInReq.ProtoReflect.Descriptor instead. func (*CheckInReq) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{15} + return file_grpc_node_proto_rawDescGZIP(), []int{15} } -func (m *CheckInReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CheckInReq.Unmarshal(m, b) -} -func (m *CheckInReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CheckInReq.Marshal(b, m, deterministic) -} -func (m *CheckInReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_CheckInReq.Merge(m, src) -} -func (m *CheckInReq) XXX_Size() int { - return xxx_messageInfo_CheckInReq.Size(m) -} -func (m *CheckInReq) XXX_DiscardUnknown() { - xxx_messageInfo_CheckInReq.DiscardUnknown(m) -} - -var xxx_messageInfo_CheckInReq proto.InternalMessageInfo - -func (m *CheckInReq) GetNode() *Node { - if m != nil { - return m.Node +func (x *CheckInReq) GetNode() *Node { + if x != nil { + return x.Node } return nil } type CheckInRes struct { - Checkinresponse *CheckInResponse `protobuf:"bytes,1,opt,name=checkinresponse,proto3" json:"checkinresponse,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Checkinresponse *CheckInResponse `protobuf:"bytes,1,opt,name=checkinresponse,proto3" json:"checkinresponse,omitempty"` } -func (m *CheckInRes) Reset() { *m = CheckInRes{} } -func (m *CheckInRes) String() string { return proto.CompactTextString(m) } -func (*CheckInRes) ProtoMessage() {} +func (x *CheckInRes) Reset() { + *x = CheckInRes{} + if protoimpl.UnsafeEnabled { + mi := &file_grpc_node_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckInRes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckInRes) ProtoMessage() {} + +func (x *CheckInRes) ProtoReflect() protoreflect.Message { + mi := &file_grpc_node_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckInRes.ProtoReflect.Descriptor instead. func (*CheckInRes) Descriptor() ([]byte, []int) { - return fileDescriptor_d13bd996b67da4ef, []int{16} + return file_grpc_node_proto_rawDescGZIP(), []int{16} } -func (m *CheckInRes) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CheckInRes.Unmarshal(m, b) -} -func (m *CheckInRes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CheckInRes.Marshal(b, m, deterministic) -} -func (m *CheckInRes) XXX_Merge(src proto.Message) { - xxx_messageInfo_CheckInRes.Merge(m, src) -} -func (m *CheckInRes) XXX_Size() int { - return xxx_messageInfo_CheckInRes.Size(m) -} -func (m *CheckInRes) XXX_DiscardUnknown() { - xxx_messageInfo_CheckInRes.DiscardUnknown(m) -} - -var xxx_messageInfo_CheckInRes proto.InternalMessageInfo - -func (m *CheckInRes) GetCheckinresponse() *CheckInResponse { - if m != nil { - return m.Checkinresponse +func (x *CheckInRes) GetCheckinresponse() *CheckInResponse { + if x != nil { + return x.Checkinresponse } return nil } -func init() { - proto.RegisterType((*LoginRequest)(nil), "node.LoginRequest") - proto.RegisterType((*LoginResponse)(nil), "node.LoginResponse") - proto.RegisterType((*Node)(nil), "node.Node") - proto.RegisterType((*CheckInResponse)(nil), "node.CheckInResponse") - proto.RegisterType((*PeersResponse)(nil), "node.PeersResponse") - proto.RegisterType((*CreateNodeReq)(nil), "node.CreateNodeReq") - proto.RegisterType((*CreateNodeRes)(nil), "node.CreateNodeRes") - proto.RegisterType((*UpdateNodeReq)(nil), "node.UpdateNodeReq") - proto.RegisterType((*UpdateNodeRes)(nil), "node.UpdateNodeRes") - proto.RegisterType((*ReadNodeReq)(nil), "node.ReadNodeReq") - proto.RegisterType((*ReadNodeRes)(nil), "node.ReadNodeRes") - proto.RegisterType((*DeleteNodeReq)(nil), "node.DeleteNodeReq") - proto.RegisterType((*DeleteNodeRes)(nil), "node.DeleteNodeRes") - proto.RegisterType((*GetPeersReq)(nil), "node.GetPeersReq") - proto.RegisterType((*GetPeersRes)(nil), "node.GetPeersRes") - proto.RegisterType((*CheckInReq)(nil), "node.CheckInReq") - proto.RegisterType((*CheckInRes)(nil), "node.CheckInRes") +var File_grpc_node_proto protoreflect.FileDescriptor + +var file_grpc_node_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x64, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x61, 0x63, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x31, 0x0a, + 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x22, 0xae, 0x06, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x36, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x36, 0x12, 0x1e, 0x0a, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x70, + 0x6f, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x6b, 0x65, 0x79, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x6b, 0x65, + 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x0a, + 0x0a, 0x6d, 0x61, 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x6d, 0x61, 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, + 0x65, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x6e, 0x6f, 0x64, 0x65, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, + 0x69, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x73, + 0x74, 0x75, 0x70, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6f, 0x73, 0x74, 0x75, + 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x1c, 0x0a, + 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, + 0x61, 0x76, 0x65, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0a, 0x73, 0x61, 0x76, 0x65, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x61, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x6b, 0x65, 0x79, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x63, + 0x68, 0x65, 0x63, 0x6b, 0x69, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, + 0x73, 0x74, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x69, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x61, 0x73, + 0x74, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x28, 0x0a, + 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x69, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, + 0x18, 0x13, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x69, 0x6e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, + 0x6f, 0x63, 0x61, 0x6c, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x70, + 0x6f, 0x73, 0x74, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x70, 0x6f, 0x73, 0x74, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x1e, 0x0a, + 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x69, 0x70, 0x73, 0x18, 0x16, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x69, 0x70, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x69, 0x73, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x18, 0x17, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x69, 0x73, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x73, 0x64, 0x75, 0x61, + 0x6c, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, + 0x64, 0x75, 0x61, 0x6c, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6e, 0x73, + 0x6f, 0x66, 0x66, 0x18, 0x18, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x64, 0x6e, 0x73, 0x6f, 0x66, + 0x66, 0x12, 0x1e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, + 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x72, 0x61, 0x6e, 0x67, + 0x65, 0x22, 0x85, 0x02, 0x0a, 0x0f, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x49, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, + 0x26, 0x0a, 0x0e, 0x6e, 0x65, 0x65, 0x64, 0x70, 0x65, 0x65, 0x72, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6e, 0x65, 0x65, 0x64, 0x70, 0x65, 0x65, + 0x72, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x6e, 0x65, 0x65, 0x64, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x10, 0x6e, 0x65, 0x65, 0x64, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x69, + 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x70, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x65, 0x64, 0x6b, 0x65, 0x79, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x6e, 0x65, 0x65, 0x64, + 0x6b, 0x65, 0x79, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x65, 0x65, + 0x64, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6e, + 0x65, 0x65, 0x64, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x22, 0xa3, 0x02, 0x0a, 0x0d, 0x50, 0x65, + 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x73, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, + 0x69, 0x73, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x61, 0x74, + 0x65, 0x77, 0x61, 0x79, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x6b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x36, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x36, 0x12, 0x1e, 0x0a, + 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0a, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x22, 0x0a, + 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x0d, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x22, + 0x2f, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, + 0x12, 0x1e, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, + 0x22, 0x2f, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, + 0x73, 0x12, 0x1e, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0a, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, + 0x65, 0x22, 0x2f, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0a, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, + 0x64, 0x65, 0x22, 0x2f, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0a, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, + 0x6f, 0x64, 0x65, 0x22, 0x47, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x61, 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x2d, 0x0a, 0x0b, + 0x52, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x04, 0x6e, + 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x51, 0x0a, 0x0d, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, + 0x6d, 0x61, 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x6d, 0x61, 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x29, + 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x47, 0x0a, 0x0b, 0x47, 0x65, 0x74, + 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x61, + 0x63, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x22, 0x38, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, + 0x73, 0x12, 0x29, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, 0x2c, 0x0a, 0x0a, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x04, 0x6e, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, + 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x4d, 0x0a, 0x0a, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x49, 0x6e, 0x52, 0x65, 0x73, 0x12, 0x3f, 0x0a, 0x0f, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x69, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x49, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x69, + 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xfc, 0x02, 0x0a, 0x0b, 0x4e, 0x6f, + 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x4c, 0x6f, 0x67, + 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4c, 0x6f, + 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0a, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x13, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x08, 0x52, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x12, + 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x4e, 0x6f, + 0x64, 0x65, 0x52, 0x65, 0x73, 0x12, 0x36, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, + 0x6f, 0x64, 0x65, 0x12, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x12, 0x36, 0x0a, + 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x13, 0x2e, 0x6e, 0x6f, + 0x64, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, + 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x52, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, + 0x73, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, + 0x73, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, + 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x30, 0x01, 0x12, 0x2d, 0x0a, 0x07, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x49, 0x6e, 0x12, 0x10, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x49, 0x6e, 0x52, 0x65, 0x73, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } -func init() { proto.RegisterFile("grpc/node.proto", fileDescriptor_d13bd996b67da4ef) } +var ( + file_grpc_node_proto_rawDescOnce sync.Once + file_grpc_node_proto_rawDescData = file_grpc_node_proto_rawDesc +) -var fileDescriptor_d13bd996b67da4ef = []byte{ - // 915 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x5f, 0x6f, 0x23, 0x35, - 0x10, 0x57, 0x72, 0x4d, 0x93, 0x4e, 0x9a, 0xb6, 0xe7, 0x72, 0x87, 0x89, 0x50, 0x15, 0xad, 0x10, - 0xea, 0x21, 0xda, 0x94, 0x22, 0x21, 0xde, 0x90, 0x38, 0xa4, 0x13, 0x12, 0x9c, 0x60, 0x11, 0x2f, - 0xbc, 0xb9, 0xeb, 0xc9, 0xde, 0x2a, 0x5b, 0x7b, 0xbb, 0xde, 0x34, 0xea, 0x07, 0x40, 0x7c, 0x5d, - 0x3e, 0x00, 0x0f, 0xc8, 0x63, 0x6f, 0xd6, 0xbb, 0x0d, 0xed, 0x71, 0x7d, 0x5b, 0xff, 0x3c, 0x7f, - 0x3c, 0xbf, 0xf9, 0x8d, 0xd7, 0x70, 0x98, 0x96, 0x45, 0x32, 0x57, 0x5a, 0xe2, 0x79, 0x51, 0xea, - 0x4a, 0xb3, 0x1d, 0xfb, 0x1d, 0x49, 0xd8, 0xff, 0x49, 0xa7, 0x99, 0x8a, 0xf1, 0x66, 0x85, 0xa6, - 0x62, 0x27, 0x00, 0xd7, 0x22, 0x11, 0x52, 0x96, 0x68, 0x0c, 0xef, 0xcd, 0x7a, 0xa7, 0x7b, 0x71, - 0x80, 0xb0, 0x29, 0x8c, 0x0a, 0x61, 0xcc, 0x5a, 0x97, 0x92, 0xf7, 0x69, 0x77, 0xb3, 0x66, 0x1c, - 0x86, 0x0a, 0xab, 0xb5, 0x2e, 0x97, 0xfc, 0x19, 0x6d, 0xd5, 0xcb, 0xe8, 0x2b, 0x98, 0xf8, 0x2c, - 0xa6, 0xd0, 0xca, 0x20, 0x9b, 0xc1, 0x58, 0x24, 0x09, 0x1a, 0x53, 0xe9, 0x25, 0x2a, 0x9f, 0x27, - 0x84, 0xa2, 0xbf, 0x07, 0xb0, 0xf3, 0x56, 0x4b, 0x64, 0x07, 0xd0, 0xcf, 0xa4, 0xb7, 0xe8, 0x67, - 0x92, 0x31, 0xd8, 0x51, 0xe2, 0x1a, 0x7d, 0x76, 0xfa, 0xb6, 0x99, 0xeb, 0x23, 0xfb, 0xcc, 0xf5, - 0x79, 0x4f, 0x00, 0xf2, 0xcc, 0x54, 0xa8, 0x0a, 0x5d, 0x56, 0x7c, 0x67, 0xd6, 0x3b, 0x1d, 0xc4, - 0x01, 0xc2, 0x3e, 0x85, 0xbd, 0x62, 0x75, 0x95, 0x67, 0xc9, 0x12, 0xef, 0xf8, 0x80, 0x7c, 0x1b, - 0xc0, 0x56, 0x8b, 0x4a, 0x16, 0x3a, 0x53, 0x15, 0xdf, 0x75, 0xd5, 0xd6, 0xeb, 0x0e, 0x53, 0xc3, - 0x07, 0x99, 0x1a, 0x75, 0x98, 0x9a, 0xc1, 0xd8, 0xb2, 0x5f, 0xb3, 0xb5, 0xe7, 0xca, 0x0f, 0x20, - 0x7b, 0xae, 0xcc, 0x14, 0xa8, 0x64, 0xa6, 0x52, 0x0e, 0xb3, 0xde, 0xe9, 0x28, 0x6e, 0x00, 0xf6, - 0x12, 0x76, 0x0b, 0x6d, 0xaa, 0x55, 0xc1, 0xc7, 0xe4, 0xea, 0x57, 0x94, 0x53, 0x9b, 0x4a, 0xea, - 0xb5, 0xe2, 0xfb, 0x3e, 0xa7, 0x5f, 0xdb, 0x88, 0x4b, 0xc4, 0x42, 0xe4, 0xd9, 0x2d, 0xf2, 0x09, - 0x11, 0xd1, 0x00, 0xb6, 0x1a, 0x23, 0x6e, 0x31, 0xd1, 0x6a, 0x91, 0xa5, 0xfc, 0x80, 0x12, 0x06, - 0x88, 0xf5, 0x76, 0xdd, 0xb1, 0x3c, 0x1d, 0x3a, 0x9e, 0x36, 0x00, 0x9d, 0x56, 0x55, 0x58, 0x2e, - 0x44, 0x82, 0xfc, 0xc8, 0xed, 0x6e, 0x00, 0x5b, 0x6d, 0x2e, 0x4c, 0x95, 0xbc, 0xc3, 0x64, 0x99, - 0x29, 0xfe, 0xdc, 0x55, 0x1b, 0x40, 0x2c, 0x82, 0x7d, 0xbb, 0xbc, 0xd6, 0x32, 0x5b, 0x64, 0x28, - 0x39, 0x23, 0x93, 0x16, 0xc6, 0x4e, 0xe1, 0xd0, 0x9b, 0x53, 0xe4, 0x5b, 0x91, 0xf3, 0x63, 0xaa, - 0xa2, 0x0b, 0x53, 0x34, 0x9d, 0x88, 0xbc, 0xee, 0xcd, 0x47, 0x3e, 0x5a, 0x80, 0xd9, 0x33, 0x59, - 0x66, 0x92, 0x77, 0x42, 0xa5, 0x68, 0xf8, 0x0b, 0x77, 0xa6, 0x00, 0xb2, 0x8c, 0x88, 0x3c, 0xd7, - 0x6b, 0x94, 0x59, 0x61, 0xf8, 0x4b, 0xd7, 0xdf, 0x06, 0xb1, 0x9a, 0xcb, 0x0c, 0xc5, 0xe4, 0x1f, - 0x13, 0x5d, 0xf5, 0xd2, 0x76, 0x47, 0x2a, 0xa3, 0x17, 0x0b, 0xce, 0x69, 0xc3, 0xaf, 0x48, 0x8b, - 0xd6, 0xa0, 0xb4, 0x09, 0xf8, 0x27, 0x2e, 0x62, 0x83, 0x44, 0x7f, 0xf6, 0xe1, 0xf0, 0xb5, 0xad, - 0xe5, 0xc7, 0x66, 0x50, 0x38, 0x0c, 0xcd, 0x8a, 0x78, 0xa6, 0x11, 0x18, 0xc5, 0xf5, 0x92, 0x7d, - 0x0e, 0x07, 0x0a, 0x51, 0x16, 0x88, 0xe5, 0xaa, 0x90, 0xa2, 0x72, 0x13, 0x31, 0x8a, 0x3b, 0x28, - 0xfb, 0x02, 0x8e, 0x2c, 0xe2, 0xfa, 0xe8, 0x2d, 0x9f, 0x91, 0xe5, 0x3d, 0xbc, 0xd6, 0xe5, 0x35, - 0x1a, 0x23, 0x52, 0xa4, 0x71, 0xf1, 0xba, 0xf4, 0x50, 0x5b, 0x97, 0x83, 0xae, 0x2e, 0x3f, 0x83, - 0x89, 0x8d, 0xb9, 0xc4, 0x3b, 0x9f, 0x68, 0x97, 0x2c, 0xda, 0xa0, 0xe5, 0xc1, 0x02, 0x12, 0x73, - 0xac, 0x90, 0x26, 0x67, 0x14, 0x07, 0x48, 0xf4, 0x57, 0x1f, 0x26, 0xbf, 0x20, 0x96, 0x66, 0xc3, - 0x02, 0x65, 0x4d, 0x45, 0x85, 0x6b, 0x71, 0xe7, 0x79, 0x68, 0x00, 0xdb, 0x6f, 0xff, 0xe9, 0x98, - 0x75, 0x37, 0x43, 0x0b, 0x7b, 0xc2, 0x9c, 0x7f, 0xf8, 0xdd, 0xd2, 0xd5, 0xe1, 0x70, 0x8b, 0x0e, - 0x1f, 0x9c, 0xca, 0x68, 0x0e, 0x93, 0xd7, 0x25, 0x8a, 0x0a, 0xed, 0x4d, 0x18, 0xe3, 0x0d, 0x3b, - 0x01, 0xba, 0xb6, 0x89, 0x83, 0xf1, 0x25, 0x9c, 0xd3, 0x7d, 0x4e, 0x9b, 0xee, 0x3a, 0xef, 0x38, - 0x98, 0xf7, 0x71, 0xf8, 0x9d, 0xba, 0xf2, 0x3f, 0x32, 0x84, 0x0e, 0x8f, 0x67, 0x78, 0x03, 0xe3, - 0x18, 0x85, 0x6c, 0xe2, 0x3f, 0xfc, 0x83, 0x09, 0x7e, 0x22, 0xfd, 0xf6, 0x4f, 0xe4, 0x2c, 0x0c, - 0xf4, 0x78, 0xde, 0x5f, 0x61, 0xf2, 0x03, 0xe9, 0xe9, 0x7d, 0x33, 0x5b, 0xf1, 0xbb, 0x54, 0x6f, - 0x9b, 0xff, 0x4b, 0x08, 0x45, 0xaf, 0xda, 0x21, 0xcd, 0x7f, 0x4f, 0xa7, 0xad, 0xfa, 0x0d, 0x56, - 0x5e, 0xc5, 0x4f, 0xa9, 0xfa, 0xdb, 0x30, 0x90, 0x61, 0xaf, 0x60, 0x60, 0x67, 0xdb, 0xf8, 0xb2, - 0x8f, 0x5d, 0xd9, 0xad, 0x69, 0x89, 0x9d, 0x45, 0xf4, 0x25, 0xc0, 0xe6, 0x36, 0x79, 0xbc, 0xaf, - 0x3f, 0x07, 0xd6, 0x86, 0x7d, 0xb7, 0xb9, 0x6c, 0x4b, 0x1f, 0xd5, 0x3b, 0xbe, 0x70, 0x8e, 0x9d, - 0x6b, 0x2a, 0xee, 0x5a, 0x5f, 0xfe, 0xd3, 0x87, 0xb1, 0x8d, 0xfe, 0x1b, 0x96, 0xb7, 0x59, 0x82, - 0xec, 0x02, 0x06, 0xf4, 0x02, 0x60, 0xcc, 0x05, 0x08, 0x1f, 0x1d, 0xd3, 0xe3, 0x16, 0xe6, 0x67, - 0xfe, 0x1b, 0x80, 0x46, 0xca, 0xcc, 0x9b, 0xb4, 0xa6, 0x61, 0xba, 0x05, 0x34, 0xec, 0x02, 0x46, - 0xb5, 0x4c, 0xd8, 0x73, 0x67, 0x10, 0xe8, 0x6f, 0x7a, 0x0f, 0x32, 0x36, 0x53, 0x23, 0xe9, 0x3a, - 0x53, 0x6b, 0x2a, 0xa6, 0x5b, 0x40, 0xf2, 0x6b, 0xe4, 0x50, 0xfb, 0xb5, 0x34, 0x37, 0xdd, 0x02, - 0x1a, 0x76, 0x09, 0xa3, 0xba, 0xa5, 0xf5, 0x09, 0x03, 0xad, 0x4c, 0xef, 0x41, 0xe6, 0xa2, 0xc7, - 0xce, 0x60, 0xe8, 0x39, 0x67, 0x47, 0x9d, 0x16, 0xdc, 0x4c, 0xbb, 0x88, 0xf9, 0x7e, 0xfe, 0xc7, - 0x59, 0xaa, 0x75, 0x9a, 0xe3, 0x79, 0xaa, 0x73, 0xa1, 0xd2, 0x73, 0x5d, 0xa6, 0x73, 0x7a, 0xf7, - 0x5d, 0xad, 0x16, 0xf3, 0xea, 0xae, 0x40, 0x33, 0x5f, 0x2a, 0xbd, 0x56, 0xf4, 0x22, 0x2c, 0xae, - 0xae, 0x76, 0x69, 0xf3, 0xeb, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x0e, 0xb4, 0x28, 0x5a, 0x27, - 0x0a, 0x00, 0x00, +func file_grpc_node_proto_rawDescGZIP() []byte { + file_grpc_node_proto_rawDescOnce.Do(func() { + file_grpc_node_proto_rawDescData = protoimpl.X.CompressGZIP(file_grpc_node_proto_rawDescData) + }) + return file_grpc_node_proto_rawDescData +} + +var file_grpc_node_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_grpc_node_proto_goTypes = []interface{}{ + (*LoginRequest)(nil), // 0: node.LoginRequest + (*LoginResponse)(nil), // 1: node.LoginResponse + (*Node)(nil), // 2: node.Node + (*CheckInResponse)(nil), // 3: node.CheckInResponse + (*PeersResponse)(nil), // 4: node.PeersResponse + (*CreateNodeReq)(nil), // 5: node.CreateNodeReq + (*CreateNodeRes)(nil), // 6: node.CreateNodeRes + (*UpdateNodeReq)(nil), // 7: node.UpdateNodeReq + (*UpdateNodeRes)(nil), // 8: node.UpdateNodeRes + (*ReadNodeReq)(nil), // 9: node.ReadNodeReq + (*ReadNodeRes)(nil), // 10: node.ReadNodeRes + (*DeleteNodeReq)(nil), // 11: node.DeleteNodeReq + (*DeleteNodeRes)(nil), // 12: node.DeleteNodeRes + (*GetPeersReq)(nil), // 13: node.GetPeersReq + (*GetPeersRes)(nil), // 14: node.GetPeersRes + (*CheckInReq)(nil), // 15: node.CheckInReq + (*CheckInRes)(nil), // 16: node.CheckInRes +} +var file_grpc_node_proto_depIdxs = []int32{ + 2, // 0: node.CreateNodeReq.node:type_name -> node.Node + 2, // 1: node.CreateNodeRes.node:type_name -> node.Node + 2, // 2: node.UpdateNodeReq.node:type_name -> node.Node + 2, // 3: node.UpdateNodeRes.node:type_name -> node.Node + 2, // 4: node.ReadNodeRes.node:type_name -> node.Node + 4, // 5: node.GetPeersRes.peers:type_name -> node.PeersResponse + 2, // 6: node.CheckInReq.node:type_name -> node.Node + 3, // 7: node.CheckInRes.checkinresponse:type_name -> node.CheckInResponse + 0, // 8: node.NodeService.Login:input_type -> node.LoginRequest + 5, // 9: node.NodeService.CreateNode:input_type -> node.CreateNodeReq + 9, // 10: node.NodeService.ReadNode:input_type -> node.ReadNodeReq + 7, // 11: node.NodeService.UpdateNode:input_type -> node.UpdateNodeReq + 11, // 12: node.NodeService.DeleteNode:input_type -> node.DeleteNodeReq + 13, // 13: node.NodeService.GetPeers:input_type -> node.GetPeersReq + 15, // 14: node.NodeService.CheckIn:input_type -> node.CheckInReq + 1, // 15: node.NodeService.Login:output_type -> node.LoginResponse + 6, // 16: node.NodeService.CreateNode:output_type -> node.CreateNodeRes + 10, // 17: node.NodeService.ReadNode:output_type -> node.ReadNodeRes + 8, // 18: node.NodeService.UpdateNode:output_type -> node.UpdateNodeRes + 12, // 19: node.NodeService.DeleteNode:output_type -> node.DeleteNodeRes + 14, // 20: node.NodeService.GetPeers:output_type -> node.GetPeersRes + 16, // 21: node.NodeService.CheckIn:output_type -> node.CheckInRes + 15, // [15:22] is the sub-list for method output_type + 8, // [8:15] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_grpc_node_proto_init() } +func file_grpc_node_proto_init() { + if File_grpc_node_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_grpc_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Node); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CheckInResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeersResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateNodeReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateNodeRes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateNodeReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateNodeRes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadNodeReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadNodeRes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteNodeReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteNodeRes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetPeersReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetPeersRes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CheckInReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_grpc_node_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CheckInRes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_grpc_node_proto_rawDesc, + NumEnums: 0, + NumMessages: 17, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_grpc_node_proto_goTypes, + DependencyIndexes: file_grpc_node_proto_depIdxs, + MessageInfos: file_grpc_node_proto_msgTypes, + }.Build() + File_grpc_node_proto = out.File + file_grpc_node_proto_rawDesc = nil + file_grpc_node_proto_goTypes = nil + file_grpc_node_proto_depIdxs = nil } diff --git a/grpc/node.proto b/grpc/node.proto index a50f53b2..4ffe3c5e 100644 --- a/grpc/node.proto +++ b/grpc/node.proto @@ -24,6 +24,7 @@ message Node { string id = 1; string name = 2; string address = 3; + string address6 = 26; int32 listenport = 4; string publickey = 5; string endpoint = 6; @@ -44,6 +45,7 @@ message Node { string postchanges = 21; string allowedips = 22; bool islocal = 23; + bool isdualstack = 27; bool dnsoff = 24; string localrange = 25; } @@ -64,6 +66,7 @@ message PeersResponse { string publickey = 5; string endpoint = 6; string address = 3; + string address6 = 8; int32 listenport = 4; string localaddress = 7; int32 keepalive = 13; diff --git a/models/structs.go b/models/structs.go index acb7cbc6..0d62dcc3 100644 --- a/models/structs.go +++ b/models/structs.go @@ -94,6 +94,7 @@ type PeersResponse struct { PublicKey string `json:"publickey" bson:"publickey"` Endpoint string `json:"endpoint" bson:"endpoint"` Address string `json:"address" bson:"address"` + Address6 string `json:"address6" bson:"address6"` LocalAddress string `json:"localaddress" bson:"localaddress"` IsGateway bool `json:"isgateway" bson:"isgateway"` GatewayRange string `json:"gatewayrange" bson:"gatewayrange"` From 2199e4f2f8085f1e21216e5f1a4599ce1ecbaf4c Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 11:49:39 +0000 Subject: [PATCH 09/14] adding ipv6 responses --- controllers/nodeGrpcController.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/nodeGrpcController.go b/controllers/nodeGrpcController.go index e3786878..1c683ee7 100644 --- a/controllers/nodeGrpcController.go +++ b/controllers/nodeGrpcController.go @@ -3,7 +3,6 @@ package controller import ( "context" "fmt" - "strconv" nodepb "github.com/gravitl/netmaker/grpc" "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/functions" @@ -56,6 +55,7 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe Listenport: node.ListenPort, Keepalive: node.PersistentKeepalive, Islocal: *network.IsLocal, + Isdualstack: *network.IsDualStack, Localrange: network.LocalRange, }, @@ -101,8 +101,6 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo return nil, status.Errorf(codes.NotFound, fmt.Sprintf("Could not find network: %v", err)) } else { fmt.Println("Creating node in network " + network.NetID) - fmt.Println("Network is local? " + strconv.FormatBool(*network.IsLocal)) - fmt.Println("Range if local: " + network.LocalRange) } @@ -147,6 +145,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo Listenport: node.ListenPort, Keepalive: node.PersistentKeepalive, Islocal: *network.IsLocal, + Isdualstack: *network.IsDualStack, Localrange: network.LocalRange, }, } @@ -276,6 +275,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo Listenport: newnode.ListenPort, Keepalive: newnode.PersistentKeepalive, Islocal: *network.IsLocal, + Isdualstack: *network.IsDualStack, Localrange: network.LocalRange, }, From 4c0cc042e0c944df8eede529329c18de04e3e7e4 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 09:25:05 -0400 Subject: [PATCH 10/14] got netclient ipv6 working --- netclient/config/config.go | 2 + netclient/functions/common.go | 103 ++++++++++++++++++++++++++++------ netclient/main.go | 10 ++-- 3 files changed, 94 insertions(+), 21 deletions(-) diff --git a/netclient/config/config.go b/netclient/config/config.go index f37ade5d..6522607d 100644 --- a/netclient/config/config.go +++ b/netclient/config/config.go @@ -35,6 +35,7 @@ type NodeConfig struct { RoamingOff bool `yaml:"roamingoff"` DNSOff bool `yaml:"dnsoff"` IsLocal bool `yaml:"islocal"` + IsDualStack bool `yaml:"isdualstack"` AllowedIPs string `yaml:"allowedips"` LocalRange string `yaml:"localrange"` PostUp string `yaml:"postup"` @@ -45,6 +46,7 @@ type NodeConfig struct { PrivateKey string `yaml:"privatekey"` Endpoint string `yaml:"endpoint"` PostChanges string `yaml:"postchanges"` + IPForwarding string `yaml:"ipforwarding"` } //reading in the env file diff --git a/netclient/functions/common.go b/netclient/functions/common.go index 8d15c9d8..018df074 100644 --- a/netclient/functions/common.go +++ b/netclient/functions/common.go @@ -72,7 +72,7 @@ func GetFreePort(rangestart int32) (int32, error){ return portno, err } -func Install(accesskey string, password string, server string, network string, noauto bool, accesstoken string, inputname string, pubip string, dnsoff bool) error { +func Install(accesskey string, password string, server string, network string, noauto bool, accesstoken string, inputname string, pubip string, dnsoff bool, ipforward string) error { tserver := "" tnetwork := "" @@ -144,6 +144,7 @@ func Install(accesskey string, password string, server string, network string, n fmt.Println("SERVER SETTINGS:") nodecfg.DNSOff = dnsoff + nodecfg.IPForwarding = ipforward if server == "" { if servercfg.Address == "" && tserver == "" { @@ -410,6 +411,7 @@ func Install(accesskey string, password string, server string, network string, n fmt.Println("NODE RECIEVED SETTINGS: ") fmt.Println(" Password: " + node.Password) fmt.Println(" WG Address: " + node.Address) + fmt.Println(" WG ipv6 Address: " + node.Address6) fmt.Println(" Network: " + node.Nodenetwork) fmt.Println(" Public Endpoint: " + node.Endpoint) fmt.Println(" Local Address: " + node.Localaddress) @@ -422,8 +424,12 @@ func Install(accesskey string, password string, server string, network string, n fmt.Println(" Public Key: " + node.Publickey) fmt.Println(" Mac Address: " + node.Macaddress) fmt.Println(" Is Local?: " + strconv.FormatBool(node.Islocal)) + fmt.Println(" Is Dual Stack?: " + strconv.FormatBool(node.Isdualstack)) fmt.Println(" Local Range: " + node.Localrange) + if node.Dnsoff==true && !nodecfg.DNSOff { + nodecfg.DNSOff = true + } if !islocal && node.Islocal && node.Localrange != "" { fmt.Println("Resetting local settings for local network.") node.Localaddress, err = getLocalIP(node.Localrange) @@ -448,7 +454,7 @@ func Install(accesskey string, password string, server string, network string, n } } - peers, hasGateway, gateways, err := getPeers(node.Macaddress, network, server) + peers, hasGateway, gateways, err := getPeers(node.Macaddress, network, server, node.Isdualstack) if err != nil { return err @@ -594,12 +600,19 @@ func modConfig(node *nodepb.Node) error{ if node.Address != ""{ nodecfg.WGAddress = node.Address } - if node.Address != ""{ - nodecfg.WGAddress = node.Address + if node.Address6 != ""{ + nodecfg.WGAddress6 = node.Address6 } if node.Postchanges != "" { nodecfg.PostChanges = node.Postchanges } + if node.Dnsoff == true { + nodecfg.DNSOff = node.Dnsoff + } + if node.Isdualstack == true { + nodecfg.IsDualStack = true + } + if node.Localrange != "" && node.Islocal { nodecfg.IsLocal = true nodecfg.LocalRange = node.Localrange @@ -647,6 +660,7 @@ func initWireguard(node *nodepb.Node, privkey string, peers []wgtypes.PeerConfig nodecfg := modcfg.Node + servercfg := modcfg.Server fmt.Println("beginning local WG config") @@ -668,7 +682,14 @@ func initWireguard(node *nodepb.Node, privkey string, peers []wgtypes.PeerConfig if node.Address == "" { log.Fatal("no address to configure") } - + nameserver := servercfg.Address + nameserver = strings.Split(nameserver, ":")[0] + network := node.Nodenetwork + if nodecfg.Network != "" { + network = nodecfg.Network + } else if node.Nodenetwork != "" { + network = node.Nodenetwork + } cmdIPDevLinkAdd := &exec.Cmd { Path: ipExec, Args: []string{ ipExec, "link", "add", "dev", ifacename, "type", "wireguard" }, @@ -742,6 +763,33 @@ func initWireguard(node *nodepb.Node, privkey string, peers []wgtypes.PeerConfig fmt.Printf("This is inconvenient: %v", err) } } + + //=========DNS Setup==========\\ + if nodecfg.DNSOff != true { + + _, err := exec.LookPath("resolvectl") + if err != nil { + fmt.Println(err) + fmt.Println("WARNING: resolvectl not present. Unable to set dns. Install resolvectl or run manually.") + } else { + _, err = exec.Command("resolvectl", "domain", ifacename, "~"+network).Output() + if err != nil { + fmt.Println(err) + fmt.Println("WARNING: Error encountered setting dns. Aborted setting dns.") + } else { + _, err = exec.Command("resolvectl", "default-route", ifacename, "false").Output() + if err != nil { + fmt.Println(err) + fmt.Println("WARNING: Error encountered setting dns. Aborted setting dns.") + } else { + _, err = exec.Command("resolvectl", "dns", ifacename, nameserver).Output() + fmt.Println(err) + } + } + } + } + //=========End DNS Setup=======\\ + cmdIPLinkUp := &exec.Cmd { Path: ipExec, Args: []string{ ipExec, "link", "set", "up", "dev", ifacename}, @@ -783,6 +831,14 @@ func initWireguard(node *nodepb.Node, privkey string, peers []wgtypes.PeerConfig fmt.Println("Error encountered adding gateway: " + err.Error()) } } + /* + if (node.Address6 != "" && node.Isdualstack) { + _, err := exec.Command(ipExec,"-6","route","add",node.Address6,"dev",ifacename).Output() + if err != nil { + fmt.Println("Error encountered adding ipv6: " + err.Error()) + } + } + */ } return err } @@ -876,7 +932,7 @@ func setWGConfig(network string) error { nodecfg := cfg.Node node := getNode(network) - peers, hasGateway, gateways, err := getPeers(node.Macaddress, nodecfg.Network, servercfg.Address) + peers, hasGateway, gateways, err := getPeers(node.Macaddress, nodecfg.Network, servercfg.Address, node.Isdualstack) if err != nil { return err } @@ -961,12 +1017,20 @@ func CheckIn(network string) error { setupcheck := true ipchange := false - if !nodecfg.DNSOff { - vals := strings.Split(servercfg.Address, ":") - server := vals[0] - err = SetDNS(server) - if err != nil { - fmt.Printf("Error encountered setting dns: %v", err) + if !(nodecfg.IPForwarding == "off") { + out, err := exec.Command("sysctl", "net.ipv4.ip_forward").Output() + if err != nil { + fmt.Println(err) + fmt.Println("WARNING: Error encountered setting ip forwarding. This can break functionality.") + } else { + s := strings.Fields(string(out)) + if s[2] != "1" { + _, err = exec.Command("sysctl", "-w", "net.ipv4.ip_forward=1").Output() + if err != nil { + fmt.Println(err) + fmt.Println("WARNING: Error encountered setting ip forwarding. You may want to investigate this.") + } + } } } @@ -1238,6 +1302,7 @@ func getNode(network string) nodepb.Node { node.Nodenetwork = nodecfg.Network node.Localaddress = nodecfg.LocalAddress node.Address = nodecfg.WGAddress + node.Address6 = nodecfg.WGAddress6 node.Listenport = nodecfg.Port node.Keepalive = nodecfg.KeepAlive node.Postup = nodecfg.PostUp @@ -1246,9 +1311,8 @@ func getNode(network string) nodepb.Node { node.Macaddress = nodecfg.MacAddress node.Endpoint = nodecfg.Endpoint node.Password = nodecfg.Password - - //spew.Dump(node) - + node.Dnsoff = nodecfg.DNSOff + node.Isdualstack = nodecfg.IsDualStack return node } @@ -1389,7 +1453,7 @@ func DeleteInterface(ifacename string, postdown string) error{ return err } -func getPeers(macaddress string, network string, server string) ([]wgtypes.PeerConfig, bool, []string, error) { +func getPeers(macaddress string, network string, server string, dualstack bool) ([]wgtypes.PeerConfig, bool, []string, error) { //need to implement checkin on server side hasGateway := false var gateways []string @@ -1488,6 +1552,13 @@ func getPeers(macaddress string, network string, server string) ([]wgtypes.PeerC allowedips = append(allowedips, *ipnet) } } + if res.Peers.Address6 != "" && dualstack { + var addr6 = net.IPNet{ + IP: net.ParseIP(res.Peers.Address6), + Mask: net.CIDRMask(128, 128), + } + allowedips = append(allowedips, addr6) + } if keepalive != 0 { peer = wgtypes.PeerConfig{ PublicKey: pubkey, diff --git a/netclient/main.go b/netclient/main.go index f715f457..a1ceffaf 100644 --- a/netclient/main.go +++ b/netclient/main.go @@ -39,10 +39,10 @@ func main() { tname := flag.String("name", "noname", "give the node a name at runtime") tserver := flag.String("s", "localhost:50051", "The location (including port) of the remote gRPC server.") tnetwork := flag.String("n", "nonetwork", "The node network you are attempting to join.") - tdnsoff := flag.Bool("dnsoff", false, "No dns mode. If true, netclient will not alter system dns.") + tdnsoff := flag.Bool("dnsoff", false, "DNS Mode. If true, netclient will not alter system dns. false by default.") tpublicip := flag.String("ip4", "nopubip", "The node network you are attempting to join.") tnoauto := flag.Bool("na", false, "No auto mode. If true, netmclient will not be installed as a system service and you will have to retrieve updates manually via checkin command.") - tnoforward := flag.Bool("nf", false, "No Forward mode. If true, netclient will not check for IP forwarding. This may break functionality") + tipforward := flag.String("nf", "on", "No Forward mode. If true, netclient will not check for IP forwarding. This may break functionality") command := flag.String("c", "required", "The command to run") @@ -91,7 +91,7 @@ func main() { fmt.Println("Required, '-n'. No network provided. Exiting.") os.Exit(1) } - + /* if !*tnoforward { forward := exec.Command("sysctl", "net.ipv4.ip_forward") out, err := forward.Output() @@ -108,9 +108,9 @@ func main() { log.Fatal("It is recommended to enable IP Forwarding. Current status is: " + s[2] + ", but should be 1. if you would like to run without IP Forwarding, re-run with flag '-nf true'") } } - + */ fmt.Println("Beginning agent installation.") - err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname, *tpublicip, *tdnsoff) + err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname, *tpublicip, *tdnsoff, *tipforward) if err != nil { fmt.Println("Error encountered while installing.") if !strings.Contains(err.Error(), "ALREADY_INSTALLED") { From 3dafbc0daac427d929494d02f216386942d61b9b Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 10:16:34 -0400 Subject: [PATCH 11/14] now able to add ipv6 address to iface --- netclient/functions/common.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/netclient/functions/common.go b/netclient/functions/common.go index 018df074..daf1c4f9 100644 --- a/netclient/functions/common.go +++ b/netclient/functions/common.go @@ -703,7 +703,6 @@ func initWireguard(node *nodepb.Node, privkey string, peers []wgtypes.PeerConfig Stderr: os.Stdout, } - currentiface, err := net.InterfaceByName(ifacename) @@ -830,15 +829,15 @@ func initWireguard(node *nodepb.Node, privkey string, peers []wgtypes.PeerConfig if err != nil { fmt.Println("Error encountered adding gateway: " + err.Error()) } + } } - /* if (node.Address6 != "" && node.Isdualstack) { - _, err := exec.Command(ipExec,"-6","route","add",node.Address6,"dev",ifacename).Output() + fmt.Println("Adding address: " + node.Address6) + out, err := exec.Command(ipExec, "address", "add", "dev", ifacename, node.Address6+"/64").Output() if err != nil { + fmt.Println(out) fmt.Println("Error encountered adding ipv6: " + err.Error()) } - } - */ } return err } From 0765c92efd267dcb69a27a5b28a87e8dccab3b17 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 14:33:05 +0000 Subject: [PATCH 12/14] ipv6 and private dns now working. docs updated. --- README.md | 105 ++++++++++++++++++++++++------ controllers/common.go | 5 -- controllers/nodeGrpcController.go | 41 ++++++++++-- functions/helpers.go | 36 ++++++++-- 4 files changed, 150 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index b045ce81..183d1d2c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +

@@ -6,7 +7,11 @@

## What is Netmaker? -Netmaker is a tool for creating and managing virtual networks. The goal is to provide functionality similar to Tailscale, ZeroTier, and Nebula, but faster, easier, and more dynamic. It should be like clicking a button. Netmaker consists of a server, an agent, and a UI. You spin up the Netmaker server and then install netclient (the agent) on your computers. Netmaker will do the rest. It will tell all of your computers how to reach each other and will keep them informed of any changes to the network. +Netmaker is a tool for creating and managing virtual networks. If you have servers spread across multiple locations, data centers, or clouds, they all live on separate networks. This can make life very difficult. Netmaker takes all those machines and puts them on a single, flat network so that they can talk to each other easily and securely. + +Think of it like Tailscale, ZeroTier, or Nebula, but faster, easier, and more dynamic. + +You spin up the Netmaker server and UI, and then install the Netclient (agent) on your computers. Netmaker will do the rest. It will tell all of your computers how to reach each other and will keep them informed of any changes to the network. Netmaker's handy dandy UI can be found [here](https://github.com/gravitl/netmaker-ui). @@ -28,7 +33,9 @@ Under the hood, Netmaker uses WireGuard to create encrypted tunnels between ever ## Compatible Systems -Netmaker works on most linux systems that have systemd. It works with Fedora, Ubuntu, and Raspian. Just make sure you have WireGuard installed. Having a problem? Open an issue or Contact us. +Netmaker is primarily designed for **linux**, specifically **systemd-based linux.** This includes Fedora, Ubuntu, and Raspian. Just make sure you have WireGuard installed. Having a problem? Open an issue or Contact us. + +In version 0.3 we have released Private DNS. Nameservers can be configured manually on any system, but to have the Netclient add dns automatically, it requires **resolvectl.** In future releases, we have plans to support other platforms such as Windows and MacOS. @@ -47,33 +54,91 @@ In future releases, we have plans to support other platforms such as Windows and [Intro/Overview Video Tutorial](https://youtu.be/PWLPT320Ybo) [Site-to-Site Video Tutorial](https://youtu.be/krCKBJhwwDk) - -#### Prereqs: -1. A server with an IP reachable by your computers (a small ec2 instance or droplet would do just fine). -2. Linux installed on the above server (we use Ubuntu, but anything that runs Docker should work). -3. Install Docker if running in Docker Mode (see below). + +### Note about permissions +The default installation requires special privileges on the server side, because Netmaker will control the local kernel Wireguard. This can be turned off and run in non-privileged mode if necessary (but disables some features). For more details, see the **Usage** docs. + +### Prereqs + 1. A running linux server to host Netmaker, with an IP reachable by your computers (Debian-based preferred but not required). + 2. Linux installed on the above server (Debian-based preferred but not required). + 3. Install Docker and Docker Compose if running in Docker Mode (see below). + 4. System dependencies installed: + - Docker (if running in default Docker mode. DO NOT use snap install for docker.) + - Docker Compose + - Wireguard + Resolvectl (if running in default Client mode) + +#### CoreDNS Preparation +v0.3 introduces CoreDNS as a private nameserver. To run CoreDNS on your server host, you must disable systemd-resolved to open port 53: +1. systemctl stop systemd-resolved +2. systemctl disable systemd-resolved +3. vim /etc/systemd/resolved.conf + - uncomment **DNS=** and add 8.8.8.8 or whatever is your preference + - uncomment **DNSStubListener=** and set to **"no"** + 4. sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf -#### Launch Netmaker: -Netmaker v0.2 introduces the server as a 'client'. This means the server can add itself into networks if you would like. To do so, Netmaker requires privileged access where it is running, and needs to modify the host filesystem. To run in this mode, we are not currently using Docker. - -**If you would like to run with "client mode", you can use the following script to deploy:** -`sudo curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.2/netmaker-install-clientmode.sh | sudo SERVER_DOMAIN=< your server IP > sh -` - -**If you would like to run without "client mode", and manually add/remove the server from networks:** +### Launch Netmaker +Note, this installs Netmaker with CoreDNS and a Netclient (privileged). If you want to run the server non-privileged or without CoreDNS, see the advanced usage docs. 1. Clone this repo or just copy contents of "docker-compose.yml" to your Netmaker server (from prereqs). 2. In docker-compose.yml, change BACKEND_URL to the public IP of your server. 3. Run `sudo docker-compose up` 4. Navigate to your server's IP in the browser and you should see the Netmaker UI asking to create a new admin user. 5. Create a new admin user -6. You are now ready to begin using Netmaker. There should be a default network you can use or you can create your own. Then, Create a key or enable manual node sign up so that your nodes can connect. +6. You are now ready to begin using Netmaker. -#### On your machines : -A command will be displayed when you generate a token for signing up nodes. Run it on each machine you would like to connect. -`curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.2/netclient-install.sh | KEY= sh -` -(Note: Key can be left out if manual node signup is enabled) +### Create a Network +You can also just use the "default" network. +1. Click "CREATE NETWORK" in the upper left of your console +2. Enter a valid address range, e.g. 10.11.12.0/24 +3. Enter a name such as "homenet" +4. Additional options: + - **Dual Stack**: Machines will recieve a private IPv6 address in addition to their IPv4 address. + - **Local:** Will use local address range for endpoints instead of public. Use Case: Home or Office network where most devices do not have public IP's. In this case you can create a gateway into the network after creating the Local Network. + +After Network creation, you can edit the network in the NETWORK DETAILS pane, modifying the address range and default options. You can also toggle on **Allow Node Signup Without Keys**, which makes the next step unnecessary, but allows anyone to create a node in your network, which will be cordoned in pending state. + +### Create Keys +1. Click the "ACCESS KEYS" tab +2. Click "ADD NEW ACCESSS KEY" +3. Give your key a name and number of uses +4. Several values will be displayed. Save these somewhere, as they will only be displayed once: + - **Access Key:** Use only in special edge cases where server connection string must be modified + - **Access Token:** Use on machines that already have the netclient utility + - **Install Command:** Use on machines that do not have the netclient utility + +### Install Agent: +For machines **without** netclient, run the install command (from above): `curl -sfL https://raw.githubusercontent.com/gravitl/netmaker/v0.2/netclient-install.sh | KEY= sh -` +For machines **with** netclient run the following (with access token from above): `sudo netclient -c install -t ` +For networks with **manual signup** enabled (see above), install using the network name: `sudo netclient -c install -n ` + +### Manage Nodes +Your machines should now be visible in the control pane. +**Modify nodes:** Click the pencil icon in the NODES pane to modify details like WireGuard port, address, and node name. You can also **DELETE** nodes here and they will lose network access. +**Approve nodes:** If a node is in pending state (signed up without key), you can approve it. An icon will appear for pending nodes that need approval. + +**Gateway Mode:** Click the Gateway icon to enable gateway mode on a given node. A popup will allow you to choose an existing network, or enter a custom address range. +*Example: You create a network in netmaker called Homenet. It has several machines on your home server. You create another network called Cloudnet. It has several machines in AWS. You have one server (server X) which is added to both networks. On Cloudnet, you make Server X a gateway to Homenet. Now, the cloudnet machines have access to your homenet machines. via Server X.* + +*On Homenet, you add Server Y, a machine in AWS, and make it a gateway to a custom address range 172.16.0.0/16. The machines on your home network now have access to any AWS machines in that address range via Server Y* + +### Manage DNS +On the DNS tab you can create custom DNS entries for a given network. + + 1. All dns entries will be *postfixed* with a private TLD of the network name, for example, ".mynet" + 2. Default DNS is created for node name + TLD, for instance, node-c42wt.mynet. This is not editable. + 3. Click ADD ENTRY to add custom DNS + - You can click CHOOSE NODE to direct DNS to a specific node in the network + - You can also specify any custom address you would like, which can be outside the network (for instance, the IP for google.com) + - Add a dns entry name, which will be postfixed with the network TLD. E.g. if you enter "privateapi.com", it will become "privateapi.com.networkname" + +### Uninstalling Client +To uninstall the client from a network: `sudo netclient -c remove -n < networkname >` +To uninstall entirely, run the above for each network, and then run `sudo rm -rf /etc/netclient` + +### Uninstralling Netmaker +To uninstall the netmaker server, simply run `docker-compose down` #### LICENSE @@ -81,5 +146,5 @@ Netmaker's source code and all artifacts in this repository are freely available #### CONTACT -Email: info@gravitl.com +Email: alex@gravitl.com Discord: https://discord.gg/zRb9Vfhk8A diff --git a/controllers/common.go b/controllers/common.go index 7bbf810b..b391b55d 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -375,16 +375,11 @@ func CreateNode(node models.Node, networkName string) (models.Node, error) { //Anyways, this scrolls through all the IP Addresses in the network range and checks against nodes //until one is open and then returns it node.Address, err = functions.UniqueAddress(networkName) - fmt.Println("Setting node address: " + node.Address) if err != nil { return node, err } - fmt.Println("Setting node address: " + node.Address) node.Address6, err = functions.UniqueAddress6(networkName) - if node.Address6 != "" { - fmt.Println("Setting node ipv6 address: " + node.Address6) - } if err != nil { return node, err } diff --git a/controllers/nodeGrpcController.go b/controllers/nodeGrpcController.go index 1c683ee7..6e178127 100644 --- a/controllers/nodeGrpcController.go +++ b/controllers/nodeGrpcController.go @@ -35,6 +35,17 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe } */ // Cast to ReadNodeRes type + dualvar := false + if network.IsDualStack != nil { + dualvar = *network.IsDualStack + } + localvar := false + if network.IsLocal != nil { + localvar = *network.IsLocal + } + + + response := &nodepb.ReadNodeRes{ Node: &nodepb.Node{ Macaddress: node.MacAddress, @@ -54,8 +65,8 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe Publickey: node.PublicKey, Listenport: node.ListenPort, Keepalive: node.PersistentKeepalive, - Islocal: *network.IsLocal, - Isdualstack: *network.IsDualStack, + Islocal: localvar, + Isdualstack: dualvar, Localrange: network.LocalRange, }, @@ -127,6 +138,15 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo fmt.Sprintf("Internal error: %v", err), ) } + dualvar := false + if network.IsDualStack != nil { + dualvar = *network.IsDualStack + } + localvar := false + if network.IsLocal != nil { + localvar = *network.IsLocal + } + // return the node in a CreateNodeRes type response := &nodepb.CreateNodeRes{ Node: &nodepb.Node{ @@ -144,8 +164,8 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo Publickey: node.PublicKey, Listenport: node.ListenPort, Keepalive: node.PersistentKeepalive, - Islocal: *network.IsLocal, - Isdualstack: *network.IsDualStack, + Islocal: localvar, + Isdualstack: dualvar, Localrange: network.LocalRange, }, } @@ -256,6 +276,15 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo fmt.Sprintf("Could not find node with supplied Mac Address: %v", err), ) } + dualvar := false + if network.IsDualStack != nil { + dualvar = *network.IsDualStack + } + localvar := false + if network.IsLocal != nil { + localvar = *network.IsLocal + } + return &nodepb.UpdateNodeRes{ Node: &nodepb.Node{ Macaddress: newnode.MacAddress, @@ -274,8 +303,8 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo Dnsoff: servercfg.IsDNSMode(), Listenport: newnode.ListenPort, Keepalive: newnode.PersistentKeepalive, - Islocal: *network.IsLocal, - Isdualstack: *network.IsDualStack, + Islocal: localvar, + Isdualstack: dualvar, Localrange: network.LocalRange, }, diff --git a/functions/helpers.go b/functions/helpers.go index d05b0305..6fd7c994 100644 --- a/functions/helpers.go +++ b/functions/helpers.go @@ -528,11 +528,6 @@ func UniqueAddress6(networkName string) (string, error) { return "", nil } - if err != nil { - fmt.Println("UniqueAddress6 encountered an error") - return "666", err - } - offset := true ip, ipnet, err := net.ParseCIDR(network.AddressRange6) if err != nil { @@ -544,7 +539,7 @@ func UniqueAddress6(networkName string) (string, error) { offset = false continue } - if IsIPUnique(networkName, ip.String()) { + if IsIP6Unique(networkName, ip.String()) { return ip.String(), err } } @@ -616,6 +611,35 @@ func IsIPUnique(network string, ip string) bool { return isunique } +//checks if IP is unique in the address range +//used by UniqueAddress +func IsIP6Unique(network string, ip string) bool { + + var node models.Node + + isunique := true + + collection := mongoconn.Client.Database("netmaker").Collection("nodes") + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + + filter := bson.M{"address6": ip, "network": network} + + err := collection.FindOne(ctx, filter).Decode(&node) + + defer cancel() + + if err != nil { + fmt.Println(err) + return isunique + } + + if node.Address6 == ip { + isunique = false + } + return isunique +} + + //called once key has been used by createNode //reduces value by one and deletes if necessary func DecrimentKey(networkName string, keyvalue string) { From d0acd85c14f7755fbcd3cd6a8b36efbb7dad7b07 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 14:38:14 +0000 Subject: [PATCH 13/14] fixing tests --- test/api_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/api_test.go b/test/api_test.go index 6d169ec7..34c99033 100644 --- a/test/api_test.go +++ b/test/api_test.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "context" "encoding/json" "io/ioutil" "net/http" From e34102a342d6e0f9438314fdcc9e7a08982f8285 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Thu, 6 May 2021 17:26:32 +0000 Subject: [PATCH 14/14] hotfixing dns --- controllers/common.go | 11 ++++++++++- controllers/nodeGrpcController.go | 6 +++--- functions/local.go | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/controllers/common.go b/controllers/common.go index b391b55d..a78419fe 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -8,6 +8,7 @@ import ( "time" "github.com/gravitl/netmaker/functions" + "github.com/gravitl/netmaker/servercfg" "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/mongoconn" "go.mongodb.org/mongo-driver/bson" @@ -306,6 +307,9 @@ func UpdateNode(nodechange models.Node, node models.Node) (models.Node, error) { if notifynetwork { errN = SetNetworkNodesLastModified(queryNetwork) } + if servercfg.IsDNSMode() { + errN = SetDNS() + } return returnnode, errN } @@ -332,6 +336,9 @@ func DeleteNode(macaddress string, network string) (bool, error) { err = SetNetworkNodesLastModified(network) fmt.Println("Deleted node " + macaddress + " from network " + network) + if servercfg.IsDNSMode() { + err = SetDNS() + } return deleted, err } @@ -421,7 +428,9 @@ func CreateNode(node models.Node, networkName string) (models.Node, error) { } SetNetworkNodesLastModified(node.Network) - + if servercfg.IsDNSMode() { + err = SetDNS() + } return node, err } diff --git a/controllers/nodeGrpcController.go b/controllers/nodeGrpcController.go index 6e178127..4408159d 100644 --- a/controllers/nodeGrpcController.go +++ b/controllers/nodeGrpcController.go @@ -60,7 +60,7 @@ func (s *NodeServiceServer) ReadNode(ctx context.Context, req *nodepb.ReadNodeRe Postdown: node.PostDown, Postup: node.PostUp, Checkininterval: node.CheckInInterval, - Dnsoff: servercfg.IsDNSMode(), + Dnsoff: !servercfg.IsDNSMode(), Ispending: node.IsPending, Publickey: node.PublicKey, Listenport: node.ListenPort, @@ -159,7 +159,7 @@ func (s *NodeServiceServer) CreateNode(ctx context.Context, req *nodepb.CreateNo Password: node.Password, Interface: node.Interface, Nodenetwork: node.Network, - Dnsoff: servercfg.IsDNSMode(), + Dnsoff: !servercfg.IsDNSMode(), Ispending: node.IsPending, Publickey: node.PublicKey, Listenport: node.ListenPort, @@ -300,7 +300,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo Nodenetwork: newnode.Network, Ispending: newnode.IsPending, Publickey: newnode.PublicKey, - Dnsoff: servercfg.IsDNSMode(), + Dnsoff: !servercfg.IsDNSMode(), Listenport: newnode.ListenPort, Keepalive: newnode.PersistentKeepalive, Islocal: localvar, diff --git a/functions/local.go b/functions/local.go index bbc18eb1..f4e54101 100644 --- a/functions/local.go +++ b/functions/local.go @@ -31,8 +31,8 @@ func SetCorefile(domains string) error { } corefile := domains + ` { + reload 15s hosts /root/dnsconfig/netmaker.hosts { - reload 15s fallthrough } forward . 8.8.8.8 8.8.4.4