소스 검색

Merge branch 'release-v0.1.14'

Mustafa Arici 8 년 전
부모
커밋
5845e2efca
5개의 변경된 파일45개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 0
      CHANGELOG.md
  2. 1 1
      bindata/bindata.go
  3. 24 0
      cmd/ovpm/vpn.go
  4. 1 1
      const.go
  5. 15 0
      vpn.go

+ 4 - 0
CHANGELOG.md

@@ -105,3 +105,7 @@
 - implement remote control proto [\#8](https://github.com/cad/ovpm/issues/8)
 - 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)*

+ 1 - 1
bindata/bindata.go

@@ -167,7 +167,7 @@ func templateServerConfTmpl() (*asset, error) {
 		return nil, err
 	}
 
-	info := bindataFileInfo{name: "template/server.conf.tmpl", size: 9600, mode: os.FileMode(420), modTime: time.Unix(1504442070, 0)}
+	info := bindataFileInfo{name: "template/server.conf.tmpl", size: 9600, mode: os.FileMode(420), modTime: time.Unix(1504442511, 0)}
 	a := &asset{bytes: bytes, info: info}
 	return a, nil
 }

+ 24 - 0
cmd/ovpm/vpn.go

@@ -169,6 +169,30 @@ var vpnUpdateCommand = cli.Command{
 			os.Exit(1)
 		}
 
+		if ipblock != "" {
+			var response string
+			for {
+				fmt.Println("If you proceed, you will loose all your static ip definitions.")
+				fmt.Println("Any user that is defined to have a static ip will be set to be dynamic again.")
+				fmt.Println()
+				fmt.Println("Are you sure ? (y/N)")
+				_, err := fmt.Scanln(&response)
+				if err != nil {
+					logrus.Fatal(err)
+					os.Exit(1)
+					return err
+				}
+				okayResponses := []string{"y", "Y", "yes", "Yes", "YES"}
+				nokayResponses := []string{"n", "N", "no", "No", "NO"}
+				if stringInSlice(response, okayResponses) {
+					break
+				} else if stringInSlice(response, nokayResponses) {
+					return fmt.Errorf("user decided to cancel")
+				}
+			}
+
+		}
+
 		dns := c.String("dns")
 		if dns != "" && !govalidator.IsIPv4(dns) {
 			fmt.Println("--dns takes an IPv4 address. e.g. 8.8.8.8")

+ 1 - 1
const.go

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

+ 15 - 0
vpn.go

@@ -270,6 +270,9 @@ func Init(hostname string, port string, proto string, ipblock string, dns string
 			logrus.Errorf("can not sign user %s: %v", user.Username, err)
 			continue
 		}
+		// Set dynamic ip to user.
+		user.HostID = 0
+		db.Save(&user.dbUserModel)
 	}
 	Emit()
 	logrus.Infof("server initialized")
@@ -305,6 +308,18 @@ func Update(ipblock string, dns string) error {
 	}
 	if changed {
 		db.Save(server.dbServerModel)
+		users, err := GetAllUsers()
+		if err != nil {
+			return err
+		}
+
+		// Set all users to dynamic ip address.
+		// This way we prevent any ip range mismatch.
+		for _, user := range users {
+			user.HostID = 0
+			db.Save(user.dbUserModel)
+		}
+
 		Emit()
 		logrus.Infof("server updated")
 	}