Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
DNS testing tools
Remoh
Commits
d17a9aa2
Commit
d17a9aa2
authored
Sep 09, 2020
by
Alexandre
Browse files
Move method into utils + improve test coverage
parent
3dc45e0a
Changes
5
Hide whitespace changes
Inline
Side-by-side
homer.py
View file @
d17a9aa2
...
...
@@ -139,12 +139,6 @@ def usage(msg=None):
"""
,
file
=
sys
.
stderr
)
print
(
"See the README.md for more details."
,
file
=
sys
.
stderr
)
def
dump_data
(
data
,
text
=
"data"
):
pref
=
' '
*
(
len
(
text
)
-
4
)
print
(
f
'
{
text
}
: '
,
data
)
print
(
pref
,
'hex:'
,
" "
.
join
(
format
(
c
,
'02x'
)
for
c
in
data
))
print
(
pref
,
'bin:'
,
" "
.
join
(
format
(
c
,
'08b'
)
for
c
in
data
))
def
get_next_domain
(
input_file
):
name
,
rtype
=
'framagit.org'
,
'AAAA'
line
=
input_file
.
readline
()
...
...
homer/__init__.py
View file @
d17a9aa2
from
.utils
import
dump_data
from
.utils
import
is_valid_hostname
from
.utils
import
is_valid_ip_address
from
.utils
import
is_valid_url
...
...
homer/connection.py
View file @
d17a9aa2
...
...
@@ -221,7 +221,7 @@ class ConnectionDOT(Connection):
def
send_data
(
self
,
data
,
dump
=
False
):
if
dump
:
dump_data
(
data
,
'data sent'
)
homer
.
dump_data
(
data
,
'data sent'
)
length
=
len
(
data
)
self
.
session
.
send
(
length
.
to_bytes
(
2
,
byteorder
=
'big'
)
+
data
)
...
...
@@ -233,7 +233,7 @@ class ConnectionDOT(Connection):
size
=
int
.
from_bytes
(
buf
,
byteorder
=
'big'
)
data
=
self
.
session
.
recv
(
size
)
if
dump
:
dump_data
(
data
,
'data recv'
)
homer
.
dump_data
(
data
,
'data recv'
)
return
(
True
,
data
,
size
)
def
send_and_receive
(
self
,
request
,
dump
=
False
):
...
...
homer/utils.py
View file @
d17a9aa2
...
...
@@ -18,6 +18,12 @@ import homer
# Do not change these
re_host
=
re
.
compile
(
r
'^([0-9a-z][0-9a-z-\.]*)|([0-9:]+)|([0-9\.])$'
)
def
dump_data
(
data
,
text
=
"data"
):
pref
=
' '
*
(
len
(
text
)
-
4
)
print
(
f
'
{
text
}
: '
,
data
)
print
(
pref
,
'hex:'
,
" "
.
join
(
format
(
c
,
'02x'
)
for
c
in
data
))
print
(
pref
,
'bin:'
,
" "
.
join
(
format
(
c
,
'08b'
)
for
c
in
data
))
def
is_valid_hostname
(
name
):
name
=
canonicalize
(
name
)
return
re_host
.
search
(
name
)
...
...
tests.yaml
View file @
d17a9aa2
...
...
@@ -146,6 +146,21 @@ tests:
stderr
:
'
'
stdout
:
"
OK
\n
"
-
exe
:
'
./homer.py'
name
:
'
--check
of
a
correct
DoT
with
debug
mode'
markers
:
-
'
dot'
-
'
check'
args
:
-
'
--dot'
-
'
--check'
-
'
--debug'
-
'
dot.bortzmeyer.fr'
-
'
dnsforum.bj'
retcode
:
0
stderr
:
'
'
partstdout
:
"
OK
\n
"
-
exe
:
'
./homer.py'
name
:
"
[doh][check]
Successcul
check"
markers
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment