sftpgo/tests/ipfilter/main.go
Nicola Murino 2df2803a37
ipfilter plugin: add protocol
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
2023-02-13 13:45:45 +01:00

32 lines
563 B
Go

package main
import (
"fmt"
"github.com/hashicorp/go-plugin"
"github.com/sftpgo/sdk/plugin/ipfilter"
)
type Filter struct{}
func (f *Filter) CheckIP(ip, protocol string) error {
if ip == "192.168.1.12" {
return fmt.Errorf("ip %q is not allowed", ip)
}
return nil
}
func (f *Filter) Reload() error {
return nil
}
func main() {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: ipfilter.Handshake,
Plugins: map[string]plugin.Plugin{
ipfilter.PluginName: &ipfilter.Plugin{Impl: &Filter{}},
},
GRPCServer: plugin.DefaultGRPCServer,
})
}