diff --git a/go.mod b/go.mod index 5d098de2..92edf5c0 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/rs/cors v1.8.3 github.com/rs/xid v1.4.0 github.com/rs/zerolog v1.29.0 - github.com/sftpgo/sdk v0.1.3-0.20230212154322-556375985d8c + github.com/sftpgo/sdk v0.1.3-0.20230213120720-de3129520736 github.com/shirou/gopsutil/v3 v3.23.1 github.com/spf13/afero v1.9.3 github.com/spf13/cobra v1.6.1 diff --git a/go.sum b/go.sum index a38dd25a..ddc7faa8 100644 --- a/go.sum +++ b/go.sum @@ -1804,6 +1804,8 @@ github.com/sftpgo/sdk v0.1.3-0.20221217110036-383c1bb50fa0 h1:e1OQroqX8SWV06Z270 github.com/sftpgo/sdk v0.1.3-0.20221217110036-383c1bb50fa0/go.mod h1:3GpW3Qy8IHH6kex0ny+Y6ayeYb9OJxz8Pxh3IZgAs2E= github.com/sftpgo/sdk v0.1.3-0.20230212154322-556375985d8c h1:SiWQZe99SZ/O4QSIsxzL91NgwFJNoo4IJ31cazUrYh4= github.com/sftpgo/sdk v0.1.3-0.20230212154322-556375985d8c/go.mod h1:B1lPGb05WtvvrX5IuhHrSjWdRT867qBaoxlS2Q9+1bA= +github.com/sftpgo/sdk v0.1.3-0.20230213120720-de3129520736 h1:QFzoqYPIxuqDOe2NJfYI7J71bZrsfC0Aejc0ChblkcA= +github.com/sftpgo/sdk v0.1.3-0.20230213120720-de3129520736/go.mod h1:B1lPGb05WtvvrX5IuhHrSjWdRT867qBaoxlS2Q9+1bA= github.com/shirou/gopsutil/v3 v3.23.1 h1:a9KKO+kGLKEvcPIs4W62v0nu3sciVDOOOPUD0Hz7z/4= github.com/shirou/gopsutil/v3 v3.23.1/go.mod h1:NN6mnm5/0k8jw4cBfCnJtr5L7ErOTg18tMNpgFkn0hA= github.com/shoenig/test v0.4.3/go.mod h1:xYtyGBC5Q3kzCNyJg/SjgNpfAa2kvmgA0i5+lQso8x0= diff --git a/internal/common/common.go b/internal/common/common.go index d846ace3..37046ac8 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -317,7 +317,7 @@ func Reload() error { // IsBanned returns true if the specified IP address is banned func IsBanned(ip, protocol string) bool { - if plugin.Handler.IsIPBanned(ip) { + if plugin.Handler.IsIPBanned(ip, protocol) { return true } if Config.defender == nil { diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index 832931d2..ec337fc3 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -387,7 +387,7 @@ func (m *Manager) GetMetadataFolders(storageID, from string, limit int) ([]strin // IsIPBanned returns true if the IP filter plugin does not allow the specified ip. // If no IP filter plugin is defined this method returns false -func (m *Manager) IsIPBanned(ip string) bool { +func (m *Manager) IsIPBanned(ip, protocol string) bool { if !m.hasIPFilter { return false } @@ -401,7 +401,7 @@ func (m *Manager) IsIPBanned(ip string) bool { return false } - return plugin.filter.CheckIP(ip) != nil + return plugin.filter.CheckIP(ip, protocol) != nil } // ReloadFilter sends a reload request to the IP filter plugin diff --git a/tests/ipfilter/go.mod b/tests/ipfilter/go.mod index 72822662..c2d4b30c 100644 --- a/tests/ipfilter/go.mod +++ b/tests/ipfilter/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/hashicorp/go-plugin v1.4.8 - github.com/sftpgo/sdk v0.1.3-0.20230212154322-556375985d8c + github.com/sftpgo/sdk v0.1.3-0.20230213120720-de3129520736 ) require ( diff --git a/tests/ipfilter/go.sum b/tests/ipfilter/go.sum index c1c48a4f..ea977501 100644 --- a/tests/ipfilter/go.sum +++ b/tests/ipfilter/go.sum @@ -37,6 +37,8 @@ github.com/sftpgo/sdk v0.1.3-0.20221208080405-e682ae869318 h1:oDr2it5L9nh13+P3Bz github.com/sftpgo/sdk v0.1.3-0.20221208080405-e682ae869318/go.mod h1:3GpW3Qy8IHH6kex0ny+Y6ayeYb9OJxz8Pxh3IZgAs2E= github.com/sftpgo/sdk v0.1.3-0.20230212154322-556375985d8c h1:SiWQZe99SZ/O4QSIsxzL91NgwFJNoo4IJ31cazUrYh4= github.com/sftpgo/sdk v0.1.3-0.20230212154322-556375985d8c/go.mod h1:B1lPGb05WtvvrX5IuhHrSjWdRT867qBaoxlS2Q9+1bA= +github.com/sftpgo/sdk v0.1.3-0.20230213120720-de3129520736 h1:QFzoqYPIxuqDOe2NJfYI7J71bZrsfC0Aejc0ChblkcA= +github.com/sftpgo/sdk v0.1.3-0.20230213120720-de3129520736/go.mod h1:B1lPGb05WtvvrX5IuhHrSjWdRT867qBaoxlS2Q9+1bA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= diff --git a/tests/ipfilter/main.go b/tests/ipfilter/main.go index 1704a6d0..79d9a19d 100644 --- a/tests/ipfilter/main.go +++ b/tests/ipfilter/main.go @@ -9,7 +9,7 @@ import ( type Filter struct{} -func (f *Filter) CheckIP(ip string) error { +func (f *Filter) CheckIP(ip, protocol string) error { if ip == "192.168.1.12" { return fmt.Errorf("ip %q is not allowed", ip) }