2022-03-23 10:58:01 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/go-plugin"
|
|
|
|
|
"github.com/sftpgo/sdk/plugin/ipfilter"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Filter struct{}
|
|
|
|
|
|
2023-02-13 13:45:45 +01:00
|
|
|
func (f *Filter) CheckIP(ip, protocol string) error {
|
2022-03-23 10:58:01 +01:00
|
|
|
if ip == "192.168.1.12" {
|
2023-02-13 12:58:21 +01:00
|
|
|
return fmt.Errorf("ip %q is not allowed", ip)
|
2022-03-23 10:58:01 +01:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 10:21:13 +01:00
|
|
|
func (f *Filter) Reload() error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-23 10:58:01 +01:00
|
|
|
func main() {
|
|
|
|
|
plugin.Serve(&plugin.ServeConfig{
|
|
|
|
|
HandshakeConfig: ipfilter.Handshake,
|
|
|
|
|
Plugins: map[string]plugin.Plugin{
|
|
|
|
|
ipfilter.PluginName: &ipfilter.Plugin{Impl: &Filter{}},
|
|
|
|
|
},
|
|
|
|
|
GRPCServer: plugin.DefaultGRPCServer,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|