etcp_connections: improve INIT diagnostics (demote spam, add type/source/fields)
- 1556: Normal decryption failed -> DEBUG_DEBUG (expected for INIT, no more spam) - 1581: added 'INIT X25519 OK from %s' with source address - 1604-1617: INFO log for decrypted packet type (PING/PONG/INIT) with peer_id+src - 1662-1668: expanded INIT accepted log with all fields: peer_id, mtu, link_id, socket_id, type, only_local, src_ip:src_port, session_id, actual src (UDP) — shows NAT mismatch
This commit is contained in:
1 parent
e2ee9b1c14
commit
c970c8c071
1 file changed
+15
-2
+15
-2
@@ -1553,7 +1553,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
goto process_decrypted;
|
||||
}
|
||||
// Normal decryption failed - might be INIT packet, fall through to INIT handling
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "Normal decryption failed, trying INIT decryption");
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "Normal decryption failed, trying INIT decryption");
|
||||
}
|
||||
|
||||
// Try INIT decryption (for incoming connection requests)
|
||||
@@ -1578,6 +1578,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
errorcode=2;
|
||||
goto ec_fr;
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CRYPTO, "INIT X25519 OK from %s", sockaddr_storage_to_str(&addr).str);
|
||||
if (sc_decrypt(&sc, data, recv_len - SC_PUBKEY_ENC_SIZE, (uint8_t*)&pkt->timestamp, &pkt_len)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "failed to decrypt init packet, from %s", sockaddr_storage_to_str(&addr).str);
|
||||
errorcode=3;
|
||||
@@ -1601,11 +1602,15 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
uint8_t code = pkt->data[0];
|
||||
uint64_t peer_id = be64toh(*(uint64_t*)(pkt->data + 1));
|
||||
if (code == ETCP_PING) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "INIT decrypted: PING from peer=0x%016llx src=%s",
|
||||
(unsigned long long)peer_id, sockaddr_storage_to_str(&addr).str);
|
||||
int ret = handle_ping(e_sock, pkt, &addr, decrypted_pubkey, pkt_len);
|
||||
if (ret) { errorcode = ret; goto ec_fr; }
|
||||
return;
|
||||
}
|
||||
if (code == ETCP_PONG) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "INIT decrypted: PONG from peer=0x%016llx src=%s",
|
||||
(unsigned long long)peer_id, sockaddr_storage_to_str(&addr).str);
|
||||
int ret = handle_pong(e_sock, pkt, &addr, pkt_len);
|
||||
if (ret) { errorcode = ret; goto ec_fr; }
|
||||
return;
|
||||
@@ -1652,7 +1657,15 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
|
||||
struct ETCP_INIT_REQUEST_PKT* req = (struct ETCP_INIT_REQUEST_PKT*)pkt->data;
|
||||
uint32_t session_id = be32toh(*(uint32_t*)req->session_id);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "INIT request session_id=%08x", session_id);
|
||||
uint16_t mtu = be16toh(*(uint16_t*)req->mtu);
|
||||
uint16_t src_port = be16toh(*(uint16_t*)req->src_port);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION,
|
||||
"INIT accepted: peer=0x%016llx mtu=%u link=%u sock=%u type=%d local=%d"
|
||||
" src_ip=%d.%d.%d.%d:%u session=%08x src=%s",
|
||||
(unsigned long long)peer_id, mtu, req->link_id, req->socket_id,
|
||||
req->type, req->only_local,
|
||||
req->src_ipv4[0], req->src_ipv4[1], req->src_ipv4[2], req->src_ipv4[3],
|
||||
src_port, session_id, sockaddr_storage_to_str(&addr).str);
|
||||
|
||||
struct ETCP_CONN* conn=e_sock->instance->connections;
|
||||
while (conn) {// ищем есть ли подключение к этому пиру
|
||||
|
||||
Reference in new issue
Block a user