diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-02-24 23:55:03 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-04-04 23:08:57 +0200 |
commit | 2b6963e2da92465d45299816e630c0e925879e53 (patch) | |
tree | 6529d014cd7f21297cb5782a4574dfe76d5ed537 /tunnel/tools/libwg-go | |
parent | 54ad806721024259a63a447141a3a95186b27690 (diff) |
tunnel: download pac in java
Diffstat (limited to 'tunnel/tools/libwg-go')
-rw-r--r-- | tunnel/tools/libwg-go/http-proxy.go | 14 | ||||
-rw-r--r-- | tunnel/tools/libwg-go/service.go | 23 |
2 files changed, 29 insertions, 8 deletions
diff --git a/tunnel/tools/libwg-go/http-proxy.go b/tunnel/tools/libwg-go/http-proxy.go index a44aaac6..9c457286 100644 --- a/tunnel/tools/libwg-go/http-proxy.go +++ b/tunnel/tools/libwg-go/http-proxy.go @@ -454,6 +454,20 @@ func (p *HttpProxy) SetPacFileUrl(pacFileUrl *url.URL) error { return nil } +func (p *HttpProxy) SetPacFileContent(pacFile string) error { + ctx := newPacBodyCtx(pacFile, p.logger) + + for _, handler := range(p.handlers) { + handler.setPacCtx(ctx) + } + + if p.ctx != nil { + p.ctx.Destroy() + } + p.ctx = ctx + return nil +} + func (p *HttpProxy) Start() (listen_port uint16, err error) { p.logger.Verbosef("HttpProxy.Start()") listen_port = 0 diff --git a/tunnel/tools/libwg-go/service.go b/tunnel/tools/libwg-go/service.go index e49081e7..f5460486 100644 --- a/tunnel/tools/libwg-go/service.go +++ b/tunnel/tools/libwg-go/service.go @@ -121,14 +121,21 @@ func (e *LibwgServiceImpl) StartHttpProxy(ctx context.Context, req *gen.StartHtt listenPort = e.httpProxy.GetAddrPort().Port() } - pacFileUrl, err := url.Parse(req.PacFileUrl) - if err != nil { - return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileUrl: %v (%s)", err, req.PacFileUrl)) - } - - err = e.httpProxy.SetPacFileUrl(pacFileUrl) - if err != nil { - return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileUrl: %v (%s)", req.PacFileUrl)) + content := req.GetPacFileContent() + if content != "" { + err := e.httpProxy.SetPacFileContent(content) + if err != nil { + return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileContent: %v (%s)", content)) + } + } else { + pacFileUrl, err := url.Parse(req.GetPacFileUrl()) + if err != nil { + return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileUrl: %v (%s)", err, req.GetPacFileUrl())) + } + err = e.httpProxy.SetPacFileUrl(pacFileUrl) + if err != nil { + return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileUrl: %v (%s)", err, pacFileUrl)) + } } r := &gen.StartHttpProxyResponse{ |