timvisee / lazymc

💤 Put your Minecraft server to rest when idle.
GNU General Public License v3.0
573 stars 15 forks source link

players with different IP are connected under the same IP #9

Closed ventoryprod closed 2 years ago

ventoryprod commented 2 years ago

when i connected to my own server in console my ip was127.0.0.1, I thought this was normal because server and me is on the same network (but this never happened on another server before), but when my friend joined he also connected as 127.0.0.1, being in a completely different city and having a different IP image image its not very big issue at least for me, but i cant use all functions of my auth plugin, and cannot use ban-ip because of that

timvisee commented 2 years ago

This is impossible to fix, sadly. The proxy is used as new client, which is why the server sees everybody as connecting from that endpoint. There is no way to communicate the real (forwarded) client IP to the Minecraft server, as it does not support such feature.

cannot use ban-ip

I could implement IP banning on lazymcs side. It could read the servers banned-ips.json file, and block incoming connections where the real IP is known. Would such thing be desirable?

but i cant use all functions of my auth plugin

Could you elaborate what functions are not usable?

ventoryprod commented 2 years ago

I could implement IP banning on lazymcs side. It could read the servers banned-ips.json file, and block incoming connections where the real IP is known. Would such thing be desirable?

I think it has no sense, it`s almost impossible to find player ip Could you elaborate what functions are not usable?

it`s not so important, auto-authorization if registration ip matches with current player ip

timvisee commented 2 years ago

I think it has no sense, it`s almost impossible to find player ip

Good point. I could log client IPs from lazymc, but that would still require manually looking it up when banning a player.

Sadly, as this is unfixable, I'll close this now. Feel free to open it again if further issues/details arise.

timvisee commented 2 years ago

I would like to add that obtaining real user IPs could be implemented as part of a plugin on your Minecraft server. This would mean that banning IPs could also be supported by the auth system if their developers cooperate to implement this.

To give some technical details: I could set up a local API server within lazymc form which Minecraft server plugins could request the real IP of a user.

In fact, I may implement a simple plugin myself just to support this. It could provide a command to ban a user by IP, and a command to request the real user IP.

What auth system are you using? I happen to know the developers behind a popular auth system, so I may be able to pull something like this off.

ventoryprod commented 2 years ago

What auth system are you using? I happen to know the developers behind a popular auth system, so I may be able to pull something like this off.

AuthMe Dev provides plugin source code, also i not very into programming and that networking stuff, maybe it's possible to make plugin that will modify server core code, that will override the IP address that the server receives, or not?

You better understand how this work, I'm just saying how I imagine it

timvisee commented 2 years ago

I've added support for banned IPs within lazymc. It now automatically reads the banned-ips.json file and handles banned players accordingly.

Though this doesn't fix the IP issue with /ban-ip player, it does properly block players from already banned IPs now.

This is part of v0.2.1, it should be available once this release pipeline succeeds: https://gitlab.com/timvisee/lazymc/-/pipelines/411024454 https://github.com/timvisee/lazymc/releases


AuthMe Dev provides plugin source code, also i not very into programming and that networking stuff

That's the one! I'm actually the 4th top contributor of that plugin. I'll ask the main developers whether integrating something like this is desirable.

maybe it's possible to make plugin that will modify server core code, that will override the IP address that the server receives, or not?

I did a quick investigation. Sadly this doesn't seem to be possible.

(..) I'm just saying how I imagine it

That's perfectly fine!

timvisee commented 2 years ago

@ventoryprod An AuthMe developer suggested a different approach.

To simplify: I can add an option to lazymc to send a standardised proxy message to the server with new connections. This proxy message includes the real client IP. The Minecraft server will be able to handle this with a companion plugin.

Implementing this would fix all IP-related issues. This should work with any plugin using IP information, within Spigot at least.

Please follow https://github.com/timvisee/lazymc/issues/10 for progress on this.

timvisee commented 2 years ago

This issue has now been fixed in v0.2.3 with the use of a PROXY header. This fixes incorrect client IPs, the /ban-ip command and any plugins using IP information.

This requires a configuration change and a companion plugin on the server.

Please see: https://github.com/timvisee/lazymc/blob/master/docs/proxy-ip.md