Files
Wireguard-tools.js/wg_addon/unix.go
Matheus Sampaio Queiroga 21312c7378
Some checks failed
Test / Test Linux (21.x) (pull_request) Failing after 1m58s
Test / Test Linux (latest) (pull_request) Failing after 2m1s
Test / Test Linux (18.x) (pull_request) Failing after 2m5s
Test / Test Linux (20.x) (pull_request) Failing after 2m4s
Refactor N-API addon and switch binding library
Replace the old `addon` package with `wg_addon` and switch the N-API
binding library from `abhisekp/napi-go` to
`Sirherobrine23/napi-go`.

This restructures the code to use `wgctrl` for Linux/Windows in
`wg_addon/wgctrl.go` and stubs a `wireguard-go` based implementation
for other Unix systems in `wg_addon/unix.go`. N-API registration and
common types are now in `wg_addon/addon.go`.

The implementation leverages features of the new N-API library, such as
struct tags for automatic marshalling and simplified async worker
creation.
2025-04-27 23:34:30 -03:00

32 lines
776 B
Go

//go:build unix && !linux
package wg_addon
import (
_ "golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/tun"
"sirherobrine23.com.br/Sirherobrine23/napi-go"
)
// Interface tunnels
var Tuns = map[string]*Tun{}
// Tunnel device
type Tun struct {
Tun tun.Device
Dev *device.Device
}
var GetConfig = napi.Callback(func(env napi.EnvType, this napi.ValueType, args []napi.ValueType) (napi.ValueType, error) {
return nil, nil
})
var SetConfig = napi.Callback(func(env napi.EnvType, this napi.ValueType, args []napi.ValueType) (napi.ValueType, error) {
return nil, nil
})
var DeleteInterface = napi.Callback(func(env napi.EnvType, this napi.ValueType, args []napi.ValueType) (napi.ValueType, error) {
return nil, nil
})