diff --git a/fastdialer/dialer.go b/fastdialer/dialer.go index e11ed83..8967cd1 100644 --- a/fastdialer/dialer.go +++ b/fastdialer/dialer.go @@ -240,9 +240,15 @@ func (d *Dialer) dial(ctx context.Context, network, address string, shouldUseTLS for _, ip := range IPS { // check if we have allow/deny list if !d.networkpolicy.Validate(ip) { + if d.options.OnInvalidTarget != nil { + d.options.OnInvalidTarget(hostname, ip, port) + } numInvalidIPS++ continue } + if d.options.OnBeforeDial != nil { + d.options.OnBeforeDial(hostname, ip, port) + } hostPort := net.JoinHostPort(ip, port) if shouldUseTLS { tlsconfigCopy := tlsconfig.Clone() diff --git a/fastdialer/options.go b/fastdialer/options.go index 88c7095..73b6f05 100644 --- a/fastdialer/options.go +++ b/fastdialer/options.go @@ -55,6 +55,8 @@ type Options struct { ProxyDialer *proxy.Dialer WithZTLS bool SNIName string + OnBeforeDial func(hostname, IP, port string) + OnInvalidTarget func(hostname, IP, port string) OnDialCallback func(hostname, IP string) DisableZtlsFallback bool WithNetworkPolicyOptions *networkpolicy.Options