28 Commits
Author SHA1 Message Date
FangkuaiYa 2fa1a2e060 Merge branch 'main' into anticheat
# Conflicts:
#	marketplace/Empostor.Plugins.PlayerLog.dll
2026-10-02 10:13:44 +08:00
FangkuaiYa 91ac52626b Add rate limiting 2026-10-01 00:00:15 +08:00
FangkuaiYa 6a98d63db2 feature/v19 2026-09-30 16:38:07 +08:00
FangkuaiYa cc8085f138 Fix build 2026-09-12 02:42:37 +08:00
FangkuaiYa 34e6751d33 Some support and improvements 2026-09-12 02:33:43 +08:00
FangkuaiYa 4ca2efc6cd Revert "Add fault tolerance to GameData messages"
This reverts commit 7c8c629ea5.
2026-08-22 14:33:47 +08:00
FangkuaiYa 43f8281486 Fix playerlog 2026-08-20 15:17:46 +08:00
FangkuaiYa ea9547cec6 Revert "Optimize"
This reverts commit a4de6a83d9.
2026-08-17 02:38:20 +08:00
FangkuaiYa a4de6a83d9 Optimize 2026-08-17 01:06:56 +08:00
FangkuaiYa 50a159f8cf Fix player log 2026-08-17 00:12:31 +08:00
FangkuaiYa e956874877 Fix 2026-08-16 22:58:16 +08:00
FangkuaiYa 895e64c820 Remove Ip match 2026-08-16 22:08:04 +08:00
FangkuaiYa 9dd45f35f7 Fix 2026-08-15 13:16:55 +08:00
FangkuaiYa 41b63f653c Fix rejoin spawn timeout without leaving players stuck
- HandleJoinGameNew: clear stale Character so spawn timeout can fire on
  rejoin in host-authority mode.
- CheckLimboPlayers: clear stale Character and start spawn timeout when
  pulling players out of limbo; keep the direct pull-out (not the PR's
  HandleJoinGameNext call, which re-set WaitingForHost and stuck players on
  the wait-for-host screen).
- DespawnPlayerInfoAsync: revert to upstream OwnerId == ServerOwned check to
  stay aligned with official Impostor.
2026-08-15 13:03:23 +08:00
FangkuaiYa bb4da29d7e Merge branch 'main' of https://cdn.gh-proxy.org/https://github.com/Empostor/Empostor 2026-08-15 12:38:55 +08:00
FangkuaiYa dcb307db8e Fix lingering players in lobby under host-authority mode
Align with upstream Impostor: use ConcurrentDictionary for _allObjects,
remove the ServerOwned guard in DespawnPlayerInfoAsync so client-spawned
PlayerInfo is cleaned up, and simplify PlayerRemove / AddClientSafeAsync
lifecycle handling. Fixes players remaining visible after disconnect and
NetId conflicts on rejoin.
2026-08-15 12:38:35 +08:00
FangkuaiYa 22b8a19159 Update URL 2026-08-13 21:30:20 +08:00
FangkuaiYa 48ba15ca09 Port Authentication 2026-08-13 20:53:54 +08:00
FangkuaiYa 715de1002d Add Reactor.Empostor 2026-08-13 11:50:33 +08:00
FangkuaiYa 8772acdc3b Fix +25 red player and friendcode 2026-08-13 11:18:36 +08:00
FangkuaiYa 5a58c630d5 Fix 2026-08-13 00:10:39 +08:00
FangkuaiYa db366e3e1a Change port config 2026-08-12 12:45:18 +08:00
FangkuaiYa 80d666e369 Fix port 2026-08-12 12:30:58 +08:00
FangkuaiYa 2cd2f92d4f New Update (No Test):
## Fix: players keep getting kicked mid-game (auth cache TTL)

**Root cause**: the auth cache (`AuthCacheService`) has a 10-min TTL but `CreatedAt` was only set when the token was created — never refreshed while the player was actually connected. After ~12 min, the cleanup timer would expire the port entry, fire `OnPortExpired` → return the port to the pool → stop the delta UDP listener → the active player got force-disconnected ("Server shutting down" in the logs).

**What I changed**:
- `AuthCacheService`: added a `_confirmedPorts` set + `ConfirmPort()`. Cleanup now **skips confirmed (actively connected) ports** — as long as the player is connected, the port lease is never cleared.
- `ClientManager`: calls `_authCache.ConfirmPort(deltaPort)` right after `_portPool.ConfirmPort()` when the port matches, so an active session is marked confirmed.
- Port is still properly released on disconnect (existing `RemoveByPort` path untouched).

---

## Change: hide the default UDP port, use last delta port as default

**Why**: the well-known default port (my config: 22023) was getting flooded with garbage UDP. So now the server reserves the **last port** of the delta range as the main listener, so the default game socket is never the obvious 22023, and even if the pool is fully allocated, the server still runs.

**What I changed**:
- `ServerConfig`: new option `ReserveLastDeltaPortAsDefault` (default true).
- `PortPoolService`: `DefaultPort` = last delta port (`DeltaPortEnd`) when enabled; pool excludes it.
- `MatchmakerService`: main UDP listener binds to `DefaultPort` instead of `ListenPort`.
- `GamesController`: fallback port in `GetDeltaPort()` uses `DefaultPort`.

---

## Change: Filtaur-style line-speed UDP packet filter

**What I changed**: new `UdpPacketFilter` in Hazel + hooked into `UdpConnectionListener.ProcessData`. It drops junk at line speed before it reaches the game server:
- size check (min/max length),
- send-option byte check (layer-7),
- per-IP connection burst limit + temporary blacklist (default 30 burst / 60s blacklist).

Only applies to **unknown endpoints** (new connection attempts); established connections are never filtered, so in-game traffic is unaffected. This is the "filtaur" idea — force spammers through overhead and drop bad packets fast so they can't overload the server and drop everyone.

---

## Config (config.json)
Added `"ReserveLastDeltaPortAsDefault": true` under `Server`.
2026-08-12 12:15:41 +08:00
FangkuaiYa b4d259688f Modify log format
Thank you for downloading the log from QQ, I don't know where to find it
Thank you for selling NikoCat233 for 180
Thank you for betraying us
2026-06-28 22:56:39 +08:00
FangkuaiYa a575991eaa Change File construction 2026-06-28 22:04:14 +08:00
FangkuaiYa 2ff57d7432 Fix admin ban Ip 2026-06-28 21:55:23 +08:00
FangkuaiYa ca80b42b3f ▎ Dynamic UDP port allocation for TCP/UDP identity matching
▎
  ▎ On HTTP authentication (POST /api/user), the server allocates a unique UDP port from a configurable pool
  ▎ (DeltaPortStart–DeltaPortEnd). The port acts as a nonce — when the client connects via UDP to that specific port,
  ▎ the server matches the connection to the authenticated PUID and FriendCode. This replaces unreliable IP-based
  ▎ matching, especially for players behind NAT/CGNAT.
  ▎
  ▎ - PortPoolService — thread-safe port pool with 5-minute auto-recycle if no connection arrives
  ▎ - IDeltaListenerManager — starts/stops UDP listeners on allocated ports (implemented by Matchmaker)
  ▎ - IFirewallService — UFW / firewalld / noop backends that automatically open/close firewall rules for allocated
  ▎ ports
  ▎ - Falls back to IP-based matching when the pool is exhausted or the feature is disabled (DeltaPortStart: 0)
  ▎ - TokenController returns both Port and Hash (matchmakerToken) to the client in the auth response
2026-06-28 14:51:39 +08:00