diff --git a/flower/control.go b/flower/control.go index f3716cf..01705c7 100644 --- a/flower/control.go +++ b/flower/control.go @@ -100,6 +100,7 @@ func (c *Controler) HandleNewTunnelRequest(req *msgpb.NewTunnelRequest) *msgpb.N resp.ErrCode = msgpb.ErrCodeBadRegistryAddr return resp } + c.logger.Infof("New tunnel %s registered", req.TunnelHash) c.proxies[req.TunnelHash] = proxy go func() { diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 19d01ec..ee333fe 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -68,7 +68,7 @@ func Host(req *http.Request) string { if err != nil { host = req.Host } - return host + return strings.ToLower(host) } // Taken from https://play.golang.org/p/BDt3qEQ_2H diff --git a/sun/registry/httpmux.go b/sun/registry/httpmux.go index bcb37dc..84a51ac 100644 --- a/sun/registry/httpmux.go +++ b/sun/registry/httpmux.go @@ -41,7 +41,7 @@ func NewHTTPTunnelMuxer(domain string, addr string) (*HTTPTunnelMuxer, error) { return &HTTPTunnelMuxer{ logger: log.New("mux[http]"), l: l, - domain: fmt.Sprintf(".%s", domain), + domain: fmt.Sprintf(".%s", strings.ToLower(domain)), registry: map[string]*httpConnListener{}, closed: false, }, nil @@ -99,6 +99,7 @@ func (hm *HTTPTunnelMuxer) handleConn(conn net.Conn) { } func (hm *HTTPTunnelMuxer) Listen(subdomain string) (*httpConnListener, error) { + subdomain = strings.ToLower(subdomain) hm.Lock() defer hm.Unlock() if hm.closed { diff --git a/sun/registry/registry.go b/sun/registry/registry.go index 5343dab..ca08db1 100644 --- a/sun/registry/registry.go +++ b/sun/registry/registry.go @@ -167,7 +167,6 @@ func (tr *TCPTunnelRegistry) makeTunnel(tracker *tracker.TunnelTracker, proto, s tunnel Tunnel err error ) - // TODO(damnever): check the subdomain or listen address whether is legal proto = strings.ToLower(proto) switch proto { case "http", "tcp": diff --git a/sun/web/tunnel.go b/sun/web/tunnel.go index f452326..bdeb722 100644 --- a/sun/web/tunnel.go +++ b/sun/web/tunnel.go @@ -73,7 +73,7 @@ func (s *Server) createTunnel(c echo.Context) error { serverAddr := c.FormValue("server_addr") if proto == "HTTP" { - serverAddr = fmt.Sprintf("%s.%s", serverAddr, user.targetName) + serverAddr = strings.ToLower(fmt.Sprintf("%s.%s", serverAddr, user.targetName)) } else { serverAddr = fmt.Sprintf("0.0.0.0:%s", serverAddr) if err := ValidateServerAddr(serverAddr); err != nil {