# Path: sshuttle/options.py
# def parse_subnetport_file(s):
# def parse_subnetport(s):
# def parse_ipport(s):
# def parse_list(lst):
#     def __init__(self, option_strings, dest, nargs=None, **kwargs):
#     def __call__(self, parser, namespace, values, option_string=None):
#     def convert_arg_line_to_args(self, arg_line):
# class Concat(Action):
# class MyArgumentParser(ArgumentParser):
# 
# Path: sshuttle/helpers.py
# def family_ip_tuple(ip):
#     if ':' in ip:
#         return (socket.AF_INET6, ip)
#     else:
#         return (socket.AF_INET, ip)
# 
# def log(s):
#     global logprefix
#     try:
#         sys.stdout.flush()
#         # Put newline at end of string if line doesn't have one.
#         if not s.endswith("\n"):
#             s = s+"\n"
# 
#         prefix = logprefix
#         s = s.rstrip("\n")
#         for line in s.split("\n"):
#             # We output with \r\n instead of \n because when we use
#             # sudo with the use_pty option, the firewall process, the
#             # other processes printing to the terminal will have the
#             # \n move to the next line, but they will fail to reset
#             # cursor to the beginning of the line. Printing output
#             # with \r\n endings fixes that problem and does not appear
#             # to cause problems elsewhere.
#             sys.stderr.write(prefix + line + "\r\n")
#             prefix = "    "
#         sys.stderr.flush()
#     except IOError:
#         # this could happen if stderr gets forcibly disconnected, eg. because
#         # our tty closes.  That sucks, but it's no reason to abort the program.
#         pass
# 
# class Fatal(Exception):
#     pass
# 
# Path: sshuttle/sudoers.py
# def sudoers(user_name=None, no_modify=None, file_name=None):
#     user_name = user_name or getpass.getuser()
#     content = build_config(user_name)
# 
#     if no_modify:
#         sys.stdout.write(content)
#         exit(0)
#     else:
#         sys.stdout.write(warning_msg)
#         save_config(content, file_name)


import re
import socket
import platform
import sshuttle.helpers as helpers
import sshuttle.client as client
import sshuttle.firewall as firewall
import sshuttle.hostwatch as hostwatch
import sshuttle.ssyslog as ssyslog
        import sshuttle.ssnet as ssnet
        import sshuttle.ssnet as ssnet
from sshuttle.options import parser, parse_ipport
from sshuttle.helpers import family_ip_tuple, log, Fatal
from sshuttle.sudoers import sudoers


def main():
    opt = parser.parse_args()

    if opt.sudoers or opt.sudoers_no_modify:
        if platform.platform().startswith('OpenBSD'):
            log('Automatic sudoers does not work on BSD')
            return 1

        if not opt.sudoers_filename:
            log('--sudoers-file must be set or omitted.')
            return 1


# Path: sshuttle/options.py
# def parse_subnetport_file(s):
# def parse_subnetport(s):
# def parse_ipport(s):
# def parse_list(lst):
#     def __init__(self, option_strings, dest, nargs=None, **kwargs):
#     def __call__(self, parser, namespace, values, option_string=None):
#     def convert_arg_line_to_args(self, arg_line):
# class Concat(Action):
# class MyArgumentParser(ArgumentParser):
# 
# Path: sshuttle/helpers.py
# def family_ip_tuple(ip):
#     if ':' in ip:
#         return (socket.AF_INET6, ip)
#     else:
#         return (socket.AF_INET, ip)
# 
# def log(s):
#     global logprefix
#     try:
#         sys.stdout.flush()
#         # Put newline at end of string if line doesn't have one.
#         if not s.endswith("\n"):
#             s = s+"\n"
# 
#         prefix = logprefix
#         s = s.rstrip("\n")
#         for line in s.split("\n"):
#             # We output with \r\n instead of \n because when we use
#             # sudo with the use_pty option, the firewall process, the
#             # other processes printing to the terminal will have the
#             # \n move to the next line, but they will fail to reset
#             # cursor to the beginning of the line. Printing output
#             # with \r\n endings fixes that problem and does not appear
#             # to cause problems elsewhere.
#             sys.stderr.write(prefix + line + "\r\n")
#             prefix = "    "
#         sys.stderr.flush()
#     except IOError:
#         # this could happen if stderr gets forcibly disconnected, eg. because
#         # our tty closes.  That sucks, but it's no reason to abort the program.
#         pass
# 
# class Fatal(Exception):
#     pass
# 
# Path: sshuttle/sudoers.py
# def sudoers(user_name=None, no_modify=None, file_name=None):
#     user_name = user_name or getpass.getuser()
#     content = build_config(user_name)
# 
#     if no_modify:
#         sys.stdout.write(content)
#         exit(0)
#     else:
#         sys.stdout.write(warning_msg)
#         save_config(content, file_name)


# Path: sshuttle/cmdline.py
import re
import socket
import platform
import sshuttle.helpers as helpers
import sshuttle.client as client
import sshuttle.firewall as firewall
import sshuttle.hostwatch as hostwatch
import sshuttle.ssyslog as ssyslog
        import sshuttle.ssnet as ssnet
        import sshuttle.ssnet as ssnet
from sshuttle.options import parser, parse_ipport
from sshuttle.helpers import family_ip_tuple, log, Fatal
from sshuttle.sudoers import sudoers



def main():
    opt = parser.parse_args()

    if opt.sudoers or opt.sudoers_no_modify:
        if platform.platform().startswith('OpenBSD'):
            log('Automatic sudoers does not work on BSD')
            return 1

        if not opt.sudoers_filename:
            log('--sudoers-file must be set or omitted.')
            return 1


        sudoers(