[check ip addr] make this optional
This commit is contained in:
parent
0d557b3083
commit
b258a3e750
3 changed files with 11 additions and 1 deletions
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,10 @@ func RunCheck(config *Config) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if !config.CheckIp {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue