wireguard-go-bridge: use C string instead of gostring_t
Signed-off-by: Andrej Mihajlov <and@mullvad.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
edde27a0a0
commit
30406dec6d
@@ -84,7 +84,7 @@ func wgSetLogger(loggerFn uintptr) {
|
||||
}
|
||||
|
||||
//export wgTurnOn
|
||||
func wgTurnOn(settings string, tunFd int32) int32 {
|
||||
func wgTurnOn(settings *C.char, tunFd int32) int32 {
|
||||
logger := &device.Logger{
|
||||
Debug: log.New(&CLogger{level: 0}, "", 0),
|
||||
Info: log.New(&CLogger{level: 1}, "", 0),
|
||||
@@ -104,7 +104,7 @@ func wgTurnOn(settings string, tunFd int32) int32 {
|
||||
logger.Info.Println("Attaching to interface")
|
||||
device := device.NewDevice(tun, logger)
|
||||
|
||||
setError := device.IpcSetOperation(bufio.NewReader(strings.NewReader(settings)))
|
||||
setError := device.IpcSetOperation(bufio.NewReader(strings.NewReader(C.GoString(settings))))
|
||||
if setError != nil {
|
||||
logger.Error.Println(setError)
|
||||
return -1
|
||||
@@ -137,12 +137,12 @@ func wgTurnOff(tunnelHandle int32) {
|
||||
}
|
||||
|
||||
//export wgSetConfig
|
||||
func wgSetConfig(tunnelHandle int32, settings string) int64 {
|
||||
func wgSetConfig(tunnelHandle int32, settings *C.char) int64 {
|
||||
device, ok := tunnelHandles[tunnelHandle]
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
err := device.IpcSetOperation(bufio.NewReader(strings.NewReader(settings)))
|
||||
err := device.IpcSetOperation(bufio.NewReader(strings.NewReader(C.GoString(settings))))
|
||||
if err != nil {
|
||||
device.Error.Println(err)
|
||||
return err.ErrorCode()
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct { const char *p; size_t n; } gostring_t;
|
||||
typedef void(*logger_fn_t)(int level, const char *msg);
|
||||
extern void wgEnableRoaming(bool enabled);
|
||||
extern void wgSetLogger(logger_fn_t logger_fn);
|
||||
extern int wgTurnOn(gostring_t settings, int32_t tun_fd);
|
||||
extern int wgTurnOn(const char *settings, int32_t tun_fd);
|
||||
extern void wgTurnOff(int handle);
|
||||
extern int64_t wgSetConfig(int handle, gostring_t settings);
|
||||
extern int64_t wgSetConfig(int handle, const char *settings);
|
||||
extern char *wgGetConfig(int handle);
|
||||
extern void wgBumpSockets(int handle);
|
||||
extern const char *wgVersion();
|
||||
|
||||
Reference in New Issue
Block a user