diff --git a/go.mod b/go.mod index 5d098de2fec67cdff892ce5c49ab82d8329b0fdf..92edf5c0b7035c43284d5dd75b5fbb43a5b7b943 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 a38dd25a89a29cb459888bcd9117fce5ab80a901..ddc7faa896a6e164427634c1983a674cf5d040cb 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 d846ace34a813cabffecc0e042e969eff705d6f0..37046ac87f1112b640e48b40e63f495109128057 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 832931d2a61b85fc202d6503f27a471b44cfccc8..ec337fc39850c63fbd4f406b9cf6105416cf8729 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 728226629dc71641165351ad42064756d187a6fd..c2d4b30ca1be59b960be1f95f46afd3c1104bae8 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 c1c48a4f80e64ce70cf0f62e106a6a2304b29809..ea9775013cb289a9c3adf0246d18745632410495 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 1704a6d076e00feed596866077d6a54e9daf4c9a..79d9a19da01c3ebc1c583db716e47087830286cb 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) }