Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
STUN protocol implementation for iOS
Objective-C
branch: master
Failed to load latest commit information.
STUN print server at start
.gitignore Initial commit
README.md Update README.md

README.md

STUN protocol implementation for iOS

This is a Session Traversal Utilities for NAT (STUN) protocol implementation for iOS. Original specification: http://tools.ietf.org/html/rfc5389

How it works

  1. Import STUNClient and GCDAsyncUdpSocket classes:

    #import "GCDAsyncUdpSocket.h"
    #import "STUNClient.h"  
    
  2. Add STUNClientDelegate protocol to your class:

    @interface MyClass : NSObject <STUNClientDelegate>{
    
  3. Create instances of GCDAsyncUdpSocket and STUNClient classes. Perform method requestPublicIPandPortWithUDPSocket:delegate: and pass to it udp socket & delegate:

    GCDAsyncUdpSocket *udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    
    STUNClient *stunClient = [[STUNClient alloc] init];
    [stunClient requestPublicIPandPortWithUDPSocket:udpSocket delegate:self];
    
  4. Catch result in delegate's method -(void)didReceivePublicIPandPort:(NSDictionary *) data:

    -(void)didReceivePublicIPandPort:(NSDictionary *) data{
        NSLog(@"Public IP=%@, public Port=%@, NAT is Symmetric: %@", [data objectForKey:publicIPKey],
        [data objectForKey:publicPortKey], [data objectForKey:isNATTypeSymmetric]);
    }
    
  5. See in log:

    2012-09-20 15:55:31.160 STUN[19255:f803] Public IP=52.177.223.158, public Port=42483
    
  6. Start send Indication messages:

    [stunClient startSendIndicationMessage];
    
  7. Injoit!

License

It's compeletely free, use this lib without any problems.
Just would be great if you add info somewhere in your app about author: "STUN-iOS: Igor form QuickBlox", but it's not a requirement.

Something went wrong with that request. Please try again.