Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
fe5ac038
authored
Feb 06, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: fix Record
parent
0ee70533
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
firewall/models.py
+11
-9
No files found.
firewall/models.py
View file @
fe5ac038
...
@@ -218,21 +218,18 @@ class Record(models.Model):
...
@@ -218,21 +218,18 @@ class Record(models.Model):
super
(
Record
,
self
)
.
save
(
*
args
,
**
kwargs
)
super
(
Record
,
self
)
.
save
(
*
args
,
**
kwargs
)
def
clean
(
self
):
def
clean
(
self
):
if
not
((
not
self
.
name
and
self
.
host
)
or
self
.
name
.
endswith
(
u'.'
+
self
.
domain
.
name
)
or
self
.
name
==
self
.
domain
.
name
):
if
(
self
.
name
.
endswith
(
u'.'
)
):
raise
ValidationError
(
u'
nemok
'
)
raise
ValidationError
(
u'
a domain nem végződhet pontra
'
)
if
self
.
host
and
self
.
type
in
[
'CNAME'
,
'A'
,
'AAAA'
,
'PTR'
]:
if
self
.
host
and
self
.
type
in
[
'CNAME'
,
'A'
,
'AAAA'
]:
if
self
.
type
==
'CNAME'
:
if
self
.
type
==
'CNAME'
:
if
not
self
.
name
or
self
.
address
:
if
not
self
.
name
or
self
.
address
:
raise
ValidationError
(
u'CNAME rekordnal csak a name legyen kitoltve, ha van host beallitva'
)
raise
ValidationError
(
u'CNAME rekordnal csak a name legyen kitoltve, ha van host beallitva'
)
elif
self
.
type
==
'PTR'
:
if
not
self
.
address
or
self
.
name
:
raise
ValidationError
(
u'PTR rekordnal csak a name legyen kitoltve, ha van host beallitva'
)
elif
self
.
name
or
self
.
address
:
elif
self
.
name
or
self
.
address
:
raise
ValidationError
(
u'A, AAAA rekord eseten nem szabad megadni name-t, address-t, ha tarsitva van host'
)
raise
ValidationError
(
u'A, AAAA rekord eseten nem szabad megadni name-t, address-t, ha tarsitva van host'
)
else
:
else
:
if
not
(
self
.
name
and
self
.
address
)
:
if
not
self
.
address
:
raise
ValidationError
(
u'
name v
address hianyzik'
)
raise
ValidationError
(
u'address hianyzik'
)
if
self
.
type
==
'A'
:
if
self
.
type
==
'A'
:
if
not
ipv4_re
.
match
(
self
.
address
):
if
not
ipv4_re
.
match
(
self
.
address
):
...
@@ -251,7 +248,7 @@ class Record(models.Model):
...
@@ -251,7 +248,7 @@ class Record(models.Model):
raise
ValidationError
(
u'ez ismeretlen rekord, ez nudli!'
)
raise
ValidationError
(
u'ez ismeretlen rekord, ez nudli!'
)
def
get_data
(
self
):
def
get_data
(
self
):
retval
=
{
'
name'
:
self
.
name
,
'
type'
:
self
.
type
,
'ttl'
:
self
.
ttl
,
'address'
:
self
.
address
}
retval
=
{
'type'
:
self
.
type
,
'ttl'
:
self
.
ttl
,
'address'
:
self
.
address
}
if
self
.
host
:
if
self
.
host
:
if
self
.
type
==
'A'
:
if
self
.
type
==
'A'
:
retval
[
'address'
]
=
self
.
host
.
pub_ipv4
if
self
.
host
.
pub_ipv4
and
not
self
.
host
.
shared_ip
else
self
.
host
.
ipv4
retval
[
'address'
]
=
self
.
host
.
pub_ipv4
if
self
.
host
.
pub_ipv4
and
not
self
.
host
.
shared_ip
else
self
.
host
.
ipv4
...
@@ -263,6 +260,11 @@ class Record(models.Model):
...
@@ -263,6 +260,11 @@ class Record(models.Model):
retval
[
'name'
]
=
self
.
host
.
get_fqdn
()
retval
[
'name'
]
=
self
.
host
.
get_fqdn
()
elif
self
.
type
==
'CNAME'
:
elif
self
.
type
==
'CNAME'
:
retval
[
'address'
]
=
self
.
host
.
get_fqdn
()
retval
[
'address'
]
=
self
.
host
.
get_fqdn
()
else
:
if
not
self
.
name
:
retval
[
'name'
]
=
unicode
(
self
.
domain
)
else
:
retval
[
'name'
]
=
self
.
name
+
u'.'
+
unicode
(
self
.
domain
)
if
not
(
retval
[
'address'
]
and
retval
[
'name'
]):
if
not
(
retval
[
'address'
]
and
retval
[
'name'
]):
return
None
return
None
return
retval
return
retval
...
...
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