VPN over Shadowsocks, three providers added, still unstable (testing, not for production)
This commit is contained in:
parent
7c46e42820
commit
db527be97c
575 changed files with 991 additions and 40930 deletions
57
client/platforms/ios/sspacket.m
Normal file
57
client/platforms/ios/sspacket.m
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#import <sspacket.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
@interface SSPacket () {
|
||||
NSData *_data;
|
||||
NSNumber *_protocolFamily;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SSPacket
|
||||
|
||||
- (instancetype)initWithSSData:(NSData *)data {
|
||||
if (self = [super init]) {
|
||||
// NSUInteger prefix_size = sizeof(uint32_t);
|
||||
// uint32_t protocol = PF_UNSPEC;
|
||||
// [data getBytes:&protocol length:prefix_size];
|
||||
// protocol = CFSwapInt32HostToBig(protocol);
|
||||
//
|
||||
// NSRange range = NSMakeRange(prefix_size, data.length - prefix_size);
|
||||
// NSData *packetData = [data subdataWithRange:range];
|
||||
|
||||
// _data = packetData;
|
||||
// _protocolFamily = @(protocol);
|
||||
_data = data;
|
||||
_protocolFamily = @(PF_INET);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithPacketFlowData:(NSData *)data protocolFamily:(NSNumber *)protocolFamily {
|
||||
if (self = [super init]) {
|
||||
_data = data;
|
||||
_protocolFamily = protocolFamily;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSData *)vpnData {
|
||||
// uint32_t prefix = CFSwapInt32HostToBig(_protocolFamily.unsignedIntegerValue);
|
||||
// NSUInteger prefix_size = sizeof(uint32_t);
|
||||
// NSMutableData *data = [NSMutableData dataWithCapacity:prefix_size + _data.length];
|
||||
//
|
||||
// [data appendBytes:&prefix length:prefix_size];
|
||||
// [data appendData:_data];
|
||||
return _data;
|
||||
}
|
||||
|
||||
- (NSData *)ssPacketFlowData {
|
||||
return _data;
|
||||
}
|
||||
|
||||
- (NSNumber *)protocolFamily {
|
||||
return _protocolFamily;
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Add a link
Reference in a new issue