mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 16:41:01 +00:00
swith socks5-impl
This commit is contained in:
parent
ab9f8011f0
commit
c61b6c74cd
11 changed files with 163 additions and 301 deletions
29
src/lib.rs
29
src/lib.rs
|
@ -1,6 +1,8 @@
|
|||
use crate::error::Error;
|
||||
use crate::socks::SocksVersion;
|
||||
use crate::{http::HttpManager, socks::SocksManager, tun2proxy::TunToProxy};
|
||||
use crate::{
|
||||
error::Error, http::HttpManager, socks::SocksManager, socks::SocksVersion,
|
||||
tun2proxy::TunToProxy,
|
||||
};
|
||||
use socks5_impl::protocol::UserKey;
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
|
||||
mod android;
|
||||
|
@ -16,7 +18,7 @@ mod virtdns;
|
|||
pub struct Proxy {
|
||||
pub proxy_type: ProxyType,
|
||||
pub addr: SocketAddr,
|
||||
pub credentials: Option<Credentials>,
|
||||
pub credentials: Option<UserKey>,
|
||||
}
|
||||
|
||||
pub enum NetworkInterface {
|
||||
|
@ -48,7 +50,7 @@ impl Proxy {
|
|||
} else {
|
||||
let username = String::from(url.username());
|
||||
let password = String::from(url.password().unwrap_or(""));
|
||||
Some(Credentials::new(&username, &password))
|
||||
Some(UserKey::new(username, password))
|
||||
};
|
||||
|
||||
let scheme = url.scheme();
|
||||
|
@ -94,7 +96,7 @@ pub struct Options {
|
|||
|
||||
impl Options {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
Options::default()
|
||||
}
|
||||
|
||||
pub fn with_virtual_dns(mut self) -> Self {
|
||||
|
@ -108,21 +110,6 @@ impl Options {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct Credentials {
|
||||
pub(crate) username: String,
|
||||
pub(crate) password: String,
|
||||
}
|
||||
|
||||
impl Credentials {
|
||||
pub fn new(username: &str, password: &str) -> Self {
|
||||
Self {
|
||||
username: String::from(username),
|
||||
password: String::from(password),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tun_to_proxy<'a>(
|
||||
interface: &NetworkInterface,
|
||||
proxy: &Proxy,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue