update code
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
This commit is contained in:
@ -2,13 +2,11 @@ module sirherobrine23.org/Wireguard/wireguard-tools.js/wg-tun
|
||||
|
||||
go 1.21.6
|
||||
|
||||
require (
|
||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
||||
)
|
||||
require golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
||||
|
||||
require (
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/crypto v0.13.0 // indirect
|
||||
golang.org/x/net v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||
)
|
||||
|
@ -2,10 +2,16 @@ github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
|
||||
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
|
||||
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
|
||||
|
@ -6,18 +6,30 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"syscall"
|
||||
_ "unsafe"
|
||||
|
||||
"golang.zx2c4.com/wireguard/conn"
|
||||
"golang.zx2c4.com/wireguard/device"
|
||||
"golang.zx2c4.com/wireguard/ipc"
|
||||
"golang.zx2c4.com/wireguard/tun"
|
||||
|
||||
)
|
||||
|
||||
const levelLog = device.LogLevelError
|
||||
|
||||
//go:linkname socketDirectory golang.xz2c4.com/wireguard/ipc.socketDirectory
|
||||
var socketDirectory = "/var/run/wireguard"
|
||||
|
||||
func init() {
|
||||
if runtime.GOOS == "windows" {
|
||||
socketDirectory = `\\.\pipe\ProtectedPrefix\Administrators\WireGuard`
|
||||
}
|
||||
}
|
||||
|
||||
// End process function callbacks
|
||||
var TunsEndProcess = make(map[string]func())
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
//go:build linux || darwin || freebsd || openbsd
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "golang.zx2c4.com/wireguard/ipc"
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
//go:linkname socketDirectory golang.xz2c4.com/wireguard/ipc.socketDirectory
|
||||
var socketDirectory = "/var/run/wireguard"
|
@ -1,5 +0,0 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
var socketDirectory = `\\.\pipe\ProtectedPrefix\Administrators\WireGuard`
|
@ -12,6 +12,9 @@ sources:
|
||||
prebuild:
|
||||
- shell: bash
|
||||
cwd: ./addon/userspace/go
|
||||
ifOs:
|
||||
- "!win32"
|
||||
- "!linux"
|
||||
env:
|
||||
CGO_ENABLED: "1"
|
||||
LDFLAGS: "-w"
|
||||
@ -31,7 +34,7 @@ target:
|
||||
- "-w"
|
||||
- "-fpermissive"
|
||||
- "-fPIC"
|
||||
windows:
|
||||
win32:
|
||||
sources:
|
||||
- "!addon/userspace/wginterface.cpp"
|
||||
- "addon/win/wginterface.cpp"
|
||||
@ -47,7 +50,7 @@ target:
|
||||
defines:
|
||||
- "_HAS_EXCEPTIONS=1"
|
||||
- "ONSTARTADDON"
|
||||
macos:
|
||||
darwin:
|
||||
flags:
|
||||
- "!-fno-exceptions"
|
||||
- "-fpermissive"
|
||||
|
@ -46,6 +46,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"node-addon-api": "^8.0.0",
|
||||
"rebory": "^0.2.5"
|
||||
"rebory": "^0.2.10"
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { isIP } from "net";
|
||||
import { format } from "util";
|
||||
import { Peer, WgConfigBase } from "./wginterface.js";
|
||||
import { SetConfig } from "./wginterface.js";
|
||||
|
||||
export interface QuickConfig extends WgConfigBase<Peer>, Partial<Record<`${"Post" | "Pre"}${"Up" | "Down"}`, string[]>> {
|
||||
export interface QuickConfig extends SetConfig, Partial<Record<`${"Post" | "Pre"}${"Up" | "Down"}`, string[]>> {
|
||||
DNS?: string[];
|
||||
Table?: number;
|
||||
MTU?: number;
|
||||
@ -92,7 +92,7 @@ export function stringify(wgConfig: QuickConfig): string {
|
||||
const peerConfig = wgConfig.peers[pubKey];
|
||||
configStr.push("", "[Peer]", format("PublicKey = %s", pubKey));
|
||||
if (peerConfig.presharedKey) configStr.push(format("PresharedKey = %s", peerConfig.presharedKey));
|
||||
if (peerConfig.keepInterval > 0) configStr.push(format("PersistentKeepalive = %n", peerConfig.keepInterval));
|
||||
if (peerConfig.keepInterval > 0) configStr.push(format("PersistentKeepalive = %d", peerConfig.keepInterval));
|
||||
if (peerConfig.endpoint) configStr.push(format("Endpoint = %s", peerConfig.endpoint));
|
||||
if (peerConfig.allowedIPs) configStr.push(format("AllowedIPs = %s", peerConfig.allowedIPs.join(", ")));
|
||||
}
|
||||
|
Reference in New Issue
Block a user