Skip to content

Commit

Permalink
Merge branch 'fix-#172'
Browse files Browse the repository at this point in the history
  • Loading branch information
illarion committed Oct 23, 2018
2 parents d4bdbab + 5fd0c92 commit b366c87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/server/tcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,17 @@ func (this *Server) handle(ctx *core.TcpContext) {
select {
case s, ok := <-cs:
isRx = ok
if !ok {
cs = nil
continue
}
this.scheduler.IncrementRx(*backend, s.CountWrite)
case s, ok := <-bs:
isTx = ok
if !ok {
bs = nil
continue
}
this.scheduler.IncrementTx(*backend, s.CountWrite)
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/utils/tls/sni/sni.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ func Sniff(conn net.Conn, readTimeout time.Duration) (net.Conn, string, error) {
buf := pool.Get().([]byte)
defer pool.Put(buf)

conn.SetReadDeadline(time.Now().Add(readTimeout))
err := conn.SetReadDeadline(time.Now().Add(readTimeout))
if err != nil {
return nil, "", err
}

i, err := conn.Read(buf)

if err != nil {
return nil, "", err
}

conn.SetReadDeadline(time.Time{}) // Reset read deadline
err = conn.SetReadDeadline(time.Time{}) // Reset read deadline
if err != nil {
return nil, "", err
}

hostname := extractHostname(buf[0:i])

Expand Down

0 comments on commit b366c87

Please sign in to comment.