asn blocking!!!!!
This commit is contained in:
@@ -24,10 +24,11 @@ type Config struct {
|
||||
|
||||
DatabasePath string
|
||||
// public host like "https://bin.zip", NOT the address minbin listens on
|
||||
Host string
|
||||
Addr string
|
||||
IPAdressSource string
|
||||
TrustedProxies []netip.Prefix
|
||||
Host string
|
||||
Addr string
|
||||
IPAdressSource string
|
||||
TrustedProxies []netip.Prefix
|
||||
BannedClientASNs map[uint32]struct{}
|
||||
}
|
||||
|
||||
func LoadConfig() (Config, error) {
|
||||
@@ -89,6 +90,20 @@ func LoadConfig() (Config, error) {
|
||||
trustedProxies = append(trustedProxies, prefix)
|
||||
}
|
||||
}
|
||||
bannedAsns := make(map[uint32]struct{})
|
||||
if rawAsn := envOrDefault("MINIBIN_BANNED_ASNS", ""); rawAsn != "" {
|
||||
for entry := range strings.SplitSeq(rawAsn, ",") {
|
||||
entry = strings.TrimSpace(entry)
|
||||
if entry == "" {
|
||||
continue
|
||||
}
|
||||
asn, err := strconv.ParseUint(entry, 10, 32)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("MINIBIN_BANNED_ASNS: invalid number %q: %w", entry, err)
|
||||
}
|
||||
bannedAsns[uint32(asn)] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
return Config{
|
||||
UploadDir: envOrDefault("MINIBIN_UPLOAD_DIR", "uploads"),
|
||||
@@ -100,11 +115,12 @@ func LoadConfig() (Config, error) {
|
||||
PoWDifficulty: powDifficulty,
|
||||
ReportOptions: reportOptions,
|
||||
|
||||
DatabasePath: envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite"),
|
||||
Host: envOrDefault("MINIBIN_HOST", "http://localhost:8080"),
|
||||
Addr: envOrDefault("MINIBIN_ADDR", "localhost:8080"),
|
||||
IPAdressSource: ipAddressSource,
|
||||
TrustedProxies: trustedProxies,
|
||||
DatabasePath: envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite"),
|
||||
Host: envOrDefault("MINIBIN_HOST", "http://localhost:8080"),
|
||||
Addr: envOrDefault("MINIBIN_ADDR", "localhost:8080"),
|
||||
IPAdressSource: ipAddressSource,
|
||||
TrustedProxies: trustedProxies,
|
||||
BannedClientASNs: bannedAsns,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user