当前位置: 首页>>代码示例>>Python>>正文


Python internet.SSLServer方法代码示例

本文整理汇总了Python中twisted.application.internet.SSLServer方法的典型用法代码示例。如果您正苦于以下问题:Python internet.SSLServer方法的具体用法?Python internet.SSLServer怎么用?Python internet.SSLServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.application.internet的用法示例。


在下文中一共展示了internet.SSLServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def makeService(self, options):
        """Override IServiceMaker.makeService."""
        factory = bashplex.DelimitedBashReceiverFactory()
        factory.ping_interval = int(options['ping-interval'])
        factory.ping_timeout = int(options['ping-timeout'])
        factory.startup_commands = filter_bash(
            '/usr/share/epoptes/client-functions')

        if config.system['ENCRYPTION']:
            client_service = internet.SSLServer(
                int(config.system['PORT']), factory, ServerContextFactory())
        else:
            client_service = internet.TCPServer(
                int(config.system['PORT']), factory)

        gid = grp.getgrnam(config.system['SOCKET_GROUP'])[2]

        if not os.path.isdir(config.system['DIR']):
            # TODO: for some reason this does 0750 instead
            os.makedirs(config.system['DIR'], 0o2770)
        os.chmod(config.system['DIR'], 0o2770)
        os.chown(config.system['DIR'], -1, gid)

        gui_service = internet.UNIXServer(
            "%s/epoptes.socket" % config.system['DIR'],
            guiplex.GUIFactory())

        top_service = service.MultiService()
        top_service.addService(client_service)
        top_service.addService(gui_service)

        return top_service 
开发者ID:epoptes,项目名称:epoptes,代码行数:34,代码来源:epoptesd.py

示例2: makeService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def makeService(config):
    s = service.MultiService()
    if config['root']:
        root = config['root']
        if config['indexes']:
            config['root'].indexNames = config['indexes']
    else:
        # This really ought to be web.Admin or something
        root = demo.Test()

    if isinstance(root, static.File):
        root.registry.setComponent(interfaces.IServiceCollection, s)

    if config['logfile']:
        site = server.Site(root, logPath=config['logfile'])
    else:
        site = server.Site(root)

    site.displayTracebacks = not config["notracebacks"]

    if not _PY3 and config['personal']:
        personal = strports.service(
            config['port'], makePersonalServerFactory(site))
        personal.setServiceParent(s)
    else:
        if config['https']:
            from twisted.internet.ssl import DefaultOpenSSLContextFactory
            i = internet.SSLServer(int(config['https']), site,
                          DefaultOpenSSLContextFactory(config['privkey'],
                                                       config['certificate']))
            i.setServiceParent(s)
        strports.service(config['port'], site).setServiceParent(s)

    return s 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:36,代码来源:tap.py

示例3: __init__

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def __init__(self, *args, **kwargs):
        internet.SSLServer.__init__(self, *args, **kwargs)
        self.protocolFactory = self.args[1]
        self.protocolFactory.myServer = self
        self.inherit = self.kwargs.get("inherit", False)
        self.backlog = self.kwargs.get("backlog", None)
        self.interface = self.kwargs.get("interface", None) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:9,代码来源:tcp.py

示例4: stopService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def stopService(self):
        """
        Wait for outstanding requests to finish

        @return: a Deferred which fires when all outstanding requests are
            complete.
        """
        internet.SSLServer.stopService(self)
        # TODO: check for an ICompletionWaiter interface
        return _allConnectionsClosed(self.protocolFactory) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:12,代码来源:tcp.py

示例5: test_SSLKeyConfiguration

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def test_SSLKeyConfiguration(self):
        """
        Test that the configuration of the SSLServer reflect the config file's
        SSL Private Key and SSL Certificate
        """
        # Note: the listeners are bundled within a MultiService named "ConnectionService"
        service = CalDAVServiceMaker().makeService(self.options)
        service = service.getServiceNamed(CalDAVService.connectionServiceName)

        sslService = None
        for s in service.services:
            if isinstance(s, internet.SSLServer):
                sslService = s
                break

        self.failIf(sslService is None, "No SSL Service found")

        context = sslService.args[2]

        self.assertEquals(
            config.SSLPrivateKey,
            context.privateKeyFileName
        )
        self.assertEquals(
            config.SSLCertificate,
            context.certificateFileName,
        ) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:29,代码来源:test_caldav.py

示例6: test_noSSL

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def test_noSSL(self):
        """
        Test the single service to make sure there is no SSL Service when SSL
        is disabled
        """
        # Note: the listeners are bundled within a MultiService named "ConnectionService"
        service = CalDAVServiceMaker().makeService(self.options)
        service = service.getServiceNamed(CalDAVService.connectionServiceName)

        self.assertNotIn(
            internet.SSLServer,
            [s.__class__ for s in service.services]
        ) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:15,代码来源:test_caldav.py

示例7: test_singleBindAddresses

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def test_singleBindAddresses(self):
        """
        Test that the TCPServer and SSLServers are bound to the proper address
        """
        # Note: the listeners are bundled within a MultiService named "ConnectionService"
        service = CalDAVServiceMaker().makeService(self.options)
        service = service.getServiceNamed(CalDAVService.connectionServiceName)

        for s in service.services:
            if isinstance(s, (internet.TCPServer, internet.SSLServer)):
                self.assertEquals(s.kwargs["interface"], "127.0.0.1") 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:13,代码来源:test_caldav.py

示例8: test_multipleBindAddresses

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def test_multipleBindAddresses(self):
        """
        Test that the TCPServer and SSLServers are bound to the proper
        addresses.
        """
        # Note: the listeners are bundled within a MultiService named "ConnectionService"
        service = CalDAVServiceMaker().makeService(self.options)
        service = service.getServiceNamed(CalDAVService.connectionServiceName)

        tcpServers = []
        sslServers = []

        for s in service.services:
            if isinstance(s, internet.TCPServer):
                tcpServers.append(s)
            elif isinstance(s, internet.SSLServer):
                sslServers.append(s)

        self.assertEquals(len(tcpServers), len(config.BindAddresses))
        self.assertEquals(len(sslServers), len(config.BindAddresses))

        for addr in config.BindAddresses:
            for s in tcpServers:
                if s.kwargs["interface"] == addr:
                    tcpServers.remove(s)

            for s in sslServers:
                if s.kwargs["interface"] == addr:
                    sslServers.remove(s)

        self.assertEquals(len(tcpServers), 0)
        self.assertEquals(len(sslServers), 0) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:34,代码来源:test_caldav.py

示例9: test_listenBacklog

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def test_listenBacklog(self):
        """
        Test that the backlog arguments is set in TCPServer and SSLServers
        """
        # Note: the listeners are bundled within a MultiService named "ConnectionService"
        service = CalDAVServiceMaker().makeService(self.options)
        service = service.getServiceNamed(CalDAVService.connectionServiceName)

        for s in service.services:
            if isinstance(s, (internet.TCPServer, internet.SSLServer)):
                self.assertEquals(s.kwargs["backlog"], 1024) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:13,代码来源:test_caldav.py

示例10: _configure_web_server

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def _configure_web_server(self, config, controller):
        interfaces, https, key_file, cert_file, chain_file, _, _ = \
            self._validate_web_config(config)

        site = server.Site(get_web_app(config, controller))
        web_servers = []

        for interface, port in interfaces:
            if https:
                cf = SSLCertOptions(key_file, cert_file, chain_file)
                web_server = SSLServer(port, site, cf, interface=interface)
                method = 'https'
            else:
                web_server = TCPServer(port, site, interface=interface)
                method = 'http'

            web_servers.append(web_server)

            if ':' in interface:
                interface = '[{}]'.format(interface)
            log.msg(format="Scrapy-Do web interface is available at "
                           "%(method)s://%(interface)s:%(port)s/",
                    method=method, interface=interface, port=port)

        return web_servers

    #--------------------------------------------------------------------------- 
开发者ID:ljanyst,项目名称:scrapy-do,代码行数:29,代码来源:app.py

示例11: makeService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def makeService(config):
    s = service.MultiService()
    if config['root']:
        root = config['root']
        if config['indexes']:
            config['root'].indexNames = config['indexes']
    else:
        # This really ought to be web.Admin or something
        root = demo.Test()

    if isinstance(root, static.File):
        root.registry.setComponent(interfaces.IServiceCollection, s)

    if config['logfile']:
        site = server.Site(root, logPath=config['logfile'])
    else:
        site = server.Site(root)

    site.displayTracebacks = not config["notracebacks"]

    if config['personal']:
        personal = strports.service(
            config['port'], makePersonalServerFactory(site))
        personal.setServiceParent(s)
    else:
        if config['https']:
            from twisted.internet.ssl import DefaultOpenSSLContextFactory
            i = internet.SSLServer(int(config['https']), site,
                          DefaultOpenSSLContextFactory(config['privkey'],
                                                       config['certificate']))
            i.setServiceParent(s)
        strports.service(config['port'], site).setServiceParent(s)

    return s 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:36,代码来源:tap.py

示例12: listenSSL

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def listenSSL(self, port, factory, ctxFactory, backlog=50, interface=''):
        s = internet.SSLServer(port, factory, ctxFactory, backlog, interface)
        s.privileged = 1
        s.setServiceParent(self.app) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:6,代码来源:compat.py

示例13: makeService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def makeService(config):
    if config['esmtp']:
        rmType = relaymanager.SmartHostESMTPRelayingManager
        smtpFactory = config.service.getESMTPFactory
    else:
        rmType = relaymanager.SmartHostSMTPRelayingManager
        smtpFactory = config.service.getSMTPFactory

    if config['relay']:
        dir = config['relay']
        if not os.path.isdir(dir):
            os.mkdir(dir)

        config.service.setQueue(relaymanager.Queue(dir))
        default = relay.DomainQueuer(config.service)

        manager = rmType(config.service.queue)
        if config['esmtp']:
            manager.fArgs += (None, None)
        manager.fArgs += (config['hostname'],)

        helper = relaymanager.RelayStateHelper(manager, 1)
        helper.setServiceParent(config.service)
        config.service.domains.setDefaultDomain(default)

    ctx = None
    if config['certificate']:
        from twisted.mail.protocols import SSLContextFactory
        ctx = SSLContextFactory(config['certificate'])

    if config['pop3']:
        s = internet.TCPServer(config['pop3'], config.service.getPOP3Factory())
        s.setServiceParent(config.service)
    if config['pop3s']:
        s = internet.SSLServer(config['pop3s'],
                               config.service.getPOP3Factory(), ctx)
        s.setServiceParent(config.service)
    if config['smtp']:
        f = smtpFactory()
        f.context = ctx
        if config['hostname']:
            f.domain = config['hostname']
            f.fArgs = (f.domain,)
        if config['esmtp']:
            f.fArgs = (None, None) + f.fArgs
        s = internet.TCPServer(config['smtp'], f)
        s.setServiceParent(config.service)
    return config.service 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:50,代码来源:tap.py

示例14: makeService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def makeService(config):
    s = service.MultiService()
    if config['root']:
        root = config['root']
        if config['indexes']:
            config['root'].indexNames = config['indexes']
    else:
        # This really ought to be web.Admin or something
        root = demo.Test()

    if isinstance(root, static.File):
        root.registry.setComponent(interfaces.IServiceCollection, s)
   
    if config['logfile']:
        site = server.Site(root, logPath=config['logfile'])
    else:
        site = server.Site(root)

    site.displayTracebacks = not config["notracebacks"]
    
    if config['personal']:
        import pwd,os

        pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell \
                 = pwd.getpwuid(os.getuid())
        i = internet.UNIXServer(os.path.join(pw_dir,
                                   distrib.UserDirectory.userSocketName),
                      pb.BrokerFactory(distrib.ResourcePublisher(site)))
        i.setServiceParent(s)
    else:
        if config['https']:
            from twisted.internet.ssl import DefaultOpenSSLContextFactory
            i = internet.SSLServer(int(config['https']), site,
                          DefaultOpenSSLContextFactory(config['privkey'],
                                                       config['certificate']))
            i.setServiceParent(s)
        strports.service(config['port'], site).setServiceParent(s)
    
    flashport = config.get('flashconduit', None)
    if flashport:
        from twisted.web.woven.flashconduit import FlashConduitFactory
        i = internet.TCPServer(int(flashport), FlashConduitFactory(site))
        i.setServiceParent(s)
    return s 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:46,代码来源:tap.py

示例15: makeService

# 需要导入模块: from twisted.application import internet [as 别名]
# 或者: from twisted.application.internet import SSLServer [as 别名]
def makeService(config):
    if config['esmtp']:
        rmType = relaymanager.SmartHostESMTPRelayingManager
        smtpFactory = config.service.getESMTPFactory
    else:
        rmType = relaymanager.SmartHostSMTPRelayingManager
        smtpFactory = config.service.getSMTPFactory

    if config['relay']:
        dir = config['relay']
        if not os.path.isdir(dir):
            os.mkdir(dir)

        config.service.setQueue(relaymanager.Queue(dir))
        default = relay.DomainQueuer(config.service)
        
        manager = rmType(config.service.queue)
        if config['esmtp']:
            manager.fArgs += (None, None)
        manager.fArgs += (config['hostname'],)
        
        helper = relaymanager.RelayStateHelper(manager, 1)
        helper.setServiceParent(config.service)
        config.service.domains.setDefaultDomain(default)

    ctx = None
    if config['certificate']:
        from twisted.mail.protocols import SSLContextFactory
        ctx = SSLContextFactory(config['certificate'])

    if config['pop3']:
        s = internet.TCPServer(config['pop3'], config.service.getPOP3Factory())
        s.setServiceParent(config.service)
    if config['pop3s']:
        s = internet.SSLServer(config['pop3s'],
                               config.service.getPOP3Factory(), ctx)
        s.setServiceParent(config.service)
    if config['smtp']:
        f = smtpFactory()
        f.context = ctx
        if config['hostname']:
            f.domain = config['hostname']
            f.fArgs = (f.domain,)
        if config['esmtp']:
            f.fArgs = (None, None) + f.fArgs
        s = internet.TCPServer(config['smtp'], f)
        s.setServiceParent(config.service)
    return config.service 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:50,代码来源:tap.py


注:本文中的twisted.application.internet.SSLServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。