Skip to content

Commit

Permalink
fix: final fixes before marking PR as ready
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Feb 7, 2022
1 parent 04758b5 commit 4d57276
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
11 changes: 4 additions & 7 deletions internal/engine/experiment/torsf/torsf.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,15 @@ func (m *Measurer) bootstrap(ctx context.Context, sess model.ExperimentSession,
//
// This function aims to _only_ include:
//
// 1. information on the tor version by intercepting the line that
// writes which tor version is opening a log file;
//
// 2. notices (more detailed debug messages may contain information
// 1. notices (more detailed debug messages may contain information
// that we'd rather not include into the logs?);
//
// 3. information about bootstrap (by looking at the progress of
// 2. information about bootstrap (by looking at the progress of
// the bootstrap we understand where it blocks and we also know the
// amount of work tor needs to do, hence we know the cache status
// because a working cache includes much less messages);
//
// 4. information about bridges being used (from there we know
// 3. information about bridges being used (from there we know
// if the bridge was cached of fresh, by the way).
//
// Tor is know to be good software that does not break its output
Expand All @@ -233,7 +230,7 @@ func (m *Measurer) readTorLogs(logger model.Logger, tk *TestKeys, logFilePath st
return
}
for _, bline := range bytes.Split(data, []byte("\n")) {
sline := string(bline) // avoid IP addresses in logs
sline := string(bline)
if !strings.Contains(sline, "[notice]") {
continue
}
Expand Down
7 changes: 5 additions & 2 deletions internal/ptx/ptx.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ func (lst *Listener) forward(ctx context.Context, left, right net.Conn, done cha
// function TAKES OWNERSHIP of the two connections and ensures
// that they are closed when we are done.
func (lst *Listener) forwardWithContext(ctx context.Context, left, right net.Conn) {
left = bytecounter.MaybeWrap(left, lst.SessionByteCounter)
left = bytecounter.MaybeWrap(left, lst.ExperimentByteCounter)
defer left.Close()
defer right.Close()
done := make(chan struct{})
Expand All @@ -162,6 +160,11 @@ func (lst *Listener) handleSocksConn(ctx context.Context, socksConn ptxSocksConn
lst.logger().Warnf("ptx: ContextDialer.DialContext error: %s", err)
return err // used for testing
}
// We _must_ wrap the ptConn. Wrapping the socks conn leads us to
// count the sent bytes as received and the received bytes as sent:
// bytes flow in the opposite direction there for the socks conn.
ptConn = bytecounter.MaybeWrap(ptConn, lst.SessionByteCounter)
ptConn = bytecounter.MaybeWrap(ptConn, lst.ExperimentByteCounter)
lst.forwardWithContext(ctx, socksConn, ptConn) // transfer ownership
return nil // used for testing
}
Expand Down
4 changes: 0 additions & 4 deletions internal/tunnel/tor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ type torTunnel struct {
// instance is the running tor instance
instance torProcess

// logFilePath is the path to the logfile.
logFilePath string

// proxy is the SOCKS5 proxy URL
proxy *url.URL
}
Expand Down Expand Up @@ -119,7 +116,6 @@ func torStart(ctx context.Context, config *Config) (Tunnel, DebugInfo, error) {
return &torTunnel{
bootstrapTime: stop.Sub(start),
instance: instance,
logFilePath: logfile,
proxy: &url.URL{Scheme: "socks5", Host: proxyAddress},
}, debugInfo, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Tunnel interface {
SOCKS5ProxyURL() *url.URL

// Stop stops the tunnel. You should not attempt to
// use the tunnel once this function is called.
// use any other tunnel method after Stop.
Stop()
}

Expand Down

0 comments on commit 4d57276

Please sign in to comment.