|
|
@@ -251,6 +251,8 @@ type EtcdServer struct {
|
|
|
|
|
|
leadTimeMu sync.RWMutex
|
|
|
leadElectedTime time.Time
|
|
|
+
|
|
|
+ hostWhitelist map[string]struct{}
|
|
|
}
|
|
|
|
|
|
// NewServer creates a new EtcdServer from the supplied configuration. The
|
|
|
@@ -434,6 +436,7 @@ func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
|
|
|
peerRt: prt,
|
|
|
reqIDGen: idutil.NewGenerator(uint16(id), time.Now()),
|
|
|
forceVersionC: make(chan struct{}),
|
|
|
+ hostWhitelist: cfg.HostWhitelist,
|
|
|
}
|
|
|
|
|
|
srv.applyV2 = &applierV2store{store: srv.v2store, cluster: srv.cluster}
|
|
|
@@ -626,6 +629,16 @@ func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) {
|
|
|
s.r.ReportSnapshot(id, status)
|
|
|
}
|
|
|
|
|
|
+// IsHostWhitelisted returns true if the host is whitelisted.
|
|
|
+// If whitelist is empty, allow all.
|
|
|
+func (s *EtcdServer) IsHostWhitelisted(host string) bool {
|
|
|
+ if len(s.hostWhitelist) == 0 { // allow all
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ _, ok := s.hostWhitelist[host]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
type etcdProgress struct {
|
|
|
confState raftpb.ConfState
|
|
|
snapi uint64
|