소스 검색

refactor(vpn): issue warning when user reported online by OpenVPN is not found in dbWe were giving errors when the CN reported by the OpenVPN mismatcheswith the records in the db.Now we are logging WARNING messages instead of errors when this happens.

Mustafa Arici 7 년 전
부모
커밋
876ce4fa2d
2개의 변경된 파일11개의 추가작업 그리고 8개의 파일을 삭제
  1. 6 6
      bindata/bindata.go
  2. 5 2
      vpn.go

+ 6 - 6
bindata/bindata.go

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

+ 5 - 2
vpn.go

@@ -647,12 +647,15 @@ func GetConnectedUsers() ([]User, error) {
 		panic(err)
 		panic(err)
 	}
 	}
 
 
-	cl, _ := parseStatusLog(f)
+	cl, _ := parseStatusLog(f) // client list from OpenVPN status log
 	for _, c := range cl {
 	for _, c := range cl {
 		var u dbUserModel
 		var u dbUserModel
 		q := db.Where(dbUserModel{Username: c.CommonName}).First(&u)
 		q := db.Where(dbUserModel{Username: c.CommonName}).First(&u)
 		if q.RecordNotFound() {
 		if q.RecordNotFound() {
-			return nil, fmt.Errorf("common name reported by the OpenVPN is not found in the database: username='%s'", c.CommonName)
+			logrus.WithFields(
+				logrus.Fields{"CommonName": c.CommonName},
+			).Error("user not found: common name reported by the OpenVPN is not found in the database")
+			continue
 		}
 		}
 		if err := q.Error; err != nil {
 		if err := q.Error; err != nil {
 			return nil, fmt.Errorf("unknown db error: %v", err)
 			return nil, fmt.Errorf("unknown db error: %v", err)