NewWithConfig calls New with the given config. For documentation, see New.
(ctx context.Context, logger slog.Logger, cfg Config)
| 34 | |
| 35 | // NewWithConfig calls New with the given config. For documentation, see New. |
| 36 | func NewWithConfig(ctx context.Context, logger slog.Logger, cfg Config) (*tunnelsdk.Tunnel, error) { |
| 37 | u := &url.URL{ |
| 38 | Scheme: "https", |
| 39 | Host: cfg.Tunnel.HostnameHTTPS, |
| 40 | } |
| 41 | |
| 42 | c := tunnelsdk.New(u) |
| 43 | if cfg.HTTPClient != nil { |
| 44 | c.HTTPClient = cfg.HTTPClient |
| 45 | } |
| 46 | return c.LaunchTunnel(ctx, tunnelsdk.TunnelConfig{ |
| 47 | Log: logger, |
| 48 | Version: cfg.Version, |
| 49 | PrivateKey: tunnelsdk.FromNoisePrivateKey(cfg.PrivateKey), |
| 50 | }) |
| 51 | } |
| 52 | |
| 53 | // New creates a tunnel with a public URL and returns a listener for incoming |
| 54 | // connections on that URL. Connections are made over the wireguard protocol. |