summaryrefslogtreecommitdiff
path: root/test/connect-vpn
blob: a43c4cdb2e56cf7241d9254a37334d4435a74f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python

import sys
import dbus

if (len(sys.argv) < 4):
	print "Usage: %s <type> ... " % (sys.argv[0])
	print "  type: openconnect"
	print "      <name> <host> <domain> <cookie> [servercert]"
	print "  type: openvpn"
	print "      <name> <host> <domain> <cafile> <certfile> <keyfile>"
	sys.exit(1)

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object("net.connman", "/"),
					"net.connman.Manager")

print "Attempting to connect service %s" % (sys.argv[3])

if sys.argv[1] == "openconnect":
	if (len(sys.argv) > 6):
		path = manager.ConnectProvider(({ "Type": "openconnect",
					"Name": sys.argv[2],
					"Host": sys.argv[3],
					"VPN.Domain": sys.argv[4],
					"OpenConnect.Cookie": sys.argv[5],
					"OpenConnect.ServerCert": sys.argv[6]}))
	else:
		path = manager.ConnectProvider(({ "Type": "openconnect",
					"Name": sys.argv[2],
					"Host": sys.argv[3],
					"VPN.Domain": sys.argv[4],
					"OpenConnect.Cookie": sys.argv[5]}))
elif sys.argv[1] == "openvpn":
	path = manager.ConnectProvider(({ "Type": "openvpn",
					"Name": sys.argv[2],
					"Host": sys.argv[3],
					"VPN.Domain": sys.argv[4],
					"OpenVPN.CACert": sys.argv[5],
					"OpenVPN.Cert": sys.argv[6],
					"OpenVPN.Key": sys.argv[7]}))
else:
	print "Unknown VPN type"
	sys.exit(1)

print "VPN service path is %s" %(path)