committed by
Jakob Borg
parent
f35e1ac0c5
commit
ceea5ebeb3
@@ -7,10 +7,9 @@
|
||||
package connections
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/yamux"
|
||||
"github.com/xtaci/smux"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -25,12 +24,10 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
yamuxConfig = &yamux.Config{
|
||||
AcceptBacklog: 256,
|
||||
EnableKeepAlive: true,
|
||||
KeepAliveInterval: 30 * time.Second,
|
||||
ConnectionWriteTimeout: 10 * time.Second,
|
||||
MaxStreamWindowSize: 256 * 1024,
|
||||
LogOutput: ioutil.Discard,
|
||||
smuxConfig = &smux.Config{
|
||||
KeepAliveInterval: 10 * time.Second,
|
||||
KeepAliveTimeout: 30 * time.Second,
|
||||
MaxFrameSize: 4096,
|
||||
MaxReceiveBuffer: 4 * 1024 * 1024,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/yamux"
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
"github.com/xtaci/kcp-go"
|
||||
"github.com/xtaci/smux"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -56,7 +56,7 @@ func (d *kcpDialer) Dial(id protocol.DeviceID, uri *url.URL) (internalConn, erro
|
||||
conn.SetWindowSize(opts.KCPSendWindowSize, opts.KCPReceiveWindowSize)
|
||||
conn.SetNoDelay(boolInt(opts.KCPNoDelay), opts.KCPUpdateIntervalMs, boolInt(opts.KCPFastResend), boolInt(!opts.KCPCongestionControl))
|
||||
|
||||
ses, err := yamux.Client(conn, yamuxConfig)
|
||||
ses, err := smux.Client(conn, smuxConfig)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return internalConn{}, err
|
||||
|
||||
@@ -16,10 +16,10 @@ import (
|
||||
|
||||
"github.com/AudriusButkevicius/pfilter"
|
||||
"github.com/ccding/go-stun/stun"
|
||||
"github.com/hashicorp/yamux"
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
"github.com/syncthing/syncthing/lib/nat"
|
||||
"github.com/xtaci/kcp-go"
|
||||
"github.com/xtaci/smux"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -116,16 +116,16 @@ func (t *kcpListener) Serve() {
|
||||
|
||||
l.Debugln("connect from", conn.RemoteAddr())
|
||||
|
||||
ses, err := yamux.Server(conn, yamuxConfig)
|
||||
ses, err := smux.Server(conn, smuxConfig)
|
||||
if err != nil {
|
||||
l.Debugln("yamux server:", err)
|
||||
l.Debugln("smux server:", err)
|
||||
conn.Close()
|
||||
continue
|
||||
}
|
||||
|
||||
stream, err := ses.AcceptStream()
|
||||
if err != nil {
|
||||
l.Debugln("yamux accept:", err)
|
||||
l.Debugln("smux accept:", err)
|
||||
ses.Close()
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/AudriusButkevicius/pfilter"
|
||||
"github.com/hashicorp/yamux"
|
||||
"github.com/xtaci/smux"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -162,8 +162,8 @@ func (f *stunFilter) reap() {
|
||||
}
|
||||
|
||||
type sessionClosingStream struct {
|
||||
*yamux.Stream
|
||||
session *yamux.Session
|
||||
*smux.Stream
|
||||
session *smux.Session
|
||||
}
|
||||
|
||||
func (w *sessionClosingStream) Close() error {
|
||||
|
||||
Reference in New Issue
Block a user