Skip to content

Commit

Permalink
save dev state
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Jan 8, 2024
1 parent ecd7688 commit 119b6d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions main/src/net/http.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::websocket::{spawn_proxy, is_websocket_req};

use super::*;

use address_status::{
Expand Down Expand Up @@ -240,6 +242,10 @@ async fn router(
}
};

if is_websocket_req(&req) {
spawn_proxy("TODO").await.unwrap();
}

if !remote_addr.ip().is_global() {
log::info!(
"{}",
Expand Down
8 changes: 7 additions & 1 deletion main/src/net/websocket.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use std::time::Duration;

use futures_util::{FutureExt, SinkExt, StreamExt};
use hyper::{header::HeaderValue, Body, Request};
use log::{error, info};
use tokio::{io, net::TcpListener, sync, time};
use tokio_tungstenite::tungstenite::Message;

async fn spawn_proxy(_addr: &str) -> io::Result<()> {
pub(crate) fn is_websocket_req(req: &Request<Body>) -> bool {
let expected = HeaderValue::from_static("websocket");
Some(&expected) == req.headers().get("upgrade")
}

pub(crate) async fn spawn_proxy(_addr: &str) -> io::Result<()> {
let (tx, _) = sync::broadcast::channel(10);

let bind_addr = "127.0.0.1:6678";
Expand Down

0 comments on commit 119b6d0

Please sign in to comment.