Skip to content

Commit

Permalink
fix: client error && websocket compress error (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
DVKunion authored Jan 25, 2024
1 parent 7cb82c8 commit 65ecb61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions cmd/client/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ func Control(ctx context.Context, sg *SigGroup) {
case t := <-sg.StartChannel:
slog.Info(consts.LISTEN_START, "type", t)
sg.wg.Add(1)
go func() {
if err := doListen(c, t); err != nil {
slog.Error(consts.LISTEN_ERROR, "type", t, "err", err)
}
}()
if err := doListen(c, t); err != nil {
slog.Error(consts.LISTEN_ERROR, "type", t, "err", err)
}
sg.wg.Done()
case t := <-sg.StopChannel:
slog.Info(consts.LISTEN_STOP, "type", t)
Expand All @@ -40,6 +38,7 @@ func doListen(ctx context.Context, t transfer.Type) error {
if err != nil {
return err
}
defer server.Close()
var proxyAddr string
var proxyType tunnel.Type
for _, p := range Config().ProxyAddr {
Expand All @@ -63,7 +62,6 @@ func doListen(ctx context.Context, t transfer.Type) error {
}

func listen(ctx context.Context, server net.Listener, pa string, pt tunnel.Type, t transfer.Type) {
defer server.Close()
for {
conn, err := server.Accept()
if err != nil {
Expand All @@ -75,9 +73,11 @@ func listen(ctx context.Context, server net.Listener, pa string, pt tunnel.Type,
slog.Error(consts.CONNECT_RMOET_ERROR, "err", err)
continue
}
if err := network.Transport(conn, destConn); err != nil {
slog.Error(consts.CONNECT_TRANS_ERROR, "err", err)
}
go func() {
if err := network.Transport(conn, destConn); err != nil {
slog.Error(consts.CONNECT_TRANS_ERROR, "err", err)
}
}()
}
}
}
4 changes: 2 additions & 2 deletions pkg/service/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *WSService) Conn(ctx context.Context, t transfer.Type, sOpts ...Option)
HandshakeTimeout: defaultTimeout,
ReadBufferSize: defaultReadBufferSize,
WriteBufferSize: defaultReadBufferSize,
EnableCompression: true,
EnableCompression: false,
}

if srvOpts.buffers != nil {
Expand Down Expand Up @@ -72,7 +72,7 @@ func (s *WSService) Serve(ln net.Listener, sOpts ...Option) error {
HandshakeTimeout: defaultTimeout,
ReadBufferSize: defaultReadBufferSize,
WriteBufferSize: defaultReadBufferSize,
EnableCompression: true,
EnableCompression: false,
CheckOrigin: func(r *http.Request) bool { return true },
}

Expand Down

0 comments on commit 65ecb61

Please sign in to comment.