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
3abe8161
Commit
3abe8161
authored
Jan 11, 2021
by
Alexandre
Browse files
Standardized output
parent
1d560610
Changes
1
Hide whitespace changes
Inline
Side-by-side
remoh.py
View file @
3abe8161
...
...
@@ -132,6 +132,17 @@ def get_next_domain(input_file):
(
name
,
rtype
)
=
line
.
split
()
return
name
,
rtype
def
print_info
(
msg
,
ip
=
None
,
prefix
=
None
,
msg_type
=
None
,
fd
=
sys
.
stdout
):
output
=
""
if
ip
:
output
+=
'%s: '
%
ip
if
prefix
:
output
+=
'%s: '
%
prefix
if
msg_type
:
output
+=
'%s: '
%
msg_type
output
+=
'%s'
%
msg
print
(
output
,
file
=
fd
)
def
print_result
(
connection
,
request
,
prefix
=
None
,
display_err
=
True
):
dot
=
connection
.
dot
server
=
connection
.
server
...
...
@@ -145,18 +156,16 @@ def print_result(connection, request, prefix=None, display_err=True):
print
(
msg
)
else
:
if
display_err
:
if
opts
.
check
:
print
(
connection
.
connect_to
,
end
=
': '
,
file
=
sys
.
stderr
)
if
prefix
:
print
(
prefix
,
end
=
': '
,
file
=
sys
.
stderr
)
ip
=
connection
.
connect_to
if
dot
:
print
(
"Error: %s"
%
msg
,
file
=
sys
.
stderr
)
msg_type
=
'Error'
else
:
try
:
msg
=
msg
.
decode
()
except
(
UnicodeDecodeError
,
AttributeError
):
pass
# Sometimes, msg can be binary, or Latin-1
print
(
"HTTP error %i: %s"
%
(
rcode
,
msg
),
file
=
sys
.
stderr
)
msg_type
=
'HTTP error %i'
%
rcode
print_info
(
msg
,
ip
,
prefix
,
msg_type
,
fd
=
sys
.
stderr
)
def
print_check_result
(
test_name
,
ok
,
verbose
=
True
):
...
...
@@ -256,7 +265,7 @@ def do_check(connection, requests, opts):
except
(
remoh
.
ConnectionException
,
remoh
.
DOHException
)
as
e
:
ok
=
False
print_check_result
(
test_name
,
ok
,
verbose
=
connection
.
verbose
)
print
(
e
,
file
=
sys
.
stderr
)
print
_info
(
e
,
connection
.
connect_to
,
fd
=
sys
.
stderr
)
continue
if
level
>=
opts
.
mandatory_level
:
...
...
@@ -311,10 +320,10 @@ def check_truncated_query(connection, opts, level=remoh.mandatory_levels["niceto
# so response can not be parsed in this case
return
True
except
remoh
.
ConnectionDOTException
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
print
_info
(
e
,
connection
.
connect_to
,
test_name
,
'Info'
,
fd
=
sys
.
stderr
)
return
connection
.
state
==
'CONN_CLOSED'
except
remoh
.
DOHException
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
print
_info
(
e
,
connection
.
connect_to
,
test_name
,
'Info'
,
fd
=
sys
.
stderr
)
return
False
if
request
.
check_response
(
connection
.
debug
):
# FORMERR is expected
...
...
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