Remove duplicated regex and unused function

This commit is contained in:
Marcos Lilljedahl
2017-05-15 14:30:42 -03:00
parent aa02432c56
commit a6c19e451f
5 changed files with 36 additions and 51 deletions

View File

@@ -36,15 +36,13 @@ func getTargetInfo(vars map[string]string, req *http.Request) (string, string) {
}
}
if strings.HasPrefix(node, "pwd") {
// Node is actually an ip, need to convert underscores by dots.
ip := strings.Replace(strings.TrimPrefix(node, "pwd"), "-", ".", -1)
// Node is actually an ip, need to convert underscores by dots.
ip := strings.Replace(node, "-", ".", -1)
if net.ParseIP(ip) == nil {
// Not a valid IP, so treat this is a hostname.
} else {
node = ip
}
if net.ParseIP(ip) == nil {
// Not a valid IP, so treat this is a hostname.
} else {
node = ip
}
return node, port
@@ -136,28 +134,3 @@ func NewTCPProxy() http.Handler {
}
return &tcpProxy{Director: director}
}
func NewSSLDaemonHandler() http.Handler {
director := func(req *http.Request) {
v := mux.Vars(req)
node := v["node"]
if strings.HasPrefix(node, "pwd") {
// Node is actually an ip, need to convert underscores by dots.
ip := strings.Replace(strings.TrimPrefix(node, "pwd"), "-", ".", -1)
if net.ParseIP(ip) == nil {
// Not a valid IP, so treat this is a hostname.
} else {
node = ip
}
}
// Only proxy http for now
req.URL.Scheme = "http"
req.URL.Host = fmt.Sprintf("%s:%s", node, "2375")
log.Printf("HTTPS Reverse proxying to %s\n", req.URL.Host)
}
return &tcpProxy{Director: director}
}