diff options
Diffstat (limited to 'vdr-vdrmanager/vdrmanagerthread.cpp')
-rw-r--r-- | vdr-vdrmanager/vdrmanagerthread.cpp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/vdr-vdrmanager/vdrmanagerthread.cpp b/vdr-vdrmanager/vdrmanagerthread.cpp index 51301e5..55a3c90 100644 --- a/vdr-vdrmanager/vdrmanagerthread.cpp +++ b/vdr-vdrmanager/vdrmanagerthread.cpp @@ -8,13 +8,17 @@ #include "select.h" #include "helpers.h" -cVdrManagerThread::cVdrManagerThread(int port, const char * password, bool forceCheckSvdrp, int compressionMode) +cVdrManagerThread::cVdrManagerThread(int port, int sslPort, const char * password, bool forceCheckSvdrp, int compressionMode, + const char * certFile, const char * keyFile) { select = NULL; - this -> port = port; - this -> password = password; - this -> forceCheckSvdrp = forceCheckSvdrp; - this -> compressionMode = compressionMode; + this->port = port; + this->sslPort = sslPort; + this->password = password; + this->forceCheckSvdrp = forceCheckSvdrp; + this->compressionMode = compressionMode; + this->certFile = certFile; + this->keyFile = keyFile; } cVdrManagerThread::~cVdrManagerThread() @@ -25,8 +29,10 @@ cVdrManagerThread::~cVdrManagerThread() void cVdrManagerThread::Action(void) { // create listener socket - if (!Init()) + if (!Init()) { + Cleanup(); return; + } // do processing select->Action(); @@ -44,19 +50,35 @@ bool cVdrManagerThread::Init() // create server socket cVdrmanagerServerSocket * sock = new cVdrmanagerServerSocket(); - if (sock == NULL || !sock->Create(port, password, forceCheckSvdrp, compressionMode)) + if (sock == NULL || !sock->Create(port, password, forceCheckSvdrp, compressionMode, NULL, NULL)) return false; - // register server socket - select->SetServerSocket(sock); + // register server sockets + select->SetServerSockets(sock, NULL); + + cVdrmanagerServerSocket * sslSock; + if (!access(certFile, R_OK) && !access(keyFile, R_OK)) { + sslSock = new cVdrmanagerServerSocket(); + if (sslSock == NULL || !sslSock->Create(sslPort, password, forceCheckSvdrp, compressionMode, certFile, keyFile)) { + return false; + } + } else { + sslSock = NULL; + isyslog("[vdrmanager] SSL key files %s and %s can't be read. SSL disabled.", certFile, keyFile); + } + + // register server sockets + select->SetServerSockets(sock, sslSock); return true; } void cVdrManagerThread::Cleanup() { - if (select) + if (select) { delete select; + select = NULL; + } } void cVdrManagerThread::Shutdown() |