logging: include REALITY handshake stage in connection failures
This commit is contained in:
1 parent
fb4e3f80e0
commit
647e3a90c9
3 files changed
+20
-6
No files matched your search
@@ -28,6 +28,17 @@ struct reality_io {
|
||||
void (*ready)(struct stcp_conn *);
|
||||
};
|
||||
|
||||
const char* reality_io_state_name(const struct stcp_conn *c) {
|
||||
if (!c->reality_io) return "none";
|
||||
switch (c->reality_io->phase) {
|
||||
case WAIT_HELLO: return c->is_server ? "waiting-ClientHello" : "waiting-ServerHello";
|
||||
case WAIT_SERVER_FLIGHT: return "waiting-server-authentication";
|
||||
case WAIT_CLIENT_FINISHED: return "waiting-client-Finished";
|
||||
case RECORD_DATA: return "protected-data";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static int replay_accept(struct reality_owner *owner, const uint8_t *ch, size_t len, uint32_t now,
|
||||
uint32_t timestamp, int64_t window) {
|
||||
if (!owner->replay) owner->replay = u_calloc(1, sizeof(*owner->replay));
|
||||
@@ -259,7 +270,8 @@ static int hello_process(struct stcp_conn *c) {
|
||||
}
|
||||
return 0;
|
||||
reject:
|
||||
DEBUG_WARN(DEBUG_CATEGORY_REALITY, "Hello rejected: buffered=%zu handshake=%zu", io->wire_len, io->handshake_len);
|
||||
DEBUG_WARN(DEBUG_CATEGORY_REALITY, "REALITY Hello rejected: buffered=%zu handshake=%zu %s",
|
||||
io->wire_len, io->handshake_len, stcp_conn_describe(c).text);
|
||||
return fallback(c);
|
||||
}
|
||||
|
||||
@@ -286,7 +298,8 @@ static int handshake_process(struct stcp_conn *c, const uint8_t *data, size_t le
|
||||
if (io->phase == WAIT_SERVER_FLIGHT && send_finished(c)) return -1;
|
||||
io->phase = RECORD_DATA;
|
||||
reality_session_handshake_done(&io->session);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_REALITY, "Finished verified: role=%s; protected STCP enabled", io->session.is_server ? "server" : "client");
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_REALITY, "REALITY Finished verified; starting protected STCP handshake: %s",
|
||||
stcp_conn_describe(c).text);
|
||||
io->ready(c);
|
||||
if (!c->reality_io || c->state == STCP_STATE_CLOSED || c->state == STCP_STATE_ERROR) return -1;
|
||||
} else {
|
||||
@@ -300,8 +313,8 @@ static int handshake_process(struct stcp_conn *c, const uint8_t *data, size_t le
|
||||
}
|
||||
return 0;
|
||||
reject:
|
||||
DEBUG_WARN(DEBUG_CATEGORY_REALITY, "protected handshake rejected: phase=%d step=%u type=%u size=%zu", io->phase,
|
||||
io->flight_step, io->handshake[0], io->handshake_len);
|
||||
DEBUG_WARN(DEBUG_CATEGORY_REALITY, "REALITY protected handshake rejected: step=%u message_type=%u buffered=%zu %s",
|
||||
io->flight_step, io->handshake[0], io->handshake_len, stcp_conn_describe(c).text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ int reality_io_client_start(struct stcp_conn *c, const struct reality_client_con
|
||||
const struct ETCP_PADDING *padding, void (*ready)(struct stcp_conn *));
|
||||
int reality_io_server_start(struct stcp_conn *c, void (*ready)(struct stcp_conn *));
|
||||
size_t reality_io_buffered(const struct stcp_conn *c);
|
||||
const char* reality_io_state_name(const struct stcp_conn *c);
|
||||
int reality_io_read(struct stcp_conn *c);
|
||||
void reality_io_resume(struct stcp_conn *c);
|
||||
int reality_io_send(struct stcp_conn *c, uint8_t *data, size_t len);
|
||||
|
||||
@@ -58,13 +58,13 @@ struct stcp_log_context stcp_conn_describe(const struct stcp_conn *c) {
|
||||
((c->is_server ? c->peer_flags : c->hs_flags) & STCP_HANDSHAKE_FLAG_PING ? "reachability-probe" : "data-link");
|
||||
snprintf(out.text, sizeof(out.text),
|
||||
"role=%s purpose=%s state=%s target=%s local=%s peer=%016llx peer_identity=%s socket=%d age_ms=%llu "
|
||||
"outer=%s recv_buffered=%zu recv_needed=%zu wire_queued=%zu finishing=%u",
|
||||
"reality_state=%s recv_buffered=%zu recv_needed=%zu wire_queued=%zu finishing=%u",
|
||||
c->is_server ? "server" : "client", purpose, state, c->log_target[0] ? c->log_target : "unknown",
|
||||
local_text.str[0] ? local_text.str : "unavailable",
|
||||
(unsigned long long)(c->peer_pubkey_set ? sc_derive_node_id_from_pubkey(c->peer_pubkey) : 0),
|
||||
c->peer_pubkey_set ? "known-key" : "unknown",
|
||||
(int)c->sock, (unsigned long long)(c->log_started_tb ? (get_time_tb() - c->log_started_tb) / 10 : 0),
|
||||
c->reality_io ? "REALITY" : "plain-STCP", c->recv_buf_len, c->recv_need, c->wire_bytes, c->finish_requested);
|
||||
reality_io_state_name(c), c->recv_buf_len, c->recv_need, c->wire_bytes, c->finish_requested);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user