Skip to content

Commit

Permalink
set env
Browse files Browse the repository at this point in the history
  • Loading branch information
ProxyGo committed May 2, 2024
1 parent f0839cf commit 81b403d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@

logs/
bin/
fly.toml

# build
build/
vendor/
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
32 changes: 32 additions & 0 deletions socks/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package socks

import (
"fmt"
"os"
)

type Config struct {
LocalAddr string
Username string
Expand All @@ -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
}
}

0 comments on commit 81b403d

Please sign in to comment.