Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
url-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
url-checker
Commits
8c8fef11
Commit
8c8fef11
authored
Oct 18, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check tcp port
parent
be9ff690
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
4 deletions
+43
-4
urlchecker_bot.py
urlchecker_bot.py
+12
-4
urlchecker_network.py
urlchecker_network.py
+31
-0
No files found.
urlchecker_bot.py
View file @
8c8fef11
...
@@ -5,6 +5,7 @@ from urlchecker_platform import logPlatform
...
@@ -5,6 +5,7 @@ from urlchecker_platform import logPlatform
from
urlchecker_status
import
logStatus
from
urlchecker_status
import
logStatus
from
urlchecker_dns
import
getResolverDict
,
expandDomainList
,
getServerIpDict
from
urlchecker_dns
import
getResolverDict
,
expandDomainList
,
getServerIpDict
from
urlchecker_http
import
getUrlHostname
from
urlchecker_http
import
getUrlHostname
from
urlchecker_network
import
isTcpPortOpen
__version__
=
"0.0.3"
__version__
=
"0.0.3"
...
@@ -46,14 +47,21 @@ class WebBot:
...
@@ -46,14 +47,21 @@ class WebBot:
domain_list
=
expandDomainList
(
domain_list
)
domain_list
=
expandDomainList
(
domain_list
)
print
(
domain_list
)
print
(
domain_list
)
#
Check if domain have an A record
#
Get the list of server to check
server_i
d
_dict
=
getServerIpDict
(
server_i
p
_dict
=
getServerIpDict
(
self
.
_db
,
status_id
,
resolver_dict
,
domain_list
,
"A"
self
.
_db
,
status_id
,
resolver_dict
,
domain_list
,
"A"
)
)
print
(
server_id_dict
)
# Check TCP port for the list of IP found
# Check TCP port for the list of IP found
# If https ok, check SSL certificate
# XXX For now, check http/https only
server_ip_list
=
[
x
for
x
in
server_ip_dict
.
keys
()]
for
server_ip
in
server_ip_list
:
isTcpPortOpen
(
self
.
_db
,
server_ip
,
80
,
status_id
)
isTcpPortOpen
(
self
.
_db
,
server_ip
,
443
,
status_id
)
print
(
server_ip_dict
)
# XXX If https ok, check SSL certificate
# Check HTTP Status
# Check HTTP Status
def
stop
(
self
):
def
stop
(
self
):
...
...
urlchecker_network.py
View file @
8c8fef11
import
socket
import
errno
TIMEOUT
=
2
def
logNetwork
(
db
,
ip
,
transport
,
port
,
state
,
status_id
):
def
logNetwork
(
db
,
ip
,
transport
,
port
,
state
,
status_id
):
with
db
.
_db
.
atomic
():
with
db
.
_db
.
atomic
():
...
@@ -25,3 +31,28 @@ def logNetwork(db, ip, transport, port, state, status_id):
...
@@ -25,3 +31,28 @@ def logNetwork(db, ip, transport, port, state, status_id):
state
=
state
,
state
=
state
,
)
)
return
previous_entry
.
id
return
previous_entry
.
id
def
isTcpPortOpen
(
db
,
ip
,
port
,
status_id
):
is_open
=
False
sock
=
socket
.
socket
()
sock
.
settimeout
(
TIMEOUT
)
try
:
sock
.
connect
((
ip
,
port
))
state
=
"open"
is_open
=
True
except
ConnectionRefusedError
:
state
=
"closed"
except
socket
.
timeout
:
state
=
"filtered"
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EHOSTUNREACH
:
# OSError: [Errno 113] No route to host
state
=
"filtered"
else
:
raise
sock
.
close
()
logNetwork
(
db
,
ip
,
"TCP"
,
port
,
state
,
status_id
)
return
is_open
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