MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / main

Function main

sshuttle/cmdline.py:17–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16
17def main():
18 if 'SSHUTTLE_ARGS' in os.environ:
19 env_args = shlex.split(os.environ['SSHUTTLE_ARGS'])
20 else:
21 env_args = []
22 args = [*env_args, *sys.argv[1:]]
23
24 opt = parser.parse_args(args)
25
26 if opt.sudoers_no_modify:
27 # sudoers() calls exit() when it completes
28 sudoers(user_name=opt.sudoers_user)
29
30 if opt.daemon:
31 opt.syslog = 1
32 if opt.wrap:
33 import sshuttle.ssnet as ssnet
34 ssnet.MAX_CHANNEL = opt.wrap
35 if opt.latency_buffer_size:
36 import sshuttle.ssnet as ssnet
37 ssnet.LATENCY_BUFFER_SIZE = opt.latency_buffer_size
38 helpers.verbose = opt.verbose
39
40 try:
41 # Since namespace and namespace-pid options are only available
42 # in linux, we must check if it exists with getattr
43 namespace = getattr(opt, 'namespace', None)
44 namespace_pid = getattr(opt, 'namespace_pid', None)
45 if namespace or namespace_pid:
46 prefix = helpers.logprefix
47 helpers.logprefix = 'ns: '
48 enter_namespace(namespace, namespace_pid)
49 helpers.logprefix = prefix
50
51 if opt.firewall:
52 if opt.subnets or opt.subnets_file:
53 parser.error('exactly zero arguments expected')
54 return firewall.main(opt.method, opt.syslog)
55 elif opt.hostwatch:
56 hostwatch.hw_main(opt.subnets, opt.auto_hosts)
57 return 0
58 else:
59 # parse_subnetports() is used to create a list of includes
60 # and excludes. It is called once for each parameter and
61 # returns a list of one or more items for each subnet (it
62 # can return more than one item when a hostname in the
63 # parameter resolves to multiple IP addresses. Here, we
64 # flatten these lists.
65 includes = [item for sublist in opt.subnets+opt.subnets_file
66 for item in sublist]
67 excludes = [item for sublist in opt.exclude for item in sublist]
68
69 if not includes and not opt.auto_nets:
70 parser.error('at least one subnet, subnet file, '
71 'or -N expected')
72 remotename = opt.remote
73 if remotename == '' or remotename == '-':
74 remotename = None

Callers 1

__main__.pyFile · 0.90

Calls 5

sudoersFunction · 0.90
enter_namespaceFunction · 0.90
family_ip_tupleFunction · 0.90
parse_ipportFunction · 0.90
logFunction · 0.90

Tested by

no test coverage detected