New creates a tunnel with a public URL and returns a listener for incoming connections on that URL. Connections are made over the wireguard protocol. Tunnel configuration is cached in the user's config directory. Successive calls to New will always use the same URL. If multiple public URLs in parall
(ctx context.Context, logger slog.Logger, customTunnelHost string)
| 59 | // This uses https://github.com/coder/wgtunnel as the server and client |
| 60 | // implementation. |
| 61 | func New(ctx context.Context, logger slog.Logger, customTunnelHost string) (*tunnelsdk.Tunnel, error) { |
| 62 | cfg, err := readOrGenerateConfig(customTunnelHost) |
| 63 | if err != nil { |
| 64 | return nil, xerrors.Errorf("read or generate config: %w", err) |
| 65 | } |
| 66 | |
| 67 | return NewWithConfig(ctx, logger, cfg) |
| 68 | } |
| 69 | |
| 70 | func cfgPath() (string, error) { |
| 71 | cfgDir, err := os.UserConfigDir() |
no test coverage detected