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_TEMPLATE_DIR="html/"
|
||||||
ECHOIP_REDIS_URL="redis://localhost:6379"
|
ECHOIP_REDIS_URL="redis://localhost:6379"
|
||||||
ECHOIP_DATABASE="ipstack"
|
ECHOIP_DATABASE="ipstack"
|
||||||
|
ECHOIP_TRUSTED_HEADERS="X-Real-IP,X-Forwaded-For"
|
||||||
ECHOIP_IPSTACK_API_KEY="askdfj39sjdkf29dsjfk39sdfkj3"
|
ECHOIP_IPSTACK_API_KEY="askdfj39sjdkf29dsjfk39sdfkj3"
|
||||||
ECHOIP_GEOIP_COUNTRY_FILE="/full/path/to/file.db"
|
ECHOIP_GEOIP_COUNTRY_FILE="/full/path/to/file.db"
|
||||||
ECHOIP_GEOIP_CITY_FILE="/full/path/to/file.db"
|
ECHOIP_GEOIP_CITY_FILE="/full/path/to/file.db"
|
||||||
|
|
|
@ -46,9 +46,7 @@ func main() {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error opening config file (/etc/echoip/config.toml): %s", err)
|
log.Printf("Error opening config file (/etc/echoip/config.toml): %s", err)
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
var b []byte
|
var b []byte
|
||||||
b, err = io.ReadAll(file)
|
b, err = io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package config
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IPStack struct {
|
type IPStack struct {
|
||||||
|
@ -36,11 +37,10 @@ type Config struct {
|
||||||
|
|
||||||
func GetConfig() (Config, error) {
|
func GetConfig() (Config, error) {
|
||||||
defaultConfig := Config{
|
defaultConfig := Config{
|
||||||
Listen: getenv_string("ECHOIP_LISTEN", ":8080"),
|
Listen: getenv_string("ECHOIP_LISTEN", ":8080"),
|
||||||
TemplateDir: getenv_string("ECHOIP_TEMPLATE_DIR", "html/"),
|
TemplateDir: getenv_string("ECHOIP_TEMPLATE_DIR", "html/"),
|
||||||
RedisUrl: getenv_string("ECHOIP_REDIS_URL", ""),
|
RedisUrl: getenv_string("ECHOIP_REDIS_URL", ""),
|
||||||
TrustedHeaders: nil,
|
Database: getenv_string("ECHOIP_DATABASE", "geoip"),
|
||||||
Database: getenv_string("ECHOIP_DATABASE", "geoip"),
|
|
||||||
IPStack: IPStack{
|
IPStack: IPStack{
|
||||||
ApiKey: getenv_string("ECHOIP_IPSTACK_API_KEY", ""),
|
ApiKey: getenv_string("ECHOIP_IPSTACK_API_KEY", ""),
|
||||||
},
|
},
|
||||||
|
@ -93,6 +93,9 @@ func GetConfig() (Config, error) {
|
||||||
}
|
}
|
||||||
defaultConfig.IPStack.EnableSecurity = ipStackEnableSecurity
|
defaultConfig.IPStack.EnableSecurity = ipStackEnableSecurity
|
||||||
|
|
||||||
|
trustedHeaders := getenv_string("ECHOIP_TRUSTED_HEADERS", "")
|
||||||
|
defaultConfig.TrustedHeaders = strings.Split(trustedHeaders, ",")
|
||||||
|
|
||||||
return defaultConfig, nil
|
return defaultConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue