Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Check the ip connect to QWebSocketServer is external or local ip

Check the ip connect to QWebSocketServer is external or local ip

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 467 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by
    #1

    My purpose is build a server-client app, the server should listen to the devices in the local network only, is it possible to check the ip try to connect to the server are come from local network or not?Thanks

    raven-worxR 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      That's rather something you should do at the system level with something like iptables. If you don't want your server to get accessed from outside of your network, then don't allow network connection from the outside to happen in the first place.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • thamT tham

        My purpose is build a server-client app, the server should listen to the devices in the local network only, is it possible to check the ip try to connect to the server are come from local network or not?Thanks

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @tham
        you mean checking if the ip is in the private ip range?

        QHostAddress clientIp(...);
        if( !clientIp.isInSubnet( QPair<QHostAddress, int>("10.0.0.0", 8) &&
             !clientIp.isInSubnet( QPair<QHostAddress, int>("172.16.0.0",12) &&
             !clientIp.isInSubnet( QPair<QHostAddress, int>("192.168.0.0",16) )
        {
             // not in private ipv4 range
        }
        

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved