Everything works fine if the interface doesn't exist.
However, I want to add / remove peers once the interface has been created. This is how I would expect to add a peer, but it doesn't work. (I figure if I leave replace peers out, it should just add a peer)
Hi there,
I don't seem to be able to modify any config.
Everything works fine if the interface doesn't exist.
However, I want to add / remove peers once the interface has been created. This is how I would expect to add a peer, but it doesn't work. (I figure if I leave replace peers out, it should just add a peer)
```javascript
import { wginterface } from "wireguard-tools.js";
const newConf: wginterface.WgConfig = {
peers: {
"QVa3K2swzHsmN3PmuoeEppv7m7J9vlXGPL5FkrAecFM=": {
keepInterval: 25,
endpoint: "x.x.x.x:51003",
allowedIPs: ["172.23.46.0/24", "10.10.9.3/32"],
}
},
};
await wginterface.setConfig("wg0", newConf);
```
```
/home/davew/netlink/node_modules/wireguard-tools.js/src/wginterface.js:47
return addon.setConfig(wgName, config);
^
Error: privateKey is empty
```
If I then add privatekey etc, it tries to add the interface again
```
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
[Error: Cannot add device, code: -17]
```
get config and set a new peer, to remove set removeMe in peer options.
import{wginterface}from"wireguard-tools.js";constconfig=awaitwginterface.getConfig("wg0")asanyasWgConfigSet;// Set new Peer from existing interface
config.peers["QVa3K2swzHsmN3PmuoeEppv7m7J9vlXGPL5FkrAecFM="]={keepInterval: 25,endpoint:"x.x.x.x:51003",allowedIPs:["172.23.46.0/24","10.10.9.3/32"]};// To remove
config.peers["QVa3K2swzHsmN3PmuoeEppv7m7J9vlXGPL5FkrAecFM="].removeMe=true;awaitwginterface.setConfig("wg0",config);
get config and set a new peer, to remove set `removeMe` in peer options.
```ts
import { wginterface } from "wireguard-tools.js";
const config = await wginterface.getConfig("wg0") as any as WgConfigSet;
// Set new Peer from existing interface
config.peers["QVa3K2swzHsmN3PmuoeEppv7m7J9vlXGPL5FkrAecFM="] = {
keepInterval: 25,
endpoint: "x.x.x.x:51003",
allowedIPs: ["172.23.46.0/24", "10.10.9.3/32"]
};
// To remove
config.peers["QVa3K2swzHsmN3PmuoeEppv7m7J9vlXGPL5FkrAecFM="].removeMe = true;
await wginterface.setConfig("wg0", config);
```
This is an addon error in which it does not find the interface and tries to create a new one, an error that went unnoticed by me
> If I then add privatekey etc, it tries to add the interface again
>
> ```
> node:internal/process/esm_loader:40
> internalBinding('errors').triggerUncaughtException(
> ^
>
> [Error: Cannot add device, code: -17]
> ```
@MorningLightMountain713 In this commit [b8b39f4a2f] i fixed this message and correctly set Wireguard configurations, the fix Will be releasing in the next tag (npm i wireguard-tools.js@next) soon
@MorningLightMountain713 In this commit [b8b39f4a2f01b3752d259a8739a22b1a47107697] i fixed this message and correctly set Wireguard configurations, the fix Will be releasing in the next tag (`npm i wireguard-tools.js@next`) soon
@MorningLightMountain713 In this commit [b8b39f4a2f] i fixed this message and correctly set Wireguard configurations, the fix Will be releasing in the next tag (npm i wireguard-tools.js@next) soon
Thats great! Thanks for the quick fix!
> @MorningLightMountain713 In this commit [b8b39f4a2f01b3752d259a8739a22b1a47107697] i fixed this message and correctly set Wireguard configurations, the fix Will be releasing in the next tag (`npm i wireguard-tools.js@next`) soon
Thats great! Thanks for the quick fix!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hi there,
I don't seem to be able to modify any config.
Everything works fine if the interface doesn't exist.
However, I want to add / remove peers once the interface has been created. This is how I would expect to add a peer, but it doesn't work. (I figure if I leave replace peers out, it should just add a peer)
If I then add privatekey etc, it tries to add the interface again
get config and set a new peer, to remove set
removeMein peer options.This is an addon error in which it does not find the interface and tries to create a new one, an error that went unnoticed by me
@MorningLightMountain713 In this commit [
b8b39f4a2f] i fixed this message and correctly set Wireguard configurations, the fix Will be releasing in the next tag (npm i wireguard-tools.js@next) soonThats great! Thanks for the quick fix!
I'm changing the wg.js compiler, so it's easy to make quick changes.
wireguard-tools.js@2.0.0is published 🎉