2019-11-16 00:20:44 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package trust
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Rule indicates whether or not a Satellite URL is trusted.
|
2019-11-16 00:20:44 +00:00
|
|
|
type Rule interface {
|
|
|
|
// IsTrusted returns true if the given Satellite is trusted and false otherwise
|
|
|
|
IsTrusted(url SatelliteURL) bool
|
|
|
|
|
|
|
|
// String returns a string representation of the rule
|
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// Rules is a collection of rules.
|
2019-11-16 00:20:44 +00:00
|
|
|
type Rules []Rule
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// IsTrusted returns true if the given Satellite is trusted and false otherwise.
|
2019-11-16 00:20:44 +00:00
|
|
|
func (rules Rules) IsTrusted(url SatelliteURL) bool {
|
|
|
|
for _, rule := range rules {
|
|
|
|
if !rule.IsTrusted(url) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|