[check ip addr] make this optional

This commit is contained in:
Piotr Domański 2026-01-05 20:52:04 +01:00
parent 0d557b3083
commit b258a3e750
3 changed files with 11 additions and 1 deletions

View file

@ -2,3 +2,4 @@ DISCORD_TOKEN=""
DISCORD_CHANNEL_ID=""
CHECK_DOMAINS="[\"google.com\"]"
CHECK_NOTIFY_EXPIRATION_DAYS=7
CHECK_IP="false"

View file

@ -42,6 +42,10 @@ func RunCheck(config *Config) {
}
}()
if !config.CheckIp {
continue
}
go func() {
defer wg.Done()

View file

@ -2,9 +2,12 @@ package src
import (
"encoding/json"
"github.com/joho/godotenv"
"os"
"slices"
"strconv"
"strings"
"github.com/joho/godotenv"
)
type Config struct {
@ -12,6 +15,7 @@ type Config struct {
NotifyExpirationDays int
DiscordToken string
DiscordChannelID string
CheckIp bool
}
func GetConfig() (*Config, error) {
@ -36,5 +40,6 @@ func GetConfig() (*Config, error) {
NotifyExpirationDays: notifyExpirationDays,
DiscordToken: os.Getenv("DISCORD_TOKEN"),
DiscordChannelID: os.Getenv("DISCORD_CHANNEL_ID"),
CheckIp: slices.Contains([]string{"true", "1"}, strings.ToLower(os.Getenv("CHECK_IP"))),
}, nil
}