windows sux :)
This commit is contained in:
@@ -35,6 +35,7 @@ type vpnSession struct {
|
||||
kID int `json:"-"`
|
||||
port int `json:"-"`
|
||||
dev string `json:"-"`
|
||||
netmask string `json:"-"`
|
||||
password string `json:"-"`
|
||||
otpCode string `json:"-"`
|
||||
localIP string `json:"-"`
|
||||
@@ -74,9 +75,9 @@ func (c *vpnSession) baseHash(salt string, i int64) string {
|
||||
func (c *vpnSession) AddRoute(ip string) error {
|
||||
var cmd *exec.Cmd
|
||||
if os.Geteuid() == 0 {
|
||||
cmd = exec.Command("/bin/ip", "route", "replace", ip, "dev", c.dev)
|
||||
cmd = exec.Command("/bin/ip", "route", "replace", ip+"/32", "dev", c.dev)
|
||||
} else {
|
||||
cmd = exec.Command("/usr/bin/sudo", "/bin/ip", "route", "replace", ip, "dev", c.dev)
|
||||
cmd = exec.Command("/usr/bin/sudo", "/bin/ip", "route", "replace", ip+"/32", "dev", c.dev)
|
||||
}
|
||||
return cmd.Run()
|
||||
}
|
||||
@@ -180,6 +181,8 @@ func (c *vpnSession) ParseEnv(s *OpenVpnMgt, infos *[]string) error {
|
||||
c.Login = r.ReplaceAllString(p[1], "")
|
||||
case "dev":
|
||||
c.dev = r.ReplaceAllString(p[1], "")
|
||||
case "ifconfig_netmask":
|
||||
c.netmask = r.ReplaceAllString(p[1], "")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -208,7 +211,7 @@ func (c *vpnSession) Auth(s *OpenVpnMgt) {
|
||||
case ok == 0:
|
||||
cmd = []string{
|
||||
fmt.Sprintf("client-auth %d %d", c.cID, c.kID),
|
||||
fmt.Sprintf("ifconfig-push %s %s", ip, c.localIP),
|
||||
fmt.Sprintf("ifconfig-push %s %s", ip, c.netmask),
|
||||
}
|
||||
for _, r := range s.ldap[c.Profile].routes {
|
||||
cmd = append(cmd, fmt.Sprintf("push \"route %s vpn_gateway\"", r))
|
||||
|
||||
Reference in New Issue
Block a user