A kcp library built for a certain cute game (with Proxy Protocol v2)
Update dependency to be compileOnly and add graceful fallback when hashing library is not available. Also standardize logging to use getOriginalClientAddress() instead of getRemoteAddress() for consistency. The changes include: - Making zero-allocation-hashing an optional dependency - Adding runtime detection and fallback for hashing functionality - Updating all address logging to use getOriginalClientAddress() |
||
|---|---|---|
| gradle/wrapper | ||
| src/main/java | ||
| .gitignore | ||
| build.gradle.kts | ||
| DOCUMENTATION.md | ||
| gradlew | ||
| gradlew.bat | ||
| LICENSE | ||
| PROXY_PROTOCOL_INTEGRATION.md | ||
| README.md | ||
| settings.gradle.kts | ||
grasskcpper-v2
A kcp library built for a certain cute game
Modification
- 4.6+ protocol support
- Kcp version detection support
- Proxy Protocol v2 support - Extract original client IP addresses when running behind proxy servers like FRP
How to add it to your project
Add the AnimeGameServers maven repo to your build file:
repositories {
...
maven {
name = "ags-mvn-Releases"
url = uri("https://mvn.animegameservers.org/releases")
}
}
Then add this to your dependencies in the gradle build file:
implementation "org.anime_game_servers:grasskcpper:0.1"
Proxy Protocol v2 Integration
This library now supports Proxy Protocol v2, enabling extraction of original client IP addresses when running behind proxy servers like FRP (Fast Reverse Proxy).
Quick Setup
// Enable proxy protocol support
ChannelConfig config = new ChannelConfig();
config.setProxyProtocolV2Enabled(true);
// Your KCP listener will receive the original client IP
KcpListener listener = new KcpListener() {
@Override
public void onConnected(Ukcp ukcp) {
// ukcp.user().getRemoteAddress() now contains the ORIGINAL client IP
InetSocketAddress originalClient = ukcp.user().getRemoteAddress();
System.out.println("Client connected from: " + originalClient.getAddress().getHostAddress());
}
// ... other methods
};
KcpServer server = new KcpServer();
server.init(listener, config, new InetSocketAddress(9999));
Features
- Automatic Header Detection: Gracefully handles both proxied and direct connections
- IPv4 and IPv6 Support: Works with both address families
- Clean Payload Processing: Strips proxy headers and processes original game data
- FRP Compatible: Tested with Fast Reverse Proxy configurations
- Zero Configuration Fallback: Works normally when no proxy headers are present
For detailed configuration and troubleshooting, see PROXY_PROTOCOL_INTEGRATION.md.
Credits
Anime game changes: Simplxss
Version 4.6+ Changes: OcenWang-GI Commit
Original library: https://github.com/l42111996/java-Kcp