mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
AB#2286 Return only primary IPs for instance metadata operations (#335)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
5c00dafe9b
commit
4151d365fb
21 changed files with 180 additions and 185 deletions
|
@ -73,16 +73,14 @@ func (s *Server) listSelf(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
for _, peer := range peers {
|
||||
for _, ip := range peer.PublicIPs {
|
||||
if ip == remoteIP {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if err := json.NewEncoder(w).Encode(peer); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
log.Infof("Request successful")
|
||||
if peer.PublicIP == remoteIP {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if err := json.NewEncoder(w).Encode(peer); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
log.Infof("Request successful")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +176,7 @@ func (s *Server) exportPCRs(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
for _, peer := range peers {
|
||||
if peer.PublicIPs[0] == remoteIP {
|
||||
if peer.PublicIP == remoteIP {
|
||||
nodeName = peer.Name
|
||||
}
|
||||
}
|
||||
|
@ -225,8 +223,8 @@ func (s *Server) listAll() ([]metadata.InstanceMetadata, error) {
|
|||
peers = append(peers, metadata.InstanceMetadata{
|
||||
Name: lease.Hostname,
|
||||
Role: instanceRole,
|
||||
PrivateIPs: []string{lease.IPaddr},
|
||||
PublicIPs: []string{lease.IPaddr},
|
||||
VPCIP: lease.IPaddr,
|
||||
PublicIP: lease.IPaddr,
|
||||
ProviderID: "qemu:///hostname/" + lease.Hostname,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue