vendor: update package

This commit is contained in:
fatedier 2019-03-11 15:54:55 +08:00
parent e691a40260
commit 5e64bbfa7c
4 changed files with 28 additions and 9 deletions

1
vendor/github.com/hashicorp/yamux/go.mod generated vendored Normal file
View File

@ -0,0 +1 @@
module github.com/hashicorp/yamux

View File

@ -3,6 +3,7 @@ package yamux
import ( import (
"fmt" "fmt"
"io" "io"
"log"
"os" "os"
"time" "time"
) )
@ -30,8 +31,13 @@ type Config struct {
// window size that we allow for a stream. // window size that we allow for a stream.
MaxStreamWindowSize uint32 MaxStreamWindowSize uint32
// LogOutput is used to control the log destination // LogOutput is used to control the log destination. Either Logger or
// LogOutput can be set, not both.
LogOutput io.Writer LogOutput io.Writer
// Logger is used to pass in the logger to be used. Either Logger or
// LogOutput can be set, not both.
Logger *log.Logger
} }
// DefaultConfig is used to return a default configuration // DefaultConfig is used to return a default configuration
@ -57,6 +63,11 @@ func VerifyConfig(config *Config) error {
if config.MaxStreamWindowSize < initialStreamWindow { if config.MaxStreamWindowSize < initialStreamWindow {
return fmt.Errorf("MaxStreamWindowSize must be larger than %d", initialStreamWindow) return fmt.Errorf("MaxStreamWindowSize must be larger than %d", initialStreamWindow)
} }
if config.LogOutput != nil && config.Logger != nil {
return fmt.Errorf("both Logger and LogOutput may not be set, select one")
} else if config.LogOutput == nil && config.Logger == nil {
return fmt.Errorf("one of Logger or LogOutput must be set, select one")
}
return nil return nil
} }

View File

@ -86,9 +86,14 @@ type sendReady struct {
// newSession is used to construct a new session // newSession is used to construct a new session
func newSession(config *Config, conn io.ReadWriteCloser, client bool) *Session { func newSession(config *Config, conn io.ReadWriteCloser, client bool) *Session {
logger := config.Logger
if logger == nil {
logger = log.New(config.LogOutput, "", log.LstdFlags)
}
s := &Session{ s := &Session{
config: config, config: config,
logger: log.New(config.LogOutput, "", log.LstdFlags), logger: logger,
conn: conn, conn: conn,
bufRead: bufio.NewReader(conn), bufRead: bufio.NewReader(conn),
pings: make(map[uint32]chan struct{}), pings: make(map[uint32]chan struct{}),
@ -309,8 +314,10 @@ func (s *Session) keepalive() {
case <-time.After(s.config.KeepAliveInterval): case <-time.After(s.config.KeepAliveInterval):
_, err := s.Ping() _, err := s.Ping()
if err != nil { if err != nil {
s.logger.Printf("[ERR] yamux: keepalive failed: %v", err) if err != ErrSessionShutdown {
s.exitErr(ErrKeepAliveTimeout) s.logger.Printf("[ERR] yamux: keepalive failed: %v", err)
s.exitErr(ErrKeepAliveTimeout)
}
return return
} }
case <-s.shutdownCh: case <-s.shutdownCh:

10
vendor/modules.txt vendored
View File

@ -23,7 +23,7 @@ github.com/gorilla/context
github.com/gorilla/mux github.com/gorilla/mux
# github.com/gorilla/websocket v1.2.0 # github.com/gorilla/websocket v1.2.0
github.com/gorilla/websocket github.com/gorilla/websocket
# github.com/hashicorp/yamux v0.0.0-20180314200745-2658be15c5f0 # github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/hashicorp/yamux github.com/hashicorp/yamux
# github.com/inconshreveable/mousetrap v1.0.0 # github.com/inconshreveable/mousetrap v1.0.0
github.com/inconshreveable/mousetrap github.com/inconshreveable/mousetrap
@ -61,11 +61,11 @@ golang.org/x/crypto/twofish
golang.org/x/crypto/xtea golang.org/x/crypto/xtea
golang.org/x/crypto/salsa20/salsa golang.org/x/crypto/salsa20/salsa
# golang.org/x/net v0.0.0-20180524181706-dfa909b99c79 # golang.org/x/net v0.0.0-20180524181706-dfa909b99c79
golang.org/x/net/ipv4
golang.org/x/net/websocket golang.org/x/net/websocket
golang.org/x/net/context
golang.org/x/net/proxy
golang.org/x/net/ipv4
golang.org/x/net/internal/socks
golang.org/x/net/bpf golang.org/x/net/bpf
golang.org/x/net/internal/iana golang.org/x/net/internal/iana
golang.org/x/net/internal/socket golang.org/x/net/internal/socket
golang.org/x/net/context
golang.org/x/net/proxy
golang.org/x/net/internal/socks