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
a4a8b06b
Commit
a4a8b06b
authored
8 years ago
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding address validator
parent
c20f9a3d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
test_validators.py
routersploit/test/test_validators.py
+4
-4
validators.py
routersploit/validators.py
+5
-2
No files found.
routersploit/test/test_validators.py
View file @
a4a8b06b
...
@@ -73,13 +73,13 @@ class ValidatorsTest(RoutersploitTestCase):
...
@@ -73,13 +73,13 @@ class ValidatorsTest(RoutersploitTestCase):
with
self
.
assertRaises
(
OptionValidationError
):
with
self
.
assertRaises
(
OptionValidationError
):
validators
.
ipv4
(
address
)
validators
.
ipv4
(
address
)
def
test_
ipv4
_strip_scheme_1
(
self
):
def
test_
address
_strip_scheme_1
(
self
):
address
=
"http://127.0.0.1"
address
=
"http://127.0.0.1"
self
.
assertEqual
(
validators
.
ipv4
(
address
),
"127.0.0.1"
)
self
.
assertEqual
(
validators
.
address
(
address
),
"127.0.0.1"
)
def
test_
ipv4
_strip_scheme_2
(
self
):
def
test_
address
_strip_scheme_2
(
self
):
address
=
"ftp://127.0.0.1"
address
=
"ftp://127.0.0.1"
self
.
assertEqual
(
validators
.
ipv4
(
address
),
"127.0.0.1"
)
self
.
assertEqual
(
validators
.
address
(
address
),
"127.0.0.1"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
This diff is collapsed.
Click to expand it.
routersploit/validators.py
View file @
a4a8b06b
...
@@ -15,9 +15,12 @@ def url(address):
...
@@ -15,9 +15,12 @@ def url(address):
return
"http://{}"
.
format
(
address
)
return
"http://{}"
.
format
(
address
)
def
address
(
addr
):
addr
=
urlparse
.
urlsplit
(
addr
)
return
addr
.
netloc
or
address
.
path
def
ipv4
(
address
):
def
ipv4
(
address
):
address
=
urlparse
.
urlsplit
(
address
)
address
=
address
.
netloc
or
address
.
path
try
:
try
:
socket
.
inet_pton
(
socket
.
AF_INET
,
address
)
socket
.
inet_pton
(
socket
.
AF_INET
,
address
)
except
AttributeError
:
except
AttributeError
:
...
...
This diff is collapsed.
Click to expand it.
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