Skip to content

Commit

Permalink
Added clone for targetAddr
Browse files Browse the repository at this point in the history
Fixes #61
  • Loading branch information
Rohit Kulkarni authored and sticnarf committed Feb 19, 2025
1 parent 7be4289 commit 5f6fa7f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Stream for ProxyAddrsStream {
}

/// A SOCKS connection target.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum TargetAddr<'a> {
/// Connect to an IP address.
Ip(SocketAddr),
Expand Down Expand Up @@ -292,6 +292,22 @@ mod tests {
Ok(block_on(t.to_proxy_addrs().map(Result::unwrap).collect()))
}

#[test]
fn test_clone_ip() {
let addr = TargetAddr::Ip(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080));
let addr_clone = addr.clone();
assert_eq!(addr, addr_clone);
assert_eq!(addr.to_string(), addr_clone.to_string());
}

#[test]
fn test_clone_domain() {
let addr = TargetAddr::Domain(Cow::Borrowed("example.com"), 80);
let addr_clone = addr.clone();
assert_eq!(addr, addr_clone);
assert_eq!(addr.to_string(), addr_clone.to_string());
}

#[test]
fn test_display_ip() {
let addr = TargetAddr::Ip(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080));
Expand Down

0 comments on commit 5f6fa7f

Please sign in to comment.