diff --git a/.gitignore b/.gitignore index 332d881..5d9b1bd 100755 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,8 @@ logs/ bin/ +fly.toml +# build +build/ +vendor/ diff --git a/main.go b/main.go index 397f2be..827ec10 100755 --- a/main.go +++ b/main.go @@ -23,6 +23,6 @@ func main() { flag.StringVar(&config.LdapAddr, "ldap-addr", "127.0.0.1:3890", "ldap address") flag.StringVar(&config.LdapBaseDN, "ldap-base-dn", "dc=example,dc=com", "ldap base dn") flag.Parse() - + config.SetEnv() socks.Start(config) } diff --git a/socks/config.go b/socks/config.go index 27dcb12..73c433d 100755 --- a/socks/config.go +++ b/socks/config.go @@ -1,5 +1,10 @@ package socks +import ( + "fmt" + "os" +) + type Config struct { LocalAddr string Username string @@ -16,3 +21,30 @@ type Config struct { LdapAddr string LdapBaseDN string } + +func(config *Config) SetEnv(){ + localPort := os.Getenv("LOCAL_PORT") + if localPort != "" { + config.LocalAddr = fmt.Sprintf(":%v", localPort) + } + httpPort := os.Getenv("HTTP_PORT") + if httpPort != "" { + config.HttpAddr = fmt.Sprintf(":%v", httpPort) + } + username := os.Getenv("USERNAME") + if username != "" { + config.Username = username + } + password := os.Getenv("PASSWORD") + if password != "" { + config.Password = password + } + auto := os.Getenv("AUTO") + if auto == "true" { + config.TLSAuto = true + } + domain := os.Getenv("DOMAIN") + if domain != "" { + config.TLSDomain = domain + } +}