From 9bbeed77070467ddd7e55966154e03b1e89eb6d8 Mon Sep 17 00:00:00 2001 From: cloudflare-warp-bot Date: Fri, 6 Apr 2018 22:47:13 +0000 Subject: [PATCH] Release Argo Tunnel Client 2018.4.4 --- cmd/cloudflared/main.go | 12 ++++++++---- h2mux/bytes_counter.go | 4 ++++ h2mux/h2mux.go | 4 ++++ h2mux/muxreader.go | 2 +- h2mux/muxwriter.go | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/cloudflared/main.go b/cmd/cloudflared/main.go index 24c8dc5f..6d93fdc8 100644 --- a/cmd/cloudflared/main.go +++ b/cmd/cloudflared/main.go @@ -275,7 +275,7 @@ func main() { Usage: "Run a DNS over HTTPS proxy server.", EnvVars: []string{"TUNNEL_DNS"}, }), - altsrc.NewUintFlag(&cli.UintFlag{ + altsrc.NewIntFlag(&cli.IntFlag{ Name: "proxy-dns-port", Value: 53, Usage: "Listen on given port for the DNS over HTTPS proxy server.", @@ -290,7 +290,7 @@ func main() { altsrc.NewStringSliceFlag(&cli.StringSliceFlag{ Name: "proxy-dns-upstream", Usage: "Upstream endpoint URL, you can specify multiple endpoints for redundancy.", - Value: cli.NewStringSlice("https://cloudflare-dns.com/dns-query"), + Value: cli.NewStringSlice("https://1.1.1.1/dns-query", "https://1.0.0.1/dns-query"), EnvVars: []string{"TUNNEL_DNS_UPSTREAM"}, }), altsrc.NewDurationFlag(&cli.DurationFlag{ @@ -384,7 +384,7 @@ func main() { &cli.StringSliceFlag{ Name: "upstream", Usage: "Upstream endpoint URL, you can specify multiple endpoints for redundancy.", - Value: cli.NewStringSlice("https://cloudflare-dns.com/dns-query"), + Value: cli.NewStringSlice("https://1.1.1.1/dns-query", "https://1.0.0.1/dns-query"), EnvVars: []string{"TUNNEL_DNS_UPSTREAM"}, }, }, @@ -428,8 +428,12 @@ func startServer(c *cli.Context) { } if c.IsSet("proxy-dns") { + port := c.Int("proxy-dns-port") + if port <= 0 || port > 65535 { + Log.Fatal("The 'proxy-dns-port' must be a valid port number in <1, 65535> range.") + } wg.Add(1) - listener, err := tunneldns.CreateListener(c.String("proxy-dns-address"), uint16(c.Uint("proxy-dns-port")), c.StringSlice("proxy-dns-upstream")) + listener, err := tunneldns.CreateListener(c.String("proxy-dns-address"), uint16(port), c.StringSlice("proxy-dns-upstream")) if err != nil { close(dnsReadySignal) listener.Stop() diff --git a/h2mux/bytes_counter.go b/h2mux/bytes_counter.go index 0cd290fd..08419e38 100644 --- a/h2mux/bytes_counter.go +++ b/h2mux/bytes_counter.go @@ -8,6 +8,10 @@ type AtomicCounter struct { count uint64 } +func NewAtomicCounter(initCount uint64) *AtomicCounter{ + return &AtomicCounter{count: initCount} +} + func (c *AtomicCounter) IncrementBy(number uint64) { atomic.AddUint64(&c.count, number) } diff --git a/h2mux/h2mux.go b/h2mux/h2mux.go index e476431b..aeef502a 100644 --- a/h2mux/h2mux.go +++ b/h2mux/h2mux.go @@ -140,6 +140,8 @@ func Handshake( updateSendWindowChan := make(chan uint32, 1) updateInBoundBytesChan := make(chan uint64) updateOutBoundBytesChan := make(chan uint64) + inBoundCounter := NewAtomicCounter(0) + outBoundCounter := NewAtomicCounter(0) pingTimestamp := NewPingTimestamp() connActive := NewSignal() idleDuration := config.HeartbeatInterval @@ -171,6 +173,7 @@ func Handshake( updateRTTChan: updateRTTChan, updateReceiveWindowChan: updateReceiveWindowChan, updateSendWindowChan: updateSendWindowChan, + bytesRead: inBoundCounter, updateInBoundBytesChan: updateInBoundBytesChan, } m.muxWriter = &MuxWriter{ @@ -187,6 +190,7 @@ func Handshake( maxFrameSize: defaultFrameSize, updateReceiveWindowChan: updateReceiveWindowChan, updateSendWindowChan: updateSendWindowChan, + bytesWrote: outBoundCounter, updateOutBoundBytesChan: updateOutBoundBytesChan, } m.muxWriter.headerEncoder = hpack.NewEncoder(&m.muxWriter.headerBuffer) diff --git a/h2mux/muxreader.go b/h2mux/muxreader.go index 3530dab8..4c8b650c 100644 --- a/h2mux/muxreader.go +++ b/h2mux/muxreader.go @@ -42,7 +42,7 @@ type MuxReader struct { // updateSendWindowChan is the channel to update sendWindow size to muxerMetricsUpdater updateSendWindowChan chan<- uint32 // bytesRead is the amount of bytes read from data frame since the last time we send bytes read to metrics - bytesRead AtomicCounter + bytesRead *AtomicCounter // updateOutBoundBytesChan is the channel to send bytesWrote to muxerMetricsUpdater updateInBoundBytesChan chan<- uint64 } diff --git a/h2mux/muxwriter.go b/h2mux/muxwriter.go index 8ea4c675..839e552b 100644 --- a/h2mux/muxwriter.go +++ b/h2mux/muxwriter.go @@ -45,7 +45,7 @@ type MuxWriter struct { // updateSendWindowChan is the channel to update sendWindow size to muxerMetricsUpdater updateSendWindowChan chan<- uint32 // bytesWrote is the amount of bytes wrote to data frame since the last time we send bytes wrote to metrics - bytesWrote AtomicCounter + bytesWrote *AtomicCounter // updateOutBoundBytesChan is the channel to send bytesWrote to muxerMetricsUpdater updateOutBoundBytesChan chan<- uint64 }