summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton <anton@picapica>2019-03-06 19:26:22 +0400
committerAnton <anton@picapica>2019-03-06 19:26:22 +0400
commitfc8c3b76068530a288c3fcd95f9c651996352402 (patch)
tree003c852c616a38b97d0d795df522dc0703da7d62
parent73c06c18c5c6401ee08748ebed08c8896f63e344 (diff)
downloadpica-pica-fc8c3b76068530a288c3fcd95f9c651996352402.tar.gz
pica-pica-fc8c3b76068530a288c3fcd95f9c651996352402.zip
add new callback direct_c2c_established_cb()
-rw-r--r--PICA_client.c2
-rw-r--r--PICA_client.h2
-rw-r--r--pica-client/skynet.cpp10
-rw-r--r--pica-client/skynet.h2
4 files changed, 14 insertions, 2 deletions
diff --git a/PICA_client.c b/PICA_client.c
index bf274ef..6949081 100644
--- a/PICA_client.c
+++ b/PICA_client.c
@@ -2428,6 +2428,7 @@ static void process_directc2c(struct PICA_c2n *c2n, fd_set *rfds, fd_set *wfds)
}
else
{
+ callbacks.direct_c2c_established_cb(c2c->peer_id, SSL_get_cipher_name(d->ssl));
c2c->directc2c_state = PICA_DIRECTC2C_STATE_ACTIVE;
}
@@ -2541,6 +2542,7 @@ static void process_directc2c(struct PICA_c2n *c2n, fd_set *rfds, fd_set *wfds)
case PICA_DIRECTC2C_CONNSTATE_ACTIVE:
c2c->directc2c_state = PICA_DIRECTC2C_STATE_ACTIVE;
+ callbacks.direct_c2c_established_cb(c2c->peer_id, SSL_get_cipher_name(d->ssl));
break;
}
diff --git a/PICA_client.h b/PICA_client.h
index fe84ea5..ba575c3 100644
--- a/PICA_client.h
+++ b/PICA_client.h
@@ -385,6 +385,8 @@ struct PICA_client_callbacks
void (*listener_error_cb)(struct PICA_listener *lst, int errorcode);
void (*multilogin_cb)(uint64_t timestamp, void *addr_bin, const char *addr_str, uint16_t port);
+
+ void (*direct_c2c_established_cb)(const unsigned char *peer_id, const char *ciphersuitename);
};
diff --git a/pica-client/skynet.cpp b/pica-client/skynet.cpp
index da39a3b..35b7e60 100644
--- a/pica-client/skynet.cpp
+++ b/pica-client/skynet.cpp
@@ -56,7 +56,8 @@ SkyNet::SkyNet()
c2n_failed_cb,
c2n_closed_cb,
listener_error_cb,
- multilogin_cb
+ multilogin_cb,
+ direct_c2c_established_cb
};
PICA_client_init(&cbs);
@@ -910,7 +911,7 @@ void SkyNet::msgok_cb(const unsigned char *peer_id)
void SkyNet::c2c_established_cb(const unsigned char *peer_id, const char *ciphersuitename)
{
- skynet->emit_ConnectionStatusUpdated(QByteArray((const char*)peer_id, PICA_ID_SIZE), QString("🔐: %1").arg(ciphersuitename));
+ skynet->emit_ConnectionStatusUpdated(QByteArray((const char*)peer_id, PICA_ID_SIZE), QString("🔐: %1 c2c").arg(ciphersuitename));
skynet->flush_queues(QByteArray((const char*)peer_id, PICA_ID_SIZE));
}
@@ -1089,3 +1090,8 @@ void SkyNet::multilogin_cb(uint64_t timestamp, void *addr_bin, const char *addr_
{
skynet->emit_MultiloginMessageReceived(timestamp, QString(addr_str), port);
}
+
+void SkyNet::direct_c2c_established_cb(const unsigned char *peer_id, const char *ciphersuitename)
+{
+ skynet->emit_ConnectionStatusUpdated(QByteArray((const char*)peer_id, PICA_ID_SIZE), QString("🔐: %1 direct c2c").arg(ciphersuitename));
+}
diff --git a/pica-client/skynet.h b/pica-client/skynet.h
index cefcb91..875277e 100644
--- a/pica-client/skynet.h
+++ b/pica-client/skynet.h
@@ -173,6 +173,8 @@ private:
static void multilogin_cb(uint64_t timestamp, void *addr_bin, const char *addr_str, uint16_t port);
+ static void direct_c2c_established_cb(const unsigned char *peer_id, const char *ciphersuitename);
+
private slots:
void nodelink_activated(PICA_c2n *c2n);
void nodelink_closed(PICA_c2n *c2n, int error);