mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-15 16:22:07 +00:00
feat: add environment variable support for server configuration
This commit is contained in:
parent
2633d4d360
commit
3e72305ac2
@ -17,6 +17,13 @@ WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/ua3f .
|
||||
|
||||
ENV UA3F_SERVER_MODE=SOCKS5
|
||||
ENV UA3F_PORT=1080
|
||||
ENV UA3F_REWRITE_MODE=GLOBAL
|
||||
ENV UA3F_PAYLOAD_UA=FFF
|
||||
ENV UA3F_UA_REGEX=
|
||||
ENV UA3F_PARTIAL_REPLACE=0
|
||||
|
||||
EXPOSE 1080
|
||||
|
||||
ENTRYPOINT ["/app/ua3f", "-b", "0.0.0.0"]
|
||||
@ -95,7 +95,35 @@ func Parse() (*Config, bool) {
|
||||
cfg.ListenAddr = fmt.Sprintf("0.0.0.0:%d", port)
|
||||
}
|
||||
|
||||
// Parse other options from environment variables
|
||||
if os.Getenv("UA3F_SERVER_MODE") != "" {
|
||||
cfg.ServerMode = ServerMode(strings.ToUpper(os.Getenv("UA3F_SERVER_MODE")))
|
||||
}
|
||||
|
||||
if os.Getenv("UA3F_PORT") != "" {
|
||||
var p int
|
||||
_, err := fmt.Sscanf(os.Getenv("UA3F_PORT"), "%d", &p)
|
||||
if err == nil {
|
||||
cfg.Port = p
|
||||
cfg.ListenAddr = fmt.Sprintf("%s:%d", cfg.BindAddr, cfg.Port)
|
||||
}
|
||||
}
|
||||
|
||||
if os.Getenv("UA3F_REWRITE_MODE") != "" {
|
||||
cfg.RewriteMode = RewriteMode(strings.ToUpper(os.Getenv("UA3F_REWRITE_MODE")))
|
||||
}
|
||||
|
||||
if os.Getenv("UA3F_PAYLOAD_UA") != "" {
|
||||
cfg.PayloadUA = os.Getenv("UA3F_PAYLOAD_UA")
|
||||
}
|
||||
|
||||
if os.Getenv("UA3F_UA_REGEX") != "" {
|
||||
cfg.UARegex = os.Getenv("UA3F_UA_REGEX")
|
||||
}
|
||||
|
||||
if os.Getenv("UA3F_PARTIAL_REPLACE") == "1" {
|
||||
cfg.PartialReplace = true
|
||||
}
|
||||
|
||||
if os.Getenv("UA3F_TCPTS") == "1" {
|
||||
cfg.DelTCPTimestamp = true
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user