diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-07-05 22:48:28 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2024-01-08 00:15:09 +0100 |
commit | d48e6914c71b1f62a9b27e5a8b37963812e34615 (patch) | |
tree | 7ce1f10860e60aca46e7636df227a00bf412d8bb /tunnel/tools/libwg-go | |
parent | 159ec9b7fe452ab7ae314ec838475dfc5a74080e (diff) |
WIP: add cap to grpc
Diffstat (limited to 'tunnel/tools/libwg-go')
-rw-r--r-- | tunnel/tools/libwg-go/http-proxy.go | 19 | ||||
-rw-r--r-- | tunnel/tools/libwg-go/service.go | 26 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tunnel/tools/libwg-go/http-proxy.go b/tunnel/tools/libwg-go/http-proxy.go index 9c457286..241c7f7d 100644 --- a/tunnel/tools/libwg-go/http-proxy.go +++ b/tunnel/tools/libwg-go/http-proxy.go @@ -451,6 +451,8 @@ func (p *HttpProxy) SetPacFileUrl(pacFileUrl *url.URL) error { p.ctx.Destroy() } p.ctx = ctx + p.logger.Verbosef("SetNotMetered(false) from SetPacFileUrl") + p.SetNotMetered(false) return nil } @@ -465,6 +467,23 @@ func (p *HttpProxy) SetPacFileContent(pacFile string) error { p.ctx.Destroy() } p.ctx = ctx + p.logger.Verbosef("SetNotMetered(false) from SetPacFileContent") + p.SetNotMetered(false) + return nil +} + +func (p *HttpProxy) SetNotMetered(notMetered bool) error { + p.logger.Verbosef("SetNotMetered: %v", notMetered) + + if p.ctx == nil { + return fmt.Errorf("No ductape context") + } + + p.ctx.PushGlobalObject() + p.ctx.PushBoolean(notMetered) + p.ctx.PutPropString(-2, "notMetered") + p.ctx.Pop() + return nil } diff --git a/tunnel/tools/libwg-go/service.go b/tunnel/tools/libwg-go/service.go index f5460486..41834fe0 100644 --- a/tunnel/tools/libwg-go/service.go +++ b/tunnel/tools/libwg-go/service.go @@ -314,3 +314,29 @@ func (e *LibwgServiceImpl) Dhcp(ctx context.Context, req *gen.DhcpRequest) (*gen } return r, nil } + +func (e *LibwgServiceImpl) CapabilitiesChanged(ctx context.Context, req *gen.CapabilitiesChangedRequest) (*gen.CapabilitiesChangedResponse, error) { + if e.httpProxy == nil { + r := &gen.CapabilitiesChangedResponse{ + Error: &gen.Error{ + Message: fmt.Sprintf("Http Proxy not running"), + }, + } + return r, nil + } + + notMetered := false + + for _, cap := range req.Capabilities { + if cap == gen.CapabilitiesChangedRequest_NOT_METERED { + notMetered = true + } + } + + e.logger.Verbosef("Set not metered %v", notMetered) + e.httpProxy.SetNotMetered(notMetered) + + r := &gen.CapabilitiesChangedResponse{ + } + return r, nil +} |