mirror of
https://github.com/uqbar-dao/nectar.git
synced 2025-01-05 00:10:23 +03:00
remove debugging prints
This commit is contained in:
parent
08ea80e13d
commit
42f641c8c5
@ -27,8 +27,6 @@ pub fn _verify_auth_token(auth_token: &str, jwt_secret: &[u8]) -> Result<String,
|
|||||||
return Err(jwt::Error::Format);
|
return Err(jwt::Error::Format);
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("hello\r");
|
|
||||||
|
|
||||||
let claims: Result<JwtClaims, jwt::Error> = auth_token.verify_with_key(&secret);
|
let claims: Result<JwtClaims, jwt::Error> = auth_token.verify_with_key(&secret);
|
||||||
|
|
||||||
match claims {
|
match claims {
|
||||||
|
@ -7,7 +7,6 @@ use tokio::sync::mpsc;
|
|||||||
/// if target is a peer, queue to be routed
|
/// if target is a peer, queue to be routed
|
||||||
/// otherwise, create peer and initiate routing
|
/// otherwise, create peer and initiate routing
|
||||||
pub async fn send_to_peer(ext: &IdentityExt, data: &NetData, km: KernelMessage) {
|
pub async fn send_to_peer(ext: &IdentityExt, data: &NetData, km: KernelMessage) {
|
||||||
// println!("send_to_peer\r");
|
|
||||||
if let Some(peer) = data.peers.get_mut(&km.target.node) {
|
if let Some(peer) = data.peers.get_mut(&km.target.node) {
|
||||||
peer.sender.send(km).expect("net: peer sender was dropped");
|
peer.sender.send(km).expect("net: peer sender was dropped");
|
||||||
} else {
|
} else {
|
||||||
@ -46,7 +45,6 @@ async fn connect_to_peer(
|
|||||||
peer_id: Identity,
|
peer_id: Identity,
|
||||||
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) {
|
) {
|
||||||
println!("connect_to_peer\r");
|
|
||||||
if peer_id.is_direct() {
|
if peer_id.is_direct() {
|
||||||
utils::print_debug(
|
utils::print_debug(
|
||||||
&ext.print_tx,
|
&ext.print_tx,
|
||||||
@ -81,7 +79,6 @@ async fn connect_via_router(
|
|||||||
peer_id: &Identity,
|
peer_id: &Identity,
|
||||||
mut peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
mut peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) {
|
) {
|
||||||
println!("connect_via_router\r");
|
|
||||||
let routers_shuffled = {
|
let routers_shuffled = {
|
||||||
let mut routers = match peer_id.routing {
|
let mut routers = match peer_id.routing {
|
||||||
NodeRouting::Routers(ref routers) => routers.clone(),
|
NodeRouting::Routers(ref routers) => routers.clone(),
|
||||||
@ -131,7 +128,6 @@ pub async fn handle_failed_connection(
|
|||||||
peer_id: &Identity,
|
peer_id: &Identity,
|
||||||
mut peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
mut peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) {
|
) {
|
||||||
println!("handle_failed_connection\r");
|
|
||||||
utils::print_debug(
|
utils::print_debug(
|
||||||
&ext.print_tx,
|
&ext.print_tx,
|
||||||
&format!("net: failed to connect to {}", peer_id.name),
|
&format!("net: failed to connect to {}", peer_id.name),
|
||||||
|
@ -4,7 +4,6 @@ use lib::types::core::{Identity, NodeRouting};
|
|||||||
use tokio::{sync::mpsc, time};
|
use tokio::{sync::mpsc, time};
|
||||||
|
|
||||||
pub async fn maintain_routers(ext: IdentityExt, data: NetData) -> anyhow::Result<()> {
|
pub async fn maintain_routers(ext: IdentityExt, data: NetData) -> anyhow::Result<()> {
|
||||||
println!("maintain_routers\r");
|
|
||||||
let NodeRouting::Routers(ref routers) = ext.our.routing else {
|
let NodeRouting::Routers(ref routers) = ext.our.routing else {
|
||||||
return Err(anyhow::anyhow!("net: no routers to maintain"));
|
return Err(anyhow::anyhow!("net: no routers to maintain"));
|
||||||
};
|
};
|
||||||
@ -25,7 +24,6 @@ pub async fn maintain_routers(ext: IdentityExt, data: NetData) -> anyhow::Result
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn connect_to_router(router_id: &Identity, ext: &IdentityExt, data: &NetData) {
|
pub async fn connect_to_router(router_id: &Identity, ext: &IdentityExt, data: &NetData) {
|
||||||
println!("connect_to_router\r");
|
|
||||||
utils::print_debug(
|
utils::print_debug(
|
||||||
&ext.print_tx,
|
&ext.print_tx,
|
||||||
&format!("net: attempting to connect to router {}", router_id.name),
|
&format!("net: attempting to connect to router {}", router_id.name),
|
||||||
|
@ -34,7 +34,6 @@ pub async fn networking(
|
|||||||
kernel_message_rx: MessageReceiver,
|
kernel_message_rx: MessageReceiver,
|
||||||
_reveal_ip: bool, // only used if indirect
|
_reveal_ip: bool, // only used if indirect
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("networking\r\n");
|
|
||||||
let ext = IdentityExt {
|
let ext = IdentityExt {
|
||||||
our: Arc::new(our),
|
our: Arc::new(our),
|
||||||
our_ip: Arc::new(our_ip),
|
our_ip: Arc::new(our_ip),
|
||||||
@ -116,7 +115,6 @@ async fn local_recv(
|
|||||||
mut kernel_message_rx: MessageReceiver,
|
mut kernel_message_rx: MessageReceiver,
|
||||||
data: NetData,
|
data: NetData,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("local_recv\r\n");
|
|
||||||
while let Some(km) = kernel_message_rx.recv().await {
|
while let Some(km) = kernel_message_rx.recv().await {
|
||||||
if km.target.node == ext.our.name {
|
if km.target.node == ext.our.name {
|
||||||
// handle messages sent to us
|
// handle messages sent to us
|
||||||
@ -306,7 +304,6 @@ async fn handle_remote_request(
|
|||||||
request_body: &[u8],
|
request_body: &[u8],
|
||||||
data: &NetData,
|
data: &NetData,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("handle_remote_request\r");
|
|
||||||
match rmp_serde::from_slice::<NetAction>(request_body) {
|
match rmp_serde::from_slice::<NetAction>(request_body) {
|
||||||
Ok(NetAction::KnsBatchUpdate(_)) | Ok(NetAction::KnsUpdate(_)) => {
|
Ok(NetAction::KnsBatchUpdate(_)) | Ok(NetAction::KnsUpdate(_)) => {
|
||||||
// for now, we don't get these from remote, only locally.
|
// for now, we don't get these from remote, only locally.
|
||||||
|
@ -82,7 +82,6 @@ pub async fn init_direct(
|
|||||||
proxy_request: bool,
|
proxy_request: bool,
|
||||||
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
||||||
println!("tcp_init_direct\r");
|
|
||||||
match time::timeout(
|
match time::timeout(
|
||||||
TIMEOUT,
|
TIMEOUT,
|
||||||
connect_with_handshake(ext, peer_id, port, None, proxy_request),
|
connect_with_handshake(ext, peer_id, port, None, proxy_request),
|
||||||
@ -113,7 +112,6 @@ pub async fn init_routed(
|
|||||||
router_port: u16,
|
router_port: u16,
|
||||||
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
||||||
println!("tcp_init_routed\r");
|
|
||||||
match time::timeout(
|
match time::timeout(
|
||||||
TIMEOUT,
|
TIMEOUT,
|
||||||
connect_with_handshake(ext, peer_id, router_port, Some(router_id), false),
|
connect_with_handshake(ext, peer_id, router_port, Some(router_id), false),
|
||||||
@ -148,7 +146,6 @@ async fn recv_connection(
|
|||||||
data: NetData,
|
data: NetData,
|
||||||
mut stream: TcpStream,
|
mut stream: TcpStream,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("tcp_recv_connection\r");
|
|
||||||
// before we begin XX handshake pattern, check first message over socket
|
// before we begin XX handshake pattern, check first message over socket
|
||||||
let (len, first_message) = utils::recv_raw(&mut stream).await?;
|
let (len, first_message) = utils::recv_raw(&mut stream).await?;
|
||||||
|
|
||||||
@ -235,7 +232,6 @@ async fn connect_with_handshake(
|
|||||||
use_router: Option<&Identity>,
|
use_router: Option<&Identity>,
|
||||||
proxy_request: bool,
|
proxy_request: bool,
|
||||||
) -> anyhow::Result<PeerConnection> {
|
) -> anyhow::Result<PeerConnection> {
|
||||||
println!("tcp_connect_with_handshake\r");
|
|
||||||
let ip = match use_router {
|
let ip = match use_router {
|
||||||
None => peer_id
|
None => peer_id
|
||||||
.get_ip()
|
.get_ip()
|
||||||
@ -315,7 +311,6 @@ pub async fn recv_via_router(
|
|||||||
peer_id: Identity,
|
peer_id: Identity,
|
||||||
router_id: Identity,
|
router_id: Identity,
|
||||||
) {
|
) {
|
||||||
println!("tcp_recv_via_router\r");
|
|
||||||
let Some((ip, port)) = router_id.tcp_routing() else {
|
let Some((ip, port)) = router_id.tcp_routing() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -358,7 +353,6 @@ async fn connect_with_handshake_via_router(
|
|||||||
router_id: &Identity,
|
router_id: &Identity,
|
||||||
mut stream: TcpStream,
|
mut stream: TcpStream,
|
||||||
) -> anyhow::Result<PeerConnection> {
|
) -> anyhow::Result<PeerConnection> {
|
||||||
println!("tcp_connect_with_handshake_via_router\r");
|
|
||||||
// before beginning XX handshake pattern, send a routing request
|
// before beginning XX handshake pattern, send a routing request
|
||||||
utils::send_raw(
|
utils::send_raw(
|
||||||
&mut stream,
|
&mut stream,
|
||||||
|
@ -36,7 +36,6 @@ pub async fn create_passthrough(
|
|||||||
pending_passthroughs: &PendingPassthroughs,
|
pending_passthroughs: &PendingPassthroughs,
|
||||||
socket_1: PendingStream,
|
socket_1: PendingStream,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("create_passthrough\r");
|
|
||||||
// if the target has already generated a pending passthrough for this source,
|
// if the target has already generated a pending passthrough for this source,
|
||||||
// immediately match them
|
// immediately match them
|
||||||
if let Some(((_target, _from), pending_stream)) =
|
if let Some(((_target, _from), pending_stream)) =
|
||||||
@ -111,7 +110,6 @@ pub async fn create_passthrough(
|
|||||||
|
|
||||||
/// cross the streams -- spawn on own task
|
/// cross the streams -- spawn on own task
|
||||||
pub async fn maintain_passthrough(socket_1: PendingStream, socket_2: PendingStream) {
|
pub async fn maintain_passthrough(socket_1: PendingStream, socket_2: PendingStream) {
|
||||||
println!("maintain_passthrough\r");
|
|
||||||
match (socket_1, socket_2) {
|
match (socket_1, socket_2) {
|
||||||
(PendingStream::Tcp(socket_1), PendingStream::Tcp(socket_2)) => {
|
(PendingStream::Tcp(socket_1), PendingStream::Tcp(socket_2)) => {
|
||||||
// do not use bidirectional because if one side closes,
|
// do not use bidirectional because if one side closes,
|
||||||
@ -204,7 +202,6 @@ pub fn validate_routing_request(
|
|||||||
buf: &[u8],
|
buf: &[u8],
|
||||||
pki: &OnchainPKI,
|
pki: &OnchainPKI,
|
||||||
) -> anyhow::Result<(Identity, Identity)> {
|
) -> anyhow::Result<(Identity, Identity)> {
|
||||||
println!("validate_routing_request\r");
|
|
||||||
let routing_request: RoutingRequest = rmp_serde::from_slice(buf)?;
|
let routing_request: RoutingRequest = rmp_serde::from_slice(buf)?;
|
||||||
let from_id = pki
|
let from_id = pki
|
||||||
.get(&routing_request.source)
|
.get(&routing_request.source)
|
||||||
|
@ -95,7 +95,6 @@ pub async fn init_direct(
|
|||||||
proxy_request: bool,
|
proxy_request: bool,
|
||||||
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
||||||
println!("init_direct\r");
|
|
||||||
match time::timeout(
|
match time::timeout(
|
||||||
TIMEOUT,
|
TIMEOUT,
|
||||||
connect_with_handshake(ext, peer_id, port, None, proxy_request),
|
connect_with_handshake(ext, peer_id, port, None, proxy_request),
|
||||||
@ -126,7 +125,6 @@ pub async fn init_routed(
|
|||||||
router_port: u16,
|
router_port: u16,
|
||||||
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
peer_rx: mpsc::UnboundedReceiver<KernelMessage>,
|
||||||
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
) -> Result<(), mpsc::UnboundedReceiver<KernelMessage>> {
|
||||||
println!("init_routed\r");
|
|
||||||
match time::timeout(
|
match time::timeout(
|
||||||
TIMEOUT,
|
TIMEOUT,
|
||||||
connect_with_handshake(ext, peer_id, router_port, Some(router_id), false),
|
connect_with_handshake(ext, peer_id, router_port, Some(router_id), false),
|
||||||
@ -164,7 +162,6 @@ pub async fn recv_via_router(
|
|||||||
peer_id: Identity,
|
peer_id: Identity,
|
||||||
router_id: Identity,
|
router_id: Identity,
|
||||||
) {
|
) {
|
||||||
println!("recv_via_router\r");
|
|
||||||
let Some((ip, port)) = router_id.ws_routing() else {
|
let Some((ip, port)) = router_id.ws_routing() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -206,7 +203,6 @@ async fn recv_connection(
|
|||||||
data: NetData,
|
data: NetData,
|
||||||
mut socket: WebSocket,
|
mut socket: WebSocket,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
println!("recv_connection\r");
|
|
||||||
// before we begin XX handshake pattern, check first message over socket
|
// before we begin XX handshake pattern, check first message over socket
|
||||||
let first_message = &utils::recv(&mut socket).await?;
|
let first_message = &utils::recv(&mut socket).await?;
|
||||||
|
|
||||||
@ -293,7 +289,6 @@ async fn connect_with_handshake(
|
|||||||
use_router: Option<&Identity>,
|
use_router: Option<&Identity>,
|
||||||
proxy_request: bool,
|
proxy_request: bool,
|
||||||
) -> anyhow::Result<PeerConnection> {
|
) -> anyhow::Result<PeerConnection> {
|
||||||
println!("connect_with_handshake\r");
|
|
||||||
let mut buf = vec![0u8; 65535];
|
let mut buf = vec![0u8; 65535];
|
||||||
let (mut noise, our_static_key) = build_initiator();
|
let (mut noise, our_static_key) = build_initiator();
|
||||||
|
|
||||||
@ -375,7 +370,6 @@ async fn connect_with_handshake_via_router(
|
|||||||
router_id: &Identity,
|
router_id: &Identity,
|
||||||
mut socket: WebSocketStream<MaybeTlsStream<TcpStream>>,
|
mut socket: WebSocketStream<MaybeTlsStream<TcpStream>>,
|
||||||
) -> anyhow::Result<PeerConnection> {
|
) -> anyhow::Result<PeerConnection> {
|
||||||
println!("connect_with_handshake_via_router\r");
|
|
||||||
// before beginning XX handshake pattern, send a routing request
|
// before beginning XX handshake pattern, send a routing request
|
||||||
socket
|
socket
|
||||||
.send(tungstenite::Message::binary(rmp_serde::to_vec(
|
.send(tungstenite::Message::binary(rmp_serde::to_vec(
|
||||||
|
Loading…
Reference in New Issue
Block a user