A asynchronous library/app for intercepting/sniffing TCP requests, modifying headers and responses.
To Install RServer, Please use the following command :
shell
cargo install rserver
How to use the RServer to intercept/sniff TCP requests. RServer currently runs on 8080 port by default.
To run RServer, use the folowing command :
shell
rserver
Please set the browser/system proxy as host 127.0.0.1 and port 8080 (default port of RServer) to use Rserver for intercepting all requests.
If you directly want to test RServer installation without doing the above step, please run the below command :
shell
https_proxy=127.0.0.1:8080 curl https://www.google.com
rserver [OPTIONS]
FLAGS:
--help Prints help information
-V, --version Prints version information
OPTIONS:
--enable-proxy <enable-proxy> Enable proxy flag [default: false]
-h, --host <host> Server host [default: 127.0.0.1]
-p, --port <port> Server port [default: 8080]
--proxy-host <proxy-host> Proxy host
--proxy-port <proxy-port> Proxy port
```rust use rserver::Config; use rserver::Server;
async fn main() -> Result<(), Box
```
How to read the stream data and return stream data & its length.
```rust
/// Read the stream data and return stream data & its length
fn readstream(stream: &mut TcpStream) -> (Vec
if n == 0 {
break;
} else {
request_len += n;
// we need not read more data in case we have read less data than buffer size
if n < buffer_size {
// let us only append the data how much we have read rather than complete existing buffer data
// as n is less than buffer size
request_buffer.append(&mut buffer[..n].to_vec()); // convert slice into vec
break;
} else {
// append complete buffer vec data into request_buffer vec as n == buffer_size
request_buffer.append(&mut buffer);
}
}
}
Err(e) => {
println!("Error in reading stream data: {:?}", e);
break;
}
}
}
(request_buffer, request_len)
}
```
To-Do