mirror of https://github.com/mpolden/echoip
forgot to come back for trusted headers
This commit is contained in:
parent
967931fd25
commit
d70ee291d4
|
@ -140,6 +140,7 @@ ECHOIP_LISTEN=":8080"
|
|||
ECHOIP_TEMPLATE_DIR="html/"
|
||||
ECHOIP_REDIS_URL="redis://localhost:6379"
|
||||
ECHOIP_DATABASE="ipstack"
|
||||
ECHOIP_TRUSTED_HEADERS="X-Real-IP,X-Forwaded-For"
|
||||
ECHOIP_IPSTACK_API_KEY="askdfj39sjdkf29dsjfk39sdfkj3"
|
||||
ECHOIP_GEOIP_COUNTRY_FILE="/full/path/to/file.db"
|
||||
ECHOIP_GEOIP_CITY_FILE="/full/path/to/file.db"
|
||||
|
|
|
@ -46,9 +46,7 @@ func main() {
|
|||
|
||||
if err != nil {
|
||||
log.Printf("Error opening config file (/etc/echoip/config.toml): %s", err)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
} else {
|
||||
var b []byte
|
||||
b, err = io.ReadAll(file)
|
||||
if err != nil {
|
||||
|
|
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type IPStack struct {
|
||||
|
@ -36,11 +37,10 @@ type Config struct {
|
|||
|
||||
func GetConfig() (Config, error) {
|
||||
defaultConfig := Config{
|
||||
Listen: getenv_string("ECHOIP_LISTEN", ":8080"),
|
||||
TemplateDir: getenv_string("ECHOIP_TEMPLATE_DIR", "html/"),
|
||||
RedisUrl: getenv_string("ECHOIP_REDIS_URL", ""),
|
||||
TrustedHeaders: nil,
|
||||
Database: getenv_string("ECHOIP_DATABASE", "geoip"),
|
||||
Listen: getenv_string("ECHOIP_LISTEN", ":8080"),
|
||||
TemplateDir: getenv_string("ECHOIP_TEMPLATE_DIR", "html/"),
|
||||
RedisUrl: getenv_string("ECHOIP_REDIS_URL", ""),
|
||||
Database: getenv_string("ECHOIP_DATABASE", "geoip"),
|
||||
IPStack: IPStack{
|
||||
ApiKey: getenv_string("ECHOIP_IPSTACK_API_KEY", ""),
|
||||
},
|
||||
|
@ -93,6 +93,9 @@ func GetConfig() (Config, error) {
|
|||
}
|
||||
defaultConfig.IPStack.EnableSecurity = ipStackEnableSecurity
|
||||
|
||||
trustedHeaders := getenv_string("ECHOIP_TRUSTED_HEADERS", "")
|
||||
defaultConfig.TrustedHeaders = strings.Split(trustedHeaders, ",")
|
||||
|
||||
return defaultConfig, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue