Răsfoiți Sursa

Merge branch 'release-v0.1.10'

Mustafa Arici 8 ani în urmă
părinte
comite
31410d047c
12 a modificat fișierele cu 63 adăugiri și 51 ștergeri
  1. 7 4
      CHANGELOG.md
  2. 2 2
      api/rpc.go
  3. 2 2
      bindata/bindata.go
  4. 9 6
      cmd/ovpm/main.go
  5. 1 1
      cmd/ovpm/net.go
  6. 20 14
      cmd/ovpm/user.go
  7. 6 4
      cmd/ovpm/vpn.go
  8. 1 1
      const.go
  9. 5 2
      net_test.go
  10. 4 0
      template/ccd.file.tmpl
  11. 1 1
      template/server.conf.tmpl
  12. 5 14
      vpn.go

+ 7 - 4
CHANGELOG.md

@@ -1,11 +1,17 @@
 # Change Log
 
+## [v0.1.10](https://github.com/cad/ovpm/tree/v0.1.10) (2017-08-27)
+[Full Changelog](https://github.com/cad/ovpm/compare/v0.1.9...v0.1.10)
+
+**Implemented enhancements:**
+
+- show network types in cli [\#27](https://github.com/cad/ovpm/issues/27)
+
 ## [v0.1.9](https://github.com/cad/ovpm/tree/v0.1.9) (2017-08-27)
 [Full Changelog](https://github.com/cad/ovpm/compare/v0.1.8...v0.1.9)
 
 **Implemented enhancements:**
 
-- show network types in cli [\#27](https://github.com/cad/ovpm/issues/27)
 - static route support  [\#21](https://github.com/cad/ovpm/issues/21)
 
 ## [v0.1.8](https://github.com/cad/ovpm/tree/v0.1.8) (2017-08-26)
@@ -71,6 +77,3 @@
 - write docs [\#4](https://github.com/cad/ovpm/issues/4)
 - write unit tests [\#3](https://github.com/cad/ovpm/issues/3)
 
-
-
-\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

+ 2 - 2
api/rpc.go

@@ -66,9 +66,9 @@ func (s *UserService) Update(ctx context.Context, req *pb.UserUpdateRequest) (*p
 
 	switch req.Gwpref {
 	case pb.UserUpdateRequest_NOGW:
-		noGW = false
-	case pb.UserUpdateRequest_GW:
 		noGW = true
+	case pb.UserUpdateRequest_GW:
+		noGW = false
 	default:
 		noGW = user.NoGW
 

Fișier diff suprimat deoarece este prea mare
+ 2 - 2
bindata/bindata.go


+ 9 - 6
cmd/ovpm/main.go

@@ -35,8 +35,9 @@ func main() {
 	}
 	app.Commands = []cli.Command{
 		{
-			Name:  "user",
-			Usage: "User Operations",
+			Name:    "user",
+			Usage:   "User Operations",
+			Aliases: []string{"u"},
 			Subcommands: []cli.Command{
 				userListCommand,
 				userCreateCommand,
@@ -47,16 +48,18 @@ func main() {
 			},
 		},
 		{
-			Name:  "vpn",
-			Usage: "VPN Operations",
+			Name:    "vpn",
+			Usage:   "VPN Operations",
+			Aliases: []string{"v"},
 			Subcommands: []cli.Command{
 				vpnStatusCommand,
 				vpnInitCommand,
 			},
 		},
 		{
-			Name:  "net",
-			Usage: "Network Operations",
+			Name:    "net",
+			Usage:   "Network Operations",
+			Aliases: []string{"n"},
 			Subcommands: []cli.Command{
 				netListCommand,
 				netTypesCommand,

+ 1 - 1
cmd/ovpm/net.go

@@ -252,7 +252,7 @@ var netAssociateCommand = cli.Command{
 
 var netDissociateCommand = cli.Command{
 	Name:    "dissoc",
-	Aliases: []string{"d"},
+	Aliases: []string{"di"},
 	Usage:   "Dissociate a user from a network.",
 	Flags: []cli.Flag{
 		cli.StringFlag{

+ 20 - 14
cmd/ovpm/user.go

@@ -14,8 +14,9 @@ import (
 )
 
 var userListCommand = cli.Command{
-	Name:  "list",
-	Usage: "List VPN users.",
+	Name:    "list",
+	Usage:   "List VPN users.",
+	Aliases: []string{"l"},
 	Action: func(c *cli.Context) error {
 		action = "user:list"
 		conn := getConn(c.GlobalString("daemon-port"))
@@ -37,14 +38,14 @@ var userListCommand = cli.Command{
 			return err
 		}
 		table := tablewriter.NewWriter(os.Stdout)
-		table.SetHeader([]string{"#", "username", "ip", "created at", "valid crt", "no gw"})
+		table.SetHeader([]string{"#", "username", "ip", "created at", "valid crt", "gw"})
 		//table.SetBorder(false)
 		for i, user := range resp.Users {
 			static := ""
 			if user.HostID != 0 {
 				static = "s"
 			}
-			data := []string{fmt.Sprintf("%v", i+1), user.Username, fmt.Sprintf("%s %s", user.IPNet, static), user.CreatedAt, fmt.Sprintf("%t", user.ServerSerialNumber == server.SerialNumber), fmt.Sprintf("%t", user.NoGW)}
+			data := []string{fmt.Sprintf("%v", i+1), user.Username, fmt.Sprintf("%s %s", user.IPNet, static), user.CreatedAt, fmt.Sprintf("%t", user.ServerSerialNumber == server.SerialNumber), fmt.Sprintf("%t", !user.NoGW)}
 			table.Append(data)
 		}
 		table.Render()
@@ -54,8 +55,9 @@ var userListCommand = cli.Command{
 }
 
 var userCreateCommand = cli.Command{
-	Name:  "create",
-	Usage: "Create a VPN user.",
+	Name:    "create",
+	Usage:   "Create a VPN user.",
+	Aliases: []string{"c"},
 	Flags: []cli.Flag{
 		cli.StringFlag{
 			Name:  "username, u",
@@ -116,8 +118,9 @@ var userCreateCommand = cli.Command{
 }
 
 var userUpdateCommand = cli.Command{
-	Name:  "update",
-	Usage: "Update a VPN user.",
+	Name:    "update",
+	Usage:   "Update a VPN user.",
+	Aliases: []string{"u"},
 	Flags: []cli.Flag{
 		cli.StringFlag{
 			Name:  "username, u",
@@ -214,8 +217,9 @@ var userUpdateCommand = cli.Command{
 }
 
 var userDeleteCommand = cli.Command{
-	Name:  "delete",
-	Usage: "Delete a VPN user.",
+	Name:    "delete",
+	Usage:   "Delete a VPN user.",
+	Aliases: []string{"d"},
 	Flags: []cli.Flag{
 		cli.StringFlag{
 			Name:  "user, u",
@@ -248,8 +252,9 @@ var userDeleteCommand = cli.Command{
 }
 
 var userRenewCommand = cli.Command{
-	Name:  "renew",
-	Usage: "Renew VPN user certificates.",
+	Name:    "renew",
+	Usage:   "Renew VPN user certificates.",
+	Aliases: []string{"r"},
 	Flags: []cli.Flag{
 		cli.StringFlag{
 			Name:  "user, u",
@@ -283,8 +288,9 @@ var userRenewCommand = cli.Command{
 }
 
 var userGenconfigCommand = cli.Command{
-	Name:  "genconfig",
-	Usage: "Generate client config for the user. (.ovpn file)",
+	Name:    "genconfig",
+	Usage:   "Generate client config for the user. (.ovpn file)",
+	Aliases: []string{"g"},
 	Flags: []cli.Flag{
 		cli.StringFlag{
 			Name:  "user, u",

+ 6 - 4
cmd/ovpm/vpn.go

@@ -13,8 +13,9 @@ import (
 )
 
 var vpnStatusCommand = cli.Command{
-	Name:  "status",
-	Usage: "Show VPN status.",
+	Name:    "status",
+	Usage:   "Show VPN status.",
+	Aliases: []string{"s"},
 	Action: func(c *cli.Context) error {
 		conn := getConn(c.GlobalString("daemon-port"))
 		defer conn.Close()
@@ -41,8 +42,9 @@ var vpnStatusCommand = cli.Command{
 }
 
 var vpnInitCommand = cli.Command{
-	Name:  "init",
-	Usage: "Initialize VPN server.",
+	Name:    "init",
+	Usage:   "Initialize VPN server.",
+	Aliases: []string{"i"},
 	Flags: []cli.Flag{
 		cli.StringFlag{
 			Name:  "hostname, s",

+ 1 - 1
const.go

@@ -2,7 +2,7 @@ package ovpm
 
 const (
 	// Version defines the version of ovpm.
-	Version = "0.1.9"
+	Version = "0.1.10"
 
 	// DefaultVPNPort is the default OpenVPN port to listen.
 	DefaultVPNPort = "1197"

+ 5 - 2
net_test.go

@@ -183,10 +183,13 @@ func TestNetAssociate(t *testing.T) {
 	cidrStr := "192.168.1.0/24"
 	netType := SERVERNET
 	userName := "testUser2"
-	user, _ := CreateNewUser(userName, "123", false, 0)
+	user, err := CreateNewUser(userName, "123", false, 0)
+	if err != nil {
+		t.Fatal(err)
+	}
 
 	n, _ := CreateNewNetwork(netName, cidrStr, netType, "")
-	err := n.Associate(user.Username)
+	err = n.Associate(user.Username)
 	if err != nil {
 		t.Fatal(err)
 	}

+ 4 - 0
template/ccd.file.tmpl

@@ -1,5 +1,9 @@
 ifconfig-push {{ .IP }} {{ .NetMask }}
 #iroute 192.168.90.0 255.255.255.0
+{{if .RedirectGW }}
+push "redirect-gateway def1 bypass-dhcp"
+{{ end }}
+
 {{range .Routes}}
 push "route {{index . 0}} {{index . 1}} {{index . 2}}"
 {{ end }}

+ 1 - 1
template/server.conf.tmpl

@@ -173,7 +173,7 @@ crl-verify {{ .CRLPath }}
 # or bridge the TUN/TAP interface to the internet
 # in order for this to work properly).
 ;push "redirect-gateway def1 bypass-dhcp"
-push "redirect-gateway def1 bypass-dhcp"
+;push "redirect-gateway def1 bypass-dhcp"
 
 # Certain Windows-specific network settings
 # can be pushed to clients, such as DNS

+ 5 - 14
vpn.go

@@ -511,16 +511,6 @@ func emitCCD() error {
 				for _, assocUsername := range network.GetAssociatedUsernames() {
 					if assocUsername == user.Username {
 						via := network.Via
-						if via == "" {
-							server, err := GetServerInstance()
-							if err != nil {
-								return err
-							}
-							via, err = IncrementIP(server.Net, server.Mask)
-							if err != nil {
-								return err
-							}
-						}
 						ip, mask, err := net.ParseCIDR(network.CIDR)
 						if err != nil {
 							return err
@@ -532,10 +522,11 @@ func emitCCD() error {
 		}
 		var result bytes.Buffer
 		params := struct {
-			IP      string
-			NetMask string
-			Routes  [][3]string // [0] is IP, [1] is Netmask, [2] is Via
-		}{IP: user.getIP().String(), NetMask: _DefaultServerNetMask, Routes: associatedRoutes}
+			IP         string
+			NetMask    string
+			Routes     [][3]string // [0] is IP, [1] is Netmask, [2] is Via
+			RedirectGW bool
+		}{IP: user.getIP().String(), NetMask: _DefaultServerNetMask, Routes: associatedRoutes, RedirectGW: !user.NoGW}
 
 		data, err := bindata.Asset("template/ccd.file.tmpl")
 		if err != nil {

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff