diff --git a/setup.py b/setup.py index 2417a61..c253d61 100755 --- a/setup.py +++ b/setup.py @@ -15,7 +15,6 @@ url='https://github.com/sorz/sstp-server', packages=['sstpd'], ext_modules = [fcsmodule], - data_files=[('', ['README.rst'])], entry_points=""" [console_scripts] sstpd = sstpd:main diff --git a/sstp-server.ini b/sstp-server.ini new file mode 100644 index 0000000..7fa26d8 --- /dev/null +++ b/sstp-server.ini @@ -0,0 +1,38 @@ +[DEAFULT] +# 1 to 50. Default 20, debug 10, verbose 5 +;log_level = 20 + +# OpenSSL cipher suite. See ciphers(1). +;cipher = EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH + +# Path to pppd +;pppd = /usr/bin/pppd + +[site1] +# To start with [site1] config, execute: +# sstpd -f /path/to/config.ini -s site1 +# Config here will override items on [DEFAULT], +# and cmdline args override the config file. + +listen = 0.0.0.0 +port = 443 + +# PEM-format certificate with key. +pem_cert = /path/to/cert.pem + +# Address of server side on ppp. +local = 192.168.20.1 + +# If RADIUS is used to mangle IP pool, comment it out. +remote = 192.168.20.0/24 + +# pppd config file path +;pppd_config = /etc/ppp/options.sstpd + +[no-ssl] +# Use plain HTTP instead of HTTPS. Useful when running behind proxy. +no_ssl = yes + +listen = 127.0.0.1 +port = 4433 + diff --git a/sstpd/__main__.py b/sstpd/__main__.py index 911def7..08827ae 100755 --- a/sstpd/__main__.py +++ b/sstpd/__main__.py @@ -2,6 +2,7 @@ import sys import logging import argparse +from ConfigParser import SafeConfigParser, NoSectionError from twisted.internet.endpoints import SSL4ServerEndpoint from twisted.internet import reactor, ssl @@ -10,9 +11,31 @@ def _getArgs(): - parser = argparse.ArgumentParser(description='A Secure Socket Tunneling ' - 'Protocol (SSTP) server.', - epilog='Author: Sorz .') + conf_parser = argparse.ArgumentParser( + description='A Secure Socket Tunneling Protocol (SSTP) server.', + epilog='Author: Sorz .', + add_help=False) + conf_parser.add_argument("-f", "--conf-file", + help="Specify config file.", metavar="FILE") + conf_parser.add_argument("-s", "--conf-section", + help="Specify section name on config file.", + metavar="SITE", default="DEFAULT") + + args, remaining_argv = conf_parser.parse_known_args() + defaults = {} + if args.conf_file: + config = SafeConfigParser() + config.read(args.conf_file) + try: + defaults = dict(config.items(args.conf_section)) + except NoSectionError as e: + print('Error: section [%s] not found in config file.' % \ + args.conf_section) + sys.exit(1) + return + + parser = argparse.ArgumentParser(parents=[conf_parser]) + parser.set_defaults(**defaults) parser.add_argument('-l', '--listen', default='', metavar='ADDRESS',