Data handling completely rebuilt. Now correctly handles all TCP/IP traffic.
This commit is contained in:
parent
1aa97d6493
commit
f19c7d8f2a
12 changed files with 493 additions and 604 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use sslrelay::{self, ConfigType, RelayConfig, HandlerCallbacks};
|
||||
|
||||
|
||||
// Handler object
|
||||
#[derive(Clone)] // Must have Clone trait implemented.
|
||||
struct Handler;
|
||||
|
||||
/*
|
||||
|
|
@ -10,24 +10,24 @@ struct Handler;
|
|||
*/
|
||||
impl HandlerCallbacks for Handler {
|
||||
|
||||
// Request non blocking callback
|
||||
// DownStream non blocking callback
|
||||
fn ds_nb_callback(&self, _in_data: Vec<u8>) {
|
||||
println!("[+] Request Non Blocking CallBack!");
|
||||
println!("[CALLBACK] Down Stream Non Blocking CallBack!");
|
||||
}
|
||||
|
||||
// Request blocking callback
|
||||
// DownStream blocking callback
|
||||
fn ds_b_callback(&self, _in_data: &mut Vec<u8>) {
|
||||
println!("[+] Request Blocking CallBack!");
|
||||
println!("[CALLBACK] Down Stream Blocking CallBack!");
|
||||
}
|
||||
|
||||
// Response non blocking callback
|
||||
// UpStream non blocking callback
|
||||
fn us_nb_callback(&self, _in_data: Vec<u8>) {
|
||||
println!("[+] Response Non Blocking CallBack!");
|
||||
println!("[CALLBACK] Up Stream Non Blocking CallBack!");
|
||||
}
|
||||
|
||||
// Response blocking callback
|
||||
// UpStream blocking callback
|
||||
fn us_b_callback(&self, _in_data: &mut Vec<u8>) {
|
||||
println!("[+] Response Blocking CallBack!");
|
||||
println!("[CALLBACK] Up Stream Blocking CallBack!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,6 @@ fn main() {
|
|||
remote_port: "443".to_string(),
|
||||
ssl_private_key_path: "./remote.com.key".to_string(),
|
||||
ssl_cert_path: "./remote.com.crt".to_string(),
|
||||
verbose_level: 2,
|
||||
}));
|
||||
|
||||
// Start listening
|
||||
|
|
|
|||
9
examples/modifydata/Cargo.toml
Normal file
9
examples/modifydata/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "modifydata"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
sslrelay = {path = "../../"}
|
||||
|
|
@ -3,5 +3,4 @@ bind_port = "443"
|
|||
ssl_private_key_path = "./remote.com.key"
|
||||
ssl_cert_path = "./remote.com.crt"
|
||||
remote_host = "remote.com"
|
||||
remote_port = "443"
|
||||
verbose_level = "2"
|
||||
remote_port = "443"
|
||||
46
examples/modifydata/src/main.rs
Normal file
46
examples/modifydata/src/main.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use sslrelay::{self, ConfigType, RelayConfig, HandlerCallbacks};
|
||||
|
||||
// Handler object
|
||||
#[derive(Clone)] // Must have Clone trait implemented.
|
||||
struct Handler;
|
||||
|
||||
/*
|
||||
Callback traits that can be used to read or inject/modify data
|
||||
into upstream or downstream data.
|
||||
*/
|
||||
impl HandlerCallbacks for Handler {
|
||||
|
||||
// DownStream non blocking callback
|
||||
fn ds_nb_callback(&self, _in_data: Vec<u8>) {
|
||||
println!("[+] Data before complete rewrite:\n{:#04X?}", _in_data);
|
||||
}
|
||||
|
||||
// DownStream blocking callback
|
||||
fn ds_b_callback(&self, _in_data: &mut Vec<u8>) {
|
||||
_in_data.reverse();
|
||||
println!("[+] Data rewritten to:\n{:#04X?}", _in_data);
|
||||
}
|
||||
|
||||
// UpStream non blocking callback
|
||||
fn us_nb_callback(&self, _in_data: Vec<u8>) {
|
||||
println!("[+] Data before complete rewrite:\n{:#04X?}", _in_data);
|
||||
}
|
||||
|
||||
// UpStream blocking callback
|
||||
fn us_b_callback(&self, _in_data: &mut Vec<u8>) {
|
||||
_in_data.reverse();
|
||||
println!("[+] Data rewritten to:\n{:#04X?}", _in_data);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
// Create new SSLRelay object
|
||||
let mut relay = sslrelay::SSLRelay::new(Handler);
|
||||
|
||||
// Load Configuration
|
||||
relay.load_config(ConfigType::Default);
|
||||
|
||||
// Start listening
|
||||
relay.start();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue