Skip to content

Commit

Permalink
Fix smux
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Nov 8, 2021
1 parent 0e3acf1 commit 1f123ee
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions protocols/smux/smux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net"
"sync"
"time"

"github.com/wzshiming/bridge"
Expand All @@ -31,15 +30,12 @@ func SMux(dialer bridge.Dialer, addr string) (bridge.Dialer, error) {
}

type sMux struct {
mux sync.Mutex
dialer bridge.Dialer
listenConfig bridge.ListenConfig
sess *smux.Session
}

func (m *sMux) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
m.mux.Lock()
defer m.mux.Unlock()
if m.sess == nil || m.sess.IsClosed() {
if m.sess != nil {
m.sess.Close()
Expand All @@ -57,8 +53,6 @@ func (m *sMux) DialContext(ctx context.Context, network, address string) (net.Co
}
conn, err := m.sess.OpenStream()
if err != nil {
m.sess.Close()
m.sess = nil
return m.DialContext(ctx, network, address)
}
return conn, nil
Expand Down Expand Up @@ -136,7 +130,7 @@ func (l *listenerSession) Accept() (net.Conn, error) {

func (l *listenerSession) Close() error {
l.cancel()
return l.Close()
return l.listener.Close()
}

func (l *listenerSession) Addr() net.Addr {
Expand Down

0 comments on commit 1f123ee

Please sign in to comment.