本文整理汇总了Golang中github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/etcd/pkg/transport.TLSInfo类的典型用法代码示例。如果您正苦于以下问题:Golang TLSInfo类的具体用法?Golang TLSInfo怎么用?Golang TLSInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TLSInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewTransport
func NewTransport(info transport.TLSInfo) (*Transport, error) {
cfg, err := info.ClientConfig()
if err != nil {
return nil, err
}
t := &Transport{
// timeouts taken from http.DefaultTransport
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
TLSClientConfig: cfg,
}
return t, nil
}
示例2: listener
func listener(addr, cafile, certfile, keyfile string) (net.Listener, error) {
rex := regexp.MustCompile("(?:([a-z]+)://)?(.*)")
groups := rex.FindStringSubmatch(addr)
var l net.Listener
var err error
switch {
case groups == nil:
return nil, fmt.Errorf("bad listener address")
case groups[1] == "", groups[1] == "tcp":
if l, err = net.Listen("tcp", groups[2]); err != nil {
return nil, err
}
case groups[1] == "fd":
if l, err = fdListener(groups[2]); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("bad listener scheme")
}
tlsinfo := transport.TLSInfo{
CAFile: cafile,
CertFile: certfile,
KeyFile: keyfile,
}
if !tlsinfo.Empty() {
cfg, err := tlsinfo.ServerConfig()
if err != nil {
return nil, err
}
l = tls.NewListener(l, cfg)
}
return l, nil
}
示例3: NewRemoteManager
func NewRemoteManager(listenAddr, cafile, certfile, keyfile string) (subnet.Manager, error) {
tls := transport.TLSInfo{
CAFile: cafile,
CertFile: certfile,
KeyFile: keyfile,
}
t, err := NewTransport(tls)
if err != nil {
return nil, err
}
var scheme string
if tls.Empty() && tls.CAFile == "" {
scheme = "http://"
} else {
scheme = "https://"
}
return &RemoteManager{
base: scheme + listenAddr + "/v1",
transport: t,
}, nil
}