[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="" DISCORD_CHANNEL_ID=""
CHECK_DOMAINS="[\"google.com\"]" CHECK_DOMAINS="[\"google.com\"]"
CHECK_NOTIFY_EXPIRATION_DAYS=7 CHECK_NOTIFY_EXPIRATION_DAYS=7
CHECK_IP="false"

View file

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

View file

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