From aab4b17a8db492568762a8eb0cf4c817f4c79a72 Mon Sep 17 00:00:00 2001 From: serxoz Date: Wed, 30 Aug 2023 12:32:29 +0200 Subject: [PATCH] =?UTF-8?q?conexi=C3=B3n=20a=20trav=C3=A9s=20de=20proxy=20?= =?UTF-8?q?socks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 19 +++++++++++++++++++ Cargo.toml | 2 +- src/main.rs | 7 +++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2035a19..b22eae1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,6 +162,12 @@ dependencies = [ "syn", ] +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "encoding" version = "0.2.33" @@ -428,6 +434,7 @@ dependencies = [ "thiserror", "tokio", "tokio-native-tls", + "tokio-socks", "tokio-stream", "tokio-util", "toml", @@ -984,6 +991,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.11" diff --git a/Cargo.toml b/Cargo.toml index 3cb9a82..972c5a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,5 +8,5 @@ edition = "2021" [dependencies] failure = "0.1.8" futures = "0.3.25" -irc = "0.15.0" +irc = { version = "0.15.0", features = ["proxy"] } tokio = { version = "1.22.0", features = ["full"] } diff --git a/src/main.rs b/src/main.rs index ac3c163..a185dda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,9 @@ async fn main() -> Result<(), failure::Error> { nickname: Some("420".to_owned()), server: Some("xinu.me".to_owned()), channels: vec!["#bots".to_owned()], + proxy_type: Some(ProxyType::Socks5), + proxy_server: Some("127.0.0.1".to_owned()), + proxy_port: Some(9050), ..Config::default() }; @@ -54,14 +57,14 @@ async fn main() -> Result<(), failure::Error> { if out_parsed.contains("\n") { for linea in out_parsed.split("\n"){ client.send_privmsg( - message.response_target().unwrap(), + message.response_target().unwrap(), linea ).unwrap(); // poƱer un sleep para evitar flood } } else { client.send_privmsg( - message.response_target().unwrap(), + message.response_target().unwrap(), out_parsed ).unwrap(); }