go-zookeeper / zk

Native ZooKeeper client for Go
BSD 3-Clause "New" or "Revised" License
504 stars 130 forks source link

TLS dialer #106

Open munakoiso opened 1 year ago

munakoiso commented 1 year ago

Hello.

Here is an implementation of a dialer using tls connect. Also I have added a function which returns a simple tls.Config. This is probably the most common way to create it, so I decided to put it in this library.

I think it might be useful.

Usage example:

    tlsConfig, err := zk.CreateTLSConfig(rootCAFile, crtFile, keyFile)
    if err != nil {
        fmt.Println(err)
        return
    }
    timeout := 1 * time.Second
    baseDialer := net.Dialer{Timeout: timeout}
    dialer, err := zk.GetTLSDialer([]string{"hostname:2281"}, &baseDialer, tlsConfig)
    if err != nil {
        fmt.Println(err)
        return
    }
    conn, _, err := zk.Connect([]string{"hostname:2281"}, timeout, zk.WithDialer(dialer))
munakoiso commented 1 year ago

Hi, @nemith . Can you review this PR please?

nemith commented 1 year ago

I am not longer a maintainer on this project

munakoiso commented 1 year ago

@nemith Oh, sorry, but I can't find any information about maintainers here. Maybe you can tell me who are maintainers?