mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
44 lines
969 B
Go
44 lines
969 B
Go
package endpoints
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/safing/portmaster/intel"
|
|
)
|
|
|
|
// EndpointLists matches endpoint lists.
|
|
type EndpointLists struct {
|
|
EndpointBase
|
|
|
|
ListSet []string
|
|
Lists string
|
|
}
|
|
|
|
// Matches checks whether the given entity matches this endpoint definition.
|
|
func (ep *EndpointLists) Matches(entity *intel.Entity) (EPResult, Reason) {
|
|
if !entity.LoadLists() {
|
|
return Undeterminable, nil
|
|
}
|
|
|
|
if entity.MatchLists(ep.ListSet) {
|
|
return ep.match(ep, entity, ep.Lists, "filterlist contains", "filterlist", entity.ListBlockReason())
|
|
}
|
|
|
|
return NoMatch, nil
|
|
}
|
|
|
|
func (ep *EndpointLists) String() string {
|
|
return ep.renderPPP(ep.Lists)
|
|
}
|
|
|
|
func parseTypeList(fields []string) (Endpoint, error) {
|
|
if strings.HasPrefix(fields[1], "L:") {
|
|
lists := strings.Split(strings.TrimPrefix(fields[1], "L:"), ",")
|
|
ep := &EndpointLists{
|
|
ListSet: lists,
|
|
Lists: "L:" + strings.Join(lists, ","),
|
|
}
|
|
return ep.parsePPP(ep, fields)
|
|
}
|
|
return nil, nil
|
|
}
|