Skip to content

soulfly/STUN-iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

STUN protocol implementation for iOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published