Search Unity

  1. We want you to join us at GDC this year! Take a peek at all of the events we will be hosting during the week of GDC.
    Dismiss Notice
  2. Tell us about your experience here and you’ll get early access to the 2018 Game Studios report + more goodies.
    Dismiss Notice
  3. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  5. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice

How do I prompt a firewall expection on build start?

Discussion in 'Multiplayer Networking' started by munkbusiness, Jan 30, 2018.

  1. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    So I have a game that uses NetworkTransport and udp broadcasts to access other devices running the app.

    I know that firewall blocks this as it works fine in editor where firewall has an exception, and it works fine when built to an .exe if I manually disable firewall, and doesn't work if I don't.

    It isn't very consumer friendly to ask them to disable the firewall or to go into settings and make an exception, so I want to know how to prompt the firewall pop-up that often appears in other online games, so that the user just have to click ok to a pop-up to allow connections for that specific program.
     
  2. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    Have I misunderstood something about how firewall works, or have no one experienced this? (Bumb)
     
  3. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    684
    AFAIK the firewall prompt is something OS does automatically when it detects an application wants to host/listen on a specific port. I don't think you can force it.
     
  4. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    I had a sneaking suspicion, but what do I do then if the OS doesn't pick up that my application wants to host/listen, but still blocks it.

    It is even the very first thing my application does, right after boot.
     
  5. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    840
    This depends on the firewall the user has. If a user has a firewall that only allow user whitelisted software as an example, there is no way to disable that without heavily going against the users will and even then it will be difficult. As for the operatingsystems os. I know windows have ways for you to ask them about firewall. You can even modify firewall settings from your application if ran with admin. And you could request admin while the application is being ran.
     
  6. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    I don't want to disable firewall, but rather have the typical pop-up that asks for white listing the game. I am primarily developing for windows, so if you have any more info on asking windows about firewall that would help a lot.

    I don't like the idea of modifying the firewall by gaining admin access though.
     
  7. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    840
    If you are talking about the Windows Defender Firewall that was introduced in XP. It will prompt users automatically. When you execute the exe it will automatically pop up a prompt, note that it only does this once. If the user press cancel, it will add a blacklist in the windows firewall. If you press allow it will add a whitelist. This firewall also has a nice API for you to use.
    https://msdn.microsoft.com/en-us/library/aa366458(VS.85).aspx
    As for third party firewalls, you are probably better of not trying. They are often developed to be secure and don't want programs modifying them. Personally I use a whitelist firewall on my linux machine which means I specifically have to whitelist applications I trust to allow them to make inbound and outbound connections. But windows protects these third party firewalls in a similar way they protect third party antivirus's. They are not treated as usual programs but rather have special limitations.
     
  8. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    I am talking about Windows Defender Firewall, at least for me to make it work I am whitelisting my build through Windows Firewall in Control Panel.

    So my problem is exactly that I am not getting the behaviour that you mention on any of my machines: "It will prompt users automatically. When you execute the exe it will automatically pop up a prompt, note that it only does this once."

    I never got that pop-up, which is why i started this thread.

    I am not worried about Linux users as they typically know what they are doing with computers. And I am not talking about any specialised Firewalls (at least I am pretty sure I am not).
     
  9. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    684
    What port is your application using/listening on?
     
  10. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    I just checked, and I am using port: 47777

    I cannot remember if that was just a default port from a tutorial I followed or if it is some arbitrary number I picked.
     
  11. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    684
    But firewall is not blocking your application correct?
    If so, firewall will only prompt you to allow access if access is blocked.
     
  12. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    Firewall is preventing my application from picking up other players, I thing it is the broadcast, but it might be the handshaking, but one of those two. When I build it doesn't connect, unless I manually give the build permission in my firewall settings or disable firewall all together. It works fine in the editor, but only because the editor also has permission.

    Anecdote if that randomly helps anything: When I updated from 2017.3.0 to 2017.3.1 the editor was blocked so I had to give it permission again.
     
  13. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    840
    Probably you pressed cancel the first time it came up, thus blacklisting it. Try renaming the build to a random name and see if it appear
     
  14. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    I would be suprised if I cancelled it on my first build as I took me sometime to figure out what was wrong back then. I just send my build to a fresh PC to test it out there also, and nothing popped up.

    I also tried building with a new name and even changed the product name in PlayerSettings in case that was the thing.

    To clarify, I am not using any internet based connection, I am using broadcasting and NetworkTransport for local only.
     
  15. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    840
    Oh, that might be a difference then. Please check what the Firewall has to say about the application after on the new PC. Since it's not doing any outbound network connections per say (even though it should use the network adapter?). Something might be going on. Check if the firewall treats it as blocked, allowed or neutral by default. I am unsure of this. But as I stated earlier. The Windows Defender Firewall has API's you can use.
     
  16. munkbusiness

    munkbusiness

    Joined:
    Aug 22, 2017
    Posts:
    19
    Just checked the inbound, outbound, and monitoring rules on the other PC i tested it on. I couldn't find anything about the build file there.

    Same goes for the builds with other names on my own machine.