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.
32 lines
776 B
Go
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
|
|
}) |