windows sux :)
This commit is contained in:
		
							parent
							
								
									eba6749ada
								
							
						
					
					
						commit
						dbdbe8aef0
					
				
							
								
								
									
										1
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								go.mod
									
									
									
									
									
								
							@ -5,4 +5,5 @@ require (
 | 
				
			|||||||
	github.com/onsi/gomega v1.5.0 // indirect
 | 
						github.com/onsi/gomega v1.5.0 // indirect
 | 
				
			||||||
	github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9
 | 
						github.com/pyke369/golang-support v0.0.0-20190703174728-34ca97aa79e9
 | 
				
			||||||
	gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
 | 
						gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
 | 
				
			||||||
 | 
						gopkg.in/ldap.v2 v2.5.1
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,33 +1,43 @@
 | 
				
			|||||||
#script-security 3
 | 
					# external files
 | 
				
			||||||
auth-user-pass-optional
 | 
					tls-auth          /etc/openvpn/tlsauth.key
 | 
				
			||||||
ca /usr/local/share/ca-certificates/Dailymotion.crt
 | 
					dh                /etc/openvpn/dh2048.pem
 | 
				
			||||||
cert /etc/ssl/certs/vpn.dailymotion.com-cert.pem
 | 
					ca                /usr/local/share/ca-certificates/Dailymotion.crt
 | 
				
			||||||
user openvpn
 | 
					cert              /etc/ssl/certs/vpn.dailymotion.com-cert.pem
 | 
				
			||||||
cipher aes-128-cbc
 | 
					key               /etc/ssl/private/vpn.dailymotion.com-key.pem
 | 
				
			||||||
dev vpnroadwarrior
 | 
					
 | 
				
			||||||
dev-type tun
 | 
					# local parameters
 | 
				
			||||||
dh dh2048.pem
 | 
					port              41690
 | 
				
			||||||
ifconfig 192.168.200.0 192.168.207.255
 | 
					tls-server
 | 
				
			||||||
ifconfig-nowarn
 | 
					mode              server
 | 
				
			||||||
keepalive 10 120
 | 
					ifconfig          192.168.200.1 255.255.248.0
 | 
				
			||||||
key /etc/ssl/private/vpn.dailymotion.com-key.pem
 | 
					topology          subnet
 | 
				
			||||||
management 127.0.0.1 4000
 | 
					dev               vpnadmin
 | 
				
			||||||
 | 
					dev-type          tun
 | 
				
			||||||
 | 
					#local             188.65.121.190
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# security
 | 
				
			||||||
 | 
					user              openvpn
 | 
				
			||||||
 | 
					group             openvpn
 | 
				
			||||||
 | 
					reneg-sec         43200
 | 
				
			||||||
 | 
					management        127.0.0.1 4000
 | 
				
			||||||
management-client
 | 
					management-client
 | 
				
			||||||
management-client-auth
 | 
					management-client-auth
 | 
				
			||||||
mode server
 | 
					auth-user-pass-optional
 | 
				
			||||||
group openvpn
 | 
					client-cert-not-required
 | 
				
			||||||
 | 
					username-as-common-name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# push
 | 
				
			||||||
 | 
					push              "dhcp-option DNS 10.190.32.2"
 | 
				
			||||||
 | 
					push              "dhcp-option DNS 10.190.32.20"
 | 
				
			||||||
 | 
					push              "route-gateway 192.168.200.1"
 | 
				
			||||||
 | 
					push              "topology subnet"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# crypto
 | 
				
			||||||
 | 
					cipher            aes-128-cbc
 | 
				
			||||||
 | 
					keepalive         10 120
 | 
				
			||||||
persist-key
 | 
					persist-key
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ifconfig-nowarn
 | 
				
			||||||
persist-remote-ip
 | 
					persist-remote-ip
 | 
				
			||||||
persist-tun
 | 
					persist-tun
 | 
				
			||||||
port 41690
 | 
					verb              0
 | 
				
			||||||
proto tcp-server
 | 
					 | 
				
			||||||
push "dhcp-option DNS 10.190.32.2"
 | 
					 | 
				
			||||||
push "dhcp-option DNS 10.190.32.20"
 | 
					 | 
				
			||||||
push "topology p2p"
 | 
					 | 
				
			||||||
reneg-sec 43200
 | 
					 | 
				
			||||||
tls-auth tlsauth.key
 | 
					 | 
				
			||||||
tls-server
 | 
					 | 
				
			||||||
topology p2p
 | 
					 | 
				
			||||||
username-as-common-name
 | 
					 | 
				
			||||||
verb 4
 | 
					 | 
				
			||||||
client-cert-not-required
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -35,6 +35,7 @@ type vpnSession struct {
 | 
				
			|||||||
	kID           int       `json:"-"`
 | 
						kID           int       `json:"-"`
 | 
				
			||||||
	port          int       `json:"-"`
 | 
						port          int       `json:"-"`
 | 
				
			||||||
	dev           string    `json:"-"`
 | 
						dev           string    `json:"-"`
 | 
				
			||||||
 | 
						netmask       string    `json:"-"`
 | 
				
			||||||
	password      string    `json:"-"`
 | 
						password      string    `json:"-"`
 | 
				
			||||||
	otpCode       string    `json:"-"`
 | 
						otpCode       string    `json:"-"`
 | 
				
			||||||
	localIP       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 {
 | 
					func (c *vpnSession) AddRoute(ip string) error {
 | 
				
			||||||
	var cmd *exec.Cmd
 | 
						var cmd *exec.Cmd
 | 
				
			||||||
	if os.Geteuid() == 0 {
 | 
						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 {
 | 
						} 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()
 | 
						return cmd.Run()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -180,6 +181,8 @@ func (c *vpnSession) ParseEnv(s *OpenVpnMgt, infos *[]string) error {
 | 
				
			|||||||
			c.Login = r.ReplaceAllString(p[1], "")
 | 
								c.Login = r.ReplaceAllString(p[1], "")
 | 
				
			||||||
		case "dev":
 | 
							case "dev":
 | 
				
			||||||
			c.dev = r.ReplaceAllString(p[1], "")
 | 
								c.dev = r.ReplaceAllString(p[1], "")
 | 
				
			||||||
 | 
							case "ifconfig_netmask":
 | 
				
			||||||
 | 
								c.netmask = r.ReplaceAllString(p[1], "")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
@ -208,7 +211,7 @@ func (c *vpnSession) Auth(s *OpenVpnMgt) {
 | 
				
			|||||||
	case ok == 0:
 | 
						case ok == 0:
 | 
				
			||||||
		cmd = []string{
 | 
							cmd = []string{
 | 
				
			||||||
			fmt.Sprintf("client-auth %d %d", c.cID, c.kID),
 | 
								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 {
 | 
							for _, r := range s.ldap[c.Profile].routes {
 | 
				
			||||||
			cmd = append(cmd, fmt.Sprintf("push \"route %s vpn_gateway\"", r))
 | 
								cmd = append(cmd, fmt.Sprintf("push \"route %s vpn_gateway\"", r))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user