octgn / OCTGN

Online Card and Tabletop Gaming Network
http://www.octgn.net
Other
359 stars 129 forks source link

Specify a port for hosted games #1924

Open q3c0 opened 4 years ago

q3c0 commented 4 years ago

Hello.

First of all, thanks for all the work you have put into OCTGN, it allowed me to play with my friends during this lockdown we are facing due to the current situation.

I was wondering if there is a way to specify a fixed port number (or at least, to restrict the possible port numbers) in order to host games. At the moment, I have to manually open ports on my router for every game as that the port number is ranging from 5000 to 6000 (and I don't want to forward the whole range). I have very basic programming skills so I may be wrong on the following, but I also took a look at the code and found OCTGN/octgnFX/Octgn.Online.GameService/NetworkHelper.cs, which however seems to specify ports between 10000 and 20000, which does not seem to be the case.

Am I missing some option which would allow to set a fixed port to host?

BenMatteson commented 4 years ago

it looks like this is currently not possible, https://github.com/octgn/OCTGN/blob/master/octgnFX/Octgn/Controls/HostGameSettings.xaml.cs#L242, so we'll call this a feature request. in the meantime, you could try using a virtual lan (e.g. zerotier or hamachi) but just so you know, at least hamachi can in rare cases cause octgn to crash because of weird windows networking stuff I don't understand. I think it can be resolved by simply disabling and re-enabling it though.

q3c0 commented 4 years ago

Hi Ben.

Thank for pointing me out to the correct line of code. At the moment I do not need Amachi or anything else, I can just manually open a port on my router when I generate a new game, which is probably faster than setting up amachi (especially since the friends I am playing with are not so much into technology :D), it was just faster if I could specify a port manually.

kellyelton commented 4 years ago

Workaround

You can launch the game server directly, you just have to do it on the command line.

{OctgnInstallDirectory}\Octgn.Online.StandAloneServer.exe -id={RandomGuid} -name="{My Hosted Game}" -hostuserid="{username}" -hostusername="{username}" -gamename="{GameName}" -gameid={GameGuid} -gameversion={GameVersion} -local -bind=0.0.0.0:{port} -spectators -broadcastport=21234

Everything you need to change is surrounded by {} (make sure to remove them when you replace the values).

OctgnInstallDirectory - The full directory where you have OCTGN installed RandomGuid - You can use this https://www.guidgenerator.com/ My Hosted Game - The name of your session. Can by anything username - Your octgn username, or whatever nickname you want for the game GameName - Actual FULL name of the game you are playing (should match what is shown in OCTGN) GameID - The GUID of the Game you're playing. You can find this in OCTGN in the game manager if you click on the game in question. GameVersion - The specific version of the game you're hosting. You can find this in OCTGN in the game manager if you click on the game in question. Port - The port you want to host on

-spectators is optional, include this if you want to allow spectators in your game.

Once you launch the game server, you can open OCTGN and you SHOULD see your game in the play tab. If you don't see your game, you can join by clicking 'join' and typing in the appropriate ip/port etc.

broadcastport is the port the game server uses to broadcast the hosted game through your network/subnet. So if you have others locally they can find your game in the Play tab and just double click it.

kellyelton commented 4 years ago

This feature should have two parts: 1) Add a PORT option with the ability to choose port ranges when hosting a local game(the range part is important. It doesn't have to be complicated, it should be a text box that can parse port number ranges and multiple port numbers 5000-6000, or 5000,5001, 5002-5010 etc.) 2) Create a GUI application configuring/launching the GameServer

The GUI application should be included in the start menu so it's easily discoverable.

q3c0 commented 4 years ago

Workaround

You can launch the game server directly, you just have to do it on the command line.

{OctgnInstallDirectory}\Octgn.Online.StandAloneServer.exe -id={RandomGuid} -name="{My Hosted Game}" -hostuserid="{username}" -hostusername="{username}" -gamename="{GameName}" -gameid={GameGuid} -gameversion={GameVersion} -local -bind=0.0.0.0:{port} -spectators -broadcastport=21234

Everything you need to change is surrounded by {} (make sure to remove them when you replace the values).

OctgnInstallDirectory - The full directory where you have OCTGN installed RandomGuid - You can use this https://www.guidgenerator.com/ My Hosted Game - The name of your session. Can by anything username - Your octgn username, or whatever nickname you want for the game GameName - Actual FULL name of the game you are playing (should match what is shown in OCTGN) GameID - The GUID of the Game you're playing. You can find this in OCTGN in the game manager if you click on the game in question. GameVersion - The specific version of the game you're hosting. You can find this in OCTGN in the game manager if you click on the game in question. Port - The port you want to host on

-spectators is optional, include this if you want to allow spectators in your game.

Once you launch the game server, you can open OCTGN and you SHOULD see your game in the play tab. If you don't see your game, you can join by clicking 'join' and typing in the appropriate ip/port etc.

broadcastport is the port the game server uses to broadcast the hosted game through your network/subnet. So if you have others locally they can find your game in the Play tab and just double click it.

Hi @kellyelton! This is great, and something I can totally live with! Just a quick question, I am thinking about scripting it (I am lazy as hell), does the Game ID needs to be different every game? Or I can re-use those?

BenMatteson commented 4 years ago

the -gameid={GameGuid} specifies which game files (scripts, images, etc.) to load, so it'll always be the same unless you're trying to play different games. oh, there's a space there, you probably knew that, I should stop trying to help first thing in the morning. :P the -id={RandomGuid} can probably be reused without issues as long as the previous instance of the server has closed. (currently mine crashes when it tries to close automatically after all players leave, so it doesn't completely quit, so you may need to do this manually)

q3c0 commented 4 years ago

~the -gameid={GameGuid} specifies which game files (scripts, images, etc.) to load, so it'll always be the same unless you're trying to play different games.~ oh, there's a space there, you probably knew that, I should stop trying to help first thing in the morning. :P the -id={RandomGuid} can probably be reused without issues as long as the previous instance of the server has closed. (currently mine crashes when it tries to close automatically after all players leave, so it doesn't completely quit, so you may need to do this manually)

Actually, you were right in the first place, I said Game ID but intended the ID, I just didn't think that there was also the GameID!

Thanks again!

kellyelton commented 4 years ago

It could screw with OCTGN if you reuse the same guid like Soul said. It could possibly still have the game cached in memory and cause conflicts.

So long as you're not creating more than one at a time, and give it like 30 seconds- min between recreating the game it should 100% reliable.

Depending on what you use for scripting, there should be a way to generate Guids also if you want to take that approach.

Either way, glad you got it working! If you come up with a reusable solution, feel free to toss it back in here in case it could help other users.

q3c0 commented 4 years ago

It could screw with OCTGN if you reuse the same guid like Soul said. It could possibly still have the game cached in memory and cause conflicts.

So long as you're not creating more than one at a time, and give it like 30 seconds- min between recreating the game it should 100% reliable.

Depending on what you use for scripting, there should be a way to generate Guids also if you want to take that approach.

Either way, glad you got it working! If you come up with a reusable solution, feel free to toss it back in here in case it could help other users.

Sure thing! I just need to create a oneline bash to generate a guid and I'll post my results here, however I am using Windows Subsystem for Linux (which actually is the opposite one may think, as is linux on windows) so I don't know how many people may find it useful :D

sIKE23 commented 4 years ago

PowerShell:

//FC

On Tue, Mar 24, 2020 at 4:27 PM Kelly Elton notifications@github.com wrote:

GUID is Microsoft's flavor of UUID. Using a UUID will work just fine in this scenario as well.

There appears to be quite a few solutions for that here, though I'm not sure which will work on WSL.

https://serverfault.com/questions/103359/how-to-create-a-uuid-in-bash

I would try

UUID=$(cat /proc/sys/kernel/random/uuid)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/octgn/OCTGN/issues/1924#issuecomment-603513788, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLONR7OVL5GEHG5K6AMGJLRJEQTHANCNFSM4LML2BSA .

q3c0 commented 4 years ago

PowerShell: [guid]::NewGuid() //FC On Tue, Mar 24, 2020 at 4:27 PM Kelly Elton @.***> wrote: GUID is Microsoft's flavor of UUID. Using a UUID will work just fine in this scenario as well. There appears to be quite a few solutions for that here, though I'm not sure which will work on WSL. https://serverfault.com/questions/103359/how-to-create-a-uuid-in-bash I would try UUID=$(cat /proc/sys/kernel/random/uuid) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1924 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLONR7OVL5GEHG5K6AMGJLRJEQTHANCNFSM4LML2BSA .

Thank you both! Didn't know of the existence of /proc/sys/kernel/random/uuid!

kellyelton commented 4 years ago

GUID is Microsoft's flavor of UUID. Using a UUID will work just fine in this scenario as well.

There appears to be quite a few solutions for that here, though I'm not sure which will work on WSL.

https://serverfault.com/questions/103359/how-to-create-a-uuid-in-bash

I would try

UUID=$(cat /proc/sys/kernel/random/uuid)