TUN-3400: Use Go HTTP2 library as transport to connect with the edge

This commit is contained in:
cthuang
2020-09-11 23:02:34 +01:00
parent d7498b0c03
commit 8d7b2575ba
7 changed files with 324 additions and 37 deletions

View File

@@ -18,7 +18,10 @@ const (
OriginCAPoolFlag = "origin-ca-pool"
CaCertFlag = "cacert"
edgeTLSServerName = "cftunnel.com"
// edgeH2muxTLSServerName is the server name to establish h2mux connection with edge
edgeH2muxTLSServerName = "cftunnel.com"
// edgeH2TLSServerName is the server name to establish http2 connection with edge
edgeH2TLSServerName = "h2.cftunnel.com"
)
// CertReloader can load and reload a TLS certificate from a particular filepath.
@@ -120,13 +123,17 @@ func LoadCustomOriginCA(originCAFilename string) (*x509.CertPool, error) {
return certPool, nil
}
func CreateTunnelConfig(c *cli.Context) (*tls.Config, error) {
func CreateTunnelConfig(c *cli.Context, isNamedTunnel bool) (*tls.Config, error) {
var rootCAs []string
if c.String(CaCertFlag) != "" {
rootCAs = append(rootCAs, c.String(CaCertFlag))
}
userConfig := &TLSParameters{RootCAs: rootCAs, ServerName: edgeTLSServerName}
serverName := edgeH2muxTLSServerName
if isNamedTunnel {
serverName = edgeH2TLSServerName
}
userConfig := &TLSParameters{RootCAs: rootCAs, ServerName: serverName}
tlsConfig, err := GetConfig(userConfig)
if err != nil {
return nil, err