RelayClient 0.0.1-alpha1

RelayClient 0.0.1-alpha1

Maintained by Igor Lira.



RelayClient 0.0.1-alpha1

Relay

Relay is a tool to tunnel iOS sockets to your local machine through a USB tunnel.

⚠️ This is an experimental project and might make your app crash. Do not use on production builds.

💕 Contributions are welcome and appreciated.

How it works

Client-side (iOS)

Relay will create one or more sockets listening on an arbitrary, user-specified port. All the communication in that port will be forwarded to and from your computer through a USB connection.

Server-side (macOS)

When running on your machine, Relay will listen for connections over USB and route the client's traffic to and from localhost at the requested port.

Installing

Client-side (iOS)

If you'd rather install manually, check ExampleRelayClient for an example.

Relay is available on CocoaPods. Add the following line on your Podfile:

pod 'RelayClient'

After running pod install, Add the following lines to your AppDelegate.m:

+#import <RelayClient/RelayConnectionManager.h>

 @interface AppDelegate ()

+@property (nonatomic, strong) RelayConnectionManager* relayManager;

 @end
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+    self.relayManager = [[RelayConnectionManager alloc] init];

+    // Use hangIfNotConnected to prevent incoming connections from being refused if we're not connected over USB
+    self.relayManager.hangIfNotConnected = YES;

+    // Will relay iOS(localhost:80) to macOS(localhost:8081)
+    [self.relayManager addLocalPort:@(80) relayPort:@(8081)];

+    [self.relayManager start];
 }

 - (void)applicationDidEnterBackground:(UIApplication *)application {
+    [self.relayManager stop];
 }


 - (void)applicationWillEnterForeground:(UIApplication *)application {
+    [self.relayManager start];
 }

Done!

Server-side (macOS)

You can either build the target RelayServer directly from the source code, or download a precompiled version here.

Relay will add an icon to your menu bar indicating if it's connected to a device:

Relay menu

Contributions

All contributions are welcome and appreciated. Thank you!