Skip to content

Commit

Permalink
Check if the command is UNKNOWN (v1) or LOCAL (v2).
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Aug 5, 2024
1 parent c8d8332 commit 827be3c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions service/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"sync/atomic"

"github.com/Jigsaw-Code/outline-sdk/transport"
proxyproto "github.com/pires/go-proxyproto"
"github.com/pires/go-proxyproto"
)

// The implementations of listeners for different network types are not
Expand Down Expand Up @@ -138,15 +138,18 @@ func (l *ProxyStreamListener) AcceptStream() (ClientStreamConn, error) {
return nil, err
}
r := bufio.NewReader(conn)
h, err := proxyproto.Read(r)
header, err := proxyproto.Read(r)
if errors.Is(err, proxyproto.ErrNoProxyProtocol) {
logger.Warningf("Received connection from %v without proxy header.", conn.RemoteAddr())
return conn, nil
}
if err != nil {
if header == nil || err != nil {
return nil, fmt.Errorf("error parsing proxy header: %v", err)
}
return &clientStreamConn{StreamConn: conn, clientAddr: h.SourceAddr}, nil
if header.Command.IsLocal() {
return conn, nil
}
return &clientStreamConn{StreamConn: conn, clientAddr: header.SourceAddr}, nil
}

type virtualPacketConn struct {
Expand Down

0 comments on commit 827be3c

Please sign in to comment.