mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 09:09:07 -05:00
feat: log origin header from websocket requests
fixes: https://todo.sr.ht/~gheartsfield/nostr-rs-relay/33
This commit is contained in:
parent
95748647f0
commit
4f1a912f36
|
@ -88,6 +88,7 @@ async fn handle_web_request(
|
||||||
Some(config),
|
Some(config),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
let origin = get_header_string("origin", request.headers());
|
||||||
let user_agent = get_header_string("user-agent", request.headers());
|
let user_agent = get_header_string("user-agent", request.headers());
|
||||||
// determine the remote IP from headers if the exist
|
// determine the remote IP from headers if the exist
|
||||||
let header_ip = settings
|
let header_ip = settings
|
||||||
|
@ -101,6 +102,7 @@ async fn handle_web_request(
|
||||||
let client_info = ClientInfo {
|
let client_info = ClientInfo {
|
||||||
remote_ip,
|
remote_ip,
|
||||||
user_agent,
|
user_agent,
|
||||||
|
origin,
|
||||||
};
|
};
|
||||||
// spawn a nostr server with our websocket
|
// spawn a nostr server with our websocket
|
||||||
tokio::spawn(nostr_server(
|
tokio::spawn(nostr_server(
|
||||||
|
@ -439,6 +441,7 @@ fn make_notice_message(notice: Notice) -> Message {
|
||||||
struct ClientInfo {
|
struct ClientInfo {
|
||||||
remote_ip: String,
|
remote_ip: String,
|
||||||
user_agent: Option<String>,
|
user_agent: Option<String>,
|
||||||
|
origin: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle new client connections. This runs through an event loop
|
/// Handle new client connections. This runs through an event loop
|
||||||
|
@ -502,9 +505,12 @@ async fn nostr_server(
|
||||||
let mut client_published_event_count: usize = 0;
|
let mut client_published_event_count: usize = 0;
|
||||||
let mut client_received_event_count: usize = 0;
|
let mut client_received_event_count: usize = 0;
|
||||||
debug!("new client connection (cid: {}, ip: {:?})", cid, conn.ip());
|
debug!("new client connection (cid: {}, ip: {:?})", cid, conn.ip());
|
||||||
if let Some(ua) = client_info.user_agent {
|
let origin = client_info.origin.unwrap_or("<unspecified>".into());
|
||||||
debug!("cid: {}, user-agent: {:?}", cid, ua);
|
let user_agent = client_info.user_agent.unwrap_or("<unspecified>".into());
|
||||||
}
|
debug!(
|
||||||
|
"cid: {}, origin: {:?}, user-agent: {:?}",
|
||||||
|
cid, origin, user_agent
|
||||||
|
);
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = shutdown.recv() => {
|
_ = shutdown.recv() => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user