black lives matter

This commit is contained in:
genofire 2020-06-16 23:30:54 +02:00 committed by Julian Kornberger
parent e97e481516
commit aff906d734
6 changed files with 19 additions and 19 deletions

View File

@ -78,7 +78,7 @@ offline_after = "10m"
#no_owner = true #no_owner = true
# #
# List of nodeids of nodes that should be filtered out, so they won't appear in output # List of nodeids of nodes that should be filtered out, so they won't appear in output
#blacklist = ["00112233445566", "1337f0badead"] #blocklist = ["00112233445566", "1337f0badead"]
# #
# List of site_codes of nodes that should be included in the output # List of site_codes of nodes that should be included in the output
#sites = ["ffhb"] #sites = ["ffhb"]
@ -116,7 +116,7 @@ path = "/var/www/html/meshviewer/data/meshviewer.json"
[nodes.output.meshviewer-ffrgb.filter] [nodes.output.meshviewer-ffrgb.filter]
# WARNING: if it is not set, it will publish contact information of other persons # WARNING: if it is not set, it will publish contact information of other persons
no_owner = false no_owner = false
#blacklist = ["00112233445566", "1337f0badead"] #blocklist = ["00112233445566", "1337f0badead"]
#sites = ["ffhb"] #sites = ["ffhb"]
#has_location = true #has_location = true

View File

@ -282,7 +282,7 @@ It is possible to have multiple output for one type of output, just add this gro
enable = true enable = true
[nodes.output.example.filter] [nodes.output.example.filter]
no_owner = true no_owner = true
blacklist = ["00112233445566", "1337f0badead"] blocklist = ["00112233445566", "1337f0badead"]
sites = ["ffhb"] sites = ["ffhb"]
domain_as_site = true domain_as_site = true
domain_append_site = true domain_append_site = true
@ -311,7 +311,7 @@ For each output format there can be set different filters
```toml ```toml
[nodes.output.example.filter] [nodes.output.example.filter]
no_owner = true no_owner = true
blacklist = ["00112233445566", "1337f0badead"] blocklist = ["00112233445566", "1337f0badead"]
sites = ["ffhb"] sites = ["ffhb"]
has_location = true has_location = true
[nodes.output.example.filter.in_area] [nodes.output.example.filter.in_area]
@ -337,12 +337,12 @@ no_owner = true
{% endmethod %} {% endmethod %}
### blacklist ### blocklist
{% method %} {% method %}
List of nodeids of nodes that should be filtered out, so they won't appear in output List of nodeids of nodes that should be filtered out, so they won't appear in output
{% sample lang="toml" %} {% sample lang="toml" %}
```toml ```toml
blacklist = ["00112233445566", "1337f0badead"] blocklist = ["00112233445566", "1337f0badead"]
``` ```
{% endmethod %} {% endmethod %}
@ -448,7 +448,7 @@ enable = true
path = "/var/www/html/meshviewer/data/meshviewer.json" path = "/var/www/html/meshviewer/data/meshviewer.json"
#[nodes.output.meshviewer-ffrgb.filter] #[nodes.output.meshviewer-ffrgb.filter]
#no_owner = false #no_owner = false
#blacklist = ["00112233445566", "1337f0badead"] #blocklist = ["00112233445566", "1337f0badead"]
#has_location = true #has_location = true
#[nodes.output.meshviewer-ffrgb.filter.in_area] #[nodes.output.meshviewer-ffrgb.filter.in_area]

View File

@ -1,7 +1,7 @@
package all package all
import ( import (
_ "github.com/FreifunkBremen/yanic/output/filter/blacklist" _ "github.com/FreifunkBremen/yanic/output/filter/blocklist"
_ "github.com/FreifunkBremen/yanic/output/filter/domainappendsite" _ "github.com/FreifunkBremen/yanic/output/filter/domainappendsite"
_ "github.com/FreifunkBremen/yanic/output/filter/domainassite" _ "github.com/FreifunkBremen/yanic/output/filter/domainassite"
_ "github.com/FreifunkBremen/yanic/output/filter/haslocation" _ "github.com/FreifunkBremen/yanic/output/filter/haslocation"

View File

@ -112,7 +112,7 @@ func TestStart(t *testing.T) {
map[string]interface{}{ map[string]interface{}{
"enable": true, "enable": true,
"filter": map[string]interface{}{ "filter": map[string]interface{}{
"blacklist": true, "blocklist": true,
}, },
}, },
}, },

View File

@ -1,4 +1,4 @@
package blacklist package blocklist
import ( import (
"errors" "errors"
@ -7,10 +7,10 @@ import (
"github.com/FreifunkBremen/yanic/runtime" "github.com/FreifunkBremen/yanic/runtime"
) )
type blacklist map[string]interface{} type blocklist map[string]interface{}
func init() { func init() {
filter.Register("blacklist", build) filter.Register("blocklist", build)
} }
func build(config interface{}) (filter.Filter, error) { func build(config interface{}) (filter.Filter, error) {
@ -19,7 +19,7 @@ func build(config interface{}) (filter.Filter, error) {
return nil, errors.New("invalid configuration, array (of strings) expected") return nil, errors.New("invalid configuration, array (of strings) expected")
} }
list := make(blacklist) list := make(blocklist)
for _, value := range values { for _, value := range values {
if nodeid, ok := value.(string); ok { if nodeid, ok := value.(string); ok {
list[nodeid] = struct{}{} list[nodeid] = struct{}{}
@ -30,7 +30,7 @@ func build(config interface{}) (filter.Filter, error) {
return &list, nil return &list, nil
} }
func (list blacklist) Apply(node *runtime.Node) *runtime.Node { func (list blocklist) Apply(node *runtime.Node) *runtime.Node {
if nodeinfo := node.Nodeinfo; nodeinfo != nil { if nodeinfo := node.Nodeinfo; nodeinfo != nil {
if _, ok := list[nodeinfo.NodeID]; ok { if _, ok := list[nodeinfo.NodeID]; ok {
return nil return nil

View File

@ -1,4 +1,4 @@
package blacklist package blocklist
import ( import (
"testing" "testing"
@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestFilterBlacklist(t *testing.T) { func TestFilterBlocklist(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
// invalid config // invalid config
@ -26,15 +26,15 @@ func TestFilterBlacklist(t *testing.T) {
n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) n := filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.NotNil(n) assert.NotNil(n)
// tests with blacklist // tests with blocklist
filter, err = build([]interface{}{"a", "c"}) filter, err = build([]interface{}{"a", "c"})
assert.NoError(err) assert.NoError(err)
// blacklist contains node with nodeid -> drop it // blocklist contains node with nodeid -> drop it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{NodeID: "a"}}) n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{NodeID: "a"}})
assert.Nil(n) assert.Nil(n)
// blacklist does not contains node without nodeid -> keep it // blocklist does not contains node without nodeid -> keep it
n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}}) n = filter.Apply(&runtime.Node{Nodeinfo: &data.Nodeinfo{}})
assert.NotNil(n) assert.NotNil(n)