Example #1
0
    def _initClientService(self, connection, params):

        p = self._prepareParams(params)
        logger.debug("create protocol service %r, params %r", connection, p)

        factory = self.buildClientFactory(p)
        endpoint = self.buildClientEndpoint(p)
        service = self.buildClientService(endpoint, factory, p)

        service.setName(connection)
        service.setServiceParent(self)
Example #2
0
    def _initClientService(self, connection, params):

        p = self._prepareParams(params)
        logger.debug("create protocol service %r, params %r", connection, p)

        factory = self.buildClientFactory(p)
        endpoint = self.buildClientEndpoint(p)
        service = self.buildClientService(endpoint, factory, p)

        service.setName(connection)
        service.setServiceParent(self)
Example #3
0
def getService():
    from twisted.application import service
    #Return the container service actual services are added when later when get
    #result from database
    amiService = service.MultiService()
    amiService.setName("AMIService")
    df = DialerFactory(1, aminame, amidomain, amiaddr, 100, 1, 10)
    serverList.append(df)
    service = internet.TCPClient(amiaddr, amiport, df, timeout=5)
    service.setName('flexvmAMI')
    amiService.addService(service)
    return amiService
Example #4
0
def createService(endpoint, role, endpoint_config):
    if role == 'bouncer':
        factory = OONIBouncer()
    elif role == 'collector':
        factory = OONICollector()
    elif role == 'web_connectivity':
        factory = http_helpers.WebConnectivityHelper
    else:
        raise Exception("unknown service type")

    service = internet.StreamServerEndpointService(endpoint, factory)
    service.setName("-".join([endpoint_config['type'], role]))
    return service
def createService(endpoint, role, endpoint_config):
    if role == "bouncer":
        factory = OONIBouncer()
    elif role == "collector":
        factory = OONICollector()
    elif role == "web_connectivity":
        factory = http_helpers.WebConnectivityHelper
    else:
        raise Exception("unknown service type")

    service = internet.StreamServerEndpointService(endpoint, factory)
    service.setName("-".join([endpoint_config["type"], role]))
    return service
Example #6
0
        def helper(name, config, transport_names):
            # Helper closure passed to / called by L{_loadItemsFromConfig}
            # This will keep track of configured transports in transport_names
            # and set up a transport if applicable
            transport_names.add(name)

            # If this transport (or another with this name, which would be a
            # configuration error) is already registered, just ignore this
            # configuration item
            if name in self.registered_transports:
                return None

            log.msg('[CONTROLLER] Configuring transport %s' % name)
            # Create a transport (L{ITransport}) using the given configuration
            transport = self.loadTransport(name, config)

            # If the transport is an L{IServerTransport}...
            if IServerTransport.providedBy(transport):
                # Create a L{twisted.application.service.IService} from it
                # using settings provided in C{config}. This is *not* an
                # applicationserver  service but a Twisted service, ie a
                # server handling incoming requests on a given socket.
                service = self.hookTransport(transport, config)
                # Set the IService name
                service.setName(name)
                # Set the IService parent to our MultiTransport
                service.setServiceParent(self.transports)

                # Parse the transport settings again so we can set up an
                # L{ITransportInfo} object for this transport
                port_info = strports.parse(config['transport'], transport)
                transport_info = transport.getTransportInfo(name, port_info)
                # Store the L{ITransportInfo}
                self.transport_info_map[name] = transport_info

                # Finally return the service
                return service
            else:
                # Set up the L{ITransportInfo} for the transport
                transport_info = transport.getTransportInfo(name)
                # Save it
                self.transport_info_map[name] = transport_info

                # And return it. We don't know how to handle this further,
                # since this is not an L{IServerTransport}, most likely the
                # 'mail' transport.
                return transport
Example #7
0
        def helper(name, config, transport_names):
            # Helper closure passed to / called by L{_loadItemsFromConfig}
            # This will keep track of configured transports in transport_names
            # and set up a transport if applicable
            transport_names.add(name)

            # If this transport (or another with this name, which would be a
            # configuration error) is already registered, just ignore this
            # configuration item
            if name in self.registered_transports:
                return None

            log.msg('[CONTROLLER] Configuring transport %s' % name)
            # Create a transport (L{ITransport}) using the given configuration
            transport = self.loadTransport(name, config)

            # If the transport is an L{IServerTransport}...
            if IServerTransport.providedBy(transport):
                # Create a L{twisted.application.service.IService} from it
                # using settings provided in C{config}. This is *not* an
                # applicationserver  service but a Twisted service, ie a 
                # server handling incoming requests on a given socket.
                service = self.hookTransport(transport, config)
                # Set the IService name
                service.setName(name)
                # Set the IService parent to our MultiTransport
                service.setServiceParent(self.transports)

                # Parse the transport settings again so we can set up an
                # L{ITransportInfo} object for this transport
                port_info = strports.parse(config['transport'], transport)
                transport_info = transport.getTransportInfo(name, port_info)
                # Store the L{ITransportInfo}
                self.transport_info_map[name] = transport_info

                # Finally return the service
                return service
            else:
                # Set up the L{ITransportInfo} for the transport
                transport_info = transport.getTransportInfo(name)
                # Save it
                self.transport_info_map[name] = transport_info

                # And return it. We don't know how to handle this further,
                # since this is not an L{IServerTransport}, most likely the
                # 'mail' transport.
                return transport
Example #8
0
 def addNamedService(self, name, service):
     # to get this at runtime use service.getServiceNamed('service_name')
     service.setName(name)
     service.setServiceParent(self)