mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-02-11 00:00:08 +08:00
Fix incorrect protocol versions for outgoing packets
This commit is contained in:
@@ -565,9 +565,7 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
// Prepend data with network protocol. It should be done because OpenVPN on iOS uses uint32_t prefixes containing network protocol.
|
||||
NSNumber *protocol = protocols[idx];
|
||||
uint32_t prefix = CFSwapInt32HostToBig((uint32_t)[protocol unsignedIntegerValue]);
|
||||
|
||||
uint32_t prefix = CFSwapInt32HostToBig([self getProtocolVersion:[protocols[idx] unsignedCharValue]]);
|
||||
[packet appendBytes:&prefix length:sizeof(prefix)];
|
||||
#endif
|
||||
|
||||
@@ -695,6 +693,14 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
|
||||
default: return PF_UNSPEC;
|
||||
}
|
||||
}
|
||||
|
||||
- (uint32_t)getProtocolVersion:(uint8_t)family {
|
||||
switch (family) {
|
||||
case PF_INET: return 4;
|
||||
case PF_INET6: return 6;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)performAsyncBlock:(void (^)())block {
|
||||
dispatch_queue_t mainQueue = dispatch_get_main_queue();
|
||||
|
||||
Reference in New Issue
Block a user