conexión a través de proxy socks

This commit is contained in:
serxoz 2023-08-30 12:32:29 +02:00
parent 6ffc0e891a
commit aab4b17a8d
3 changed files with 25 additions and 3 deletions

19
Cargo.lock generated
View File

@ -162,6 +162,12 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]] [[package]]
name = "encoding" name = "encoding"
version = "0.2.33" version = "0.2.33"
@ -428,6 +434,7 @@ dependencies = [
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
"tokio-socks",
"tokio-stream", "tokio-stream",
"tokio-util", "tokio-util",
"toml", "toml",
@ -984,6 +991,18 @@ dependencies = [
"tokio", "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]] [[package]]
name = "tokio-stream" name = "tokio-stream"
version = "0.1.11" version = "0.1.11"

View File

@ -8,5 +8,5 @@ edition = "2021"
[dependencies] [dependencies]
failure = "0.1.8" failure = "0.1.8"
futures = "0.3.25" futures = "0.3.25"
irc = "0.15.0" irc = { version = "0.15.0", features = ["proxy"] }
tokio = { version = "1.22.0", features = ["full"] } tokio = { version = "1.22.0", features = ["full"] }

View File

@ -8,6 +8,9 @@ async fn main() -> Result<(), failure::Error> {
nickname: Some("420".to_owned()), nickname: Some("420".to_owned()),
server: Some("xinu.me".to_owned()), server: Some("xinu.me".to_owned()),
channels: vec!["#bots".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() ..Config::default()
}; };
@ -54,14 +57,14 @@ async fn main() -> Result<(), failure::Error> {
if out_parsed.contains("\n") { if out_parsed.contains("\n") {
for linea in out_parsed.split("\n"){ for linea in out_parsed.split("\n"){
client.send_privmsg( client.send_privmsg(
message.response_target().unwrap(), message.response_target().unwrap(),
linea linea
).unwrap(); ).unwrap();
// poñer un sleep para evitar flood // poñer un sleep para evitar flood
} }
} else { } else {
client.send_privmsg( client.send_privmsg(
message.response_target().unwrap(), message.response_target().unwrap(),
out_parsed out_parsed
).unwrap(); ).unwrap();
} }