Skip to content

Commit

Permalink
VMess will Drain Connection On Auth failure
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokangwang committed Jun 3, 2020
1 parent 220b783 commit 38e89bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion proxy/vmess/encoding/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request

user, timestamp, valid := s.userValidator.Get(buffer.Bytes())
if !valid {
return nil, newError("invalid user")
return nil, drainConnection(newError("invalid user"))
}

iv := hashTimestamp(md5.New(), timestamp)
Expand Down
5 changes: 4 additions & 1 deletion testing/scenarios/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -265,7 +266,9 @@ func TestCommanderAddRemoveUser(t *testing.T) {
common.Must(err)
defer CloseAllServers(servers)

if err := testTCPConn(clientPort, 1024, time.Second*5)(); err != io.EOF {
if err := testTCPConn(clientPort, 1024, time.Second*5)(); err != io.EOF &&
/*We might wish to drain the connection*/
(err != nil && !strings.HasSuffix(err.Error(), "i/o timeout")) {
t.Fatal("expected error: ", err)
}

Expand Down

0 comments on commit 38e89bd

Please sign in to comment.