summaryrefslogtreecommitdiffhomepage
path: root/tunnel/tools
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2023-02-24 23:55:03 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2023-10-24 21:57:35 +0200
commit76872f3534e9c5e729b25ffecf90baf8b66fbdf1 (patch)
tree6e6121e84568034c480f3ef2fc5c7e78c6ed6061 /tunnel/tools
parent2f0bbeb4e736cb7d63589c7a961d8fe788c9c7e1 (diff)
tunnel: download pac in java
Diffstat (limited to 'tunnel/tools')
-rw-r--r--tunnel/tools/libwg-go/http-proxy.go14
-rw-r--r--tunnel/tools/libwg-go/service.go23
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 c73e1edf..9c5a1036 100644
--- a/tunnel/tools/libwg-go/http-proxy.go
+++ b/tunnel/tools/libwg-go/http-proxy.go
@@ -445,6 +445,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 37fb4b40..72916a8e 100644
--- a/tunnel/tools/libwg-go/service.go
+++ b/tunnel/tools/libwg-go/service.go
@@ -120,14 +120,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{