def __init__(self, logData=None, logColor=Colors.Foreground.Green): ''' * logData -- The LogData object * logColor -- The color to use for the Logger ''' # Create a logger just for the options loading if logData is None: logData = LogData() self.__log = logData.get("PluginTester", color=logColor) # Parse the siri proxy configuration options object options = Options(logData) options.parse(argv, Files.ConfigFile) # Set the callback for the iPhone, and Server connections Server.Callback = self.iPhoneCallback Server.Callback = self.serverCallback # Create the connection manager, and connect the iPhone and # Server connections to it connectionManager = ConnectionManager(logData) connectionManager.connect(iPhone) connectionManager.connect(Server) # Grab an instance to the plugin manager self.__pluginManager = PluginManager(connectionManager, logData)
def connect(logger): '''Connect the Siri server to handle server data. * logger -- The logger ''' host = Options.get(Sections.Server, Ids.Host) port = Options.get(Sections.Server, Ids.Port) return reactor.connectTCP(host, port, _Factory(logger))
def connect(logger): '''Connect the Siri server to handle iPhone requests. * logger -- The logger ''' # Grab the configured port for the iPhone port = Options.get(Sections.iPhone, Ids.Port) # Create the SSL context using the iPhone key and certificate files keyFile = Options.get(Sections.iPhone, Ids.KeyFile) certFile = Options.get(Sections.iPhone, Ids.CertFile) authentication = DefaultOpenSSLContextFactory(keyFile, certFile) # Create the SSL server using the given authentication files reactor.listenSSL(port, _Factory(logger), authentication)
def connect(logger): """Connect the Siri server to handle iPhone requests. * logger -- The logger """ # Grab the configured port for the iPhone port = Options.get(Sections.iPhone, Ids.Port) # Create the SSL context using the iPhone key and certificate files keyFile = Options.get(Sections.iPhone, Ids.KeyFile) certFile = Options.get(Sections.iPhone, Ids.CertFile) authentication = DefaultOpenSSLContextFactory(keyFile, certFile) # Create the SSL server using the given authentication files reactor.listenSSL(port, _Factory(logger), authentication)
def __init__(self, logger): ''' * logger -- The logger ''' # Grab the hostname of the Apple server to which we will be connecting # and use it as the name of this connection for debugging purposes hostname = Options.get(Sections.Server, Ids.Host) # Remove the '.apple.com' extension from the hostname, and also # capitalize it for better appearance hostname = hostname.replace(".apple.com", "") hostname = hostname.capitalize() Connection.__init__(self, hostname, Directions.From_Server, logger=logger, logColor=Colors.Foreground.Blue)
def connectionLost(self, reason): '''Called when the connection is lost. * reason -- The reason the connection was lost ''' self.log.info("Connection lost: %s" % reason) self.__disconnectServer() # Signal the connection manager that the iPhone connection # has been closed connectionManager = self.getConnectionManager() connectionManager.disconnect(Directions.From_iPhone) # Determine if the server should exit due to the lost connection if Options.get(Sections.Debug, Ids.ExitOnConnectionLost): serverPid = getpid() self.log.info("Forcing server [%d] to exit!!!" % serverPid) system("kill -9 %d" % serverPid)
def connectionLost(self, reason): """Called when the connection is lost. * reason -- The reason the connection was lost """ self.log.info("Connection lost: %s" % reason) self.__disconnectServer() # Signal the connection manager that the iPhone connection # has been closed connectionManager = self.getConnectionManager() connectionManager.disconnect(Directions.From_iPhone) # Determine if the server should exit due to the lost connection if Options.get(Sections.Debug, Ids.ExitOnConnectionLost): serverPid = getpid() self.log.info("Forcing server [%d] to exit!!!" % serverPid) system("kill -9 %d" % serverPid)