diff --git a/.gitignore b/.gitignore index 31925b7..e49758e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,13 @@ telehash.xcodeproj/project.xcworkspace/xcshareddata/ +##### +# CocoaPods installed Pods directory +# This one is debatable, as many prefer to have Pods cached for non-CocoaPods users +# +# Discussion: http://stackoverflow.com/questions/9446644/what-goes-into-your-gitignore-if-youre-using-cocoapods + +Pods + ######################### # .gitignore file for Xcode4 and Xcode5 Source projects # diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..48d6faf --- /dev/null +++ b/Podfile @@ -0,0 +1,7 @@ +# Uncomment this line to define a global platform for your project +platform :ios, '7.0' + +pod 'libsodium', '~> 1.0' + + + diff --git a/README.md b/README.md index d265e6b..ba0c113 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,9 @@ Using as a standalone library ----------------------------- See the sub-project thFieldTest for an example of using the library. + +To install the pre-requisite libsodium, simply type the following CocoaPods command: + +pod install --no-integrate + +NB: --no-integrate avoids CocoaPods generating an xcodeworkspace for this project. diff --git a/Telehash Playground/Telehash Playground/Base.lproj/MainMenu.xib b/Telehash Playground/Telehash Playground/Base.lproj/MainMenu.xib index f73d4dd..8371ca8 100644 --- a/Telehash Playground/Telehash Playground/Base.lproj/MainMenu.xib +++ b/Telehash Playground/Telehash Playground/Base.lproj/MainMenu.xib @@ -1,7 +1,7 @@ - + - + @@ -10,7 +10,7 @@ - + @@ -650,14 +650,13 @@ - + - @@ -665,7 +664,6 @@ - @@ -674,7 +672,6 @@ - @@ -700,7 +696,6 @@ - @@ -709,7 +704,6 @@ - @@ -718,7 +712,6 @@ - - + - + - + @@ -779,16 +771,15 @@ - - + - + - + @@ -881,7 +872,6 @@ - @@ -890,7 +880,6 @@ - @@ -902,7 +891,6 @@ - @@ -911,16 +899,15 @@ - - + - + - + @@ -984,7 +971,6 @@ - @@ -1022,7 +1008,7 @@ - + diff --git a/Telehash Playground/Telehash Playground/THAppDelegate.h b/Telehash Playground/Telehash Playground/THAppDelegate.h index 45e8aa6..77b8a34 100644 --- a/Telehash Playground/Telehash Playground/THAppDelegate.h +++ b/Telehash Playground/Telehash Playground/THAppDelegate.h @@ -10,7 +10,7 @@ #import #import -@interface THAppDelegate : NSObject { +@interface THAppDelegate : NSObject { IBOutlet NSTableView* tableView; IBOutlet NSTextField* hashnameField; IBOutlet NSTextField* addressField; @@ -25,7 +25,7 @@ @property NSString* identityPath; @property (assign) IBOutlet NSWindow *window; --(void)channelReady:(E3XChannel *)channel type:(THChannelType)type firstPacket:(THPacket *)packet; +-(void)channelReady:(E3XChannel *)channel type:(E3XChannelType)type firstPacket:(THPacket *)packet; -(BOOL)channel:(E3XChannel*)channel handlePacket:(THPacket *)packet; -(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView; diff --git a/Telehash Playground/Telehash Playground/THAppDelegate.m b/Telehash Playground/Telehash Playground/THAppDelegate.m index ba2ff5f..10c6667 100644 --- a/Telehash Playground/Telehash Playground/THAppDelegate.m +++ b/Telehash Playground/Telehash Playground/THAppDelegate.m @@ -129,7 +129,7 @@ -(void)openedLine:(E3XExchange *)line; [tableView reloadData]; } --(void)channelReady:(E3XChannel *)channel type:(THChannelType)type firstPacket:(THPacket *)packet; +-(void)channelReady:(E3XChannel *)channel type:(E3XChannelType)type firstPacket:(THPacket *)packet; { NSLog(@"Channel is ready"); NSLog(@"First packet is %@", packet.json); @@ -147,7 +147,7 @@ -(IBAction)connectToHashname:(id)sender if (key.length > 0) { /* NSData* keyData = [[NSData alloc] initWithBase64EncodedString:key options:0]; - connectToIdentity = [THIdentity identityFromPublicKey:keyData]; + connectToIdentity = [THLink identityFromPublicKey:keyData]; NSString* address = [addressField stringValue]; NSInteger port = [portField integerValue]; if (address && port > 0) { @@ -164,17 +164,17 @@ -(IBAction)connectToHashname:(id)sender } } --(void)thSwitch:(THMesh *)inSwitch status:(THSwitchStatus)status +-(void)thSwitch:(THMesh *)inSwitch status:(THMeshStatus)status { NSLog(@"Switch status is now %d", status); - if (status == THSwitchOnline && !pingChannel) { + if (status == THMeshOnline && !pingChannel) { #if 0 if (![inSwitch.identity.hashname isEqualToString:@"ee5dc2630603638dfb980cbe7062378bdc70091947d9fa6dac5cf9b072296aad"]) { THPacket* pingPacket = [THPacket new]; [pingPacket.json setObject:@"ping" forKey:@"type"]; - pingChannel = [[THReliableChannel alloc] initToIdentity:[THIdentity identityFromHashname:@"ee5dc2630603638dfb980cbe7062378bdc70091947d9fa6dac5cf9b072296aad"]]; + pingChannel = [[THReliableChannel alloc] initToIdentity:[THLink identityFromHashname:@"ee5dc2630603638dfb980cbe7062378bdc70091947d9fa6dac5cf9b072296aad"]]; pingChannel.delegate = self; [inSwitch openChannel:pingChannel firstPacket:pingPacket]; diff --git a/common/E3XChannel.h b/common/E3XChannel.h index bffb7ba..26dd4f5 100644 --- a/common/E3XChannel.h +++ b/common/E3XChannel.h @@ -1,5 +1,5 @@ // -// THChannel.h +// E3XChannel.h // telehash // // Created by Thomas Muldowney on 10/5/13. @@ -17,21 +17,21 @@ @class THPacketBuffer; typedef enum { - THChannelOpening, - THChannelOpen, - THChannelPaused, - THChannelEnded, - THChannelErrored -} THChannelState; + E3XChannelOpening, + E3XChannelOpen, + E3XChannelPaused, + E3XChannelEnded, + E3XChannelErrored +} E3XChannelState; typedef enum { - THChannelInbound, - THChannelOutbound -} THChannelDirection; + E3XChannelInbound, + E3XChannelOutbound +} E3XChannelDirection; -@protocol THChannelDelegate +@protocol E3XChannelDelegate #pragma mark State Handling --(void)channel:(E3XChannel*)channel didChangeStateTo:(THChannelState)channelState; +-(void)channel:(E3XChannel*)channel didChangeStateTo:(E3XChannelState)channelState; #pragma mark Error Handling -(void)channel:(E3XChannel*)channel didFailWithError:(NSError*)error; -(BOOL)channel:(E3XChannel*)channel handlePacket:(THPacket*)packet; @@ -41,12 +41,12 @@ typedef enum { @property NSNumber* maxSeen; @property NSArray* missing; -@property (nonatomic, strong) id delegate; +@property (nonatomic, strong) id delegate; @property THLink* toIdentity; @property E3XExchange* line; @property NSNumber* channelId; -@property THChannelState state; -@property THChannelDirection direction; +@property E3XChannelState state; +@property E3XChannelDirection direction; @property NSString* type; @property NSUInteger createdAt; @property NSUInteger lastInActivity; diff --git a/common/E3XChannel.m b/common/E3XChannel.m index c53ef98..5b17e99 100644 --- a/common/E3XChannel.m +++ b/common/E3XChannel.m @@ -1,5 +1,5 @@ // -// THChannel.m +// E3XChannel.m // telehash // // Created by Thomas Muldowney on 10/5/13. @@ -19,15 +19,15 @@ @implementation E3XChannel { - THChannelState _state; + E3XChannelState _state; } -(id)initToIdentity:(THLink*)identity { self = [super init]; if (self) { - _state = THChannelOpening; - self.direction = THChannelOutbound; + _state = E3XChannelOpening; + self.direction = E3XChannelOutbound; self.toIdentity = identity; self.channelId = 0; // We'll just go ahead and make one self.createdAt = time(NULL); @@ -39,12 +39,12 @@ -(id)initToIdentity:(THLink*)identity return self; } --(THChannelState)state +-(E3XChannelState)state { return _state; } --(void)setState:(THChannelState)state +-(void)setState:(E3XChannelState)state { _state = state; if ([self.delegate respondsToSelector:@selector(channel:didChangeStateTo:)]) { @@ -54,9 +54,9 @@ -(void)setState:(THChannelState)state -(void)sendPacket:(THPacket *)packet; { - if (self.state == THChannelEnded) { + if (self.state == E3XChannelEnded) { // XXX Error that we're trying to send on an ended channel - } else if (self.state == THChannelErrored) { + } else if (self.state == E3XChannelErrored) { // XXX Error that we're trying to send on an errored channel } @@ -72,7 +72,7 @@ -(void)handlePacket:(THPacket *)packet; NSString* err = [packet.json objectForKey:@"err"]; if (err) { [self.delegate channel:self didFailWithError:[NSError errorWithDomain:@"telehash" code:100 userInfo:@{NSLocalizedDescriptionKey:err}]]; - self.state = THChannelErrored; + self.state = E3XChannelErrored; [self.toIdentity.channels removeObjectForKey:self.channelId]; } } @@ -81,11 +81,11 @@ -(void)close { if (!self.channelId) return; - if (self.state != THChannelOpening && self.state != THChannelEnded) { + if (self.state != E3XChannelOpening && self.state != E3XChannelEnded) { THPacket* endPacket = [THPacket new]; [endPacket.json setObject:@YES forKey:@"end"]; [self sendPacket:endPacket]; - self.state = THChannelEnded; + self.state = E3XChannelEnded; } [self.toIdentity.channels removeObjectForKey:self.channelId]; diff --git a/common/E3XCipherSet.h b/common/E3XCipherSet.h index 358ca39..f513e62 100644 --- a/common/E3XCipherSet.h +++ b/common/E3XCipherSet.h @@ -1,5 +1,5 @@ // -// THCipherSet.h +// E3XCipherSet.h // telehash // // Created by Thomas Muldowney on 2/27/14. @@ -24,7 +24,7 @@ -(NSString*)identifier; @end -@interface THCipherSetLineInfo : NSObject +@interface E3XCipherSetLineInfo : NSObject @property E3XCipherSet* cipherSet; -(NSData*)encryptLinePacket:(THPacket*)packet; -(void)decryptLinePacket:(THPacket*)packet; diff --git a/common/E3XCipherSet.m b/common/E3XCipherSet.m index 06cd1ba..620f8e2 100644 --- a/common/E3XCipherSet.m +++ b/common/E3XCipherSet.m @@ -1,5 +1,5 @@ // -// THCipherSet.m +// E3XCipherSet.m // telehash // // Created by Thomas Muldowney on 2/27/14. @@ -42,20 +42,20 @@ -(NSString*)identifier -(void)finalizeLineKeys:(E3XExchange *)line { - CLCLogError(@"Not implemented THCipherSet finalizeKeys"); + CLCLogError(@"Not implemented E3XCipherSet finalizeKeys"); } @end -@implementation THCipherSetLineInfo +@implementation E3XCipherSetLineInfo -(NSData*)encryptLinePacket:(THPacket*)packet { - CLCLogError(@"Not implemented THCipherSetLineInfo encryptLinePacket:"); + CLCLogError(@"Not implemented E3XCipherSetLineInfo encryptLinePacket:"); return nil; } -(void)decryptLinePacket:(THPacket *)packet { - CLCLogError(@"Not implemented THCipherSetLineInfo decryptLinePacket:"); + CLCLogError(@"Not implemented E3XCipherSetLineInfo decryptLinePacket:"); } @end diff --git a/common/E3XCipherSet2a.h b/common/E3XCipherSet2a.h index a58e7ac..ac1e1ce 100644 --- a/common/E3XCipherSet2a.h +++ b/common/E3XCipherSet2a.h @@ -1,5 +1,5 @@ // -// THCipherSet2a.h +// E3XCipherSet2a.h // telehash // // Created by Thomas Muldowney on 4/21/14. @@ -21,7 +21,7 @@ -(THPacket*)generateOpen:(E3XExchange*)line from:(THLink*)fromIdentity; @end -@interface THCipherSetLineInfo2a : THCipherSetLineInfo +@interface E3XCipherSetLineInfo2a : E3XCipherSetLineInfo @property ECDH* ecdh; @property NSData* remoteECCKey; @property NSData* encryptorKey; diff --git a/common/E3XCipherSet2a.m b/common/E3XCipherSet2a.m index e317d12..066fef5 100644 --- a/common/E3XCipherSet2a.m +++ b/common/E3XCipherSet2a.m @@ -1,5 +1,5 @@ // -// THCipherSet2a.m +// E3XCipherSet2a.m // telehash // // Created by Thomas Muldowney on 4/21/14. @@ -26,7 +26,7 @@ static unsigned char csId2a[] = {0x2a}; static unsigned char eccHeader[] = {0x04}; -@implementation THCipherSetLineInfo2a +@implementation E3XCipherSetLineInfo2a -(NSData*)encryptLinePacket:(THPacket*)packet iv:(NSData*)iv { // So broken... @@ -166,7 +166,7 @@ -(E3XExchange*)processOpen:(THPacket *)openPacket if (newLine) { // This is a partially opened line - THCipherSetLineInfo2a* lineInfo = (THCipherSetLineInfo2a*)newLine.cipherSetInfo; + E3XCipherSetLineInfo2a* lineInfo = (E3XCipherSetLineInfo2a*)newLine.cipherSetInfo; lineInfo.remoteECCKey = prefixedRemoteEccKey; // TODO temas review @@ -176,7 +176,7 @@ -(E3XExchange*)processOpen:(THPacket *)openPacket newLine.toIdentity = senderIdentity; senderIdentity.currentLine = newLine; - THCipherSetLineInfo2a* lineInfo = [THCipherSetLineInfo2a new]; + E3XCipherSetLineInfo2a* lineInfo = [E3XCipherSetLineInfo2a new]; lineInfo.cipherSet = incomingCS; lineInfo.remoteECCKey = prefixedRemoteEccKey; @@ -189,7 +189,7 @@ -(E3XExchange*)processOpen:(THPacket *)openPacket -(void)finalizeLineKeys:(E3XExchange*)line { - THCipherSetLineInfo2a* lineInfo = (THCipherSetLineInfo2a*)line.cipherSetInfo; + E3XCipherSetLineInfo2a* lineInfo = (E3XCipherSetLineInfo2a*)line.cipherSetInfo; // Make sure we have a valid ECDH context if (!lineInfo.ecdh) { lineInfo.ecdh = [ECDH new]; @@ -216,11 +216,11 @@ -(THPacket*)generateOpen:(E3XExchange*)line from:(THLink*)fromIdentity { if (!line.cipherSetInfo) { // FIXME, should be the remote cipherSet - THCipherSetLineInfo2a* lineInfo =[THCipherSetLineInfo2a new]; + E3XCipherSetLineInfo2a* lineInfo =[E3XCipherSetLineInfo2a new]; lineInfo.cipherSet = [line.toIdentity.cipherParts objectForKey:[self identifier]]; line.cipherSetInfo = lineInfo; } - THCipherSetLineInfo2a* lineInfo = (THCipherSetLineInfo2a*)line.cipherSetInfo; + E3XCipherSetLineInfo2a* lineInfo = (E3XCipherSetLineInfo2a*)line.cipherSetInfo; E3XCipherSet2a* remoteCS = (E3XCipherSet2a*)lineInfo.cipherSet; THPacket* openPacket = [THPacket new]; diff --git a/common/E3XCipherSet3a.h b/common/E3XCipherSet3a.h index baf0f5d..78b48a7 100644 --- a/common/E3XCipherSet3a.h +++ b/common/E3XCipherSet3a.h @@ -1,5 +1,5 @@ // -// THCipherSet3a.h +// E3XCipherSet3a.h // telehash // // Created by Thomas Muldowney on 4/21/14. @@ -19,7 +19,7 @@ -(void)savePublicKeyPath:(NSString*)publicKeyPath privateKeyPath:(NSString*)privateKeyPath; @end -@interface THCipherSetLineInfo3a : THCipherSetLineInfo +@interface E3XCipherSetLineInfo3a : E3XCipherSetLineInfo @property (readonly) NSMutableData* publicLineKey; @property (readonly) NSMutableData* secretLineKey; @property NSData* remoteLineKey; diff --git a/common/E3XCipherSet3a.m b/common/E3XCipherSet3a.m index 0bb3350..9279fe6 100644 --- a/common/E3XCipherSet3a.m +++ b/common/E3XCipherSet3a.m @@ -1,5 +1,5 @@ // -// THCipherSet3a.m +// E3XCipherSet3a.m // telehash // // Created by Thomas Muldowney on 4/21/14. @@ -141,14 +141,14 @@ -(E3XExchange*)processOpen:(THPacket*)openPacket; E3XExchange* newLine = senderIdentity.currentLine; if (newLine) { // This is a partially opened line - THCipherSetLineInfo3a* lineInfo = (THCipherSetLineInfo3a*)newLine.cipherSetInfo; + E3XCipherSetLineInfo3a* lineInfo = (E3XCipherSetLineInfo3a*)newLine.cipherSetInfo; lineInfo.remoteLineKey = pubLineKey; } else { newLine = [E3XExchange new]; newLine.toIdentity = senderIdentity; senderIdentity.currentLine = newLine; - THCipherSetLineInfo3a* lineInfo = [THCipherSetLineInfo3a new]; + E3XCipherSetLineInfo3a* lineInfo = [E3XCipherSetLineInfo3a new]; lineInfo.cipherSet = incomingCS; lineInfo.remoteLineKey = pubLineKey; @@ -162,7 +162,7 @@ -(E3XExchange*)processOpen:(THPacket*)openPacket; -(void)finalizeLineKeys:(E3XExchange*)line { - THCipherSetLineInfo3a* lineInfo = (THCipherSetLineInfo3a*)line.cipherSetInfo; + E3XCipherSetLineInfo3a* lineInfo = (E3XCipherSetLineInfo3a*)line.cipherSetInfo; NSMutableData* agreedKey = [NSMutableData dataWithLength:crypto_box_BEFORENMBYTES]; crypto_box_beforenm([agreedKey mutableBytes], [lineInfo.remoteLineKey bytes], [lineInfo.secretLineKey bytes]); @@ -184,11 +184,11 @@ -(void)finalizeLineKeys:(E3XExchange*)line -(THPacket*)generateOpen:(E3XExchange*)line from:(THLink*)fromIdentity { if (!line.cipherSetInfo) { - THCipherSetLineInfo3a* lineInfo = [THCipherSetLineInfo3a new]; + E3XCipherSetLineInfo3a* lineInfo = [E3XCipherSetLineInfo3a new]; lineInfo.cipherSet = [line.toIdentity.cipherParts objectForKey:[self identifier]]; line.cipherSetInfo = lineInfo; } - THCipherSetLineInfo3a* lineInfo = (THCipherSetLineInfo3a*)line.cipherSetInfo; + E3XCipherSetLineInfo3a* lineInfo = (E3XCipherSetLineInfo3a*)line.cipherSetInfo; E3XCipherSet3a* remoteCS = (E3XCipherSet3a*)lineInfo.cipherSet; THPacket* innerPacket = [THPacket new]; @@ -254,7 +254,7 @@ -(void)savePublicKeyPath:(NSString *)publicKeyPath privateKeyPath:(NSString *)pr } @end -@implementation THCipherSetLineInfo3a +@implementation E3XCipherSetLineInfo3a -(id)init { self = [super init]; diff --git a/common/E3XExchange.h b/common/E3XExchange.h index a96d790..748a4f1 100644 --- a/common/E3XExchange.h +++ b/common/E3XExchange.h @@ -1,5 +1,5 @@ // -// THLine.h +// E3XExchange.h // telehash // // Created by Thomas Muldowney on 11/15/13. @@ -13,13 +13,13 @@ @class THPacket; @class E3XChannel; -@class THCipherSetLineInfo; +@class E3XCipherSetLineInfo; @class THPath; @interface E3XExchange : NSObject @property THLink* toIdentity; -@property THCipherSetLineInfo* cipherSetInfo; +@property E3XCipherSetLineInfo* cipherSetInfo; @property THPacket* cachedOpen; @property NSString* outLineId; diff --git a/common/E3XExchange.m b/common/E3XExchange.m index 05e6ebc..77a582e 100644 --- a/common/E3XExchange.m +++ b/common/E3XExchange.m @@ -1,6 +1,6 @@ // -// THLine.m +// E3XExchange.m // telehash // // Created by Thomas Muldowney on 11/15/13. @@ -30,7 +30,7 @@ #include -@interface THPathHandler : NSObject +@interface THPathHandler : NSObject @property E3XExchange* line; @end @@ -99,7 +99,7 @@ -(void)openLine; if ([obj class] != [E3XReliableChannel class]) return; E3XReliableChannel* channel = (E3XReliableChannel*)obj; // If the channel already thinks it's good, we'll just ignore it's state - if (channel.state == THChannelOpen) return; + if (channel.state == E3XChannelOpen) return; [channel flushOut]; }]; @@ -256,7 +256,7 @@ -(void)handlePacket:(THPacket *)packet; // This is a reliable channel, let's make sure we're in a good state E3XReliableChannel* reliableChannel = (E3XReliableChannel*)channel; if (seq.unsignedIntegerValue == 0 && [[innerPacket.json objectForKey:@"ack"] unsignedIntegerValue] == 0) { - reliableChannel.state = THChannelOpen; + reliableChannel.state = E3XChannelOpen; } } [channel handlePacket:innerPacket]; @@ -278,7 +278,7 @@ -(void)handlePacket:(THPacket *)packet; } E3XChannel* newChannel; - THChannelType newChannelType; + E3XChannelType newChannelType; if (seq && [seq unsignedIntegerValue] == 0) { newChannel = [[E3XReliableChannel alloc] initToIdentity:self.toIdentity]; newChannelType = ReliableChannel; @@ -288,8 +288,8 @@ -(void)handlePacket:(THPacket *)packet; } newChannel.channelId = channelId; - newChannel.state = THChannelOpening; - newChannel.direction = THChannelInbound; + newChannel.state = E3XChannelOpening; + newChannel.direction = E3XChannelInbound; newChannel.type = channelType; THMesh* defaultSwitch = [THMesh defaultSwitch]; @@ -297,7 +297,7 @@ -(void)handlePacket:(THPacket *)packet; [newChannel handlePacket:innerPacket]; // Now we're full open and ready to roll - newChannel.state = THChannelOpen; + newChannel.state = E3XChannelOpen; if ([defaultSwitch.delegate respondsToSelector:@selector(channelReady:type:firstPacket:)]) { [defaultSwitch.delegate channelReady:newChannel type:newChannelType firstPacket:innerPacket]; } @@ -377,7 +377,7 @@ -(void)negotiatePath [self addChannelHandler:handler]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - CLCLogDebug(@"THLine removing pathChannel %@", pathChannel.channelId); + CLCLogDebug(@"E3XExchange removing pathChannel %@", pathChannel.channelId); [self removeChannelHandler:handler]; [pathChannel close]; }); @@ -469,7 +469,7 @@ -(BOOL)channel:(E3XChannel *)channel handlePacket:(THPacket *)packet return YES; } --(void)channel:(E3XChannel *)channel didChangeStateTo:(THChannelState)channelState +-(void)channel:(E3XChannel *)channel didChangeStateTo:(E3XChannelState)channelState { } diff --git a/common/E3XReliableChannel.m b/common/E3XReliableChannel.m index dd57820..da24f29 100644 --- a/common/E3XReliableChannel.m +++ b/common/E3XReliableChannel.m @@ -95,7 +95,7 @@ -(void)sendPacket:(THPacket *)packet; { [super sendPacket:packet]; - if (self.state == THChannelEnded || self.state == THChannelErrored) return; + if (self.state == E3XChannelEnded || self.state == E3XChannelErrored) return; // Save the type NSString* packetType = [packet.json objectForKey:@"type"]; @@ -131,7 +131,7 @@ -(void)sendPacket:(THPacket *)packet; [outPacketBuffer push:packet]; } - if (self.state == THChannelOpen) { + if (self.state == E3XChannelOpen) { #ifdef FUZZY_LOSS // 10% packet loss fuzz if ((int)(arc4random() % 11) == 1) @@ -152,7 +152,7 @@ -(void)resendMissingPackets:(NSArray*)miss CLCLogDebug(@"resending %d missing packets", missedPackets.count); for (THPacket* packet in missedPackets) { [packet.json removeObjectForKey:@"miss"]; - if (self.state == THChannelOpen) [self.toIdentity sendPacket:packet]; + if (self.state == E3XChannelOpen) [self.toIdentity sendPacket:packet]; } } else { CLCLogWarning(@"outPacketBuffer didnt have packets for resendMissingPackets"); @@ -184,9 +184,9 @@ -(void)delegateHandlePackets; self.nextExpectedSequence = lastProcessed + 1; } - if (self.state != THChannelEnded && [[curPacket.json objectForKey:@"end"] boolValue] == YES) { + if (self.state != E3XChannelEnded && [[curPacket.json objectForKey:@"end"] boolValue] == YES) { // TODO: Shut it down! - self.state = THChannelEnded; + self.state = E3XChannelEnded; [self close]; return; } diff --git a/common/E3XUnreliableChannel.m b/common/E3XUnreliableChannel.m index 06e4c53..0185e83 100644 --- a/common/E3XUnreliableChannel.m +++ b/common/E3XUnreliableChannel.m @@ -13,7 +13,7 @@ @implementation E3XUnreliableChannel { NSMutableArray* packetBuffer; - THChannelState _state; + E3XChannelState _state; } -(void)dealloc @@ -27,15 +27,15 @@ -(id)initToIdentity:(THLink *)identity; return self; } --(void)setState:(THChannelState)state +-(void)setState:(E3XChannelState)state { _state = state; - if (_state == THChannelOpen) { + if (_state == E3XChannelOpen) { [self flushSend]; } } --(THChannelState)state +-(E3XChannelState)state { return _state; } @@ -48,11 +48,11 @@ -(void)handlePacket:(THPacket *)packet; NSString* packetType = [packet.json objectForKey:@"type"]; if (!self.type && packetType) self.type = packetType; - if (self.state != THChannelOpening && [self.delegate respondsToSelector:@selector(channel:handlePacket:)]) { + if (self.state != E3XChannelOpening && [self.delegate respondsToSelector:@selector(channel:handlePacket:)]) { [self.delegate channel:self handlePacket:packet]; } - if (self.state != THChannelEnded && [[packet.json objectForKey:@"end"] boolValue] == YES) { - self.state = THChannelEnded; + if (self.state != E3XChannelEnded && [[packet.json objectForKey:@"end"] boolValue] == YES) { + self.state = E3XChannelEnded; [self close]; } } @@ -61,7 +61,7 @@ -(void)sendPacket:(THPacket *)packet; { [super sendPacket:packet]; - if (self.state == THChannelEnded || self.state == THChannelErrored) return; + if (self.state == E3XChannelEnded || self.state == E3XChannelErrored) return; // Save the type NSString* packetType = [packet.json objectForKey:@"type"]; @@ -69,10 +69,10 @@ -(void)sendPacket:(THPacket *)packet; [packet.json setObject:self.channelId forKey:@"c"]; - if (self.state == THChannelPaused || self.state == THChannelOpening) { + if (self.state == E3XChannelPaused || self.state == E3XChannelOpening) { if (!packetBuffer) packetBuffer = [NSMutableArray array]; [packetBuffer addObject:packet]; - } else if (self.state == THChannelOpen) { + } else if (self.state == E3XChannelOpen) { [self realSend:packet]; } } @@ -88,7 +88,7 @@ -(void)realSend:(THPacket*)packet -(void)flushSend { while (packetBuffer.count > 0) { - if (self.state != THChannelOpen) return; + if (self.state != E3XChannelOpen) return; THPacket* outPacket = [packetBuffer firstObject]; [packetBuffer removeObjectAtIndex:0]; [self realSend:outPacket]; diff --git a/common/THLink.h b/common/THLink.h index d234e25..6bf2106 100644 --- a/common/THLink.h +++ b/common/THLink.h @@ -1,5 +1,5 @@ // -// THIdentity.h +// THLink.h // telehash // // Created by Thomas Muldowney on 10/5/13. diff --git a/common/THLink.m b/common/THLink.m index dc04dde..b555580 100644 --- a/common/THLink.m +++ b/common/THLink.m @@ -1,5 +1,5 @@ // -// THIdentity.m +// THLink.m // telehash // // Created by Thomas Muldowney on 10/5/13. @@ -345,8 +345,8 @@ -(void)closeChannels { [self.channels enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { E3XChannel* curChannel = (E3XChannel*)obj; - if (curChannel.state != THChannelEnded) { - curChannel.state = THChannelEnded; + if (curChannel.state != E3XChannelEnded) { + curChannel.state = E3XChannelEnded; } }]; diff --git a/common/THMesh.h b/common/THMesh.h index 7ecf45a..fb8e7d7 100644 --- a/common/THMesh.h +++ b/common/THMesh.h @@ -1,5 +1,5 @@ // -// THSwitch.h +// THMesh.h // telehash // // Created by Thomas Muldowney on 10/3/13. @@ -18,23 +18,23 @@ typedef enum { ReliableChannel, UnreliableChannel -} THChannelType; +} E3XChannelType; typedef enum { THSWitchOffline, - THSwitchListening, - THSwitchOnline -} THSwitchStatus; + THMeshListening, + THMeshOnline +} THMeshStatus; typedef void(^LineOpenBlock)(THLink*); @class THMesh; -@protocol THSwitchDelegate +@protocol THMeshDelegate -(void)openedLine:(E3XExchange*)line; --(void)channelReady:(E3XChannel*)channel type:(THChannelType)type firstPacket:(THPacket*)packet; --(void)thSwitch:(THMesh*)thSwitch status:(THSwitchStatus)status; +-(void)channelReady:(E3XChannel*)channel type:(E3XChannelType)type firstPacket:(THPacket*)packet; +-(void)thSwitch:(THMesh*)thSwitch status:(THMeshStatus)status; @end @@ -45,8 +45,8 @@ typedef void(^LineOpenBlock)(THLink*); @property NSMutableDictionary* openLines; @property NSMutableArray* pendingJobs; @property THLink* identity; -@property id delegate; -@property THSwitchStatus status; +@property id delegate; +@property THMeshStatus status; @property NSMutableDictionary* transports; @property NSMutableArray* potentialBridges; @@ -64,7 +64,7 @@ typedef void(^LineOpenBlock)(THLink*); -(void)openLine:(THLink*)toIdentity; -(void)closeLine:(E3XExchange*)line; -(void)loadSeeds:(NSData*)seedData; --(void)updateStatus:(THSwitchStatus)status; +-(void)updateStatus:(THMeshStatus)status; -(THPacket*)generateOpen:(E3XExchange*)toLine; -(void)handlePacket:(THPacket*)packet; diff --git a/common/THMesh.m b/common/THMesh.m index 4d257db..5c2b77d 100644 --- a/common/THMesh.m +++ b/common/THMesh.m @@ -1,5 +1,5 @@ // -// THSwitch.m +// THMesh.m // telehash // // Created by Thomas Muldowney on 10/3/13. @@ -80,7 +80,7 @@ -(void)start for (NSString* key in self.transports) { [[self.transports objectForKey:key] start]; } - [self updateStatus:THSwitchListening]; + [self updateStatus:THMeshListening]; } -(void)addTransport:(THTransport *)transport @@ -149,7 +149,7 @@ -(void)channel:(E3XChannel*)channel line:(E3XExchange*)line firstPacket:(THPacke channel.channelId = [NSNumber numberWithUnsignedInteger:line.nextChannelId]; } [channel.toIdentity.channels setObject:channel forKey:channel.channelId]; - channel.state = THChannelOpen; + channel.state = E3XChannelOpen; if (packet) [channel sendPacket:packet]; } @@ -413,7 +413,7 @@ -(void)processOpen:(THPacket*)incomingPacket }]; } --(void)updateStatus:(THSwitchStatus)status +-(void)updateStatus:(THMeshStatus)status { if (status != self.status) { self.status = status; diff --git a/common/THPeerRelay.h b/common/THPeerRelay.h index 8d380d4..a8246b4 100644 --- a/common/THPeerRelay.h +++ b/common/THPeerRelay.h @@ -12,7 +12,7 @@ @class THLink; @class E3XChannel; -@interface THPeerRelay : NSObject +@interface THPeerRelay : NSObject @property E3XChannel* connectChannel; @property E3XChannel* peerChannel; -(void)sendPacket:(THPacket*)packet; diff --git a/common/THPeerRelay.m b/common/THPeerRelay.m index fe606d6..5ab8a7c 100644 --- a/common/THPeerRelay.m +++ b/common/THPeerRelay.m @@ -41,7 +41,7 @@ -(BOOL)channel:(E3XChannel *)channel handlePacket:(THPacket *)packet return YES; } --(void)channel:(E3XChannel *)channel didChangeStateTo:(THChannelState)channelState +-(void)channel:(E3XChannel *)channel didChangeStateTo:(E3XChannelState)channelState { CLCLogWarning(@"THPeerRelay channel didChangeStateTo: %d", channelState); } diff --git a/common/THRelay.h b/common/THRelay.h index fd65077..8ea6674 100644 --- a/common/THRelay.h +++ b/common/THRelay.h @@ -11,7 +11,7 @@ #import "E3XUnreliableChannel.h" #import "THPath.h" -@interface THRelay : NSObject +@interface THRelay : NSObject @property (assign) THLink* toIdentity; @property (retain) THLink* relayIdentity; @property (retain) THPath* relayedPath; diff --git a/common/THRelay.m b/common/THRelay.m index 5607ccd..dcaf788 100644 --- a/common/THRelay.m +++ b/common/THRelay.m @@ -127,11 +127,11 @@ -(void)channel:(E3XChannel *)channel didFailWithError:(NSError *)error } } --(void)channel:(E3XChannel *)channel didChangeStateTo:(THChannelState)channelState +-(void)channel:(E3XChannel *)channel didChangeStateTo:(E3XChannelState)channelState { CLCLogDebug(@"relay peerChannel for %@ didChangeStateTo: %d", self.toIdentity.hashname, channelState); - if (channel == self.peerChannel && (channelState == THChannelEnded || channelState == THChannelErrored)) { + if (channel == self.peerChannel && (channelState == E3XChannelEnded || channelState == E3XChannelErrored)) { CLCLogWarning(@"relay peerChannel for %@ closed", self.toIdentity.hashname); self.peerChannel = nil; } diff --git a/telehash.xcodeproj/project.pbxproj b/telehash.xcodeproj/project.pbxproj index 4cd5388..c34d0cf 100644 --- a/telehash.xcodeproj/project.pbxproj +++ b/telehash.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 79C22A1C1B4F2D840051F148 /* libPods-libsodium.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 79C22A171B4F2D590051F148 /* libPods-libsodium.a */; }; + 79C22A1D1B4F2D840051F148 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 79C22A151B4F2D590051F148 /* libPods.a */; }; 820BADF318D77EFA003D7CBA /* THPeerRelay.h in Headers */ = {isa = PBXBuildFile; fileRef = 820BADF118D77EFA003D7CBA /* THPeerRelay.h */; }; 820BADF418D77EFA003D7CBA /* THPeerRelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 820BADF218D77EFA003D7CBA /* THPeerRelay.m */; }; 820BADF518D77EFA003D7CBA /* THPeerRelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 820BADF218D77EFA003D7CBA /* THPeerRelay.m */; }; @@ -58,7 +60,6 @@ 8236E1A818F5EDB600169201 /* THTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = 8236E1A618F5EDB600169201 /* THTransport.m */; }; 8236E1A918F5EDB600169201 /* THTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = 8236E1A618F5EDB600169201 /* THTransport.m */; }; 8249D63F1905F6640009F03B /* libsodium.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8249D63E1905F6640009F03B /* libsodium.a */; }; - 8249D6411905F6730009F03B /* libsodium.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8249D6401905F6730009F03B /* libsodium.a */; }; 8249D6441906100C0009F03B /* E3XCipherSet3a.h in Headers */ = {isa = PBXBuildFile; fileRef = 8249D6421906100C0009F03B /* E3XCipherSet3a.h */; }; 8249D6451906100C0009F03B /* E3XCipherSet3a.m in Sources */ = {isa = PBXBuildFile; fileRef = 8249D6431906100C0009F03B /* E3XCipherSet3a.m */; }; 8249D6461906100C0009F03B /* E3XCipherSet3a.m in Sources */ = {isa = PBXBuildFile; fileRef = 8249D6431906100C0009F03B /* E3XCipherSet3a.m */; }; @@ -112,6 +113,34 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 79C22A141B4F2D590051F148 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 5769BB36ACF0AD3987FFA1B4; + remoteInfo = Pods; + }; + 79C22A161B4F2D590051F148 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = F0141CB16C942C7E214F7D45; + remoteInfo = "Pods-libsodium"; + }; + 79C22A1E1B4F2D8B0051F148 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 454FBD4AF4ED4CD44B8538FB; + remoteInfo = Pods; + }; + 79C22A201B4F2D8B0051F148 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 1BAB48A2ADEB538A00553177; + remoteInfo = "Pods-libsodium"; + }; 8207A0BF18562A5F009EF845 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8207A0B818562A5E009EF845 /* thFieldTest.xcodeproj */; @@ -199,6 +228,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Pods.xcodeproj; path = Pods/Pods.xcodeproj; sourceTree = ""; }; 8207A0B818562A5E009EF845 /* thFieldTest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = thFieldTest.xcodeproj; path = thFieldTest/thFieldTest.xcodeproj; sourceTree = ""; }; 820BADF118D77EFA003D7CBA /* THPeerRelay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = THPeerRelay.h; sourceTree = ""; }; 820BADF218D77EFA003D7CBA /* THPeerRelay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = THPeerRelay.m; sourceTree = ""; }; @@ -312,7 +342,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8249D6411905F6730009F03B /* libsodium.a in Frameworks */, + 79C22A1C1B4F2D840051F148 /* libPods-libsodium.a in Frameworks */, + 79C22A1D1B4F2D840051F148 /* libPods.a in Frameworks */, 8218D19D17FA6EA50053AFAC /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -331,6 +362,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 79C22A101B4F2D580051F148 /* Products */ = { + isa = PBXGroup; + children = ( + 79C22A151B4F2D590051F148 /* libPods.a */, + 79C22A171B4F2D590051F148 /* libPods-libsodium.a */, + ); + name = Products; + sourceTree = ""; + }; 8207A0B918562A5E009EF845 /* Products */ = { isa = PBXGroup; children = ( @@ -343,6 +383,7 @@ 8218D16417FA6E8A0053AFAC = { isa = PBXGroup; children = ( + 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */, 82D221361871D3630015E7EA /* cryptopp.xcodeproj */, 8207A0B818562A5E009EF845 /* thFieldTest.xcodeproj */, 8231EC081836C60D00BC41C1 /* Telehash Playground.xcodeproj */, @@ -640,6 +681,8 @@ buildRules = ( ); dependencies = ( + 79C22A1F1B4F2D8B0051F148 /* PBXTargetDependency */, + 79C22A211B4F2D8B0051F148 /* PBXTargetDependency */, 8263D96718BD275000DED8E5 /* PBXTargetDependency */, ); name = "telehash-ios"; @@ -694,6 +737,10 @@ ProductGroup = 82D221371871D3630015E7EA /* Products */; ProjectRef = 82D221361871D3630015E7EA /* cryptopp.xcodeproj */; }, + { + ProductGroup = 79C22A101B4F2D580051F148 /* Products */; + ProjectRef = 79C22A0F1B4F2D580051F148 /* Pods.xcodeproj */; + }, { ProductGroup = 8231EC091836C60D00BC41C1 /* Products */; ProjectRef = 8231EC081836C60D00BC41C1 /* Telehash Playground.xcodeproj */; @@ -714,6 +761,20 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ + 79C22A151B4F2D590051F148 /* libPods.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libPods.a; + remoteRef = 79C22A141B4F2D590051F148 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 79C22A171B4F2D590051F148 /* libPods-libsodium.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libPods-libsodium.a"; + remoteRef = 79C22A161B4F2D590051F148 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 8207A0C018562A5F009EF845 /* thFieldTest.app */ = { isa = PBXReferenceProxy; fileType = wrapper.application; @@ -869,6 +930,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 79C22A1F1B4F2D8B0051F148 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Pods; + targetProxy = 79C22A1E1B4F2D8B0051F148 /* PBXContainerItemProxy */; + }; + 79C22A211B4F2D8B0051F148 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "Pods-libsodium"; + targetProxy = 79C22A201B4F2D8B0051F148 /* PBXContainerItemProxy */; + }; 8218D18517FA6E8B0053AFAC /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8218D16C17FA6E8A0053AFAC /* telehash */; @@ -1102,6 +1173,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(PROJECT_DIR)/cryptopp", "$(PROJECT_DIR)/libsodium/build-ios/include", + "$(PROJECT_DIR)/Pods/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; LIBRARY_SEARCH_PATHS = ( @@ -1130,6 +1202,7 @@ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, "$(PROJECT_DIR)/cryptopp", "$(PROJECT_DIR)/libsodium/build-ios/include", + "$(PROJECT_DIR)/Pods/**", ); IPHONEOS_DEPLOYMENT_TARGET = 7.0; LIBRARY_SEARCH_PATHS = ( diff --git a/telehashTests/telehashTests.m b/telehashTests/telehashTests.m index e6dd258..71c8567 100644 --- a/telehashTests/telehashTests.m +++ b/telehashTests/telehashTests.m @@ -59,12 +59,12 @@ -(void)testOpenPacketParsing -(void)testHashname { /* XXX TODO: Rewrite this for the new hashnames - THIdentity* identity = [THIdentity new]; + THLink* identity = [THLink new]; NSURL* pubURL = [[NSURL alloc] initFileURLWithPath:@"telehashTests/server.pder"]; NSData* serverPub = [NSData dataWithContentsOfURL:pubURL]; NSURL* privURL = [[NSURL alloc] initFileURLWithPath:@"telehashTests/server.der"]; NSData* serverPriv = [NSData dataWithContentsOfURL:privURL]; - THCipherSet2a* cs2a = [[THCipherSet2a alloc] initWithPublicKey:serverPub privateKey:serverPriv]; + E3XCipherSet2a* cs2a = [[E3XCipherSet2a alloc] initWithPublicKey:serverPub privateKey:serverPriv]; [identity.cipherParts setValue:cs2a forKey:@"2a"]; XCTAssertEqualObjects(@"50a5d0d0e00080edf6cdf98eae2fc38196890e6c443e3d268b5963cf0052a900", identity.hashname, @"Hashname incorrect"); diff --git a/thFieldTest/thFieldTest.xcodeproj/project.pbxproj b/thFieldTest/thFieldTest.xcodeproj/project.pbxproj index 014fb42..f542a12 100644 --- a/thFieldTest/thFieldTest.xcodeproj/project.pbxproj +++ b/thFieldTest/thFieldTest.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 79C22A231B4F310C0051F148 /* seeds.json in Resources */ = {isa = PBXBuildFile; fileRef = 79C22A221B4F310C0051F148 /* seeds.json */; }; 8207A07E18562A5E009EF845 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8207A07D18562A5E009EF845 /* Foundation.framework */; }; 8207A08018562A5E009EF845 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8207A07F18562A5E009EF845 /* CoreGraphics.framework */; }; 8207A08218562A5E009EF845 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8207A08118562A5E009EF845 /* UIKit.framework */; }; @@ -27,8 +28,7 @@ 823652DC18FCE92D00F75308 /* libcryptopp-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 823652DB18FCE92D00F75308 /* libcryptopp-ios.a */; }; 82835BD91857962800168C3B /* libc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 82835BD81857962800168C3B /* libc++.dylib */; }; 82835BDF185798BB00168C3B /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82835BDE185798BB00168C3B /* Security.framework */; }; - 82835BE118579A0800168C3B /* seeds-real.json in Resources */ = {isa = PBXBuildFile; fileRef = 82835BE018579A0800168C3B /* seeds-real.json */; }; - 82E44855188E0AEE00B3AAEB /* seeds.json in Resources */ = {isa = PBXBuildFile; fileRef = 82E44854188E0AEE00B3AAEB /* seeds.json */; }; + 82835BE118579A0800168C3B /* seeds-old.json in Resources */ = {isa = PBXBuildFile; fileRef = 82835BE018579A0800168C3B /* seeds-old.json */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -42,6 +42,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 79C22A221B4F310C0051F148 /* seeds.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = seeds.json; sourceTree = ""; }; 8207A07A18562A5E009EF845 /* thFieldTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = thFieldTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8207A07D18562A5E009EF845 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 8207A07F18562A5E009EF845 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -70,9 +71,8 @@ 8263D95718BD16B600DED8E5 /* libcryptopp-ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libcryptopp-ios.a"; path = "../../../../../Library/Developer/Xcode/DerivedData/telehash-hdsfxjzmsvyqtyccnkdyjwfyzarx/Build/Products/Debug-iphoneos/libcryptopp-ios.a"; sourceTree = ""; }; 82835BD81857962800168C3B /* libc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.dylib"; path = "usr/lib/libc++.dylib"; sourceTree = SDKROOT; }; 82835BDE185798BB00168C3B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; - 82835BE018579A0800168C3B /* seeds-real.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "seeds-real.json"; sourceTree = ""; }; + 82835BE018579A0800168C3B /* seeds-old.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "seeds-old.json"; sourceTree = ""; }; 82D222CA1871E0F70015E7EA /* libcryptopp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcryptopp.a; path = "../../../../../Library/Developer/Xcode/DerivedData/telehash-hdsfxjzmsvyqtyccnkdyjwfyzarx/Build/Products/Debug-iphoneos/libcryptopp.a"; sourceTree = ""; }; - 82E44854188E0AEE00B3AAEB /* seeds.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = seeds.json; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -160,12 +160,12 @@ 8207A08418562A5E009EF845 /* Supporting Files */ = { isa = PBXGroup; children = ( - 82835BE018579A0800168C3B /* seeds-real.json */, + 79C22A221B4F310C0051F148 /* seeds.json */, + 82835BE018579A0800168C3B /* seeds-old.json */, 8207A08518562A5E009EF845 /* thFieldTest-Info.plist */, 8207A08618562A5E009EF845 /* InfoPlist.strings */, 8207A08918562A5E009EF845 /* main.m */, 8207A08B18562A5E009EF845 /* thFieldTest-Prefix.pch */, - 82E44854188E0AEE00B3AAEB /* seeds.json */, ); name = "Supporting Files"; sourceTree = ""; @@ -267,10 +267,10 @@ files = ( 8207A09418562A5E009EF845 /* Main_iPad.storyboard in Resources */, 8207A09C18562A5E009EF845 /* Images.xcassets in Resources */, - 82E44855188E0AEE00B3AAEB /* seeds.json in Resources */, + 79C22A231B4F310C0051F148 /* seeds.json in Resources */, 8207A09118562A5E009EF845 /* Main_iPhone.storyboard in Resources */, 8207A08818562A5E009EF845 /* InfoPlist.strings in Resources */, - 82835BE118579A0800168C3B /* seeds-real.json in Resources */, + 82835BE118579A0800168C3B /* seeds-old.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/thFieldTest/thFieldTest/THAppDelegate.m b/thFieldTest/thFieldTest/THAppDelegate.m index c3c9fad..1b4dcdd 100644 --- a/thFieldTest/thFieldTest/THAppDelegate.m +++ b/thFieldTest/thFieldTest/THAppDelegate.m @@ -8,7 +8,7 @@ #import "THAppDelegate.h" #import -#import +#import static const UInt8 kKeychainItemIdentifier[] = "org.telehash.thFieldTest.publicKey\0"; diff --git a/thFieldTest/thFieldTest/THMasterViewController.h b/thFieldTest/thFieldTest/THMasterViewController.h index 7676c47..71de068 100644 --- a/thFieldTest/thFieldTest/THMasterViewController.h +++ b/thFieldTest/thFieldTest/THMasterViewController.h @@ -7,13 +7,13 @@ // #import -#import -#import +#import +#import @class THDetailViewController; -@interface THMasterViewController : UITableViewController { - THSwitch* thSwitch; +@interface THMasterViewController : UITableViewController { + THMesh* thSwitch; } @property (strong, nonatomic) THDetailViewController *detailViewController; diff --git a/thFieldTest/thFieldTest/THMasterViewController.m b/thFieldTest/thFieldTest/THMasterViewController.m index a3b5fa8..775e808 100644 --- a/thFieldTest/thFieldTest/THMasterViewController.m +++ b/thFieldTest/thFieldTest/THMasterViewController.m @@ -10,12 +10,12 @@ #import "THDetailViewController.h" -#import -#import +#import +#import #import #import #import -#import +#import @implementation THMasterViewController @@ -41,7 +41,7 @@ - (void)viewDidLoad self.detailViewController = (THDetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController]; */ - thSwitch = [THSwitch defaultSwitch]; + thSwitch = [THMesh defaultSwitch]; NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = [searchPaths objectAtIndex:0]; @@ -50,12 +50,12 @@ - (void)viewDidLoad NSString* privPath = [NSString stringWithFormat:@"%@/privkey.der", documentPath]; // Insert code here to initialize your application - thSwitch = [THSwitch defaultSwitch]; + thSwitch = [THMesh defaultSwitch]; thSwitch.delegate = self; - THIdentity* baseIdentity = [THIdentity new]; - THCipherSet2a* cs2a = [[THCipherSet2a alloc] initWithPublicKeyPath:pubPath privateKeyPath:privPath]; + THLink* baseIdentity = [THLink new]; + E3XCipherSet2a* cs2a = [[E3XCipherSet2a alloc] initWithPublicKeyPath:pubPath privateKeyPath:privPath]; if (!cs2a) { - cs2a = [THCipherSet2a new]; + cs2a = [E3XCipherSet2a new]; [cs2a generateKeys]; [cs2a.rsaKeys savePublicKey:pubPath privateKey:privPath]; } @@ -90,12 +90,12 @@ - (void)didReceiveMemoryWarning // Dispose of any resources that can be recreated. } --(void)openedLine:(THLine *)line +-(void)openedLine:(E3XExchange *)line { [self.tableView reloadData]; } --(void)channelReady:(THChannel *)channel type:(THChannelType)type firstPacket:(THPacket *)packet +-(void)channelReady:(E3XChannel *)channel type:(E3XChannelType)type firstPacket:(THPacket *)packet { [self.tableView reloadData]; } @@ -119,7 +119,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger NSMutableArray *keys = [[thSwitch.openLines allKeys] mutableCopy]; [keys sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; NSString* key = [keys objectAtIndex:section]; - THLine* line = [thSwitch.openLines objectForKey:key]; + E3XExchange* line = [thSwitch.openLines objectForKey:key]; return line.toIdentity.channels.count; } @@ -130,10 +130,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N NSMutableArray *keys = [[thSwitch.openLines allKeys] mutableCopy]; [keys sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; NSString* key = [keys objectAtIndex:indexPath.section]; - THLine* line = [thSwitch.openLines objectForKey:key]; + E3XExchange* line = [thSwitch.openLines objectForKey:key]; keys = [[line.toIdentity.channels allKeys] mutableCopy]; [keys sortUsingSelector:@selector(compare:)]; - THChannel* channel = [line.toIdentity.channels objectForKey:[keys objectAtIndex:indexPath.row]]; + E3XChannel* channel = [line.toIdentity.channels objectForKey:[keys objectAtIndex:indexPath.row]]; cell.textLabel.text = [NSString stringWithFormat:@"Channel - %@ - %@", channel.type, channel.channelId]; return cell; } @@ -169,10 +169,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath NSMutableArray *keys = [[thSwitch.openLines allKeys] mutableCopy]; [keys sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; NSString* key = [keys objectAtIndex:indexPath.section]; - THLine* line = [thSwitch.openLines objectForKey:key]; + E3XExchange* line = [thSwitch.openLines objectForKey:key]; keys = [[line.toIdentity.channels allKeys] mutableCopy]; [keys sortUsingSelector:@selector(compare:)]; - THChannel* channel = [line.toIdentity.channels objectForKey:[keys objectAtIndex:indexPath.row]]; + E3XChannel* channel = [line.toIdentity.channels objectForKey:[keys objectAtIndex:indexPath.row]]; self.detailViewController.detailItem = line.toIdentity.activePath.information; } @@ -184,10 +184,10 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender NSMutableArray *keys = [[thSwitch.openLines allKeys] mutableCopy]; [keys sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; NSString* key = [keys objectAtIndex:indexPath.section]; - THLine* line = [thSwitch.openLines objectForKey:key]; + E3XExchange* line = [thSwitch.openLines objectForKey:key]; keys = [[line.toIdentity.channels allKeys] mutableCopy]; [keys sortUsingSelector:@selector(compare:)]; - THChannel* channel = [line.toIdentity.channels objectForKey:[keys objectAtIndex:indexPath.row]]; + E3XChannel* channel = [line.toIdentity.channels objectForKey:[keys objectAtIndex:indexPath.row]]; [[segue destinationViewController] setDetailItem:line.toIdentity.activePath.information]; } @@ -196,7 +196,7 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender -(void)doStuff { [self.tableView reloadData]; - //[thSwitch openLine:[THIdentity identityFromHashname:@"580154007d7c0c925735e62354eb54fd7f12245a1e7755905960478c537c1144"]]; + //[thSwitch openLine:[THLink identityFromHashname:@"580154007d7c0c925735e62354eb54fd7f12245a1e7755905960478c537c1144"]]; } @end diff --git a/thFieldTest/thFieldTest/seeds-real.json b/thFieldTest/thFieldTest/seeds-old.json similarity index 100% rename from thFieldTest/thFieldTest/seeds-real.json rename to thFieldTest/thFieldTest/seeds-old.json diff --git a/thFieldTest/thFieldTest/seeds.json b/thFieldTest/thFieldTest/seeds.json new file mode 100644 index 0000000..e1bf15e --- /dev/null +++ b/thFieldTest/thFieldTest/seeds.json @@ -0,0 +1,30 @@ +{ + "52f7ee68d64ab243351df4764c93910ba8da8eaea97add77a4b81df1821859da": { + "paths": [ + { + "type": "http", + "http": "http://107.170.62.175:42424" + }, + { + "type": "ipv4", + "ip": "107.170.62.175", + "port": 42424 + }, + { + "type": "ipv6", + "ip": "fe80::601:12ff:fe6b:8d01", + "port": 42424 + } + ], + "parts": { + "3a": "91159fd2f0c41978e30c33df4d56d26efe9f76181fbcc2270c6bafd73684f38f", + "2a": "0822a41c80bf03f20febd70801d1b4457d03434f156a76c3b283a1cf1e735478", + "1a": "607405b00f669acd5b4ca31f7f0b7192df47d5de0f168d0de1bf1ebb1d4e5606" + }, + "keys": { + "3a": "G/ejyu3F9LTlaPDVYdbLVfxShuFH8V0ZHpiYhh37mWg=", + "2a": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgUZDDXmoSGF3XSA52mKhc4AO0+QVvd8YGQzj5AiSPlsY14v+w4J6k1Je6I/36A2ZflEK1cYUcGw2Y70IEAmhDjSjIL4+ZynhV8rx15SbkdLTlgODRqh8N79wzXPSIGRlBG6EthZXlAa46fCls4fjGY5LzrsfPHCUa9axpdOGCY8Oui17IJ9+sv51XEVmqOBw6lejt4we14hE0+08/31QDeQzcrzGecARWBsKG7nXt8CqdnJ3D2uF5aFkhWNNM7R+AMLN9FifPYUWC4LmTWhtXawk3SE0EFjseSofXUScBEz+zEgToH79alGBYO+cytpCbSQGBP4DO+9VQR9MH93rMwIDAQAB", + "1a": "GPXvBy8AewF9RAeY7dFobJ5aYI8XZIWoUwt2j6mK/u+ihazyGrmtYw==" + } + } +} \ No newline at end of file