Skip to content

Commit

Permalink
use UserKey from SOCKS5 impl
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Jan 4, 2024
1 parent 487f9df commit 7824dc2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions azalea-protocol/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use azalea_auth::game_profile::GameProfile;
use azalea_auth::sessionserver::{ClientSessionServerError, ServerSessionServerError};
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
use bytes::BytesMut;
use socks5_impl::protocol::UserKey;
use std::fmt::Debug;
use std::io::Cursor;
use std::marker::PhantomData;
Expand Down Expand Up @@ -258,14 +257,16 @@ pub enum ConnectionError {
Io(#[from] std::io::Error),
}

use socks5_impl::protocol::UserKey;

#[derive(Debug, Clone)]
pub struct Proxy {
pub addr: SocketAddr,
pub auth: Option<(String, String)>,
pub auth: Option<UserKey>
}

impl Proxy {
pub fn new(addr: SocketAddr, auth: Option<(String, String)>) -> Self {
pub fn new(addr: SocketAddr, auth: Option<UserKey>) -> Self {
Self { addr, auth }
}
}
Expand All @@ -278,7 +279,7 @@ impl Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> {
let proxy_stream = TcpStream::connect(proxy.addr).await?;
let mut stream = BufStream::new(proxy_stream);
let auth = match proxy.auth {
Some((username, password)) => Some(UserKey::new(&username, &password)),
Some(user_key) => Some(user_key),
None => None,
};

Check warning on line 284 in azalea-protocol/src/connect.rs

View workflow job for this annotation

GitHub Actions / clippy

manual implementation of `Option::map`

warning: manual implementation of `Option::map` --> azalea-protocol/src/connect.rs:281:28 | 281 | let auth = match proxy.auth { | ____________________________^ 282 | | Some(user_key) => Some(user_key), 283 | | None => None, 284 | | }; | |_________________^ help: try: `proxy.auth.map(|user_key| user_key)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map = note: `#[warn(clippy::manual_map)]` on by default

Check warning on line 284 in azalea-protocol/src/connect.rs

View workflow job for this annotation

GitHub Actions / clippy

this match expression is unnecessary

warning: this match expression is unnecessary --> azalea-protocol/src/connect.rs:281:28 | 281 | let auth = match proxy.auth { | ____________________________^ 282 | | Some(user_key) => Some(user_key), 283 | | None => None, 284 | | }; | |_________________^ help: replace it with: `proxy.auth` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_match = note: `#[warn(clippy::needless_match)]` on by default

Expand Down

0 comments on commit 7824dc2

Please sign in to comment.