From 8d08d6687476a0e28b1c23d29838245285b45e74 Mon Sep 17 00:00:00 2001 From: GFW-knocker <123458121+GFW-knocker@users.noreply.github.com> Date: Thu, 2 Jan 2025 02:12:42 +0330 Subject: [PATCH 1/2] add hex to udp noise add option for hex noise --- infra/conf/freedom.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 693df1e3e82b..55204de84c36 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -2,6 +2,7 @@ package conf import ( "encoding/base64" + "encoding/hex" "net" "strings" @@ -169,6 +170,13 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { //user input string NConfig.StrNoise = []byte(strings.TrimSpace(noise.Packet)) + case "hex": + // user input hex - Decode hex string into byte slice + NConfig.StrNoise, err = hex.DecodeString(noise.Packet) + if err != nil { + return nil, errors.New("Invalid hex string: ", err) + } + case "base64": //user input base64 NConfig.StrNoise, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) From a620910a1270ff61fb968c7eed0bff0549b24d8f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 2 Jan 2025 09:04:49 +0000 Subject: [PATCH 2/2] Update freedom.go --- infra/conf/freedom.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index cdd53d7ca98b..5eb3e8719d79 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -167,25 +167,25 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { } case "str": - //user input string + // user input string NConfig.Packet = []byte(strings.TrimSpace(noise.Packet)) case "hex": - // user input hex - Decode hex string into byte slice - NConfig.StrNoise, err = hex.DecodeString(noise.Packet) + // user input hex + NConfig.Packet, err = hex.DecodeString(noise.Packet) if err != nil { - return nil, errors.New("Invalid hex string: ", err) + return nil, errors.New("Invalid hex string").Base(err) } case "base64": - //user input base64 + // user input base64 NConfig.Packet, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) if err != nil { - return nil, errors.New("Invalid base64 string") + return nil, errors.New("Invalid base64 string").Base(err) } default: - return nil, errors.New("Invalid packet, only rand/str/base64 are supported") + return nil, errors.New("Invalid packet, only rand/str/hex/base64 are supported") } if noise.Delay != nil {