Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Commit

Permalink
Fix upper case domain
Browse files Browse the repository at this point in the history
  • Loading branch information
damnever committed Nov 3, 2017
1 parent a4b68ab commit 574fff1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions flower/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion sun/registry/httpmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion sun/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion sun/web/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 574fff1

Please sign in to comment.