mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 08:44:29 +00:00
feat: add packet modification configuration with environment variables
This commit is contained in:
parent
3f98c35e62
commit
b20acf2cbe
@ -32,11 +32,6 @@ start_service() {
|
||||
config_get_bool set_ipid "main" "set_ipid" 0
|
||||
config_get_bool del_tcpts "main" "del_tcpts" 0
|
||||
|
||||
local others=","
|
||||
[ "$set_ipid" -eq "1" ] && others="${others}ipid,"
|
||||
[ "$del_tcpts" -eq "1" ] && others="${others}tcpts,"
|
||||
[ "$set_ttl" -eq "1" ] && others="${others}ttl,"
|
||||
|
||||
procd_open_instance "$NAME"
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command -m "$server_mode"
|
||||
@ -47,8 +42,10 @@ start_service() {
|
||||
procd_append_param command -l "$log_level"
|
||||
procd_append_param command -x "$rewrite_mode"
|
||||
procd_append_param command -z "$rewrite_rules"
|
||||
procd_append_param command -o "$others"
|
||||
[ "$partial_replace" = "1" ] && procd_append_param command -s
|
||||
procd_append_param env UA3F_TTL="$set_ttl"
|
||||
procd_append_param env UA3F_IPID="$set_ipid"
|
||||
procd_append_param env UA3F_TCPTS="$del_tcpts"
|
||||
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -86,7 +87,18 @@ func Parse() (*Config, bool) {
|
||||
cfg.ListenAddr = fmt.Sprintf("0.0.0.0:%d", port)
|
||||
}
|
||||
|
||||
// Parse other options
|
||||
// Parse other options from environment variables
|
||||
if os.Getenv("UA3F_TCPTS") == "1" {
|
||||
cfg.DelTCPTimestamp = true
|
||||
}
|
||||
if os.Getenv("UA3F_TTL") == "1" {
|
||||
cfg.SetTTL = true
|
||||
}
|
||||
if os.Getenv("UA3F_IPID") == "1" {
|
||||
cfg.SetIPID = true
|
||||
}
|
||||
|
||||
// Parse other options from -o flag
|
||||
opts := strings.Split(others, ",")
|
||||
for _, opt := range opts {
|
||||
switch strings.ToLower(strings.TrimSpace(opt)) {
|
||||
|
||||
@ -45,8 +45,8 @@ func (s *Server) Start() (err error) {
|
||||
slog.Error("s.Firewall.Setup", slog.Any("error", err))
|
||||
return err
|
||||
}
|
||||
slog.Info("Packet modification configuration", slog.Bool("ttl", s.cfg.SetTTL), slog.Bool("tcpts", s.cfg.DelTCPTimestamp), slog.Bool("ipid", s.cfg.SetIPID))
|
||||
if s.cfg.DelTCPTimestamp || s.cfg.SetIPID {
|
||||
slog.Info("Packet modification features enabled")
|
||||
return s.nfqServer.Start()
|
||||
}
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user