Giter Club home page Giter Club logo

lirum.network's Introduction

Lirum.Network

alt tag

This is an implementation of netstat, used in Lirum Device Info - that lists all active connections. Netstat (network statistics) is a command-line network utility tool that displays network connections for TCP (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics. It is available on Unix-like operating systems including OS X, Linux, Solaris, and BSD, and is available on Windows NT-based operating systems including Windows XP, Windows Vista, Windows 7, Windows 8 and Windows 10. For iOS however, there wasn't a native implementation, so we had to adapt the code of netstat to work with Objective-C, and put it into a library. The implementation runs on iPhones, iPod Touches and iPads prior to iOS 10 (since the iOS 10 betas, this code does not returns the active connections anymore).

Link to YouTube - Lirum Device Info - Network Connections

To use it, just add the static library on Linked Frameworks and Libraries, and then call the initializers:

Lirum_Network * l = [[Lirum_Network alloc] init];
NSMutableDictionary *m = [l getConnections];

[Lirum_Network initializeNetworkElements];

NSLog(@"Connections: %@", m);

NSLog(@"WWAN IP: %@", [Lirum_Network getWWanIP]);
NSLog(@"Wifi IP: %@", [Lirum_Network getWifiIP]);

NSString *wwanIP = [Lirum_Network getWWanIP];
NSString *wifiIP = [Lirum_Network getWifiIP];

[txtOutput setText: [NSString stringWithFormat:@"WWAN IP: %@\nWifi IP: %@\nConnections:\n%@", wwanIP, wifiIP, m]];

Running on an iPhone 6S Plus - iOS 9.3.5: alt tag

The return from Lirum_Network getConnections is a NSDictionary grouped by Protocol Type (IPv6, IPv4, TCP, UDP, etc). Sample return in plaintext:

"IP6.TCP" =     (
            {
        local = "fe80:8::1c70:97ae:bfc8:c1a0.61731";
        "local.namedport" = "fe80:8::1c70:97ae:bfc8:c1a0.61731";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:8::26a0:74ff:feea:538.57527";
        "remote.namedport" = "fe80:8::26a0:74ff:feea:538.57527";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:8::1c70:97ae:bfc8:c1a0.61730";
        "local.namedport" = "fe80:8::1c70:97ae:bfc8:c1a0.61730";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:8::26a0:74ff:feea:538.57477";
        "remote.namedport" = "fe80:8::26a0:74ff:feea:538.57477";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.1025";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.blackjac";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.60492";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.60492";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.3555";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.razor";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.1025";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.1025";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.1025";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.blackjac";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.36540";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.36540";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.1025";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.blackjac";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.51787";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.51787";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.1025";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.blackjac";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.47541";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.47541";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.62475";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.62475";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.1025";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.1025";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "fe80:b::db25:5b8:d6c4:b265.1024";
        "local.namedport" = "fe80:b::db25:5b8:d6c4:b265.1024";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "fe80:b::f39f:9239:85b6:5d1e.1024";
        "remote.namedport" = "fe80:b::f39f:9239:85b6:5d1e.1024";
        sendq = "     0";
        state = ESTABLISHED;
    },
            {
        local = "*.62078";
        "local.namedport" = "*.62078";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "*.*";
        "remote.namedport" = "*.*";
        sendq = "     0";
        state = LISTEN;
    },
            {
        local = "::1.8021";
        "local.namedport" = "::1.intu-ec-";
        proto = "tcp6 ";
        recvq = "     0";
        remote = "*.*";
        "remote.namedport" = "*.*";
        sendq = "     0";
        state = LISTEN;
    }
);
"IP6.UCP" =     (
            {
        local = "*.5353";
        "local.namedport" = "*.5353";
        proto = "ucp6 ";
        recvq = "     0";
        remote = "*.*";
        "remote.namedport" = "*.*";
        sendq = "     0";
    }
);

lirum.network's People

Contributors

rogerioth avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mainarke

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.