A kcp library built for a certain cute game (with Proxy Protocol v2)
Find a file
Yuuki f43439a3c6 refactor(hashing): make zero-allocation-hashing optional and improve address logging
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()
2025-07-20 20:15:38 +08:00
gradle/wrapper [Building/Feature] Added missing gradle files, move to build.gradle.kts and add support for newer kcp packets 2025-01-13 22:22:14 +01:00
src/main/java refactor(hashing): make zero-allocation-hashing optional and improve address logging 2025-07-20 20:15:38 +08:00
.gitignore [Building/Feature] Added missing gradle files, move to build.gradle.kts and add support for newer kcp packets 2025-01-13 22:22:14 +01:00
build.gradle.kts refactor(hashing): make zero-allocation-hashing optional and improve address logging 2025-07-20 20:15:38 +08:00
DOCUMENTATION.md feat(proxy): add Proxy Protocol v2 support for FRP and other proxies 2025-07-20 18:58:07 +08:00
gradlew [Building/Feature] Added missing gradle files, move to build.gradle.kts and add support for newer kcp packets 2025-01-13 22:22:14 +01:00
gradlew.bat [Building/Feature] Added missing gradle files, move to build.gradle.kts and add support for newer kcp packets 2025-01-13 22:22:14 +01:00
LICENSE add LICENSE 2022-06-10 01:03:56 +08:00
PROXY_PROTOCOL_INTEGRATION.md feat(proxy): add Proxy Protocol v2 support for FRP and other proxies 2025-07-20 18:58:07 +08:00
README.md feat(proxy): add Proxy Protocol v2 support for FRP and other proxies 2025-07-20 18:58:07 +08:00
settings.gradle.kts [Building/Feature] Added missing gradle files, move to build.gradle.kts and add support for newer kcp packets 2025-01-13 22:22:14 +01:00

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