Skip to content
Snippets Groups Projects
  1. Aug 05, 2021
    • David Fifield's avatar
      Factor out httpRendezvous separate from BrokerChannel. · 0f34a777
      David Fifield authored
      Makes BrokerChannel abstract over a rendezvousMethod. BrokerChannel
      itself is responsible for keepLocalAddresses and the NAT type state, as
      well as encoding and decoding client poll messages. rendezvousMethod is
      only responsible for delivery of encoded messages.
      0f34a777
    • David Fifield's avatar
      Change the representation of domain fronting in HTTP rendezvous. · 55f4814d
      David Fifield authored
      Formerly, BrokerChannel represented the broker URL and possible domain
      fronting as
      	bc.url  *url.URL
              bc.Host string
      That is, bc.url is the URL of the server which we contact directly, and
      bc.Host is the Host header to use in the request. With no domain
      fronting, bc.url points directly at the broker itself, and bc.Host is
      blank. With domain fronting, we do the following reshuffling:
      	if front != "" {
      		bc.Host = bc.url.Host
      		bc.url.Host = front
      	}
      That is, we alter bc.url to reflect that the server to which we send
      requests directly is the CDN, not the broker, and store the broker's own
      URL in the HTTP Host header.
      
      The above representation was always confusing to me, because in my
      mental model, we are always conceptually communicating with the broker;
      but we may optionally be using a CDN proxy in the middle. The new
      representation is
      	bc.url   *url.URL
              bc.front string
      bc.url is the URL of the broker itself, and never changes. bc.front is
      the optional CDN front domain, and likewise never changes after
      initialization. When domain fronting is in use, we do the swap in the
      http.Request struct, not in BrokerChannel itself:
      	if bc.front != "" {
      		request.Host = request.URL.Host
      		request.URL.Host = bc.front
      	}
      
      Compare to the representation in meek-client:
      
      https://gitweb.torproject.org/pluggable-transports/meek.git/tree/meek-client/meek-client.go?h=v0.35.0#n94
      	var options struct {
      		URL       string
      		Front     string
      	}
      https://gitweb.torproject.org/pluggable-transports/meek.git/tree/meek-client/meek-client.go?h=v0.35.0#n308
      	if ok { // if front is set
      		info.Host = info.URL.Host
      		info.URL.Host = front
      	}
      55f4814d
    • David Fifield's avatar
      Use a URL with a Host component in BrokerChannel tests. · 191510c4
      David Fifield authored
      The tests were using a broker URL of "test.broker" (i.e., a schema-less,
      host-less, relative path), and running assertions on the value of
      b.url.Path. This is strange, especially in tests regarding domain
      fronting, where we care about b.url.Host, not b.url.Path. This commit
      changes the broker URL to "http://test.broker" and changes tests to
      check b.url.Host. I also added an additional assertion for an empty
      b.Host in the non-domain-fronted case.
      191510c4
  2. Jul 21, 2021
  3. Jul 19, 2021
  4. Jul 18, 2021
  5. Jul 13, 2021
  6. Jul 08, 2021
  7. Jul 07, 2021
  8. Jun 24, 2021
  9. Jun 23, 2021
  10. Jun 19, 2021
    • Cecylia Bocovich's avatar
      Store net.Addr in clientIDAddrMap · 6634f2be
      Cecylia Bocovich authored
      This fixes a stats collection bug where we were converting client
      addresses between a string and net.Addr using the clientAddr function
      multiple times, resulting in an empty string for all addresses.
      6634f2be
  11. Jun 14, 2021
    • sbs's avatar
      fix(client/snowflake.go): prevent wg.Add race condition · aefabe68
      sbs authored
      In VSCode, the staticcheck tool emits this warning:
      
      > should call wg.Add(1) before starting the goroutine to
      > avoid a race (SA2000)go-staticcheck
      
      To avoid this warning, just move wg.Add outside.
      aefabe68
  12. Jun 07, 2021
  13. Jun 02, 2021
  14. May 24, 2021
    • David Fifield's avatar
      Release resources in client Transport.Dial on error. · ae7cc478
      David Fifield authored
      Make a stack of cleanup functions to run (as with defer), but clear the
      stack before returning if no error occurs.
      
      Uselessly pushing the stream.Close() cleanup just before clearing the
      stack is an intentional safeguard, for in case additional operations are
      added before the return in the future.
      
      Fixes #40042.
      ae7cc478
    • David Fifield's avatar
      Fix error handling around transport.Dial. · 01a96c7d
      David Fifield authored
      The code checked for and displayed an error, but would then go on to
      call copyLoop on the nil Conn returned from transport.Dial. Add a return
      in that case, and put the cleanup operations in defer. Also remove an
      obsolete comment about an empty address. Obsolete because:
      !31 (comment 2733279)
      01a96c7d
  15. May 21, 2021
  16. May 20, 2021
    • Arlo Breault's avatar
      Remove sync.Once from around logMetrics · 7ef49272
      Arlo Breault authored
      Follow up to 160ae2dd
      
      Analysis by @dcf,
      
      > I don't think the sync.Once around logMetrics is necessary anymore.
      Its original purpose was to inhibit logging on later file handles of
      metrics.log, if there were more than one opened. See 171c55a9 and #29734
      (comment 2593039) "Making a singleton *Metrics variable causes problems
      with how Convey does tests. It shouldn't be called more than once, but
      for now I'm using sync.Once on the logging at least so it's explicit."
      Commit ba4fe1a7 changed it so that metrics.log is opened in main, used
      to create a *log.Logger, and that same instance of *log.Logger is passed
      to both NewMetrics and NewBrokerContext. It's safe to share the same
      *log.Logger across multiple BrokerContext.
      7ef49272
  17. May 19, 2021
    • Arlo Breault's avatar
      Make promMetrics not a global · 160ae2dd
      Arlo Breault authored
      Doesn't seem like it needs to exist outside of the metrics struct.
      
      Also, the call to logMetrics is moved to the constructor.  A metrics
      instance is only created when a BrokerContext is created, which only
      happens at startup.  The sync of only doing that once is left for
      documentation purposes, since it doesn't hurt, but also seems redundant.
      160ae2dd
  18. May 12, 2021
Loading