當前位置: 首頁>>代碼示例>>Python>>正文


Python StreamServerEndpointService.setServiceParent方法代碼示例

本文整理匯總了Python中twisted.application.internet.StreamServerEndpointService.setServiceParent方法的典型用法代碼示例。如果您正苦於以下問題:Python StreamServerEndpointService.setServiceParent方法的具體用法?Python StreamServerEndpointService.setServiceParent怎麽用?Python StreamServerEndpointService.setServiceParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.application.internet.StreamServerEndpointService的用法示例。


在下文中一共展示了StreamServerEndpointService.setServiceParent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: makeService

# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
def makeService(options):
    """
    Construct a Pantheon SSH service.
    """
    from twisted.internet import reactor

    factory = SSHFactory()
    key = options["host-key"]
    factory.privateKeys = {key.sshType(): key}
    factory.publicKeys = {key.sshType(): key.public()}
    realm = PantheonRealm(
        reactor,
        options['auth-host'], options['auth-port'],
        options['client-key'].path, options['client-cert'].path)
    checker = PantheonHTTPChecker(
        reactor,
        options['auth-host'], options['auth-port'],
        options['client-key'].path, options['client-cert'].path)
    factory.portal = Portal(realm, [checker])

    service = MultiService()
    for endpoint in options["listen"]:
        child = StreamServerEndpointService(endpoint, factory)
        child.setServiceParent(service)
    return service
開發者ID:exarkun,項目名稱:Pantheon-SSH,代碼行數:27,代碼來源:tap.py

示例2: makeService

# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
    def makeService(self, options):
        greatPath = FilePath(great.__file__).parent()
        staticPath = greatPath.child("static")
        templatesPath = greatPath.child("templates")

        rootResource = Resource()
        rootResource.putChild("", File(staticPath.child("index.html").path))
        rootResource.putChild("static", File(staticPath.path))
        rootResource.putChild("templates", File(templatesPath.path))

        rootResource.putChild("great", MinionResource(create_app()))

        greatService = StreamServerEndpointService(
            endpoint=options["endpoint"],
            factory=server.Site(rootResource),
        )

        redirects = options["redirects"]
        if not redirects:
            return greatService

        service = MultiService()
        greatService.setServiceParent(service)

        for redirect in redirects:
            redirectService = StreamServerEndpointService(
                endpoint=redirect,
                factory=server.Site(Redirect(options["canonical_url"])),
            )
            redirectService.setServiceParent(service)

        return service
開發者ID:Julian,項目名稱:Great,代碼行數:34,代碼來源:great.py

示例3: startService

# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
    def startService(self):
        MultiService.startService(self)

        staticPath = FilePath(__file__).sibling("static")
        root = NoListDirFile(staticPath.path)
        root.putChild('api', SockJSResource(
            Factory.forProtocol(DaneDoctorProtocol))
        )

        webService = StreamServerEndpointService(
            serverFromString(self._reactor, "tcp:8080"),
            Site(root)
        )
        webService.setServiceParent(self)
開發者ID:hynek,項目名稱:tnw,代碼行數:16,代碼來源:tap.py

示例4: makeService

# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
    def makeService(self, options):
        reactor = self.reactor
        if reactor is None:
            from twisted.internet import reactor

        resolver = self.resolver
        if resolver is None:
            resolver = getResolver()

        with open(options.config) as infile:
            config = yaml.safe_load(infile)

        multiService = MultiService()

        for proxy in config['proxies']:
            client = endpoints.clientFromString(reactor, str(proxy['client']))
            server = endpoints.serverFromString(reactor, str(proxy['server']))
            fac = ProxyFactory(client, resolver, proxy)
            service = StreamServerEndpointService(server, fac)
            service.setServiceParent(multiService)

        return multiService
開發者ID:weykent,項目名稱:zangoose,代碼行數:24,代碼來源:zangoose.py

示例5: getContext

# 需要導入模塊: from twisted.application.internet import StreamServerEndpointService [as 別名]
# 或者: from twisted.application.internet.StreamServerEndpointService import setServiceParent [as 別名]
            self.setContextFactory(name, connection)
        else:
            log.msg('SNI not provided, closing SSL connection')
            connection.shutdown()

    def getContext(self):
        return self._context


sslContext = SNIContextFactory(depl, config)

ports = [
    endpoints.TCP4ServerEndpoint(reactor, config.getint('master', 'port')),
    endpoints.SSL4ServerEndpoint(reactor, config.getint('master', 'sslport'),
                                 sslContext),
]

logfile = filepath.FilePath(config.get('master', 'http_logfile'))
if not logfile.parent().exists():
    logfile.parent().makedirs()

depl.root.putChild('_admin', resources.VhostListing(depl))
site = server.Site(depl.root, logPath=logfile.path)

application = service.Application('appserver')
depl.setServiceParent(application)

for port in ports:
    svc = StreamServerEndpointService(port, site)
    svc.setServiceParent(application)
開發者ID:simbha,項目名稱:appserver,代碼行數:32,代碼來源:server.py


注:本文中的twisted.application.internet.StreamServerEndpointService.setServiceParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。