Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bungeefan opened this issue Dec 16, 2023 · 0 comments
Open
Labels
type: feature New feature or request

Comments

@Bungeefan
Copy link

Bungeefan commented Dec 16, 2023

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.

@4drian3d 4drian3d added the type: feature New feature or request label Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants