From 918b8e83a252e0b28164502f3c4f5d09044e6fc0 Mon Sep 17 00:00:00 2001
From: sorz <orz@sorz.org>
Date: Wed, 11 Jan 2017 22:03:01 +0800
Subject: [PATCH] Move version number & add docstring

---
 setup.py          | 11 +++++++----
 sstpd/__init__.py | 10 +++++++++-
 sstpd/__main__.py | 13 +++++++------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/setup.py b/setup.py
index c253d61..385df2c 100755
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,9 @@
 #!/usr/bin/env python2
 from setuptools import setup, Extension
 
+from sstpd import __version__ as version
+
+
 with open('README.rst') as readme:
     long_description = readme.read()
 
@@ -8,16 +11,16 @@
 
 setup(
     name='sstp-server',
-    version='0.3.6',
+    version=version,
     description='Secure Socket Tunneling Protocol (SSTP) VPN server.',
-    author='Sorz',
-    author_email='orz@sorz.org',
+    author='Shell Chen',
+    author_email='me@sorz.org',
     url='https://github.com/sorz/sstp-server',
     packages=['sstpd'],
     ext_modules = [fcsmodule],
     entry_points="""
     [console_scripts]
-    sstpd = sstpd:main
+    sstpd = sstpd:run
     """,
     install_requires=[
         'twisted', 'service_identity', 'argparse', 'py2-ipaddress'
diff --git a/sstpd/__init__.py b/sstpd/__init__.py
index c7af93c..386ba8e 100644
--- a/sstpd/__init__.py
+++ b/sstpd/__init__.py
@@ -1 +1,9 @@
-from __main__ import main
+"""A Secure Socket Tunneling Protocol (SSTP) server.
+https://github.com/sorz/sstp-server
+"""
+__version__ = '0.3.7'
+
+
+def run():
+    from __main__ import main
+    main()
diff --git a/sstpd/__main__.py b/sstpd/__main__.py
index 08827ae..79f1a7c 100755
--- a/sstpd/__main__.py
+++ b/sstpd/__main__.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python2
+from __future__ import absolute_import, print_function
 import sys
 import logging
 import argparse
@@ -6,14 +7,13 @@
 from twisted.internet.endpoints import SSL4ServerEndpoint
 from twisted.internet import reactor, ssl
 
-from sstp import SSTPProtocolFactory
-from address import IPPool
+from . import __doc__
+from .sstp import SSTPProtocolFactory
+from .address import IPPool
 
 
 def _getArgs():
     conf_parser = argparse.ArgumentParser(
-            description='A Secure Socket Tunneling Protocol (SSTP) server.',
-            epilog='Author: Sorz <orz@sorz.org>.',
             add_help=False)
     conf_parser.add_argument("-f", "--conf-file",
             help="Specify config file.", metavar="FILE")
@@ -30,11 +30,12 @@ def _getArgs():
             defaults = dict(config.items(args.conf_section))
         except NoSectionError as e:
             print('Error: section [%s] not found in config file.' % \
-                  args.conf_section)
+                  args.conf_section, file=sys.stderr)
             sys.exit(1)
             return
 
-    parser = argparse.ArgumentParser(parents=[conf_parser])
+    parser = argparse.ArgumentParser(parents=[conf_parser],
+            description=__doc__)
     parser.set_defaults(**defaults)
     parser.add_argument('-l', '--listen',
             default='',