diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-12 18:04:36 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-12 18:08:38 +0100 |
commit | 8523979c9c2540b3d1db544674731ccc624f6f96 (patch) | |
tree | 5081bf00f4d8fa2a7a4006378bbb73b51c1ec232 /tunnel/tools/libwg-go/api-android.go | |
parent | 8768acee68be592c1823bb5dfe316ca3e730b31c (diff) |
tunnel: report git commit as wgVersion
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel/tools/libwg-go/api-android.go')
-rw-r--r-- | tunnel/tools/libwg-go/api-android.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tunnel/tools/libwg-go/api-android.go b/tunnel/tools/libwg-go/api-android.go index 5fce4705..5e85d086 100644 --- a/tunnel/tools/libwg-go/api-android.go +++ b/tunnel/tools/libwg-go/api-android.go @@ -16,6 +16,8 @@ import ( "os" "os/signal" "runtime" + "runtime/debug" + "strings" "unsafe" "golang.org/x/sys/unix" @@ -206,7 +208,20 @@ func wgGetConfig(tunnelHandle int32) *C.char { //export wgVersion func wgVersion() *C.char { - return C.CString(device.WireGuardGoVersion) + info, ok := debug.ReadBuildInfo() + if !ok { + return C.CString("unknown") + } + for _, dep := range info.Deps { + if dep.Path == "golang.zx2c4.com/wireguard" { + parts := strings.Split(dep.Version, "-") + if len(parts) == 3 && len(parts[2]) == 12 { + return C.CString(parts[2][:7]) + } + return C.CString(dep.Version) + } + } + return C.CString("unknown") } func main() {} |