Skip to content
Merged

V2 #3

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
6f74284
refactor: migrate from Java/Gradle to Rust/Cargo for server implement…
sharrlotte Jan 15, 2026
fa1f87f
chore: clean up gitignore by removing empty lines and comments
sharrlotte Jan 15, 2026
fbe2d73
feat: implement PlayerConnect server with HTTP and proxy services
sharrlotte Jan 15, 2026
1436950
feat(packets): implement packet serialization and add ArcCloseReason
sharrlotte Jan 16, 2026
3d1a79b
refactor(server): restructure connection and room management
sharrlotte Jan 16, 2026
f51d702
refactor(proxy): restructure codebase and improve connection handling
sharrlotte Jan 16, 2026
f3b7c32
c
sharrlotte Jan 16, 2026
c9b48ce
refactor(proxy): extract TCP/UDP writers into separate structs
sharrlotte Jan 16, 2026
06cdc89
refactor(Dockerfile): optimize build process and remove redundant steps
sharrlotte Jan 16, 2026
80ee2f3
ci: update docker image tag in release workflow
sharrlotte Jan 16, 2026
da3ef73
refactor(state): simplify rooms read access by adding helper method
sharrlotte Jan 17, 2026
93497d7
refactor(rooms): restructure room management and connection handling
sharrlotte Jan 17, 2026
d9c08eb
feat(proxy_server): notify state on room stats update
sharrlotte Jan 17, 2026
a2c3eec
refactor(http_server,proxy_server): improve error handling and code o…
sharrlotte Jan 17, 2026
b72a8b2
refactor(proxy_server): improve connection logging with unique IDs
sharrlotte Jan 17, 2026
a19ee83
refactor(proxy): improve connection handling and logging
sharrlotte Jan 17, 2026
f631ef7
fix(state): prevent broadcast channel from closing prematurely
sharrlotte Jan 17, 2026
802d617
perf(http_server): reduce SSE keep-alive interval to 3 seconds
sharrlotte Jan 17, 2026
b261003
perf(http): remove redundant keep-alive text to optimize SSE
sharrlotte Jan 17, 2026
ee3b352
refactor(packets): replace manual stats parsing with serde_json
sharrlotte Jan 18, 2026
3652505
refactor(http_server): simplify rooms_sse response handling
sharrlotte Jan 18, 2026
ed3c734
refactor(http): simplify API endpoint paths
sharrlotte Jan 18, 2026
5b8bfe8
feat(room): add ping tracking and room view model
sharrlotte Jan 18, 2026
4aee19c
fix(serialization): add missing serde rename attributes
sharrlotte Jan 18, 2026
22d0851
fix(http_server): wrap RoomUpdateEvent in vector for SSE response
sharrlotte Jan 18, 2026
f78459c
fix(proxy_server): add warning logs for unhandled packets and queue full
sharrlotte Jan 18, 2026
aff1560
fix(proxy_server): handle room creation and update properly
sharrlotte Jan 18, 2026
0e827de
feat: add logging for received UDP and TCP packets
sharrlotte Jan 18, 2026
5cffc9c
fuck wifi
sharrlotte Jan 18, 2026
8c7c73d
docs: add base rules for code structure and error handling
sharrlotte Jan 18, 2026
e581f38
refactor: remove redundant packet logging and add connection logging
sharrlotte Jan 18, 2026
21a9bf4
s
sharrlotte Jan 18, 2026
d3f41df
refactor(proxy_server): improve packet handling and logging
sharrlotte Jan 18, 2026
f861d74
feat(state): notify host about member join/leave events
sharrlotte Jan 18, 2026
1570368
feat: add packet processing action and handle UDP packets differently
sharrlotte Jan 18, 2026
a0b4ba9
fix: increase connection timeout and improve room error handling
sharrlotte Jan 18, 2026
dcb9a9f
fix(proxy_server): handle missing connection gracefully instead of er…
sharrlotte Jan 18, 2026
b217e1a
fix: correct udp log message and clean up packet buffer handling
sharrlotte Jan 18, 2026
57181e0
a
sharrlotte Jan 18, 2026
7dbb2fd
a
sharrlotte Jan 18, 2026
9adbfc1
fix(proxy_server): handle packet reading errors gracefully
sharrlotte Jan 18, 2026
7e661be
feat(constant): add PackingSpamming variant to CloseReason enum
sharrlotte Jan 18, 2026
0d33991
refactor(packets): extract connection id and is_tcp before buffer read
sharrlotte Jan 18, 2026
7471cdf
feat(connection): add idle timeout handling for connections
sharrlotte Jan 18, 2026
ea97e57
refactor(packets): use Bytes instead of slices for packet reading
sharrlotte Jan 19, 2026
6e2557b
refactor(networking): replace Bytes with BytesMut for packet handling
sharrlotte Jan 19, 2026
e311efa
refactor(proxy): remove SendUDP action and simplify UDP raw sending
sharrlotte Jan 19, 2026
64f4584
fix(proxy_server): handle connection sender check before action
sharrlotte Jan 19, 2026
3430e9b
refactor(packets): move prepend_len method to ConnectionActor
sharrlotte Jan 19, 2026
9f9121c
refactor: clean up unused imports and simplify packet handling
sharrlotte Jan 19, 2026
0bc4ad3
fix: remove unnecessary length prepend in TCP raw send
sharrlotte Jan 19, 2026
e440a1e
refactor(proxy_server): modify packet writing to prepend length
sharrlotte Jan 19, 2026
da16fab
perf(proxy_server): write TCP packets directly instead of batching
sharrlotte Jan 19, 2026
2e55d1a
perf(proxy_server): batch TCP writes instead of immediate writes
sharrlotte Jan 19, 2026
120cdb9
refactor(packets): rename data to raw for clarity and use extend_from…
sharrlotte Jan 19, 2026
f66343c
fix(proxy_server): change default connection type to UDP
sharrlotte Jan 19, 2026
833e3b7
a
sharrlotte Jan 19, 2026
469d3c8
refactor(packet): restructure packet handling and error management
sharrlotte Jan 20, 2026
5cd24a3
refactor(server): rename http_server to http and proxy_server to proxy
sharrlotte Jan 20, 2026
745f624
refactor(logging): reduce info logs and promote important warnings
sharrlotte Jan 20, 2026
e49a0de
feat(connection): use random connection IDs instead of sequential
sharrlotte Jan 20, 2026
6bb484c
refactor(packet): change connection IDs from i32 to u32
sharrlotte Jan 20, 2026
1c87d70
refactor(networking): improve packet handling and connection throughput
sharrlotte Jan 21, 2026
8d14843
perf: add performance monitoring for network operations
sharrlotte Jan 21, 2026
dbe61d9
feat(logging): add selective packet logging and improve broadcast timing
sharrlotte Jan 21, 2026
df9e7e9
fix: reduce idle timeout from 5000ms to 1000ms to improve connection …
sharrlotte Jan 21, 2026
9f75266
perf: remove excessive logging and timing measurements
sharrlotte Jan 21, 2026
1b2279e
refactor(connection): move idle notification logic to connection actor
sharrlotte Jan 21, 2026
db6079c
refactor(connection): update timeout and interval constants to use Du…
sharrlotte Jan 21, 2026
04f2250
refactor(connection): improve connection handling and idle state mana…
sharrlotte Jan 21, 2026
4575906
feat(connection): add packet logging for all sent and received packets
sharrlotte Jan 21, 2026
e6e1b62
fix(connection): adjust log levels and idle condition logic
sharrlotte Jan 21, 2026
3330b18
fix(connection): handle idle notification more carefully
sharrlotte Jan 21, 2026
224f6c2
refactor(state): simplify idle connection handling logic
sharrlotte Jan 21, 2026
5facfc9
refactor(proxy): simplify UDP packet handling logic
sharrlotte Jan 21, 2026
eed1e59
feat(connection): add logging for connection ticks
sharrlotte Jan 21, 2026
076a3f5
refactor(connection): remove redundant tick log and improve idle dete…
sharrlotte Jan 21, 2026
2a5864f
fix: remove redundant log and update idle state on send actions
sharrlotte Jan 21, 2026
2097147
refactor(connection): remove redundant debug logging
sharrlotte Jan 21, 2026
b2a6b2c
perf(connection): increase tick interval from 120Hz to 30Hz
sharrlotte Jan 21, 2026
2706129
fix(connection): improve error logging with connection ID
sharrlotte Jan 21, 2026
d8a5f94
refactor(proxy): improve udp packet handling readability
sharrlotte Jan 21, 2026
bc80fcc
fix(connection): handle unsupported client version with popup message
sharrlotte Jan 21, 2026
b958a8c
refactor(connection): reorder select branches for better readability
sharrlotte Jan 22, 2026
0406841
feat(models): add protocol version field to room structures
sharrlotte Jan 22, 2026
2df35ec
fix(connection): handle peer disconnection with proper error propagation
sharrlotte Jan 22, 2026
9681236
feat: add debug logging for packet send/receive operations
sharrlotte Jan 22, 2026
bdf507b
refactor(proxy): simplify UDP packet handling with if let pattern
sharrlotte Jan 22, 2026
acb7855
fix: send popup and close connection on invalid room join
sharrlotte Jan 22, 2026
31322ea
perf: remove verbose packet logging to reduce overhead
sharrlotte Jan 22, 2026
e4f08d3
fix(packet): validate no extra data after packet and add logging
sharrlotte Jan 22, 2026
331caba
refactor: replace RwLock with DashMap for concurrent state management
sharrlotte Jan 22, 2026
b07e27b
perf(packet): remove debug logging from packet parsing
sharrlotte Jan 22, 2026
4d7b418
refactor(room): simplify room membership tracking and cleanup logic
sharrlotte Jan 23, 2026
d5758ec
fix: improve connection cleanup and error handling
sharrlotte Jan 23, 2026
62a32f7
refactor: consolidate idle notification logic and adjust constants
sharrlotte Jan 23, 2026
6199f8e
perf: increase tick rate from 60Hz to 15Hz for better performance
sharrlotte Jan 23, 2026
4203aa9
fix(packet): change ConnectionId type from u32 to i32
sharrlotte Jan 23, 2026
123a8c5
perf(connection): batch process packets to reduce allocations
sharrlotte Jan 23, 2026
0d1245d
fix(connection): improve idle notification and logging logic
sharrlotte Jan 24, 2026
5995f76
fix(connection): correct idle state handling for TCP writer
sharrlotte Jan 24, 2026
afe2dbc
feat(connection): handle stream packets to prevent connection timeout
sharrlotte Jan 24, 2026
0740b85
chore: reduce log noise and increase log verbosity
sharrlotte Jan 24, 2026
b74f244
perf: increase packet batch size to improve throughput
sharrlotte Jan 24, 2026
c19d407
refactor(constant): rename and restructure close reason enums
sharrlotte Jan 24, 2026
68176f6
refactor(connection): simplify error handling and remove outdated pac…
sharrlotte Jan 24, 2026
a663613
fix(connection): replace generic error responses with localized messages
sharrlotte Jan 24, 2026
924cde6
fix(connection): correct UDP registration connection ID and log closu…
sharrlotte Jan 24, 2026
cc798ea
fix: notify host of room closure before members
sharrlotte Jan 24, 2026
5e3af9e
fix: pass RoomCloseReason when closing rooms
sharrlotte Jan 25, 2026
fb879b1
fix(proxy): increase packet rate limit from 1000 to 10000
sharrlotte Jan 27, 2026
37c1b18
feat: add ping packet handling for connection actor
sharrlotte Jan 27, 2026
3af0256
refactor(state): encapsulate fields and extract room update logic
sharrlotte Jan 27, 2026
0e08fc5
fix: remove redundant log on connection timeout
sharrlotte Jan 27, 2026
9a2d669
refactor(http): remove room page endpoint and extract room views logic
sharrlotte Jan 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/workflows/gradle.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and push to DockerHub
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./
push: true
tags: ghcr.io/mindustrytool/player-connect-server:latest
26 changes: 26 additions & 0 deletions .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and push to DockerHub
on:
push:
branches:
- v2

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./
push: true
tags: ghcr.io/mindustrytool/player-connect-server-rust:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.project
build/
bin/
target
115 changes: 115 additions & 0 deletions .trae/rules/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
1. Project & File Structure Rules

One responsibility per module

Each mod should have a single clear purpose.

Avoid “god modules”.

Predictable layout

src/ main.rs error.rs config.rs

Public API at the top

pub struct, pub enum, pub fn first

Helpers and private impls later

2. Naming Rules (Very Important for AI)

Use descriptive names, never single letters ❌ x, tmp, r, v ✅ request, buffer, user_id, packet_type

Avoid abbreviations ❌ cfg, mgr, svc ✅ config, manager, service

Types > comments

Prefer expressive type names over comments

Boolean names must answer yes/no

is_connected has_permission should_retry

3. Type System Rules

Prefer strong types over primitives

struct UserId(u64); struct Port(u16);

Never use String when an enum fits

enum Protocol { Tcp, Udp, }

Avoid Option<T> for required data

Use constructor validation instead

Avoid Vec<u8> without context

struct PacketBytes(Vec<u8>);

4. Error Handling Rules

Never use unwrap() or expect() in library code

OK only in tests or binaries

Use a single error enum

enum AppError { Io(std::io::Error), InvalidPacket, Timeout, }

Errors must be meaningful ❌ Err(AppError::Invalid) ✅ Err(AppError::InvalidPacketHeader)

Implement Display for errors

AI tools rely on readable messages

5. Function Design Rules

Functions should fit on one screen

~20–40 lines max

One logical action per function

Avoid hidden side effects

No silent global mutation

Explicit input > implicit state

fn encode(packet: &Packet, buffer: &mut BytesMut)

Prefer returning values over mutating inputs

6. Ownership & Borrowing Rules

Prefer borrowing over cloning

fn process(data: &Data)

Clone only at API boundaries

Avoid complex lifetime annotations

If lifetimes get hard, redesign

Use Arc<T> only for shared ownership

Never “just in case”

7. Async & Concurrency Rules

Never block in async code ❌ std::thread::sleep ✅ tokio::time::sleep

Name async functions clearly

async fn fetch_user()

One async runtime

Do not mix Tokio + async-std

Use channels instead of shared mutable state

8. Run cargo check before committing, and fix all errors
Loading