defaultScheme based on tls

release-0.4
Xiang Li 2013-08-10 17:49:30 -07:00
parent 84624f1ec0
commit 6610fc39cc
1 changed files with 22 additions and 12 deletions

34
etcd.go
View File

@ -199,6 +199,26 @@ func main() {
cluster = strings.Split(string(b), ",")
}
raftTlsConfs, ok := tlsConf(RaftServer)
if !ok {
fatal("Please specify cert and key file or cert and key file and CAFile or none of the three")
}
raftDefaultScheme := "http"
if raftTlsConfs[0] != nil {
raftDefaultScheme = "https"
}
etcdTlsConfs, ok := tlsConf(EtcdServer)
if !ok {
fatal("Please specify cert and key file or cert and key file and CAFile or none of the three")
}
etcdDefaultScheme := "http"
if etcdTlsConfs[0] != nil {
raftDefaultScheme = "https"
}
// Otherwise ask user for info and write it to file.
argInfo.Name = strings.TrimSpace(argInfo.Name)
@ -206,8 +226,8 @@ func main() {
fatal("ERROR: server name required. e.g. '-n=server_name'")
}
argInfo.RaftURL = checkURL(argInfo.RaftURL, "http")
argInfo.EtcdURL = checkURL(argInfo.EtcdURL, "http")
argInfo.RaftURL = checkURL(argInfo.RaftURL, raftDefaultScheme)
argInfo.EtcdURL = checkURL(argInfo.EtcdURL, etcdDefaultScheme)
// Setup commands.
registerCommands()
@ -219,16 +239,6 @@ func main() {
info = getInfo(dirPath)
raftTlsConfs, ok := tlsConf(RaftServer)
if !ok {
fatal("Please specify cert and key file or cert and key file and CAFile or none of the three")
}
etcdTlsConfs, ok := tlsConf(EtcdServer)
if !ok {
fatal("Please specify cert and key file or cert and key file and CAFile or none of the three")
}
// Create etcd key-value store
etcdStore = store.CreateStore(maxSize)