Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
riseup_vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
leap
riseup_vpn
Commits
e8575286
Verified
Commit
e8575286
authored
6 years ago
by
meskio
Browse files
Options
Downloads
Patches
Plain Diff
[feat] add fixed openvpn args and parse the client ones
parent
fff37767
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
helper/args.go
+104
-0
104 additions, 0 deletions
helper/args.go
helper/darwin.go
+13
-4
13 additions, 4 deletions
helper/darwin.go
helper/helper.go
+2
-1
2 additions, 1 deletion
helper/helper.go
helper/linux.go
+7
-1
7 additions, 1 deletion
helper/linux.go
helper/windows.go
+9
-2
9 additions, 2 deletions
helper/windows.go
with
135 additions
and
8 deletions
helper/args.go
0 → 100644
+
104
−
0
View file @
e8575286
package
main
import
(
"log"
"net"
"os"
"regexp"
"strconv"
)
const
(
openvpnUser
=
"nobody"
openvpnGroup
=
"nobody"
nameserver
=
"10.42.0.1"
)
var
(
fixedArgs
=
[]
string
{
"--nobind"
,
"--client"
,
"--dev"
,
"tun"
,
"--tls-client"
,
"--remote-cert-tls"
,
"server"
,
"--dhcp-option"
,
"DNS"
,
nameserver
,
"--user"
,
openvpnUser
,
"--group"
,
openvpnGroup
,
"--log"
,
logFolder
+
"openvpn.log"
,
}
allowendArgs
=
map
[
string
][]
string
{
"--remote"
:
[]
string
{
"IP"
,
"NUMBER"
,
"PROTO"
},
"--tls-cipher"
:
[]
string
{
"CIPHER"
},
"--cipher"
:
[]
string
{
"CIPHER"
},
"--auth"
:
[]
string
{
"CIPHER"
},
"--management-client"
:
[]
string
{},
"--management"
:
[]
string
{
"IP"
,
"NUMBER"
},
"--cert"
:
[]
string
{
"FILE"
},
"--key"
:
[]
string
{
"FILE"
},
"--ca"
:
[]
string
{
"FILE"
},
"--fragment"
:
[]
string
{
"NUMBER"
},
"--keepalive"
:
[]
string
{
"NUMBER"
,
"NUMBER"
},
"--verb"
:
[]
string
{
"NUMBER"
},
"--tun-ipv6"
:
[]
string
{},
}
cipher
=
regexp
.
MustCompile
(
"^[A-Z0-9-]+$"
)
formats
=
map
[
string
]
func
(
s
string
)
bool
{
"NUMBER"
:
isNumber
,
"PROTO"
:
isProto
,
"IP"
:
isIP
,
"CIPHER"
:
cipher
.
MatchString
,
"FILE"
:
isFile
,
}
)
func
parseOpenvpnArgs
(
args
[]
string
)
[]
string
{
newArgs
:=
fixedArgs
for
i
:=
0
;
i
<
len
(
args
);
i
++
{
params
,
ok
:=
allowendArgs
[
args
[
i
]]
if
!
ok
{
log
.
Printf
(
"Invalid openvpn arg: %s"
,
args
[
i
])
continue
}
for
j
,
arg
:=
range
args
[
i
+
1
:
i
+
len
(
params
)
+
1
]
{
if
!
formats
[
params
[
j
]](
arg
)
{
ok
=
false
break
}
}
if
ok
{
newArgs
=
append
(
newArgs
,
args
[
i
:
i
+
len
(
params
)
+
1
]
...
)
i
=
i
+
len
(
params
)
}
else
{
log
.
Printf
(
"Invalid openvpn arg params: %v"
,
args
[
i
:
i
+
len
(
params
)
+
1
])
}
}
return
newArgs
}
func
isNumber
(
s
string
)
bool
{
_
,
err
:=
strconv
.
Atoi
(
s
)
return
err
==
nil
}
func
isProto
(
s
string
)
bool
{
for
_
,
proto
:=
range
[]
string
{
"tcp"
,
"udp"
,
"tcp4"
,
"udp4"
,
"tcp6"
,
"udp6"
}
{
if
s
==
proto
{
return
true
}
}
return
false
}
func
isIP
(
s
string
)
bool
{
return
net
.
ParseIP
(
s
)
!=
nil
}
func
isFile
(
s
string
)
bool
{
info
,
err
:=
os
.
Stat
(
s
)
if
err
!=
nil
{
return
false
}
return
!
info
.
IsDir
()
}
This diff is collapsed.
Click to expand it.
helper/darwin.go
+
13
−
4
View file @
e8575286
...
...
@@ -39,17 +39,26 @@ import (
)
const
(
logPath
=
"/Applications/RiseupVPN.app/Contents/helper/helper.log"
openvpnPath
=
"/Applications/RiseupVPN.app/Contents/Resources/openvpn.leap"
appPath
=
"/Applications/RiseupVPN.app/"
helperPath
=
appPath
+
"Contents/helper/"
logFolder
=
helperPath
openvpnPath
=
appPath
+
"Contents/Resources/openvpn.leap"
rulefilePath
=
"/Applications/RiseupVPN.app/Contents/helper/
bitmask.pf.conf"
rulefilePath
=
helperPath
+
"
bitmask.pf.conf"
bitmask_anchor
=
"com.apple/250.BitmaskFirewall"
gateways_table
=
"bitmask_gateways"
nameserver
=
"10.42.0.1"
pfctl
=
"/sbin/pfctl"
)
var
(
platformOpenvpnFlags
=
[]
string
{
"--script-security"
,
"2"
,
"--up"
,
helperPath
+
"client.up.sh"
,
"--down"
,
helperPath
+
"client.down.sh"
,
}
)
func
daemonize
()
{
cntxt
:=
&
daemon
.
Context
{
PidFileName
:
"pid"
,
...
...
This diff is collapsed.
Click to expand it.
helper/helper.go
+
2
−
1
View file @
e8575286
...
...
@@ -63,6 +63,7 @@ func (openvpn *openvpnT) start(w http.ResponseWriter, r *http.Request) {
return
}
args
=
parseOpenvpnArgs
(
args
)
log
.
Printf
(
"start openvpn: %v"
,
args
)
err
=
openvpn
.
run
(
args
)
if
err
!=
nil
{
...
...
@@ -145,7 +146,7 @@ func getArgs(r *http.Request) ([]string, error) {
}
func
configureLogger
()
(
io
.
Closer
,
error
)
{
logFile
,
err
:=
os
.
OpenFile
(
log
Path
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0666
)
logFile
,
err
:=
os
.
OpenFile
(
log
Folder
+
"helper.log"
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0666
)
if
err
==
nil
{
log
.
SetOutput
(
io
.
MultiWriter
(
logFile
,
os
.
Stderr
))
}
...
...
This diff is collapsed.
Click to expand it.
helper/linux.go
+
7
−
1
View file @
e8575286
...
...
@@ -23,11 +23,17 @@ import (
)
const
(
log
Path
=
"/var/log/
riseupvpn-helper.log
"
log
Folder
=
"/var/log/"
systemOpenvpnPath
=
"/usr/sbin/openvpn"
snapOpenvpnPath
=
"/snap/bin/riseup-vpn.openvpn"
)
var
(
platformOpenvpnFlags
=
[]
string
{
"--script-security"
,
"1"
,
}
)
func
daemonize
()
{}
func
getOpenvpnPath
()
string
{
...
...
This diff is collapsed.
Click to expand it.
helper/windows.go
+
9
−
2
View file @
e8575286
...
...
@@ -23,11 +23,18 @@ import (
)
const
(
logPath
=
`C:\Program Files\RiseupVPN\helper.log`
openvpnPath
=
`C:\Program Files\RiseupVPN\openvpn.exe`
appPath
=
`C:\Program Files\RiseupVPN\`
logFolder
=
appPath
openvpnPath
=
appPath
+
`openvpn.exe`
chocoOpenvpnPath
=
`C:\Program Files\OpenVPN\bin\openvpn.exe`
)
var
(
platformOpenvpnFlags
=
[]
string
{
"--script-security"
,
"1"
,
}
)
func
daemonize
()
{}
func
getOpenvpnPath
()
string
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment