Unverified Commit 480780ec authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #6362 from ipfs/ci/really-enable-lint

ci: actually enable golangci-lint
parents cf3b6c43 c39ad0b8
......@@ -120,5 +120,6 @@ workflows:
test:
jobs:
- gobuild
- golint
- gotest
- sharness
......@@ -494,15 +494,15 @@ Different key types can specify other 'best' rules.
pfm := pfuncMap{
notif.Value: func(obj *notif.QueryEvent, out io.Writer, verbose bool) error {
if verbose {
fmt.Fprintf(out, "got value: '%s'\n", obj.Extra)
} else {
res, err := base64.StdEncoding.DecodeString(obj.Extra)
if err != nil {
return err
}
out.Write(res)
_, err := fmt.Fprintf(out, "got value: '%s'\n", obj.Extra)
return err
}
return nil
res, err := base64.StdEncoding.DecodeString(obj.Extra)
if err != nil {
return err
}
_, err = out.Write(res)
return err
},
}
......
......@@ -22,9 +22,10 @@ import (
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
swarm "github.com/libp2p/go-libp2p-swarm"
mafilter "github.com/libp2p/go-maddr-filter"
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"
mafilter "github.com/whyrusleeping/multiaddr-filter"
mamask "github.com/whyrusleeping/multiaddr-filter"
)
const (
......@@ -599,8 +600,8 @@ Filters default to those specified under the "Swarm.AddrFilters" config key.
}
var output []string
for _, f := range swrm.Filters.Filters() {
s, err := mafilter.ConvertIPNet(f)
for _, f := range swrm.Filters.FiltersForAction(mafilter.ActionDeny) {
s, err := mamask.ConvertIPNet(&f)
if err != nil {
return err
}
......@@ -657,12 +658,12 @@ add your filters to the ipfs config file.
}
for _, arg := range req.Arguments {
mask, err := mafilter.NewMask(arg)
mask, err := mamask.NewMask(arg)
if err != nil {
return err
}
swrm.Filters.AddDialFilter(mask)
swrm.Filters.AddFilter(*mask, mafilter.ActionDeny)
}
added, err := filtersAdd(r, cfg, req.Arguments)
......@@ -716,9 +717,9 @@ remove your filters from the ipfs config file.
}
if req.Arguments[0] == "all" || req.Arguments[0] == "*" {
fs := swrm.Filters.Filters()
fs := swrm.Filters.FiltersForAction(mafilter.ActionDeny)
for _, f := range fs {
swrm.Filters.Remove(f)
swrm.Filters.RemoveLiteral(f)
}
removed, err := filtersRemoveAll(r, cfg)
......@@ -730,12 +731,12 @@ remove your filters from the ipfs config file.
}
for _, arg := range req.Arguments {
mask, err := mafilter.NewMask(arg)
mask, err := mamask.NewMask(arg)
if err != nil {
return err
}
swrm.Filters.Remove(mask)
swrm.Filters.RemoveLiteral(*mask)
}
removed, err := filtersRemove(r, cfg, req.Arguments)
......
......@@ -39,7 +39,7 @@ func makeAddrsFactory(announce []string, noAnnounce []string) (p2pbhost.AddrsFac
for _, addr := range noAnnounce {
f, err := mamask.NewMask(addr)
if err == nil {
filters.AddDialFilter(f)
filters.AddFilter(*f, mafilter.ActionDeny)
continue
}
maddr, err := ma.NewMultiaddr(addr)
......
......@@ -16,17 +16,17 @@ func TestResolveNoComponents(t *testing.T) {
}
_, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipns/"))
if err != path.ErrNoComponents {
t.Fatal("Should error with no components (/ipns/).", err)
if err.Error() != "invalid path \"/ipns/\": ipns path missing IPNS ID" {
t.Error("Should error with no components (/ipns/).", err)
}
_, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipfs/"))
if err != path.ErrNoComponents {
t.Fatal("Should error with no components (/ipfs/).", err)
if err.Error() != "invalid path \"/ipfs/\": not enough path components" {
t.Error("Should error with no components (/ipfs/).", err)
}
_, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/../.."))
if err != path.ErrBadPath {
t.Fatal("Should error with invalid path.", err)
if err.Error() != "invalid path \"/../..\": unknown namespace \"..\"" {
t.Error("Should error with invalid path.", err)
}
}
......@@ -14,7 +14,7 @@ import (
$shortpkg "$pkg"
)
var Plugins = $shortpkg.Plugins
var Plugins = $shortpkg.Plugins //nolint
func main() {
panic("this is a plugin, build it as a plugin, this is here as for go#20312")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment