Skip to content

Commit

Permalink
Freedom outbound: Change legacy variable name of UDP noise
Browse files Browse the repository at this point in the history
  • Loading branch information
Fangliding authored Jan 2, 2025
1 parent e80ca67 commit 7a4eff9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 47 deletions.
4 changes: 2 additions & 2 deletions infra/conf/freedom.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) {

case "str":
//user input string
NConfig.StrNoise = []byte(strings.TrimSpace(noise.Packet))
NConfig.Noise = []byte(strings.TrimSpace(noise.Packet))

case "base64":
//user input base64
NConfig.StrNoise, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet))
NConfig.Noise, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet))
if err != nil {
return nil, errors.New("Invalid base64 string")
}
Expand Down
96 changes: 53 additions & 43 deletions proxy/freedom/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions proxy/freedom/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ message Noise {
uint64 length_max = 2;
uint64 delay_min = 3;
uint64 delay_max = 4;

// Deprecated: noises now support binary data, str will be converted in infra/conf
bytes str_noise = 5;

bytes noise = 6;
}

message Config {
Expand Down
4 changes: 2 additions & 2 deletions proxy/freedom/freedom.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
var err error
for _, n := range w.noises {
//User input string or base64 encoded string
if n.StrNoise != nil {
noise = n.StrNoise
if n.Noise != nil {
noise = n.Noise
} else {
//Random noise
noise, err = GenerateRandomBytes(randBetween(int64(n.LengthMin),
Expand Down

0 comments on commit 7a4eff9

Please sign in to comment.