Browse Source

feat(cmd): add vpn restart cmd

Mustafa Arici 8 years ago
parent
commit
ce31ee4923
3 changed files with 27 additions and 6 deletions
  1. 6 6
      bindata/bindata.go
  2. 1 0
      cmd/ovpm/main.go
  3. 20 0
      cmd/ovpm/vpn.go

+ 6 - 6
bindata/bindata.go

@@ -93,7 +93,7 @@ func templateAuthSwaggerJson() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/auth.swagger.json", size: 2503, mode: os.FileMode(420), modTime: time.Unix(1507746012, 0)}
+	info := bindataFileInfo{name: "template/auth.swagger.json", size: 2503, mode: os.FileMode(420), modTime: time.Unix(1507746709, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
@@ -113,7 +113,7 @@ func templateBundleJs() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/bundle.js", size: 298007, mode: os.FileMode(420), modTime: time.Unix(1507746023, 0)}
+	info := bindataFileInfo{name: "template/bundle.js", size: 298007, mode: os.FileMode(420), modTime: time.Unix(1507746720, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
@@ -193,7 +193,7 @@ func templateIndexHtml() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/index.html", size: 577, mode: os.FileMode(420), modTime: time.Unix(1507746023, 0)}
+	info := bindataFileInfo{name: "template/index.html", size: 577, mode: os.FileMode(420), modTime: time.Unix(1507746720, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
@@ -233,7 +233,7 @@ func templateNetworkSwaggerJson() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/network.swagger.json", size: 6669, mode: os.FileMode(420), modTime: time.Unix(1507746012, 0)}
+	info := bindataFileInfo{name: "template/network.swagger.json", size: 6669, mode: os.FileMode(420), modTime: time.Unix(1507746709, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
@@ -273,7 +273,7 @@ func templateUserSwaggerJson() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/user.swagger.json", size: 6556, mode: os.FileMode(420), modTime: time.Unix(1507746012, 0)}
+	info := bindataFileInfo{name: "template/user.swagger.json", size: 6556, mode: os.FileMode(420), modTime: time.Unix(1507746709, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }
@@ -293,7 +293,7 @@ func templateVpnSwaggerJson() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/vpn.swagger.json", size: 3732, mode: os.FileMode(420), modTime: time.Unix(1507746012, 0)}
+	info := bindataFileInfo{name: "template/vpn.swagger.json", size: 3732, mode: os.FileMode(420), modTime: time.Unix(1507746709, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }

+ 1 - 0
cmd/ovpm/main.go

@@ -55,6 +55,7 @@ func main() {
 				vpnStatusCommand,
 				vpnInitCommand,
 				vpnUpdateCommand,
+				vpnRestartCommand,
 			},
 		},
 		{

+ 20 - 0
cmd/ovpm/vpn.go

@@ -220,3 +220,23 @@ var vpnUpdateCommand = cli.Command{
 		return nil
 	},
 }
+
+var vpnRestartCommand = cli.Command{
+	Name:    "restart",
+	Usage:   "Restart VPN server.",
+	Aliases: []string{"s"},
+	Action: func(c *cli.Context) error {
+		conn := getConn(c.GlobalString("daemon-port"))
+		defer conn.Close()
+		vpnSvc := pb.NewVPNServiceClient(conn)
+
+		_, err := vpnSvc.Restart(context.Background(), &pb.VPNRestartRequest{})
+		if err != nil {
+			os.Exit(1)
+			return err
+		}
+
+		logrus.Info("ovpm server restarted")
+		return nil
+	},
+}