summaryrefslogtreecommitdiffhomepage
path: root/tunnel/tools/libwg-go
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel/tools/libwg-go')
-rw-r--r--tunnel/tools/libwg-go/http-proxy.go14
-rw-r--r--tunnel/tools/libwg-go/service.go24
2 files changed, 31 insertions, 7 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 66bdd5ef..2c688e26 100644
--- a/tunnel/tools/libwg-go/service.go
+++ b/tunnel/tools/libwg-go/service.go
@@ -5,7 +5,7 @@ import (
"fmt"
"io"
"net"
- "net/url"
+// "net/url"
"os"
"google.golang.org/grpc"
@@ -106,33 +106,43 @@ func buildStartHttpProxyError(message string) (*gen.StartHttpProxyResponse, erro
}
func (e *LibwgServiceImpl) StartHttpProxy(ctx context.Context, req *gen.StartHttpProxyRequest) (*gen.StartHttpProxyResponse, error) {
+ e.logger.Verbosef("StartHttpProxy 1")
var listenPort uint16
if e.httpProxy == nil {
+ e.logger.Verbosef("StartHttpProxy 2")
e.httpProxy = NewHttpProxy(e.uidRequest, e.logger)
+ e.logger.Verbosef("StartHttpProxy 3")
var err error
listenPort, err = e.httpProxy.Start()
+ e.logger.Verbosef("StartHttpProxy 4")
if err != nil {
e.httpProxy = nil
+ e.logger.Verbosef("StartHttpProxy 5")
return buildStartHttpProxyError(fmt.Sprintf("Http proxy start failed: %v", err))
}
} else {
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))
- }
+ e.logger.Verbosef("StartHttpProxy 6")
+ // pacFileUrl, err := url.Parse(req.PacFileUrl)
+ // if err != nil {
+ // e.logger.Verbosef("StartHttpProxy 7")
+ // return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileUrl: %v (%s)", err, req.PacFileUrl))
+ // }
- err = e.httpProxy.SetPacFileUrl(pacFileUrl)
+ e.logger.Verbosef("StartHttpProxy 8")
+ err := e.httpProxy.SetPacFileContent(req.GetPacFileContent())
if err != nil {
- return buildStartHttpProxyError(fmt.Sprintf("Bad pacFileUrl: %v (%s)", req.PacFileUrl))
+ e.logger.Verbosef("StartHttpProxy 9")
+ return buildStartHttpProxyError(fmt.Sprintf("Bad pacFile: %v (%s)", req.GetPacFileContent()))
}
r := &gen.StartHttpProxyResponse{
ListenPort: uint32(listenPort),
}
+ e.logger.Verbosef("StartHttpProxy 10")
return r, nil
}