Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
78a08c26
Commit
78a08c26
authored
Jun 05, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding IPv4 validator.
parent
070c247b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
exceptions.py
routersploit/exceptions.py
+5
-0
validators.py
routersploit/validators.py
+21
-0
No files found.
routersploit/exceptions.py
View file @
78a08c26
class
RoutersploitException
(
Exception
):
class
RoutersploitException
(
Exception
):
pass
pass
class
OptionValidationError
(
RoutersploitException
):
pass
\ No newline at end of file
routersploit/validators.py
View file @
78a08c26
import
socket
from
.exceptions
import
OptionValidationError
def
url
(
address
):
def
url
(
address
):
"""Sanitize url.
"""Sanitize url.
...
@@ -7,3 +12,18 @@ def url(address):
...
@@ -7,3 +12,18 @@ def url(address):
return
address
return
address
else
:
else
:
return
"http://{}"
.
format
(
address
)
return
"http://{}"
.
format
(
address
)
def
ipv4
(
address
):
try
:
socket
.
inet_pton
(
socket
.
AF_INET
,
address
)
except
AttributeError
:
try
:
socket
.
inet_aton
(
address
)
except
socket
.
error
:
raise
OptionValidationError
(
"Option have to be valid IP address."
)
return
address
.
count
(
'.'
)
==
3
except
socket
.
error
:
raise
OptionValidationError
(
"Option have to be valid IP address."
)
return
address
\ No newline at end of file
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