Compare commits

..

13 Commits

Author SHA1 Message Date
Adam Chalmers a4097ee1c6 Release 2021.5.2 2021-05-13 17:31:00 -05:00
Areg Harutyunyan 0aca9d5c23 Setup a Github action for checking the cloudflared build 2021-05-13 01:43:08 +01:00
Adam Chalmers 21efb39a9d Release 2021.5.1 2021-05-12 12:42:15 -05:00
Adam Chalmers 736a1f1b58 Release 2021.5.0 2021-05-11 19:26:05 +00:00
Nuno Diegues 1274da091a TUN-4342: Fix false positive warning about unused hostname property 2021-05-11 06:55:59 +00:00
Michael Borkenstein ea54ed62ba AUTH-3537: AUDs in JWTs are now always arrays 2021-05-10 20:37:24 +00:00
Adam Chalmers 4f362c97f6 TUN-4384: Silence log from automaxprocs 2021-05-10 13:33:47 -05:00
Adam Chalmers f5f9efa459 TUN-4359: Warn about unused keys in 'tunnel ingress validate' 2021-05-06 17:29:18 -05:00
Adam Chalmers 3dc095b4ce TUN-4357: Bump Go to 1.16 2021-05-06 20:53:32 +00:00
Adam Chalmers 76a1997b82 TUN-4356: Set AUTOMAXPROCS to the CPU limit when running in a Linux container 2021-05-06 15:08:50 -05:00
Adam Chalmers c010e10f7c TUN-4343: Fix broken build by setting debug field correctly 2021-05-03 16:46:43 -05:00
Daniel Hwang c605780c95 debug: log host / path
to help understand why the ingress rule logged is being selected.

in addition, combine "Request Headers..." and "Serving with ingress..." logs
into this updated log.

Co-authored-by: Silver <sssilver@users.noreply.github.com>
2021-05-03 15:47:42 +01:00
abelinkinbio 336dd7cd10 TUN-4000: Release notes for cloudflared replica model 2021-04-30 16:21:17 -05:00
9 changed files with 61 additions and 104 deletions
+1 -19
View File
@@ -1,24 +1,6 @@
**Experimental**: This is a new format for release notes. The format and availability is subject to change.
## 2021.5.9
### New Features
- Uses new Worker based login helper service to facilitate token exchange in cloudflared flows.
### Bug Fixes
- Fixes Centos-7 builds.
## 2021.5.8
### New Features
- When creating a DNS record to point a hostname at a tunnel, you can now use --overwrite-dns to overwrite any existing
DNS records with that hostname. This works when using the CLI to provision DNS, and when starting an adhoc tunnel, e.g.
- `cloudflared route --overwrite-dns dns foo foo.example.com`
- `cloudflared tunnel --overwrite-dns --name foo --hostname foo.example.com`
## 2021.5.7
### New Features
- Named Tunnels will automatically select the protocol to connect to Cloudflare's edge network.
## 2021.5.0
## 2020.5.0
### New Features
- It is now possible to run the same tunnel using more than one `cloudflared` instance. This is a server-side change and
+2 -21
View File
@@ -1,24 +1,5 @@
2021.5.9
- 2021-05-20 TUN-4426: Fix centos builds
- 2021-05-20 Update changelog
- 2021-04-30 AUTH-3426: Point to new transfer service URL and eliminate PUT /ok
2021.5.8
- 2021-05-14 TUN-4419: Improve error message when cloudflared cannot reach origin
- 2021-05-19 TUN-4425: --overwrite-dns flag for in adhoc and route dns cmds
2021.5.7
- 2021-05-17 Fix typo in Changes.md
- 2021-05-17 TUN-4421: Named Tunnels will automatically select the protocol to connect to Cloudflare's edge network
2021.5.6
- 2021-05-14 TUN-4418: Downgrade to Go 1.16.3
2021.5.5
2021.5.4
- Fix release pipeline
2021.5.2
- 2021-05-04 Setup a Github action for checking the cloudflared build
2021.5.1
- 2021-05-10 TUN-4342: Fix false positive warning about unused hostname property
+5 -7
View File
@@ -1,4 +1,4 @@
pinned_go: &pinned_go go=1.16.3-1
pinned_go: &pinned_go go=1.16.4-3
pinned_go_fips: &pinned_go_fips go-fips=1.15.5-3
build_dir: &build_dir /cfsetup_build
@@ -279,9 +279,8 @@ centos-7:
- https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
pre-cache:
- yum install -y fakeroot
- yum upgrade -y binutils-2.27-44.base.el7.x86_64
- wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz -P /tmp/
- tar -C /usr/local -xzf /tmp/go1.16.3.linux-amd64.tar.gz
- wget https://golang.org/dl/go1.16.4.linux-amd64.tar.gz -P /tmp/
- tar -C /usr/local -xzf /tmp/go1.16.4.linux-amd64.tar.gz
post-cache:
- export PATH=$PATH:/usr/local/go/bin
- export GOOS=linux
@@ -292,9 +291,8 @@ centos-7:
builddeps: *el7_builddeps
pre-cache:
- yum install -y fakeroot
- yum upgrade -y binutils-2.27-44.base.el7.x86_64
- wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz -P /tmp/
- tar -C /usr/local -xzf /tmp/go1.16.3.linux-amd64.tar.gz
- wget https://golang.org/dl/go1.16.4.linux-amd64.tar.gz -P /tmp/
- tar -C /usr/local -xzf /tmp/go1.16.4.linux-amd64.tar.gz
post-cache:
- export PATH=$PATH:/usr/local/go/bin
- export GOOS=linux
+3 -8
View File
@@ -87,10 +87,6 @@ const (
var (
graceShutdownC chan struct{}
version string
routeFailMsg = fmt.Sprintf("failed to provision routing, please create it manually via Cloudflare dashboard or UI; "+
"most likely you already have a conflicting record there. You can also rerun this command with --%s to overwrite "+
"any existing DNS records for this hostname.", overwriteDNSFlag)
)
func Flags() []cli.Flag {
@@ -185,7 +181,7 @@ func runAdhocNamedTunnel(sc *subcommandContext, name, credentialsOutputPath stri
if r, ok := routeFromFlag(sc.c); ok {
if res, err := sc.route(tunnel.ID, r); err != nil {
sc.log.Err(err).Str("route", r.String()).Msg(routeFailMsg)
sc.log.Err(err).Str("route", r.String()).Msg("failed to provision routing, please create it manually via Cloudflare dashboard or UI; most likely you already have a conflicting record there")
} else {
sc.log.Info().Msg(res.SuccessSummary())
}
@@ -203,12 +199,12 @@ func runClassicTunnel(sc *subcommandContext) error {
return StartServer(sc.c, version, nil, sc.log, sc.isUIEnabled)
}
func routeFromFlag(c *cli.Context) (route tunnelstore.Route, ok bool) {
func routeFromFlag(c *cli.Context) (tunnelstore.Route, bool) {
if hostname := c.String("hostname"); hostname != "" {
if lbPool := c.String("lb-pool"); lbPool != "" {
return tunnelstore.NewLBRoute(hostname, lbPool), true
}
return tunnelstore.NewDNSRoute(hostname, c.Bool(overwriteDNSFlagName)), true
return tunnelstore.NewDNSRoute(hostname), true
}
return nil, false
}
@@ -617,7 +613,6 @@ func tunnelFlags(shouldHide bool) []cli.Flag {
Hidden: shouldHide,
}),
selectProtocolFlag,
overwriteDNSFlag,
}...)
return flags
+1 -1
View File
@@ -20,7 +20,7 @@ import (
const (
baseLoginURL = "https://dash.cloudflare.com/argotunnel"
callbackStoreURL = "https://login.cloudflareaccess.org/"
callbackStoreURL = "https://login.argotunnel.com/"
)
func buildLoginSubcommand(hidden bool) *cli.Command {
+8 -16
View File
@@ -29,11 +29,10 @@ import (
)
const (
allSortByOptions = "name, id, createdAt, deletedAt, numConnections"
connsSortByOptions = "id, startedAt, numConnections, version"
CredFileFlagAlias = "cred-file"
CredFileFlag = "credentials-file"
overwriteDNSFlagName = "overwrite-dns"
allSortByOptions = "name, id, createdAt, deletedAt, numConnections"
connsSortByOptions = "id, startedAt, numConnections, version"
CredFileFlagAlias = "cred-file"
CredFileFlag = "credentials-file"
LogFieldTunnelID = "tunnelID"
)
@@ -111,7 +110,7 @@ var (
}
selectProtocolFlag = altsrc.NewStringFlag(&cli.StringFlag{
Name: "protocol",
Value: "auto",
Value: "h2mux",
Aliases: []string{"p"},
Usage: fmt.Sprintf("Protocol implementation to connect with Cloudflare's edge network. %s", connection.AvailableProtocolFlagMessage),
EnvVars: []string{"TUNNEL_TRANSPORT_PROTOCOL"},
@@ -134,12 +133,6 @@ var (
Usage: `Constraints the cleanup to stop the connections of a single Connector (by its ID). You can find the various Connectors (and their IDs) currently connected to your tunnel via 'cloudflared tunnel info <name>'.`,
EnvVars: []string{"TUNNEL_CLEANUP_CONNECTOR"},
}
overwriteDNSFlag = &cli.BoolFlag{
Name: overwriteDNSFlagName,
Aliases: []string{"f"},
Usage: `Overwrites existing DNS records with this hostname`,
EnvVars: []string{"TUNNEL_FORCE_PROVISIONING_DNS"},
}
)
func buildCreateCommand() *cli.Command {
@@ -677,11 +670,10 @@ Further information about managing Cloudflare WARP traffic to your tunnel is ava
Subcommands: []*cli.Command{
buildRouteIPSubcommand(),
},
Flags: []cli.Flag{overwriteDNSFlag},
}
}
func dnsRouteFromArg(c *cli.Context, overwriteExisting bool) (tunnelstore.Route, error) {
func dnsRouteFromArg(c *cli.Context) (tunnelstore.Route, error) {
const (
userHostnameIndex = 2
expectedNArgs = 3
@@ -695,7 +687,7 @@ func dnsRouteFromArg(c *cli.Context, overwriteExisting bool) (tunnelstore.Route,
} else if !validateHostname(userHostname, true) {
return nil, errors.Errorf("%s is not a valid hostname", userHostname)
}
return tunnelstore.NewDNSRoute(userHostname, overwriteExisting), nil
return tunnelstore.NewDNSRoute(userHostname), nil
}
func lbRouteFromArg(c *cli.Context) (tunnelstore.Route, error) {
@@ -764,7 +756,7 @@ func routeCommand(c *cli.Context) error {
if err != nil {
return err
}
route, err = dnsRouteFromArg(c, c.Bool(overwriteDNSFlagName))
route, err = dnsRouteFromArg(c)
if err != nil {
return err
}
+11 -18
View File
@@ -18,10 +18,9 @@ import (
)
const (
TagHeaderNamePrefix = "Cf-Warp-Tag-"
LogFieldCFRay = "cfRay"
LogFieldRule = "ingressRule"
LogFieldOriginService = "originService"
TagHeaderNamePrefix = "Cf-Warp-Tag-"
LogFieldCFRay = "cfRay"
LogFieldRule = "ingressRule"
)
type proxy struct {
@@ -71,7 +70,7 @@ func (p *proxy) Proxy(w connection.ResponseWriter, req *http.Request, sourceConn
rule: ingress.ServiceWarpRouting,
}
if err := p.proxyStreamRequest(serveCtx, w, req, p.warpRouting.Proxy, logFields); err != nil {
p.logRequestError(err, cfRay, "", ingress.ServiceWarpRouting)
p.logRequestError(err, cfRay, ingress.ServiceWarpRouting)
return err
}
return nil
@@ -87,8 +86,7 @@ func (p *proxy) Proxy(w connection.ResponseWriter, req *http.Request, sourceConn
if sourceConnectionType == connection.TypeHTTP {
if err := p.proxyHTTPRequest(w, req, rule, logFields); err != nil {
rule, srv := ruleField(p.ingressRules, ruleNum)
p.logRequestError(err, cfRay, rule, srv)
p.logRequestError(err, cfRay, ruleField(p.ingressRules, ruleNum))
return err
}
return nil
@@ -101,19 +99,17 @@ func (p *proxy) Proxy(w connection.ResponseWriter, req *http.Request, sourceConn
}
if err := p.proxyStreamRequest(serveCtx, w, req, connectionProxy, logFields); err != nil {
rule, srv := ruleField(p.ingressRules, ruleNum)
p.logRequestError(err, cfRay, rule, srv)
p.logRequestError(err, cfRay, ruleField(p.ingressRules, ruleNum))
return err
}
return nil
}
func ruleField(ing ingress.Ingress, ruleNum int) (ruleID string, srv string) {
srv = ing.Rules[ruleNum].Service.String()
func ruleField(ing ingress.Ingress, ruleNum int) string {
if ing.IsSingleRule() {
return "", srv
return ""
}
return fmt.Sprintf("%d", ruleNum), srv
return fmt.Sprintf("%d", ruleNum)
}
func (p *proxy) proxyHTTPRequest(w connection.ResponseWriter, req *http.Request, rule *ingress.Rule, fields logFields) error {
@@ -137,7 +133,7 @@ func (p *proxy) proxyHTTPRequest(w connection.ResponseWriter, req *http.Request,
resp, err := httpService.RoundTrip(req)
if err != nil {
return errors.Wrap(err, "Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared")
return errors.Wrap(err, "Error proxying request to origin")
}
defer resp.Body.Close()
@@ -275,7 +271,7 @@ func (p *proxy) logOriginResponse(resp *http.Response, fields logFields) {
}
}
func (p *proxy) logRequestError(err error, cfRay string, rule, service string) {
func (p *proxy) logRequestError(err error, cfRay string, rule string) {
requestErrors.Inc()
log := p.log.Error().Err(err)
if cfRay != "" {
@@ -284,9 +280,6 @@ func (p *proxy) logRequestError(err error, cfRay string, rule, service string) {
if rule != "" {
log = log.Str(LogFieldRule, rule)
}
if service != "" {
log = log.Str(LogFieldOriginService, service)
}
log.Msg("")
}
+23 -3
View File
@@ -15,7 +15,7 @@ import (
)
const (
baseStoreURL = "https://login.cloudflareaccess.org/"
baseStoreURL = "https://login.argotunnel.com/"
clientTimeout = time.Second * 60
)
@@ -83,13 +83,11 @@ func buildRequestURL(baseURL *url.URL, key, value string, cli, useHostOnly bool)
if useHostOnly {
baseURL.Path = ""
}
// TODO: pass arg for tunnel login
if !cli {
return baseURL.String(), nil
}
q.Set("redirect_url", baseURL.String()) // we add the token as a query param on both the redirect_url and the main url
q.Set("send_org_token", "true") // indicates that the cli endpoint should return both the org and app token
q.Set("edge_token_transfer", "true") // use new LoginHelper service built on workers
baseURL.RawQuery = q.Encode() // and this actual baseURL.
baseURL.Path = "cdn-cgi/access/cli"
return baseURL.String(), nil
@@ -105,6 +103,9 @@ func transferRequest(requestURL string, log *zerolog.Logger) ([]byte, string, er
if err != nil {
return nil, "", err
} else if len(buf) > 0 {
if err := putSuccess(client, requestURL); err != nil {
log.Err(err).Msg("Failed to update resource success")
}
return buf, key, nil
}
}
@@ -135,3 +136,22 @@ func poll(client *http.Client, requestURL string, log *zerolog.Logger) ([]byte,
}
return buf.Bytes(), resp.Header.Get("service-public-key"), nil
}
// putSuccess tells the server we successfully downloaded the resource
func putSuccess(client *http.Client, requestURL string) error {
req, err := http.NewRequest("PUT", requestURL+"/ok", nil)
if err != nil {
return err
}
resp, err := client.Do(req)
if err != nil {
return err
}
resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("HTTP Response Status Code: %d", resp.StatusCode)
}
return nil
}
+7 -11
View File
@@ -81,8 +81,7 @@ type RouteResult interface {
}
type DNSRoute struct {
userHostname string
overwriteExisting bool
userHostname string
}
type DNSRouteResult struct {
@@ -90,22 +89,19 @@ type DNSRouteResult struct {
CName Change `json:"cname"`
}
func NewDNSRoute(userHostname string, overwriteExisting bool) Route {
func NewDNSRoute(userHostname string) Route {
return &DNSRoute{
userHostname: userHostname,
overwriteExisting: overwriteExisting,
userHostname: userHostname,
}
}
func (dr *DNSRoute) MarshalJSON() ([]byte, error) {
s := struct {
Type string `json:"type"`
UserHostname string `json:"user_hostname"`
OverwriteExisting bool `json:"overwrite_existing"`
Type string `json:"type"`
UserHostname string `json:"user_hostname"`
}{
Type: dr.RecordType(),
UserHostname: dr.userHostname,
OverwriteExisting: dr.overwriteExisting,
Type: dr.RecordType(),
UserHostname: dr.userHostname,
}
return json.Marshal(&s)
}