CI: Export executable

This commit is contained in:
Snowiiii 2024-10-13 18:57:13 +02:00
parent 533357ceaa
commit 018ee7c583
4 changed files with 17 additions and 14 deletions

View File

@ -29,7 +29,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 22
cache: npm cache: npm
- name: Setup Pages - name: Setup Pages
uses: actions/configure-pages@v5 uses: actions/configure-pages@v5

View File

@ -53,9 +53,10 @@ jobs:
- run: cargo test --verbose - run: cargo test --verbose
build_release: build_release:
name: Build project in release name: Build project in release
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
toolchain: toolchain:
- stable - stable
@ -65,6 +66,11 @@ jobs:
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose --release - run: cargo build --verbose --release
- name: Export executable
uses: actions/upload-artifact@v4
with:
name: pumpkin-${{ matrix.os }}
path: target/${{ matrix.target }}/release/pumpkin*
clippy_release: clippy_release:
name: Run lints in release mode name: Run lints in release mode
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -77,5 +83,5 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo clippy --release --all-targets --all-features --no-default-features -- -D warnings - run: cargo clippy --release --all-targets --all-features --no-default-features -- -D warnings

View File

@ -50,7 +50,7 @@ pub struct GameProfile {
/// 2. Mojang's servers verify the client's credentials and add the player to the their Servers /// 2. Mojang's servers verify the client's credentials and add the player to the their Servers
/// 3. Now our server will send a Request to the Session servers and check if the Player has joined the Session Server . /// 3. Now our server will send a Request to the Session servers and check if the Player has joined the Session Server .
/// ///
/// **Note:** This process helps prevent unauthorized access to the server and ensures that only legitimate Minecraft accounts can connect. /// See <https://snowiiii.github.io/Pumpkin/developer/authentication.html>
pub async fn authenticate( pub async fn authenticate(
username: &str, username: &str,
server_hash: &str, server_hash: &str,

View File

@ -362,22 +362,19 @@ impl Client {
/// Close connection when an error occurs or when the Client closed the connection /// Close connection when an error occurs or when the Client closed the connection
pub async fn poll(&self, event: &Event) { pub async fn poll(&self, event: &Event) {
if event.is_readable() { if event.is_readable() {
let mut received_data = vec![0; 4096]; let mut received_data = vec![];
let mut bytes_read = 0; let mut buf = [0; 4096];
loop { loop {
let connection = self.connection.clone(); let connection = self.connection.clone();
let mut connection = connection.lock(); let mut connection = connection.lock();
match connection.read(&mut received_data[bytes_read..]) { match connection.read(&mut buf) {
Ok(0) => { Ok(0) => {
// Reading 0 bytes means the other side has closed the // Reading 0 bytes means the other side has closed the
// connection or is done writing, then so are we. // connection or is done writing, then so are we.
self.close(); self.close();
break; break;
} }
Ok(n) => { Ok(n) => received_data.extend(&buf[..n]),
bytes_read += n;
received_data.extend(&vec![0; n]);
}
// Would block "errors" are the OS's way of saying that the // Would block "errors" are the OS's way of saying that the
// connection is not actually ready to perform this I/O operation. // connection is not actually ready to perform this I/O operation.
Err(ref err) if would_block(err) => break, Err(ref err) if would_block(err) => break,
@ -387,9 +384,9 @@ impl Client {
} }
} }
if bytes_read != 0 { if received_data.len() != 0 {
let mut dec = self.dec.lock(); let mut dec = self.dec.lock();
dec.queue_slice(&received_data[..bytes_read]); dec.queue_slice(&received_data);
match dec.decode() { match dec.decode() {
Ok(packet) => { Ok(packet) => {
if let Some(packet) = packet { if let Some(packet) = packet {