Factorio Multiplayer Protocol
Moderator: ickputzdirwech
-
- Burner Inserter
- Posts: 11
- Joined: Sun Mar 07, 2021 8:45 am
- Contact:
Factorio Multiplayer Protocol
I would like to make a proxy for Factorio which serves to redirect joining players to a server which is not necessarily running. It’s expensive for me to keep a factorion server running 24/7 and it makes financial sense to only run the server when someone is playing. I have done this for Minecraft, and it worked great. I believe Minecraft’s multiplayer protocol is reverse engineered by the community https://minecraft.wiki/w/Java_Edition_protocol. But I do not have the capacity to do so for Factorio, some attempts were made in the past, but not to a significant degree. It would be great if some insight could be given to the workings of the factorion multiplayer protocol, (specifically the server joining part). I know that maintaining documentation about the full protocol is impossible because of the way the game works.
Re: Factorio Multiplayer Protocol
The Factorio server auto paused by default when no one is online, so in that sense it will use virtually no CPU. Is that not the goal?
If you want to get ahold of me I'm almost always on Discord.
Re: Factorio Multiplayer Protocol
Is it really necessary to write a whole proxy service?
What do you need to start on demand, is it just a service (the Factorio server process) or do you need to start up a whole virtual machine?
With systemd, it's possible to listen on a port (in this case the Factorio udp port) with a *.socket unit and start a *.service unit that's supposed to serve this port. So the service isn't running as default, and if systemd detects activity on the port, it starts the associated *.service unit.
This *.service doesn't need to be the factorio server service, it can be any *.sh script. I guess you're able to start your vm from within, and if it is up, add an iptables rule to forward the local udp port to the vm udp port. This is actually your proxy: a corresponding iptables NAT rule for udp traffic on the given port. Don't need to look inside the packets.
What do you need to start on demand, is it just a service (the Factorio server process) or do you need to start up a whole virtual machine?
With systemd, it's possible to listen on a port (in this case the Factorio udp port) with a *.socket unit and start a *.service unit that's supposed to serve this port. So the service isn't running as default, and if systemd detects activity on the port, it starts the associated *.service unit.
This *.service doesn't need to be the factorio server service, it can be any *.sh script. I guess you're able to start your vm from within, and if it is up, add an iptables rule to forward the local udp port to the vm udp port. This is actually your proxy: a corresponding iptables NAT rule for udp traffic on the given port. Don't need to look inside the packets.