本文整理匯總了Golang中github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/etcd/pkg/transport.TLSInfo.Empty方法的典型用法代碼示例。如果您正苦於以下問題:Golang TLSInfo.Empty方法的具體用法?Golang TLSInfo.Empty怎麽用?Golang TLSInfo.Empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/flannel/Godeps/_workspace/src/github.com/coreos/etcd/pkg/transport.TLSInfo
的用法示例。
在下文中一共展示了TLSInfo.Empty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}