Skip to content

Commit

Permalink
Fix reg nil pointer bug (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyech authored Aug 16, 2023
1 parent 88af533 commit 77a85af
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cmd/application/conns.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,7 @@ readLoop:

transports:
for i, t := range possibleTransports {
wrappedReg, wrapped, err := t.WrapConnection(&received, clientConn, originalDstIP, regManager)
reg, ok := wrappedReg.(*cj.DecoyRegistration)
if !ok {
logger.Errorf("unexpected returned reg type from transport: %T, expected: %T", wrapped, reg)
delete(possibleTransports, i)
continue transports
}
wrappedReg, wrappedConn, err := t.WrapConnection(&received, clientConn, originalDstIP, regManager)

err = generalizeErr(err)
if errors.Is(err, transports.ErrTryAgain) {
Expand All @@ -342,6 +336,16 @@ readLoop:
return
}

ok := false
reg, ok = wrappedReg.(*cj.DecoyRegistration)
if !ok {
logger.Errorf("unexpected returned reg type from transport: %T, expected: %T", wrapped, reg)
delete(possibleTransports, i)
continue transports
}
// set outer wrapped var
wrapped = wrappedConn

// We found our transport! First order of business: disable deadline
err = wrapped.SetDeadline(time.Time{})
if err != nil {
Expand Down

0 comments on commit 77a85af

Please sign in to comment.