Skip to content

A API enhancement for getting the ip and port for current connected server. Closes #1750.#1764

Open
qyl27 wants to merge 2 commits intoPaperMC:dev/3.0.0from
qyl27:patch-1750
Open

A API enhancement for getting the ip and port for current connected server. Closes #1750.#1764
qyl27 wants to merge 2 commits intoPaperMC:dev/3.0.0from
qyl27:patch-1750

Conversation

@qyl27
Copy link
Copy Markdown

@qyl27 qyl27 commented Apr 5, 2026

This is an api enhancement of the use case mentioned in #1750. It adds a getConnectedServerInfo for getting the current connected IP and port.

If I have a backend server with some-dynamic-host-name:25565, it will be resolved in VelocityServerConnection#connect, but the resolution result (as the server player really connects to) cannot be gotten by the API; I got an unsolved InetSocketAddress instead.

It assumes future.channel().remoteAddress() will return an InetSocketAddress because it was up-cast from it in Bootstrap#connect(SocketAddress).

…erver. Closes PaperMC#1750.

Signed-off-by: 秋雨落 <i@rain.cx>
@qyl27 qyl27 marked this pull request as ready for review April 5, 2026 11:13
Copilot AI review requested due to automatic review settings April 5, 2026 11:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an API to expose the resolved (actually connected) backend server address (IP/port) for a ServerConnection, addressing cases where configured ServerInfo#getAddress() may remain unresolved when a hostname is used.

Changes:

  • Added ServerConnection#getConnectedServerInfo() to expose connected/resolved server address details.
  • Implemented tracking of the connected server’s resolved ServerInfo inside VelocityServerConnection during backend connect, and cleared it on disconnect.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
api/src/main/java/com/velocitypowered/api/proxy/ServerConnection.java Adds new API method getConnectedServerInfo() for exposing the resolved/connected server info.
proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java Stores connected server resolved address from Netty channel remote address and exposes it via the new API method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants