tls-client icon indicating copy to clipboard operation
tls-client copied to clipboard

[Feature Request]: Setting custom Dial function

Open plzcloseyoureyes opened this issue 2 months ago • 2 comments

Describe the feature / enhancement and how it would improve things

Inspiration is from imroc/req: https://pkg.go.dev/github.com/imroc/req/v3#Client.SetDial

Describe how your proposal will work, with code and/or pseudo-code

package main

import (
	"context"
	"net"

	"github.com/imroc/req/v3"
)

func main() {

	reqC := req.C()
	reqC.SetDial(func(ctx context.Context, network string, addr string) (net.Conn, error) {
		return net.Dial(network, addr)
	})
}

This could be used for custom proxy handling, or other advanced options before establshing the connections.

plzcloseyoureyes avatar Oct 05 '25 04:10 plzcloseyoureyes

@l10r There is the WithDialer Option: https://github.com/bogdanfinn/tls-client/blob/master/client_options.go#L124

bogdanfinn avatar Oct 06 '25 06:10 bogdanfinn

It would be nice if it came with more control, like an actual way to return the net.Conn, like imroc/req api, because to be honest I have no clue how to set a net.Dialer that does something like that. Couldn't get it done with LLMs aswell

plzcloseyoureyes avatar Oct 09 '25 03:10 plzcloseyoureyes