|
|
@@ -19,6 +19,7 @@ import (
|
|
|
"github.com/coreos/etcd/raft"
|
|
|
"github.com/coreos/etcd/snap"
|
|
|
"github.com/coreos/etcd/store"
|
|
|
+ "github.com/coreos/etcd/transport"
|
|
|
"github.com/coreos/etcd/wal"
|
|
|
)
|
|
|
|
|
|
@@ -48,6 +49,8 @@ var (
|
|
|
proxyFlagValueReadonly,
|
|
|
proxyFlagValueOn,
|
|
|
}
|
|
|
+
|
|
|
+ clientTLSInfo = transport.TLSInfo{}
|
|
|
)
|
|
|
|
|
|
func init() {
|
|
|
@@ -58,6 +61,10 @@ func init() {
|
|
|
peers.Set("0x1=localhost:8080")
|
|
|
addrs.Set("127.0.0.1:4001")
|
|
|
proxyFlag.Set(proxyFlagValueOff)
|
|
|
+
|
|
|
+ flag.StringVar(&clientTLSInfo.CAFile, "ca-file", "", "Path to the client server TLS CA file.")
|
|
|
+ flag.StringVar(&clientTLSInfo.CertFile, "cert-file", "", "Path to the client server TLS cert file.")
|
|
|
+ flag.StringVar(&clientTLSInfo.KeyFile, "key-file", "", "Path to the client server TLS key file.")
|
|
|
}
|
|
|
|
|
|
func main() {
|
|
|
@@ -167,18 +174,28 @@ func startEtcd() {
|
|
|
Info: cors,
|
|
|
}
|
|
|
|
|
|
+ l, err := transport.NewListener(*paddr, transport.TLSInfo{})
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
// Start the peer server in a goroutine
|
|
|
go func() {
|
|
|
log.Print("Listening for peers on ", *paddr)
|
|
|
- log.Fatal(http.ListenAndServe(*paddr, ph))
|
|
|
+ log.Fatal(http.Serve(l, ph))
|
|
|
}()
|
|
|
|
|
|
// Start a client server goroutine for each listen address
|
|
|
for _, addr := range *addrs {
|
|
|
addr := addr
|
|
|
+ l, err := transport.NewListener(addr, clientTLSInfo)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
go func() {
|
|
|
log.Print("Listening for client requests on ", addr)
|
|
|
- log.Fatal(http.ListenAndServe(addr, ch))
|
|
|
+ log.Fatal(http.Serve(l, ch))
|
|
|
}()
|
|
|
}
|
|
|
}
|
|
|
@@ -201,9 +218,14 @@ func startProxy() {
|
|
|
// Start a proxy server goroutine for each listen address
|
|
|
for _, addr := range *addrs {
|
|
|
addr := addr
|
|
|
+ l, err := transport.NewListener(addr, clientTLSInfo)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
go func() {
|
|
|
log.Print("Listening for client requests on ", addr)
|
|
|
- log.Fatal(http.ListenAndServe(addr, ph))
|
|
|
+ log.Fatal(http.Serve(l, ph))
|
|
|
}()
|
|
|
}
|
|
|
}
|