mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: add logging to client tailnet yamux (#11908)
Adds logging to yamux when used for tailnet client connections, e.g. CLI and wsproxy. This could be useful for debugging connection issues with tailnet v2 API.
This commit is contained in:
@ -1,19 +1,21 @@
|
||||
package tailnet
|
||||
|
||||
import (
|
||||
"io"
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/hashicorp/yamux"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"cdr.dev/slog"
|
||||
"github.com/coder/coder/v2/codersdk/drpc"
|
||||
"github.com/coder/coder/v2/tailnet/proto"
|
||||
)
|
||||
|
||||
func NewDRPCClient(conn net.Conn) (proto.DRPCTailnetClient, error) {
|
||||
func NewDRPCClient(conn net.Conn, logger slog.Logger) (proto.DRPCTailnetClient, error) {
|
||||
config := yamux.DefaultConfig()
|
||||
config.LogOutput = io.Discard
|
||||
config.LogOutput = nil
|
||||
config.Logger = slog.Stdlib(context.Background(), logger, slog.LevelInfo)
|
||||
session, err := yamux.Client(conn, config)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("multiplex client: %w", err)
|
||||
|
Reference in New Issue
Block a user