diff options
-rw-r--r-- | src/core/pvsConnectionManager.cpp | 9 | ||||
-rw-r--r-- | src/net/pvsServerConnection.cpp | 2 | ||||
-rw-r--r-- | src/pvs.cpp | 14 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/core/pvsConnectionManager.cpp b/src/core/pvsConnectionManager.cpp index d1442dd..703d1c4 100644 --- a/src/core/pvsConnectionManager.cpp +++ b/src/core/pvsConnectionManager.cpp @@ -41,9 +41,12 @@ PVSConnectionManager::PVSConnectionManager() if (!(_pvsServer.startListen(SERVER_PORT_INT))) ConsoleLog writeError(QString("Server listening failed!")); setUpdateRate(500); - _sdBroadcaster.setFingerprint( - CertManager::getCertificate("manager").digest(QCryptographicHash::Sha1) - ); + + QByteArray fingerprint = CertManager::getCertificate("manager").digest(QCryptographicHash::Sha1); + _sdBroadcaster.setFingerprint(fingerprint); + qDebug() << "Fingerprint: " << fingerprint.toHex(); + qDebug() << "Sessionname: " << getSessionName(); + _timerId = startTimer(1000); } diff --git a/src/net/pvsServerConnection.cpp b/src/net/pvsServerConnection.cpp index d187ce3..2ec2e5d 100644 --- a/src/net/pvsServerConnection.cpp +++ b/src/net/pvsServerConnection.cpp @@ -36,6 +36,8 @@ bool PVSServerConnection::connectToServer(PVSDiscoveredServer* server, QString p if (port < 1 || port > 65535) port = SERVER_PORT_INT; ConsoleLog writeNetwork("Connecting to host:"); ConsoleLog writeNetwork(host.toString().toUtf8().data()); + ConsoleLog writeNetwork("Fingerprint is:"); + ConsoleLog writeNetwork(QString(server->getFingerprint().toHex())); timerStop(); if (_socket != NULL) { diff --git a/src/pvs.cpp b/src/pvs.cpp index cf45dd7..296c8a4 100644 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -92,6 +92,20 @@ PVS::PVS() : sigaction(SIGQUIT, &act, 0); initializeInputEventHandling(); + + // Read Config and try to autoconnect to given host + QHostAddress host(_settings.value("Connection/host").toString()); + int port = _settings.value("Connection/port").toInt(); + QByteArray fingerprint = QByteArray::fromHex(_settings.value("Connection/fingerprint").toByteArray()); + QString name = _settings.value("Connection/sessionname").toString(); + if (!host.isNull() && port > 0 && fingerprint != "" && name != "") + { + qDebug() << "Autoconnecting to " << host.toString(); + PVSDiscoveredServer* server = new PVSDiscoveredServer(this, host, port, fingerprint, name); + connectToHost(server, ""); + } + else + qDebug() << "No Config for autoconnection found"; } PVS::~PVS() |