Giter Site home page Giter Site logo

Comments (5)

RandyGaul avatar RandyGaul commented on June 1, 2024 1

There's a difference between your public IP and your machines local IP. You found the core issue, you would like to host your server on an IP behind a NAT device, which provides the machine with a local IP. The server starts up with it's local IP. However, the connect token has a reference to the public IP and the client must access the server on the public IP. The client and the connect token don't know anything about the server's local IP. So the security check fails since there's no matching IP between server local and the connect token list.

I think we can support this use-case with a small addition to the server's API. We can add an optional setting to the server, where it will know it's own public IP despite starting up with a local IP. You would have to provide the server with the public IP yourself, it will not have a way to find it on its own.

I do want to point out though, this is not a great solution for games today in terms of shipping. Requiring port-forwarding is outdated. Instead, by hosting your server on the cloud with a public IP none of this workaround is necessary at all, and no port-forwarding is required. I would encourage users to try out port-forwarding for testing and development, but not for releasing a game.

@Siltnamis Do you think this server API addition would work for you?

from cute_headers.

r-lyeh avatar r-lyeh commented on June 1, 2024

try to use '0.0.0.0:port' to bind the server address

from cute_headers.

Siltnamis avatar Siltnamis commented on June 1, 2024

does not work. it calls cn_endpoint_equals(server_endpoint, token.endpoints[i]). And token endpoint contains "publicip:port" while server endpoint is "0.0.0.0:port" and ignores this connection attempt.
So my understanding is that server thinks that this connection is not meant for it. If I skip this check and assume that it matches - everything appears to work just fine.

from cute_headers.

Siltnamis avatar Siltnamis commented on June 1, 2024

Yes it would be useful for me. I'm far away from shipping anything so it is just easier to host on my local dev machine and let a friend join and tryout the game outside LAN.
Thank you for explanation :)

from cute_headers.

RandyGaul avatar RandyGaul commented on June 1, 2024

Verified this working with my own router + port forwarding. You can now call cn_server_set_public_ip for development and testing.

from cute_headers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.