-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathbans.go
47 lines (39 loc) · 1.35 KB
/
bans.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cmd
import (
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/supabase/cli/internal/bans/get"
"github.com/supabase/cli/internal/bans/update"
"github.com/supabase/cli/internal/utils/flags"
)
var (
bansCmd = &cobra.Command{
GroupID: groupManagementAPI,
Use: "network-bans",
Short: "Manage network bans",
Long: `Network bans are IPs that get temporarily blocked if their traffic pattern looks abusive (e.g. multiple failed auth attempts).
The subcommands help you view the current bans, and unblock IPs if desired.`,
}
dbIpsToUnban []string
bansRemoveCmd = &cobra.Command{
Use: "remove",
Short: "Remove a network ban",
RunE: func(cmd *cobra.Command, args []string) error {
return update.Run(cmd.Context(), flags.ProjectRef, dbIpsToUnban, afero.NewOsFs())
},
}
bansGetCmd = &cobra.Command{
Use: "get",
Short: "Get the current network bans",
RunE: func(cmd *cobra.Command, args []string) error {
return get.Run(cmd.Context(), flags.ProjectRef, afero.NewOsFs())
},
}
)
func init() {
bansCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
bansCmd.AddCommand(bansGetCmd)
bansRemoveCmd.Flags().StringSliceVar(&dbIpsToUnban, "db-unban-ip", []string{}, "IP to allow DB connections from.")
bansCmd.AddCommand(bansRemoveCmd)
rootCmd.AddCommand(bansCmd)
}