mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
34 lines
680 B
Go
34 lines
680 B
Go
package endpoints
|
|
|
|
// Reason describes the reason why an endpoint has been
|
|
// permitted or blocked.
|
|
type Reason interface {
|
|
// String should return a human readable string
|
|
// describing the decision reason.
|
|
String() string
|
|
|
|
// Context returns the context that was used
|
|
// for the decision.
|
|
Context() interface{}
|
|
}
|
|
|
|
type reason struct {
|
|
description string
|
|
Filter string
|
|
Value string
|
|
Permitted bool
|
|
Extra map[string]interface{}
|
|
}
|
|
|
|
func (r *reason) String() string {
|
|
prefix := "denied by rule: "
|
|
if r.Permitted {
|
|
prefix = "allowed by rule: "
|
|
}
|
|
|
|
return prefix + r.description + " " + r.Value
|
|
}
|
|
|
|
func (r *reason) Context() interface{} {
|
|
return r
|
|
}
|