diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-11 22:47:16 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-11 22:47:16 -0600 |
| commit | 4a66f002c276a57e028e9456f6800b0b3c248885 (patch) | |
| tree | f87cbdc51c09d497548f972b9b1633ceb7606443 /azalea-protocol/src | |
| parent | ff1e28f88e93ba83cf76569b5613445b841efd45 (diff) | |
| download | azalea-drasl-4a66f002c276a57e028e9456f6800b0b3c248885.tar.xz | |
Add options to request Mojang sessionserver with a proxy (#293)
* add options to request mojang sessionserver with a socks5 proxy
* update changelog
* rename auth_proxy to sessionserver_proxy
Diffstat (limited to 'azalea-protocol/src')
| -rw-r--r-- | azalea-protocol/src/connect.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index 556f0f1c..fd599ff8 100644 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -277,7 +277,7 @@ pub enum ConnectionError { use socks5_impl::protocol::UserKey; -/// An address and authentication method for connecting to a Socks5 proxy. +/// An address and authentication method for connecting to a SOCKS5 proxy. #[derive(Debug, Clone)] pub struct Proxy { pub addr: SocketAddr, @@ -299,6 +299,13 @@ impl Display for Proxy { } } +impl From<Proxy> for reqwest::Proxy { + fn from(proxy: Proxy) -> Self { + reqwest::Proxy::all(proxy.to_string()) + .expect("azalea proxies should not fail to parse as reqwest proxies") + } +} + impl Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> { /// Create a new connection to the given address. pub async fn new(address: &SocketAddr) -> Result<Self, ConnectionError> { @@ -310,7 +317,7 @@ impl Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> { Self::new_from_stream(stream).await } - /// Create a new connection to the given address and Socks5 proxy. + /// Create a new connection to the given address and SOCKS5 proxy. /// /// If you're not using a proxy, use [`Self::new`] instead. pub async fn new_with_proxy( @@ -443,7 +450,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> { /// ClientboundLoginPacket::Hello(p) => { /// // tell Mojang we're joining the server & enable encryption /// let e = azalea_crypto::encrypt(&p.public_key, &p.challenge).unwrap(); - /// conn.authenticate(&access_token, &profile.id, e.secret_key, &p) + /// conn.authenticate(&access_token, &profile.id, e.secret_key, &p, None) /// .await?; /// conn.write(ServerboundKey { /// key_bytes: e.encrypted_public_key, @@ -464,14 +471,18 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> { uuid: &Uuid, private_key: [u8; 16], packet: &ClientboundHello, + sessionserver_proxy: Option<Proxy>, ) -> Result<(), ClientSessionServerError> { - azalea_auth::sessionserver::join( + use azalea_auth::sessionserver::{self, SessionServerJoinOpts}; + + sessionserver::join(SessionServerJoinOpts { access_token, - &packet.public_key, - &private_key, + public_key: &packet.public_key, + private_key: &private_key, uuid, - &packet.server_id, - ) + server_id: &packet.server_id, + proxy: sessionserver_proxy.map(Proxy::into), + }) .await } } |
