aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen Leenarts <jeroen.leenarts@gmail.com>2018-08-12 21:40:44 +0200
committerJeroen Leenarts <jeroen.leenarts@gmail.com>2018-08-12 21:40:44 +0200
commitf6fc8cd9bd5977251b4660ac8a19716dd3e67993 (patch)
tree9a71d79320326736ab41f8138ee9f249d7a41957
parentDo not read from packetFlow when tunnel is not yet fully initialized and configured. (diff)
downloadwireguard-apple-f6fc8cd9bd5977251b4660ac8a19716dd3e67993.tar.xz
wireguard-apple-f6fc8cd9bd5977251b4660ac8a19716dd3e67993.zip
Universal logging.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--WireGuardNetworkExtension/WireGuardGoWrapper.m8
1 files changed, 7 insertions, 1 deletions
diff --git a/WireGuardNetworkExtension/WireGuardGoWrapper.m b/WireGuardNetworkExtension/WireGuardGoWrapper.m
index 2d6056d..8deb527 100644
--- a/WireGuardNetworkExtension/WireGuardGoWrapper.m
+++ b/WireGuardNetworkExtension/WireGuardGoWrapper.m
@@ -84,6 +84,7 @@ static void do_log(int level, const char *tag, const char *msg);
static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
{
+// os_log_debug([WireGuardGoWrapper log], "do_read - start - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
WireGuardGoWrapper *wrapper = (__bridge WireGuardGoWrapper *)ctx;
if (wrapper.isClosed) return -1;
@@ -99,9 +100,11 @@ static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
[wrapper.packetFlow readPacketsWithCompletionHandler:^(NSArray<NSData *> * _Nonnull packets, NSArray<NSNumber *> * _Nonnull protocols) {
[wrapper.packets addObjectsFromArray:packets];
[wrapper.protocols addObjectsFromArray:protocols];
+ os_log_debug([WireGuardGoWrapper log], "do_read - signal - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
[wrapper.condition signal];
}];
});
+ os_log_debug([WireGuardGoWrapper log], "do_read - wait - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
[wrapper.condition wait];
}
@@ -113,15 +116,18 @@ static ssize_t do_read(const void *ctx, const unsigned char *buf, size_t len)
NSUInteger packetLength = [packet length];
if (packetLength > len) {
// The packet will be dropped when we end up here.
+ os_log_debug([WireGuardGoWrapper log], "do_read - drop - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
return 0;
}
memcpy(buf, [packet bytes], packetLength);
-
+ os_log_debug([WireGuardGoWrapper log], "do_read - packet - on thread \"%{public}@\" - %d", NSThread.currentThread.name, (int)NSThread.currentThread);
return packetLength;
}
static ssize_t do_write(const void *ctx, const unsigned char *buf, size_t len)
{
+ os_log_debug([WireGuardGoWrapper log], "do_write - start");
+
WireGuardGoWrapper *wrapper = (__bridge WireGuardGoWrapper *)ctx;
//TODO: determine IPv4 or IPv6 status.
NSData *packet = [[NSData alloc] initWithBytes:buf length:len];