monkey.patch_all(thread=False, ssl=False) # Make time, socket gevent compatible. Not thread: pyfilesystem and system tray icon not compatible, Not ssl: broken in 2.7.9 # Log current config logging.debug("Config: %s" % config) # Socks Proxy monkey patch if config.proxy: from util import SocksProxy import urllib2 logging.info("Patching sockets to socks proxy: %s" % config.proxy) config.fileserver_ip = '127.0.0.1' # Do not accept connections anywhere but localhost SocksProxy.monkeyPath(*config.proxy.split(":")) # Load plugins from Plugin import PluginManager PluginManager.plugin_manager.loadPlugins() # -- Actions -- @PluginManager.acceptPlugins class Actions(object): # Default action: Start serving UiServer and FileServer def main(self): logging.info("Version: %s r%s, Python %s, Gevent: %s" % (config.version, config.rev, sys.version, gevent.__version__)) global ui_server, file_server
if config.stack_size: import threading threading.stack_size(config.stack_size) # Use pure-python implementation of msgpack to save CPU if config.msgpack_purepython: os.environ["MSGPACK_PUREPYTHON"] = "True" # Socks Proxy monkey patch if config.proxy: from util import SocksProxy import urllib2 logging.info("Patching sockets to socks proxy: %s" % config.proxy) if config.fileserver_ip == "*": config.fileserver_ip = '127.0.0.1' # Do not accept connections anywhere but localhost SocksProxy.monkeyPatch(*config.proxy.split(":")) elif config.tor == "always": from util import SocksProxy import urllib2 logging.info("Patching sockets to tor socks proxy: %s" % config.tor_proxy) if config.fileserver_ip == "*": config.fileserver_ip = '127.0.0.1' # Do not accept connections anywhere but localhost SocksProxy.monkeyPatch(*config.tor_proxy.split(":")) config.disable_udp = True # -- Actions -- @PluginManager.acceptPlugins class Actions(object): def call(self, function_name, kwargs): logging.info("Version: %s r%s, Python %s, Gevent: %s" % (config.version, config.rev, sys.version, gevent.__version__))
config.parse() # Parse again to add plugin configuration options # Log current config logging.debug("Config: %s" % config) # Use pure-python implementation of msgpack to save CPU if config.msgpack_purepython: os.environ["MSGPACK_PUREPYTHON"] = "True" # Socks Proxy monkey patch if config.proxy: from util import SocksProxy import urllib2 logging.info("Patching sockets to socks proxy: %s" % config.proxy) config.fileserver_ip = '127.0.0.1' # Do not accept connections anywhere but localhost SocksProxy.monkeyPath(*config.proxy.split(":")) # -- Actions -- @PluginManager.acceptPlugins class Actions(object): def call(self, function_name, kwargs): func = getattr(self, function_name, None) func(**kwargs) # Default action: Start serving UiServer and FileServer def main(self): logging.info( "Version: %s r%s, Python %s, Gevent: %s" % (config.version, config.rev, sys.version, gevent.__version__))