Skip to content

Commit d80e0e9

Browse files
committed
Make code2network() faster by using bash only
1 parent 6dc26b0 commit d80e0e9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

testssl.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12139,16 +12139,20 @@ send_close_notify() {
1213912139
fi
1214012140
}
1214112141

12142-
# Format string properly for socket
12143-
# ARG1: any commented sequence of two bytes hex, separated by commas. It can contain comments, new lines, tabs and white spaces
12144-
# NW_STR holds the global with the string prepared for printf, like '\x16\x03\x03\'
12142+
# Format string properly for socket in ARG1 as it can be found here
12143+
# ARG1: sequence of 2 bytes hex, separated by commas. Can contain comments, new lines, tabs + white spaces
12144+
# NW_STR: holds afterwards the global with the string prepared for printf, like '\x16\x03\x03\'
12145+
#
1214512146
code2network() {
12146-
NW_STR=$(sed -e 's/,/\\\x/g' <<< "$1" | sed -e 's/# .*$//g' -e 's/ //g' -e '/^$/d' | tr -d '\n' | tr -d '\t')
12147+
NW_STR="$(sed -e 's/,/\\\x/g' -e 's/# .*$//g' -e 's/ //g' -e '/^$/d' <<< "$1")"
12148+
NW_STR="${NW_STR//$'\n'/}"
12149+
NW_STR="${NW_STR//$'\t'/}"
1214712150
}
1214812151

1214912152
# sockets inspired by https://blog.chris007.de/using-bash-for-network-socket-operation/
1215012153
# ARG1: hexbytes separated by commas, with a leading comma
1215112154
# ARG2: seconds to sleep
12155+
#
1215212156
socksend_clienthello() {
1215312157
local data=""
1215412158

@@ -12167,6 +12171,7 @@ socksend_clienthello() {
1216712171

1216812172
# ARG1: hexbytes -- preceded by x -- separated by commas, with a leading comma
1216912173
# ARG2: seconds to sleep
12174+
#
1217012175
socksend() {
1217112176
local data line
1217212177

0 commit comments

Comments
 (0)