mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-12 14:29:06 -05:00
improvement: log source IP for persisted events
This commit is contained in:
parent
bd07a11f50
commit
2e42b1b86e
|
@ -26,6 +26,7 @@ pub type PooledConnection = r2d2::PooledConnection<r2d2_sqlite::SqliteConnection
|
|||
pub struct SubmittedEvent {
|
||||
pub event: Event,
|
||||
pub notice_tx: tokio::sync::mpsc::Sender<Notice>,
|
||||
pub source_ip: String,
|
||||
}
|
||||
|
||||
/// Database file
|
||||
|
@ -227,11 +228,12 @@ pub async fn db_writer(
|
|||
notice_tx.try_send(Notice::duplicate(event.id)).ok();
|
||||
} else {
|
||||
info!(
|
||||
"persisted event: {:?} (kind: {}) from: {:?} in: {:?}",
|
||||
"persisted event: {:?} (kind: {}) from: {:?} in: {:?} (IP: {:?})",
|
||||
event.get_event_id_prefix(),
|
||||
event.kind,
|
||||
event.get_author_prefix(),
|
||||
start.elapsed()
|
||||
start.elapsed(),
|
||||
subm_event.source_ip,
|
||||
);
|
||||
event_write = true;
|
||||
// send this out to all clients
|
||||
|
|
|
@ -736,7 +736,7 @@ async fn nostr_server(
|
|||
// check if the event is too far in the future.
|
||||
if e.is_valid_timestamp(settings.options.reject_future_seconds) {
|
||||
// Write this to the database.
|
||||
let submit_event = SubmittedEvent { event: e.clone(), notice_tx: notice_tx.clone() };
|
||||
let submit_event = SubmittedEvent { event: e.clone(), notice_tx: notice_tx.clone(), source_ip: conn.ip().to_string()};
|
||||
event_tx.send(submit_event).await.ok();
|
||||
client_published_event_count += 1;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user