Browse Source

cleaning up old grpc functionality

afeiszli 4 years ago
parent
commit
7e8af20b64

+ 1 - 1
netclient/command/commands.go

@@ -121,7 +121,7 @@ func List(cfg config.ClientConfig) error {
 	return err
 }
 
-func Uninstall(cfg config.GlobalConfig) error {
+func Uninstall() error {
 	log.Println("Uninstalling netclient")
 	err := functions.Uninstall()
 	return err

+ 0 - 99
netclient/config/config.go

@@ -60,29 +60,6 @@ func Write(config *ClientConfig, network string) error {
 	return err
 }
 
-//reading in the env file
-func WriteGlobal(config *GlobalConfig) error {
-	_, err := os.Stat("/etc/netclient")
-	if os.IsNotExist(err) {
-		os.Mkdir("/etc/netclient", 744)
-	} else if err != nil {
-		return err
-	}
-	home := "/etc/netclient"
-
-	if err != nil {
-		log.Fatal(err)
-	}
-	file := fmt.Sprintf(home + "/netconfig-global-001")
-	f, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
-	defer f.Close()
-
-	err = yaml.NewEncoder(f).Encode(config)
-	if err != nil {
-		return err
-	}
-	return err
-}
 func WriteServer(server string, accesskey string, network string) error {
 	if network == "" {
 		err := errors.New("No network provided. Exiting.")
@@ -197,58 +174,6 @@ func (config *ClientConfig) ReadConfig() {
 		}
 	}
 }
-func ModGlobalConfig(cfg models.IntClient) error {
-	var modconfig GlobalConfig
-	var err error
-	if FileExists("/etc/netclient/netconfig-global-001") {
-		useconfig, err := ReadGlobalConfig()
-		if err != nil {
-			return err
-		}
-		modconfig = *useconfig
-	}
-	if cfg.ServerWGPort != "" {
-		modconfig.Client.ServerWGPort = cfg.ServerWGPort
-	}
-	if cfg.ServerGRPCPort != "" {
-		modconfig.Client.ServerGRPCPort = cfg.ServerGRPCPort
-	}
-	if cfg.ServerAPIPort != "" {
-		modconfig.Client.ServerAPIPort = cfg.ServerAPIPort
-	}
-	if cfg.PublicKey != "" {
-		modconfig.Client.PublicKey = cfg.PublicKey
-	}
-	if cfg.PrivateKey != "" {
-		modconfig.Client.PrivateKey = cfg.PrivateKey
-	}
-	if cfg.ServerPublicEndpoint != "" {
-		modconfig.Client.ServerPublicEndpoint = cfg.ServerPublicEndpoint
-	}
-	if cfg.ServerPrivateAddress != "" {
-		modconfig.Client.ServerPrivateAddress = cfg.ServerPrivateAddress
-	}
-	if cfg.Address != "" {
-		modconfig.Client.Address = cfg.Address
-	}
-	if cfg.Address6 != "" {
-		modconfig.Client.Address6 = cfg.Address6
-	}
-	if cfg.Network != "" {
-		modconfig.Client.Network = cfg.Network
-	}
-	if cfg.ServerKey != "" {
-		modconfig.Client.ServerKey = cfg.ServerKey
-	}
-	if cfg.AccessKey != "" {
-		modconfig.Client.AccessKey = cfg.AccessKey
-	}
-	if cfg.ClientID != "" {
-		modconfig.Client.ClientID = cfg.ClientID
-	}
-	err = WriteGlobal(&modconfig)
-	return err
-}
 
 func ModConfig(node *models.Node) error {
 	network := node.Network
@@ -397,30 +322,6 @@ func ReadConfig(network string) (*ClientConfig, error) {
 	return &cfg, err
 }
 
-func ReadGlobalConfig() (*GlobalConfig, error) {
-	nofile := false
-	home := "/etc/netclient"
-	file := fmt.Sprintf(home + "/netconfig-global-001")
-	f, err := os.Open(file)
-
-	if err != nil {
-		nofile = true
-	}
-	defer f.Close()
-
-	var cfg GlobalConfig
-
-	if !nofile {
-		decoder := yaml.NewDecoder(f)
-		err = decoder.Decode(&cfg)
-		if err != nil {
-			fmt.Println("trouble decoding file")
-			return nil, err
-		}
-	}
-	return &cfg, err
-}
-
 func FileExists(f string) bool {
 	info, err := os.Stat(f)
 	if os.IsNotExist(err) {

+ 1 - 1
netclient/functions/common.go

@@ -362,7 +362,7 @@ func GetNetworks() ([]string, error) {
 		return networks, err
 	}
 	for _, f := range files {
-		if strings.Contains(f.Name(), "netconfig-") && !strings.Contains(f.Name(), "global-001") {
+		if strings.Contains(f.Name(), "netconfig-") {
 			networkname := stringAfter(f.Name(), "netconfig-")
 			networks = append(networks, networkname)
 		}

+ 0 - 16
netclient/local/local.go

@@ -303,22 +303,6 @@ func WipeLocal(network string) error {
 
 }
 
-func WipeGRPCClient() error {
-	home := "/etc/netclient"
-	_ = os.Remove(home + "/netconfig-global-001")
-
-	ipExec, err := exec.LookPath("ip")
-
-	cmdIPLinkDel := &exec.Cmd{
-		Path:   ipExec,
-		Args:   []string{ipExec, "link", "del", "grpc-wg-001"},
-		Stdout: os.Stdout,
-		Stderr: os.Stdout,
-	}
-	err = cmdIPLinkDel.Run()
-	return err
-}
-
 func HasNetwork(network string) bool {
 
 	return FileExists("/etc/systemd/system/netclient-"+network+".timer") ||

+ 1 - 7
netclient/main.go

@@ -306,13 +306,7 @@ func main() {
 			// the action, or code that will be executed when
 			// we execute our `ns` command
 			Action: func(c *cli.Context) error {
-				cfg, err := config.ReadGlobalConfig()
-				if err != nil {
-					return err
-				}
-				var gconf config.GlobalConfig
-				gconf = *cfg
-				err = command.Uninstall(gconf)
+				err := command.Uninstall()
 				return err
 			},
 		},