Skip to content

Commit

Permalink
Rename disallowLoopbackForTesting to reflect what it aims for
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovis7 committed Aug 22, 2024
1 parent 839812c commit 595aaae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tlslistener/clienthelloconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func Delayed(d time.Duration, r HandshakeReaction) HandshakeReaction {
return r2
}

var disallowLoopbackForTesting bool
var allowLoopbackForTesting bool

var bufferPool = sync.Pool{
New: func() interface{} {
Expand Down Expand Up @@ -197,7 +197,7 @@ func (rrc *clientHelloRecordingConn) processHello(info *tls.ClientHelloInfo) (*t
sourceIP := rrc.RemoteAddr().(*net.TCPAddr).IP
// We allow loopback to generate session states (makesessions) to
// distribute to Lantern clients.
if !disallowLoopbackForTesting && sourceIP.IsLoopback() {
if !allowLoopbackForTesting && sourceIP.IsLoopback() {
return nil, nil
}

Expand Down
8 changes: 4 additions & 4 deletions tlslistener/clienthelloconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

func TestAbortOnHello(t *testing.T) {
disallowLoopbackForTesting = true
allowLoopbackForTesting = true
testCases := []struct {
response HandshakeReaction
expectedErr string
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestAbortOnHello(t *testing.T) {
}

func TestSuccess(t *testing.T) {
disallowLoopbackForTesting = false
allowLoopbackForTesting = false
l, _ := net.Listen("tcp", ":0")
defer l.Close()

Expand Down Expand Up @@ -151,9 +151,9 @@ func TestSuccess(t *testing.T) {
defer conn.Close()

// Now disallow loopback for testing, then dial again and make sure session ticket still works
disallowLoopbackForTesting = true
allowLoopbackForTesting = true
defer func() {
disallowLoopbackForTesting = false
allowLoopbackForTesting = false
}()

conn, err = utls.Dial("tcp", l.Addr().String(), ucfg)
Expand Down

0 comments on commit 595aaae

Please sign in to comment.