[tor-commits] [snowflake/main] Remove BytesLoggers from exported functions

cohosh at torproject.org cohosh at torproject.org
Thu Oct 28 14:05:56 UTC 2021


commit b2edf948e21c2420d3b3696c680856f106dae9f4
Author: Cecylia Bocovich <cohosh at torproject.org>
Date:   Tue Oct 26 14:52:17 2021 -0400

    Remove BytesLoggers from exported functions
---
 proxy/lib/snowflake.go  |  2 +-
 proxy/lib/util.go       | 40 ++++++++++++++++++++--------------------
 proxy/lib/webrtcconn.go |  2 +-
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go
index e35eabd..793fa2b 100644
--- a/proxy/lib/snowflake.go
+++ b/proxy/lib/snowflake.go
@@ -306,7 +306,7 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(sdp *webrtc.SessionDescrip
 
 		pr, pw := io.Pipe()
 		conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
-		conn.bytesLogger = NewBytesSyncLogger()
+		conn.bytesLogger = newBytesSyncLogger()
 
 		dc.OnOpen(func() {
 			log.Println("OnOpen channel")
diff --git a/proxy/lib/util.go b/proxy/lib/util.go
index c6613d9..2df23eb 100644
--- a/proxy/lib/util.go
+++ b/proxy/lib/util.go
@@ -5,37 +5,37 @@ import (
 	"time"
 )
 
-// BytesLogger is an interface which is used to allow logging the throughput
-// of the Snowflake. A default BytesLogger(BytesNullLogger) does nothing.
-type BytesLogger interface {
+// bytesLogger is an interface which is used to allow logging the throughput
+// of the Snowflake. A default bytesLogger(bytesNullLogger) does nothing.
+type bytesLogger interface {
 	AddOutbound(int)
 	AddInbound(int)
 	ThroughputSummary() string
 }
 
-// BytesNullLogger Default BytesLogger does nothing.
-type BytesNullLogger struct{}
+// bytesNullLogger Default bytesLogger does nothing.
+type bytesNullLogger struct{}
 
-// AddOutbound in BytesNullLogger does nothing
-func (b BytesNullLogger) AddOutbound(amount int) {}
+// AddOutbound in bytesNullLogger does nothing
+func (b bytesNullLogger) AddOutbound(amount int) {}
 
-// AddInbound in BytesNullLogger does nothing
-func (b BytesNullLogger) AddInbound(amount int) {}
+// AddInbound in bytesNullLogger does nothing
+func (b bytesNullLogger) AddInbound(amount int) {}
 
-// ThroughputSummary in BytesNullLogger does nothing
-func (b BytesNullLogger) ThroughputSummary() string { return "" }
+// ThroughputSummary in bytesNullLogger does nothing
+func (b bytesNullLogger) ThroughputSummary() string { return "" }
 
-// BytesSyncLogger uses channels to safely log from multiple sources with output
+// bytesSyncLogger uses channels to safely log from multiple sources with output
 // occuring at reasonable intervals.
-type BytesSyncLogger struct {
+type bytesSyncLogger struct {
 	outboundChan, inboundChan              chan int
 	outbound, inbound, outEvents, inEvents int
 	start                                  time.Time
 }
 
-// NewBytesSyncLogger returns a new BytesSyncLogger and starts it loggin.
-func NewBytesSyncLogger() *BytesSyncLogger {
-	b := &BytesSyncLogger{
+// newBytesSyncLogger returns a new bytesSyncLogger and starts it loggin.
+func newBytesSyncLogger() *bytesSyncLogger {
+	b := &bytesSyncLogger{
 		outboundChan: make(chan int, 5),
 		inboundChan:  make(chan int, 5),
 	}
@@ -44,7 +44,7 @@ func NewBytesSyncLogger() *BytesSyncLogger {
 	return b
 }
 
-func (b *BytesSyncLogger) log() {
+func (b *bytesSyncLogger) log() {
 	for {
 		select {
 		case amount := <-b.outboundChan:
@@ -58,17 +58,17 @@ func (b *BytesSyncLogger) log() {
 }
 
 // AddOutbound add a number of bytes to the outbound total reported by the logger
-func (b *BytesSyncLogger) AddOutbound(amount int) {
+func (b *bytesSyncLogger) AddOutbound(amount int) {
 	b.outboundChan <- amount
 }
 
 // AddInbound add a number of bytes to the inbound total reported by the logger
-func (b *BytesSyncLogger) AddInbound(amount int) {
+func (b *bytesSyncLogger) AddInbound(amount int) {
 	b.inboundChan <- amount
 }
 
 // ThroughputSummary view a formatted summary of the throughput totals
-func (b *BytesSyncLogger) ThroughputSummary() string {
+func (b *bytesSyncLogger) ThroughputSummary() string {
 	var inUnit, outUnit string
 	units := []string{"B", "KB", "MB", "GB"}
 
diff --git a/proxy/lib/webrtcconn.go b/proxy/lib/webrtcconn.go
index 5c6192b..20b1172 100644
--- a/proxy/lib/webrtcconn.go
+++ b/proxy/lib/webrtcconn.go
@@ -29,7 +29,7 @@ type webRTCConn struct {
 	lock sync.Mutex // Synchronization for DataChannel destruction
 	once sync.Once  // Synchronization for PeerConnection destruction
 
-	bytesLogger BytesLogger
+	bytesLogger bytesLogger
 }
 
 func (c *webRTCConn) Read(b []byte) (int, error) {





More information about the tor-commits mailing list