mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-23 00:23:36 +01:00
23 lines
455 B
Go
23 lines
455 B
Go
|
package grpc
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"net"
|
||
|
|
||
|
log "github.com/sirupsen/logrus"
|
||
|
"google.golang.org/grpc"
|
||
|
|
||
|
nbnet "github.com/netbirdio/netbird/util/net"
|
||
|
)
|
||
|
|
||
|
func WithCustomDialer() grpc.DialOption {
|
||
|
return grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||
|
conn, err := nbnet.NewDialer().DialContext(ctx, "tcp", addr)
|
||
|
if err != nil {
|
||
|
log.Errorf("Failed to dial: %s", err)
|
||
|
return nil, err
|
||
|
}
|
||
|
return conn, nil
|
||
|
})
|
||
|
}
|