mirror of
https://github.com/coder/coder.git
synced 2026-11-10 18:13:50 +08:00
Upgrades to slog v3 which includes a small, but backward incompatible API change to the acceptible call arguments when logging. This change allows us to verify via compile time type checking that arguments are correct and won't cause a panic, as was possible in slog v1, which this replaces (v2 was tagged but never used in coder/coder). It also updates dependencies that also use slog and were updated. I've left the `aibridge` dependency as a commit SHA, under the assumption that the team there (cc @pawbana @dannykopping ) will tag and update the dependency soon and on their own schedule. Other dependencies, I pushed new tags.
26 lines
631 B
Go
26 lines
631 B
Go
package tailnet
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"github.com/hashicorp/yamux"
|
|
"golang.org/x/xerrors"
|
|
|
|
"cdr.dev/slog/v3"
|
|
|
|
"github.com/coder/coder/v2/codersdk/drpcsdk"
|
|
"github.com/coder/coder/v2/tailnet/proto"
|
|
)
|
|
|
|
func NewDRPCClient(conn net.Conn, logger slog.Logger) (proto.DRPCTailnetClient, error) {
|
|
config := yamux.DefaultConfig()
|
|
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)
|
|
}
|
|
return proto.NewDRPCTailnetClient(drpcsdk.MultiplexedConn(session)), nil
|
|
}
|