Skip to content

Commit

Permalink
Fix tls tricks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xConsumer committed Jan 15, 2024
1 parent f18d6d8 commit e2d9485
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,26 +336,33 @@ func BuildConfig(configOpt ConfigOptions, input option.Options) option.Options {
directDNSDomains = append(directDNSDomains, fmt.Sprintf("full:%s", server))
}
}
if value, ok := obj["tls"]; ok {
tls := value.(map[string]interface{})
tls["mixedcase_sni"] = configOpt.TLSTricks.EnableMixedSNICase
if configOpt.TLSTricks.EnablePadding {
tls["padding_size"] = configOpt.TLSTricks.PaddingSize
} else {
tls["padding_size"] = ""

if !(out.Type == C.TypeSelector || out.Type == C.TypeURLTest || out.Type == C.TypeBlock || out.Type == C.TypeDNS) {
if configOpt.EnableFragment {
tlsFragment := make(map[string]interface{})
tlsFragment["enabled"] = configOpt.TLSTricks.EnableFragment
tlsFragment["size"] = configOpt.TLSTricks.FragmentSize
tlsFragment["sleep"] = configOpt.TLSTricks.FragmentSleep
obj["tls_fragment"] = tlsFragment
}

if value, ok := obj["tls"]; ok {
tlsTricks := make(map[string]interface{})
tlsTricks["mixedcase_sni"] = configOpt.TLSTricks.EnableMixedSNICase
if configOpt.TLSTricks.EnablePadding {
tlsTricks["padding_size"] = configOpt.TLSTricks.PaddingSize
} else {
tlsTricks["padding_size"] = ""
}
value.(map[string]interface{})["tls_tricks"] = tlsTricks
}
}
if value, ok := obj["tls_fragment"]; ok {
tls := value.(map[string]interface{})
tls["enabled"] = configOpt.TLSTricks.EnableFragment
tls["size"] = configOpt.TLSTricks.FragmentSize
tls["sleep"] = configOpt.TLSTricks.FragmentSleep
}

modifiedJson, err := json.Marshal(obj)
if err == nil {
err = out.UnmarshalJSON(modifiedJson)
if err != nil {
fmt.Println("error: ", err)
fmt.Println("error: ", out.Tag, out.Type, err)
}
}
}
Expand Down

0 comments on commit e2d9485

Please # to comment.