mirror of
https://github.com/dalbodeule/sshchat.git
synced 2025-12-08 07:05:44 +09:00
apply geoip2, config file.
This commit is contained in:
32
utils/config.go
Normal file
32
utils/config.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
Geoip string
|
||||
CountryBlacklist []string
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
}
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
geoip_dbfile := os.Getenv("GEOIP_DB")
|
||||
country_blacklist := os.Getenv("COUNTRY_BLACKLIST")
|
||||
|
||||
return &Config{
|
||||
Port: port,
|
||||
Geoip: geoip_dbfile,
|
||||
CountryBlacklist: strings.Split(country_blacklist, ","),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user