add support for TCP routes (#1695)

This commit is contained in:
Caleb Doxsey 2020-12-16 13:09:48 -07:00 committed by GitHub
parent 64816720c8
commit ad828c6e84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 13 deletions

View file

@ -84,6 +84,10 @@ func GetAbsoluteURL(r *http.Request) *url.URL {
// For standard HTTP (80)/HTTPS (443) ports, it returns `example.com` and `example.com:<port>`.
// Otherwise, return the URL.Host value.
func GetDomainsForURL(u *url.URL) []string {
if IsTCP(u) {
return []string{u.Host}
}
var defaultPort string
if u.Scheme == "http" {
defaultPort = "80"
@ -102,6 +106,11 @@ func GetDomainsForURL(u *url.URL) []string {
return []string{u.Hostname(), net.JoinHostPort(u.Hostname(), defaultPort)}
}
// IsTCP returns whether or not the given URL is for TCP via HTTP Connect.
func IsTCP(u *url.URL) bool {
return u.Scheme == "tcp+http" || u.Scheme == "tcp+https"
}
// ParseEnvoyQueryParams returns a new URL with queryparams parsed from envoy format.
func ParseEnvoyQueryParams(u *url.URL) *url.URL {
nu := &url.URL{