Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: client error && websocket compress error #48

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading