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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/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>]"
print " type: pptp"
print " <name> <host> <domain> <user> <password>"
print " type: l2tp"
print " <name> <host> <domain> <user> <password>"
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":
if (len(sys.argv) < 6):
path = manager.ConnectProvider(({ "Type": "openvpn",
"Name": sys.argv[2],
"Host": sys.argv[3],
"VPN.Domain": sys.argv[4] }))
else:
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]}))
elif sys.argv[1] == "pptp":
path = manager.ConnectProvider(({ "Type": "pptp",
"Name": sys.argv[2],
"Host": sys.argv[3],
"VPN.Domain": sys.argv[4],
"PPTP.User": sys.argv[5],
"PPTP.Password": sys.argv[6]}))
elif sys.argv[1] == "l2tp":
path = manager.ConnectProvider(({ "Type": "l2tp",
"Name": sys.argv[2],
"Host": sys.argv[3],
"VPN.Domain": sys.argv[4],
"L2TP.User": sys.argv[5],
"L2TP.Password": sys.argv[6]}))
else:
print "Unknown VPN type"
sys.exit(1)
print "VPN service path is %s" %(path)
|