cyphernet-labs / rust-internet2

Set of rust crates for software supporting Internet2 (Tor, Noise protocol, lightning network-style messaging)
Apache License 2.0
18 stars 9 forks source link

Brontozaur: Support connecting with existing tcp stream #29

Closed TheCharlatan closed 2 years ago

TheCharlatan commented 2 years ago

This supports creating connecting Brontozaur sessions with an external tcp stream, for example one spawned by a socks proxy.

Example usage:

use internet2::addr::{InetSocketAddr, LocalNode};
use std::str::FromStr;
use socks::Socks5Stream;
use internet2::session::BrontozaurSession;

dummy = InetSocketAddr::from_str("127.0.0.1:12345").unwrap();
let local_node = LocalNode::new(bitcoin::secp256k1::SECP256K1)
let socks_stream = Socks5Stream::connect(
    "127.0.0.1:9050",
    "fdbzgjl7vtezlzwyx6xipvbczq3cuhvxfnypoljuctnl5mqc4bwrr7ad.onion"
).unwrap();
let mut stream = socks_stream.into_inner();
let session = BrontozaurSession::with(stream, local_node.private_key(), dummy).unwrap();
codecov-commenter commented 2 years ago

Codecov Report

Merging #29 (1750242) into master (8e9d496) will decrease coverage by 0.3%. The diff coverage is 0.0%.

@@           Coverage Diff            @@
##           master     #29     +/-   ##
========================================
- Coverage    65.8%   65.5%   -0.3%     
========================================
  Files          26      26             
  Lines        3104    3118     +14     
========================================
  Hits         2042    2042             
- Misses       1062    1076     +14     
Impacted Files Coverage Δ
src/session/session.rs 51.6% <0.0%> (-5.4%) :arrow_down:
src/session/noise/chacha.rs 95.8% <0.0%> (-2.1%) :arrow_down:
src/lib.rs 76.9% <0.0%> (+1.0%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more