storage: Check allowlists in StorageFindSector
This commit is contained in:
parent
5c77c25747
commit
8b548ac02f
32
extern/sector-storage/stores/index.go
vendored
32
extern/sector-storage/stores/index.go
vendored
@ -29,6 +29,8 @@ var SkippedHeartbeatThresh = HeartbeatInterval * 5
|
|||||||
// filesystem, local or networked / shared by multiple machines
|
// filesystem, local or networked / shared by multiple machines
|
||||||
type ID string
|
type ID string
|
||||||
|
|
||||||
|
type Group = string
|
||||||
|
|
||||||
type StorageInfo struct {
|
type StorageInfo struct {
|
||||||
ID ID
|
ID ID
|
||||||
URLs []string // TODO: Support non-http transports
|
URLs []string // TODO: Support non-http transports
|
||||||
@ -38,8 +40,8 @@ type StorageInfo struct {
|
|||||||
CanSeal bool
|
CanSeal bool
|
||||||
CanStore bool
|
CanStore bool
|
||||||
|
|
||||||
Groups []string
|
Groups []Group
|
||||||
AllowTo []string
|
AllowTo []Group
|
||||||
}
|
}
|
||||||
|
|
||||||
type HealthReport struct {
|
type HealthReport struct {
|
||||||
@ -297,6 +299,8 @@ func (i *Index) StorageFindSector(ctx context.Context, s abi.SectorID, ft storif
|
|||||||
storageIDs := map[ID]uint64{}
|
storageIDs := map[ID]uint64{}
|
||||||
isprimary := map[ID]bool{}
|
isprimary := map[ID]bool{}
|
||||||
|
|
||||||
|
allowTo := map[Group]struct{}{}
|
||||||
|
|
||||||
for _, pathType := range storiface.PathTypes {
|
for _, pathType := range storiface.PathTypes {
|
||||||
if ft&pathType == 0 {
|
if ft&pathType == 0 {
|
||||||
continue
|
continue
|
||||||
@ -328,6 +332,14 @@ func (i *Index) StorageFindSector(ctx context.Context, s abi.SectorID, ft storif
|
|||||||
urls[k] = rl.String()
|
urls[k] = rl.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if allowTo != nil && len(st.info.AllowTo) > 0 {
|
||||||
|
for _, group := range st.info.AllowTo {
|
||||||
|
allowTo[group] = struct{}{}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allowTo = nil // allow to any
|
||||||
|
}
|
||||||
|
|
||||||
out = append(out, SectorStorageInfo{
|
out = append(out, SectorStorageInfo{
|
||||||
ID: id,
|
ID: id,
|
||||||
URLs: urls,
|
URLs: urls,
|
||||||
@ -370,6 +382,22 @@ func (i *Index) StorageFindSector(ctx context.Context, s abi.SectorID, ft storif
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if allowTo != nil {
|
||||||
|
allow := false
|
||||||
|
for _, group := range st.info.Groups {
|
||||||
|
if _, found := allowTo[group]; found {
|
||||||
|
log.Debugf("path %s in allowed group %s", st.info.ID, group)
|
||||||
|
allow = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !allow {
|
||||||
|
log.Debugf("not selecting on %s, not in allowed group, allow %#v; path has %#v", st.info.ID, allowTo, st.info.Groups)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
urls := make([]string, len(st.info.URLs))
|
urls := make([]string, len(st.info.URLs))
|
||||||
for k, u := range st.info.URLs {
|
for k, u := range st.info.URLs {
|
||||||
rl, err := url.Parse(u)
|
rl, err := url.Parse(u)
|
||||||
|
Loading…
Reference in New Issue
Block a user