mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-06 00:00:03 +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
|
#if TARGET_OS_IPHONE
|
||||||
// Prepend data with network protocol. It should be done because OpenVPN on iOS uses uint32_t prefixes containing network protocol.
|
// 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([self getProtocolVersion:[protocols[idx] unsignedCharValue]]);
|
||||||
uint32_t prefix = CFSwapInt32HostToBig((uint32_t)[protocol unsignedIntegerValue]);
|
|
||||||
|
|
||||||
[packet appendBytes:&prefix length:sizeof(prefix)];
|
[packet appendBytes:&prefix length:sizeof(prefix)];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -695,6 +693,14 @@ static void socketCallback(CFSocketRef socket, CFSocketCallBackType type, CFData
|
|||||||
default: return PF_UNSPEC;
|
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 {
|
- (void)performAsyncBlock:(void (^)())block {
|
||||||
dispatch_queue_t mainQueue = dispatch_get_main_queue();
|
dispatch_queue_t mainQueue = dispatch_get_main_queue();
|
||||||
|
|||||||
Reference in New Issue
Block a user