PaperMC / PaperMC/Velocity

Feature Request: Add targeted server to InboundConnection (or similar)

Open
#1,162 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
Dominant language
Java
Stars
2.3k
Forks
959
Avg merge
5d 10h
Merged PRs (30d)
2

Description

Hi, I am currently in the process of porting a plugin of mine from BungeeCord to Velocity.
Without getting in to too much detail, the plugin tries to handle pings and login attempts, but only for specific servers behind the proxy (e.g. only for survival.example.com).

Example, the ProxyPingEvent:

My proxy is set to ping-passthrough = "ALL" and has a list of forced hosts.
Now I want to manipulate the ping (e.g. MOTD) for some specific servers only.
However, Velocity has no API to retrieve the chosen target server for the event.

I know that there isn't always a target server for a connection, but in the case of the ping-passthrough, the ping has to come from a specific backend server eventually (provided it doesn't fail).

Meanwhile, in BungeeCord, I was able to achieve this by using PendingConnection#getListener and matching against the list from getServerPriority.

Proposed API:

I am proposing to add it to InboundConnection as this would simultaneously help other similar events too.
However, it should also be possible to create a sub-interface only for the applicable events (in cases where it isn't always empty), if desired.

public interface InboundConnection {
    // ...

    /**
     * Returns the chosen target server for this connection, if applicable.
     * Usually matches with {@link InboundConnection#getVirtualHost()}.
     *
     * @return the registered server that is targeted for the client
     */
    Optional<RegisteredServer> getTargetServer();
}
Alternatives:

AFAIK, the only workaround without reflection is by parsing the velocity.toml config yourself, duplicating the matching algorithm from Velocity's internal classes and trying to find the right server that matches getVirtualHost.
Which would still not guarantee that it always matches the result of Velocity.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the InboundConnection API and the ProxyPingEvent, then trace how forced hosts and ping-passthrough select a backend server. Review the velocity.toml matching behavior and the internal classes mentioned in the issue. Done means an agreed API shape that exposes the applicable target consistently for connection events.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.