Compile issue @2.0.0 #8

Closed
opened 2024-02-20 19:20:40 +00:00 by MorningLightMountain713 · 6 comments
davew@chud:~/netlink$ npm list
netlink@ /home/davew/netlink
└── wireguard-tools.js@2.0.0

davew@chud:~/netlink$ uname -a
Linux chud 5.15.0-94-generic #104-Ubuntu SMP Tue Jan 9 15:25:40 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

If I run the following code, it can't find the lib:

import { wginterface } from "wireguard-tools.js";

const conf = await wginterface.getConfig("wg0");
davew@chud:~/netlink$ npx tsx set.ts
file:///home/davew/netlink/node_modules/rebory/src/index.js:544
                    process["dlopen"](mod, release);
                                     ^

Error: /lib/x86_64-linux-gnu/libc.so: invalid ELF header
    at Object.loadRelease (file:///home/davew/netlink/node_modules/rebory/src/index.js:544:38)
    at file:///home/davew/netlink/node_modules/wireguard-tools.js/src/wginterface.js:9:85 {
  code: 'ERR_DLOPEN_FAILED'
}

Here is libc.so:

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a  AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )

if I rename libc.so and link in libc.so.6 - it will then work again.

However, I still get the same issue when trying to add a peer. (maybe that's related to the above?)

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

[Error: File exists, code: -17]

Node.js v20.9.0

Thanks,

David

``` davew@chud:~/netlink$ npm list netlink@ /home/davew/netlink └── wireguard-tools.js@2.0.0 davew@chud:~/netlink$ uname -a Linux chud 5.15.0-94-generic #104-Ubuntu SMP Tue Jan 9 15:25:40 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux ``` If I run the following code, it can't find the lib: ```javascript import { wginterface } from "wireguard-tools.js"; const conf = await wginterface.getConfig("wg0"); ``` ```bash davew@chud:~/netlink$ npx tsx set.ts file:///home/davew/netlink/node_modules/rebory/src/index.js:544 process["dlopen"](mod, release); ^ Error: /lib/x86_64-linux-gnu/libc.so: invalid ELF header at Object.loadRelease (file:///home/davew/netlink/node_modules/rebory/src/index.js:544:38) at file:///home/davew/netlink/node_modules/wireguard-tools.js/src/wginterface.js:9:85 { code: 'ERR_DLOPEN_FAILED' } ``` Here is `libc.so`: ```bash /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf64-x86-64) GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) ) ``` if I rename `libc.so` and link in `libc.so.6` - it will then work again. However, I still get the same issue when trying to add a peer. (maybe that's related to the above?) ```bash node:internal/process/esm_loader:40 internalBinding('errors').triggerUncaughtException( ^ [Error: File exists, code: -17] Node.js v20.9.0 ``` Thanks, David

Edit node_modules/wireguard-tools.js/addons/tools/wginterface-linux.cpp in the line 332, change to:

if (res != -EEXIST) SetError(getKernelMesage(res));

remove addon prebuilds and run prebuild

rm -rfv node_modules/wireguard-tools.js/build
./node_modules/.bin/rebory build -w node_modules/wireguard-tools.js

if I rename libc.so and link in libc.so.6 - it will then work again.

I'm using zig to make the pre-compiled binaries, I only have Respeberry Pi with actions runner.

Edit `node_modules/wireguard-tools.js/addons/tools/wginterface-linux.cpp` in the line 332, change to: ```cpp if (res != -EEXIST) SetError(getKernelMesage(res)); ``` remove addon prebuilds and run `prebuild` ```sh rm -rfv node_modules/wireguard-tools.js/build ./node_modules/.bin/rebory build -w node_modules/wireguard-tools.js ``` > if I rename libc.so and link in libc.so.6 - it will then work again. I'm using `zig` to make the pre-compiled binaries, I only have Respeberry Pi with actions runner.

I make test to wginterface.ts and get this error, sorry not have test to wireguard interface, now have in set in CI/CD test this

image

I make test to `wginterface.ts` and get this error, sorry not have test to wireguard interface, now have in set in CI/CD test this ![image](/attachments/c409aac9-31a2-4b40-942c-c61d30f9784c)

Test this pkg, i build this addon in my wsl

Test

Test this pkg, i build this addon in my wsl ![Test](/attachments/06127ace-908d-4c47-a3a5-875b7a95f229)

@MorningLightMountain713 waiting for u response

@MorningLightMountain713 waiting for u response

@MorningLightMountain713 waiting for u response

That all works now... can remove / add peers 👍

> @MorningLightMountain713 waiting for u response That all works now... can remove / add peers 👍

Thanks, release 2.0.1

Thanks, release 2.0.1
Sign in to join this conversation.
No description provided.