func DialOptionsFromConfig(cfg *atlas.Config) ([]grpc.DialOption, error) {
	opts := []grpc.DialOption{}
	if cfg.TLSClientCertificate != "" {
		logrus.WithField("cert", cfg.TLSClientCertificate)
		var creds credentials.TransportCredentials
		if cfg.TLSClientKey != "" {
			logrus.WithField("key", cfg.TLSClientKey)
			cert, err := tls.LoadX509KeyPair(cfg.TLSClientCertificate, cfg.TLSClientKey)
			if err != nil {
				return nil, err
			}
			creds = credentials.NewTLS(&tls.Config{
				Certificates:       []tls.Certificate{cert},
				InsecureSkipVerify: cfg.TLSInsecureSkipVerify,
			})
		} else {
			c, err := credentials.NewClientTLSFromFile(cfg.TLSClientCertificate, "")
			if err != nil {
				return nil, err
			}
			creds = c
		}
		opts = append(opts, grpc.WithTransportCredentials(creds))
	} else {
		opts = append(opts, grpc.WithInsecure())
	}
	return opts, nil
}
DialOptionsFromConfig returns dial options configured from a Stellar config
package client
import (
	"context"
	"crypto/tls"
	"net"
	"net/url"
	"time"
	"github.com/sirupsen/logrus"
	"github.com/stellarproject/atlas"
	api "github.com/stellarproject/atlas/api/services/nameserver/v1"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
)
type Client struct {
	conn              *grpc.ClientConn
	nameserverService api.NameserverClient
}
func NewClient(addr string, opts ...grpc.DialOption) (*Client, error) {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
	defer cancel()
	if len(opts) == 0 {
		opts = []grpc.DialOption{
			grpc.WithInsecure(),
			grpc.WithBlock(),
		}
	}
	u, err := url.Parse(addr)
	if err != nil {
		return nil, err
	}
	endpoint := u.Host
	if u.Scheme == "unix" {
		endpoint = u.Path
		opts = append(opts, grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
			return net.DialTimeout("unix", addr, timeout)
		}))
	}
	opts = append(opts, grpc.WithDefaultCallOptions(
		grpc.WaitForReady(true),
	))
	c, err := grpc.DialContext(ctx,
		endpoint,
		opts...,
	)
	if err != nil {
		return nil, err
	}
	client := &Client{
		conn:              c,
		nameserverService: api.NewNameserverClient(c),
	}
	return client, nil
}
func (c *Client) Conn() *grpc.ClientConn {
	return c.conn
}
func (c *Client) Close() error {
	return c.conn.Close()
}