Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: test/connect-vpn

Issue 6513009: flimflam: Add L2TP/IPsec VPN plugin (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flimflam.git@master
Patch Set: Add gateway when requested Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/task.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import optparse 6 import optparse
7 import pprint, sys 7 import pprint, sys
8 import dbus, flimflam 8 import dbus, flimflam
9 9
10 def show_usage(parser, vpn_type):
11 parser.error("Incorrect number of parameters provided for %s" % vpn_type)
12
10 def main(argv): 13 def main(argv):
11 parser = optparse.OptionParser('%prog [options]... (VPN)\n\n' 14 parser = optparse.OptionParser(
12 ' VPN := openvpn <vpn-name> ' 15 "%prog [options]... (VPN)\n"
13 '<remote-host-ip> <vpn-domain>\n ' 16 "\n"
14 ' <ca-file> <client-cert-file> ' 17 " VPN := openvpn <vpn-name> <remote-host-ip> <vpn-domain>\n"
15 '<client-key-file>') 18 " <ca-file> <client-cert-file> <client-key-file>\n"
16 parser.add_option('--verbose', 19 " | l2tpipsec <vpn-name> <remote-host-ip> <vpn-domain>\n"
17 dest = 'verbose', 20 " <ca-file> <client-cert-file> <client-key-file>\n"
18 action = 'store_true', 21 " <ipsec-psk> <username> <password>")
22 parser.add_option("--verbose",
23 dest = "verbose",
24 action = "store_true",
19 default = False, 25 default = False,
20 help = "Output diagnostic information during run.") 26 help = "Output diagnostic information during run.")
21 parser.add_option('--complzo', 27 parser.add_option("--complzo",
22 dest = 'complzo', 28 dest = "complzo",
23 action = 'store_true', 29 action = "store_true",
24 default = True, 30 default = True,
25 help = "Enables the OpenVPN option 'complzo' (default). ") 31 help = ("Enables the OpenVPN option 'complzo' "
26 parser.add_option('--no-complzo', 32 "(default)"))
27 dest = 'complzo', 33 parser.add_option("--no-complzo",
28 action = 'store_false', 34 dest = "complzo",
35 action = "store_false",
29 help = "Disables the OpenVPN option 'complzo'.") 36 help = "Disables the OpenVPN option 'complzo'.")
30 parser.add_option('--remote-cert-tls', 37 parser.add_option("--remote-cert-tls",
31 dest = 'remote_cert_tls', 38 dest = "remote_cert_tls",
32 action = 'store', 39 action = "store",
33 default = 'server', 40 default = "server",
34 type = 'string', 41 type = "string",
35 metavar = '(server | client | none)', 42 metavar = "(server | client | none)",
36 help = "This is passed through to OpenVPN when " 43 help = ("This is passed through to OpenVPN when "
37 "not 'none'.") 44 "not 'none'."))
38 45
39 (options, args) = parser.parse_args(argv[1:]) 46 (options, args) = parser.parse_args(argv[1:])
40 47
41 if (len(args) > 1): 48 if (len(args) > 1):
42 params = { "Type" : args[0] } 49 params = { "Type" : args[0] }
43 50
44 if params["Type"] == "openvpn": 51 if params["Type"] == "openvpn":
45 if (len(args) == 7): 52 if (len(args) == 7):
46 params["Name"] = args[1] 53 params["Name"] = args[1]
47 params["Host"] = args[2] 54 params["Host"] = args[2]
48 params["VPN.Domain"] = args[3] 55 params["VPN.Domain"] = args[3]
49 params["OpenVPN.CACert"] = args[4] 56 params["OpenVPN.CACert"] = args[4]
50 params["OpenVPN.Cert"] = args[5] 57 params["OpenVPN.Cert"] = args[5]
51 params["OpenVPN.Key"] = args[6] 58 params["OpenVPN.Key"] = args[6]
52 59
53 if options.complzo: # 'complzo' can only be enabled. 60 if options.complzo: # "complzo" can only be enabled.
54 params["OpenVPN.CompLZO"] = 'true' 61 params["OpenVPN.CompLZO"] = "true"
55 62
56 if options.remote_cert_tls != 'server' and \ 63 if (options.remote_cert_tls != "server" and
57 options.remote_cert_tls != 'client' and \ 64 options.remote_cert_tls != "client" and
58 options.remote_cert_tls != 'none': 65 options.remote_cert_tls != "none"):
59 print "\n--remote-cert-tls argument ('%s') " \ 66 print("\n--remote-cert-tls argument ('%s') "
60 "is invalid.\n" % options.remote_cert_tls 67 "is invalid.\n" % options.remote_cert_tls)
61 sys.exit(1) 68 sys.exit(1)
62 69
63 params["OpenVPN.RemoteCertTLS"] = options.remote_cert_tls 70 params["OpenVPN.RemoteCertTLS"] = options.remote_cert_tls
64 else: 71 else:
65 parser.error("Incorrect number of parameters " 72 show_usage(parser, params["Type"])
66 "provided for 'openvpn'") 73 elif params["Type"] == "l2tpipsec":
74 if len(args) == 10:
75 params["Name"] = args[1]
76 params["Host"] = args[2]
77 params["VPN.Domain"] = args[3]
78 params["L2TPIPsec.CACert"] = args[4]
79 params["L2TPIPsec.Cert"] = args[5]
80 params["L2TPIPsec.Key"] = args[6]
81 params["L2TPIPsec.PSK"] = args[7]
82 params["L2TPIPsec.User"] = args[8]
83 params["L2TPIPsec.Password"] = args[9]
84 else:
85 show_usage(parser, params["Type"])
67 else: 86 else:
68 print "Unknown VPN type: '%s'" % params["Type"] 87 print "Unknown VPN type: '%s'" % params["Type"]
69 sys.exit(1) 88 sys.exit(1)
70 89
71 if options.verbose: 90 if options.verbose:
72 print "\nVPN Startup Parameters:\n" 91 print "\nVPN Startup Parameters:\n"
73 for k, v in params.iteritems(): 92 for k, v in params.iteritems():
74 print " %25s: '%s'" % (k, v) 93 print " %25s: '%s'" % (k, v)
75 print "" 94 print ""
76 95
77 flim = flimflam.FlimFlam(dbus.SystemBus()) 96 flim = flimflam.FlimFlam(dbus.SystemBus())
78 service = flim.GetVPNService(params) 97 service = flim.GetVPNService(params)
79 98
80 if options.verbose == 'true': 99 if options.verbose == "true":
81 print "VPN is %s, connecting..." % service.object_path 100 print "VPN is %s, connecting..." % service.object_path
82 101
83 (success, diagnostics) = flim.ConnectService(service_type = 'vpn', 102 (success, diagnostics) = flim.ConnectService(service_type = "vpn",
84 service = service) 103 service = service)
85 if not success or options.verbose: 104 if not success or options.verbose:
86 print 'Success:', success 105 print "Success:", success
87 pprint.pprint(diagnostics) 106 pprint.pprint(diagnostics)
88 else: 107 else:
89 parser.print_help() 108 parser.print_help()
90 sys.exit(1) 109 sys.exit(1)
91 110
92 if __name__ == '__main__': 111 if __name__ == '__main__':
93 main(sys.argv) 112 main(sys.argv)
OLDNEW
« no previous file with comments | « src/task.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698