diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-05-24 22:48:37 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2024-01-08 00:14:45 +0100 |
commit | e786b19646cc8ffd2c83db8cdb9457610d614ebd (patch) | |
tree | 6968b2455c699f7281f1356aa4c2165f23b7574a /tunnel/tools/libwg-go/service.go | |
parent | 7de29045e927369b6071bd6103ea46da665ffacb (diff) |
tunnel: implement gRPC based wgSetConfig
Diffstat (limited to 'tunnel/tools/libwg-go/service.go')
-rw-r--r-- | tunnel/tools/libwg-go/service.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tunnel/tools/libwg-go/service.go b/tunnel/tools/libwg-go/service.go index 30fe650b..f5460486 100644 --- a/tunnel/tools/libwg-go/service.go +++ b/tunnel/tools/libwg-go/service.go @@ -226,6 +226,33 @@ func (e *LibwgServiceImpl) Reverse(stream gen.Libwg_ReverseServer) error { return nil } +func (e *LibwgServiceImpl) IpcSet(ctx context.Context, req *gen.IpcSetRequest) (*gen.IpcSetResponse, error) { + tunnel, ok := GetTunnel(req.GetTunnel().GetHandle()) + if !ok { + r := &gen.IpcSetResponse{ + Error: &gen.Error{ + Message: fmt.Sprintf("Invalid tunnel"), + }, + } + return r, nil + } + + err := tunnel.device.IpcSet(req.GetConfig()) + if err != nil { + r := &gen.IpcSetResponse{ + Error: &gen.Error{ + Message: fmt.Sprintf("IpcSet failed: %v", err), + }, + } + return r, nil + } + + r := &gen.IpcSetResponse{ + } + + return r, nil +} + func (e *LibwgServiceImpl) Dhcp(ctx context.Context, req *gen.DhcpRequest) (*gen.DhcpResponse, error) { var relayAddr netip.Addr var sourceAddr netip.Addr |