aboutsummaryrefslogtreecommitdiffstats
path: root/wireguard-go-bridge
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-31 03:13:00 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-31 03:22:22 +0100
commit2a9c7e47451fbc4e4bba827f069fa410ef178136 (patch)
tree8132216c6962c6afea4f62adf036f852c49a11fa /wireguard-go-bridge
parentNetworkExtension: close context before turning off go (diff)
downloadwireguard-apple-2a9c7e47451fbc4e4bba827f069fa410ef178136.tar.xz
wireguard-apple-2a9c7e47451fbc4e4bba827f069fa410ef178136.zip
wireguard-go-bridge: simplify logging and remove tags
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'wireguard-go-bridge')
-rw-r--r--wireguard-go-bridge/example.c4
-rw-r--r--wireguard-go-bridge/src/api-ios.go14
-rw-r--r--wireguard-go-bridge/wireguard.h2
3 files changed, 8 insertions, 12 deletions
diff --git a/wireguard-go-bridge/example.c b/wireguard-go-bridge/example.c
index 33ed1f08..7ba0c42e 100644
--- a/wireguard-go-bridge/example.c
+++ b/wireguard-go-bridge/example.c
@@ -27,9 +27,9 @@ ssize_t do_write(void *ctx, unsigned char *buf, size_t len)
return len;
}
-void do_log(int level, const char *tag, const char *msg)
+void do_log(int level, const char *msg)
{
- printf("Log level %d for %s: %s", level, tag, msg);
+ printf("Log level %d: %s", level, msg);
}
int main(int argc, char *argv[])
diff --git a/wireguard-go-bridge/src/api-ios.go b/wireguard-go-bridge/src/api-ios.go
index 7bb648e5..07dd45a5 100644
--- a/wireguard-go-bridge/src/api-ios.go
+++ b/wireguard-go-bridge/src/api-ios.go
@@ -7,9 +7,9 @@ package main
// #include <stdlib.h>
// #include <sys/types.h>
-// static void callLogger(void *func, int level, const char *tag, const char *msg)
+// static void callLogger(void *func, int level, const char *msg)
// {
-// ((void(*)(int, const char *, const char *))func)(level, tag, msg);
+// ((void(*)(int, const char *))func)(level, msg);
// }
import "C"
@@ -40,10 +40,8 @@ func (l *CLogger) Write(p []byte) (int, error) {
if uintptr(loggerFunc) == 0 {
return 0, errors.New("No logger initialized")
}
- tag := C.CString("WireGuard/GoBackend/"+l.interfaceName)
- message := C.CString(string(p))
- C.callLogger(loggerFunc, l.level, tag, message)
- C.free(unsafe.Pointer(tag))
+ message := C.CString(l.interfaceName + ": " + string(p))
+ C.callLogger(loggerFunc, l.level, message)
C.free(unsafe.Pointer(message))
return len(p), nil
}
@@ -64,9 +62,7 @@ func init() {
n := runtime.Stack(buf, true)
buf[n] = 0
if uintptr(loggerFunc) != 0 {
- tag := C.CString("WireGuard/GoBackend/Stacktrace")
- C.callLogger(loggerFunc, 0, tag, (*_Ctype_char)(unsafe.Pointer(&buf[0])))
- C.free(unsafe.Pointer(tag))
+ C.callLogger(loggerFunc, 0, (*_Ctype_char)(unsafe.Pointer(&buf[0])))
}
}
}
diff --git a/wireguard-go-bridge/wireguard.h b/wireguard-go-bridge/wireguard.h
index a0950bf9..8517bcee 100644
--- a/wireguard-go-bridge/wireguard.h
+++ b/wireguard-go-bridge/wireguard.h
@@ -11,7 +11,7 @@
typedef struct { const char *p; size_t n; } gostring_t;
typedef ssize_t(*read_write_fn_t)(void *ctx, unsigned char *buf, size_t len);
-typedef void(*logger_fn_t)(int level, const char *tag, const char *msg);
+typedef void(*logger_fn_t)(int level, const char *msg);
extern void wgSetLogger(logger_fn_t logger_fn);
extern int wgTurnOn(gostring_t ifname, gostring_t settings, uint16_t mtu, read_write_fn_t read_fn, read_write_fn_t write_fn, void *ctx);
extern void wgTurnOff(int handle);