PrismarineJS / node-minecraft-protocol

Parse and serialize minecraft packets, plus authentication and encryption.
https://prismarinejs.github.io/node-minecraft-protocol/
BSD 3-Clause "New" or "Revised" License
1.24k stars 239 forks source link

Advanced proxy example with multiple servers #302

Open misiek08 opened 9 years ago

misiek08 commented 9 years ago

Hi! I think we need example proxy code with switching servers, so it will work a little like MCProxy or Bungeecord to show NMP's power.

rom1504 commented 9 years ago

Yeah it might be interesting to do an example like that.

roblabla commented 9 years ago

While having such a project would be fun, it wouldn't belong in the examples. It is a very complex task with lots of pitfalls, and wouldn't fit a single small file showing off a feature.

misiek08 commented 9 years ago

I mean just proxy with switching servers without complex logic and plugins, so only handling command or pluginmessage to reconnect player internally to another server.

I tried repeating same steps as BungeeCord do, but it didn't work in some situations. I'll share code (it's a bit old) when I get home later today.

roblabla commented 9 years ago

The problem is switching server is hard to get right. You need to keep a mapping of the entityId of each player of each server. You need to make sure those ids never collision with some id assigned by other servers. Then there is the trouble of the scoreboard that needs to be reset when switching server. The player list has a similar problem.

It's just a complicated mess and making a proper example that works in every situation requires careful handling of almost every packet. Not to mention, with every mc update, it'll probably keep getting bigger and more convoluted. I think it's a great idea, but i don't think it belongs in the nmp examples.

On Tue, Nov 10, 2015, 3:16 PM Misiek notifications@github.com wrote:

I mean just proxy with switching servers without complex logic and plugins, so only handling command or pluginmessage to reconnect player internally to another server.

I tried repeating same steps as BungeeCord do, but it didn't work in some situations. I'll share code (it's a bit old) when I get home later today.

— Reply to this email directly or view it on GitHub https://github.com/PrismarineJS/node-minecraft-protocol/issues/302#issuecomment-155432232 .

misiek08 commented 9 years ago

I knew about scoreboards and player list and it's very easy to clear them (my code wasn't doing it), so I'll rewrite this code in next few weeks (I take much time for testing, writing code takes few minutes) and try with other solution. I was looking at other solutions and they don't care about entityIds, but are only clearing scoreboard and playerlist. I'll try to reproduce one solution in NMP first.

vimes1984 commented 8 years ago

hey @misiek08 did you manage to get any of this code written in the end I'd be really interested in taking a look

growlf commented 8 years ago

me too - this would be very helpful for a project I am involved in as well.

misiek08 commented 8 years ago

I gave up on NMP and did own implementation in Go. Saved me many hours fighting with this library. I had to implement only few packets and pass-through others, so it worked good. I was sys-admin on some minecraft server-network and I left, because of way too small salary :)

If NMP will stabilize with multiple protocol support and API I can try again with proxy.

EDIT: Doing such proxy, even with EMP, should take about 300-500 lines of code to write, so just try on your own. I gave up, because my implementation need to ask HTTP server for permission when someone is connecting and this didn't work well with NMP.

vimes1984 commented 8 years ago

do you have the Go implementation you wrote I can take a peek at by any chance?

misiek08 commented 8 years ago

I can't share it now, because it contains data about endpoints used for auth, but I think about making it clean and selling it, because it was pretty fast.

rom1504 commented 8 years ago

If NMP will stabilize with multiple protocol support and API I can try again with proxy.

NMP API has been mostly stable for a long time (let's say 3 years). multiple version support is a new thing, yes. Not sure what's your point about that.

What would be nice concerning proxy and nmp is a proxy lib. There is a client lib based on nmp (mineflayer) and a server lib based on nmp (flying-squid, although it could be made more of a lib and less of a server) but there is no proxy lib currently. If someone would create a proxy lib on top of nmp, it could make it much easier to build any kind of nmp proxy.

https://github.com/Egoscio/gelato is interesting, but it's more of a proxy/wrapper than a proxy lib.

A proxy lib should provide proxy functionnalities and not force their usage. Then all these various proxy projects could be simplified by using that proxy lib.

vimes1984 commented 8 years ago

I'll see if I can't write that :D

growlf commented 8 years ago

That sounds like that is the ticket, then. Right. Well, time to roll up the sleeves and get started.

growlf commented 8 years ago

By the way, Rom1504? I don't know if you hear this enough, but thank you and the others in the FlyingSquid and Prismarine groups for this amazing option to enhance our servers and the community. You folx rock!

vimes1984 commented 8 years ago

@rom1504 where does mcserve sit in the node-minecraft-protocol spectrum then?

rom1504 commented 8 years ago

It's a vanilla (java, mojang) minecraft server wrapper. Similar to https://github.com/rom1504/node-minecraft-wrap/blob/master/lib/wrap.js with some more functionalities.