Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
aa53d585
authored
Oct 15, 2013
by
Bach Dániel
Committed by
Bach Dániel
Oct 15, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: remove get_data()
parent
a9b24356
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
40 deletions
+16
-40
circle/firewall/admin.py
+1
-11
circle/firewall/fw.py
+14
-15
circle/firewall/models.py
+1
-14
No files found.
circle/firewall/admin.py
View file @
aa53d585
...
@@ -105,17 +105,7 @@ class DomainAdmin(admin.ModelAdmin):
...
@@ -105,17 +105,7 @@ class DomainAdmin(admin.ModelAdmin):
class
RecordAdmin
(
admin
.
ModelAdmin
):
class
RecordAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name_'
,
'type'
,
'address_'
,
'ttl'
,
'host'
,
'owner'
)
list_display
=
(
'name'
,
'type'
,
'address'
,
'ttl'
,
'host'
,
'owner'
)
@staticmethod
def
address_
(
instance
):
a
=
instance
.
get_data
()
return
a
[
'address'
]
if
a
else
None
@staticmethod
def
name_
(
instance
):
a
=
instance
.
get_data
()
return
a
[
'name'
]
if
a
else
None
class
BlacklistAdmin
(
admin
.
ModelAdmin
):
class
BlacklistAdmin
(
admin
.
ModelAdmin
):
...
...
circle/firewall/fw.py
View file @
aa53d585
...
@@ -355,23 +355,22 @@ def dns():
...
@@ -355,23 +355,22 @@ def dns():
models
.
settings
[
'dns_ttl'
]))
models
.
settings
[
'dns_ttl'
]))
for
r
in
models
.
Record
.
objects
.
all
():
for
r
in
models
.
Record
.
objects
.
all
():
d
=
r
.
get_data
()
if
r
.
type
==
'A'
:
if
d
[
'type'
]
==
'A'
:
DNS
.
append
(
"+
%
s:
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
DNS
.
append
(
"+
%
s:
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]))
elif
r
.
type
==
'AAAA'
:
elif
d
[
'type'
]
==
'AAAA'
:
DNS
.
append
(
":
%
s:28:
%
s:
%
s"
%
DNS
.
append
(
":
%
s:28:
%
s:
%
s"
%
(
d
[
'name'
],
ipv6_to_octal
(
d
[
'address'
]),
d
[
'ttl'
]
))
(
r
.
fqdn
,
ipv6_to_octal
(
r
.
address
),
r
.
ttl
))
elif
d
[
'type'
]
==
'NS'
:
elif
r
.
type
==
'NS'
:
DNS
.
append
(
"&
%
s::
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]
))
DNS
.
append
(
"&
%
s::
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
elif
d
[
'type'
]
==
'CNAME'
:
elif
r
.
type
==
'CNAME'
:
DNS
.
append
(
"C
%
s:
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]
))
DNS
.
append
(
"C
%
s:
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
elif
d
[
'type'
]
==
'MX'
:
elif
r
.
type
==
'MX'
:
mx
=
d
[
'address'
]
.
split
(
':'
,
2
)
mx
=
r
.
address
.
split
(
':'
,
2
)
DNS
.
append
(
"@
%(fqdn)
s::
%(mx)
s:
%(dist)
s:
%(ttl)
s"
%
DNS
.
append
(
"@
%(fqdn)
s::
%(mx)
s:
%(dist)
s:
%(ttl)
s"
%
{
'fqdn'
:
d
[
'name'
]
,
'mx'
:
mx
[
1
],
'dist'
:
mx
[
0
],
{
'fqdn'
:
r
.
fqdn
,
'mx'
:
mx
[
1
],
'dist'
:
mx
[
0
],
'ttl'
:
d
[
'ttl'
]
})
'ttl'
:
r
.
ttl
})
elif
d
[
'type'
]
==
'PTR'
:
elif
r
.
type
==
'PTR'
:
DNS
.
append
(
"^
%
s:
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]
))
DNS
.
append
(
"^
%
s:
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
return
DNS
return
DNS
...
...
circle/firewall/models.py
View file @
aa53d585
...
@@ -687,9 +687,7 @@ class Record(models.Model):
...
@@ -687,9 +687,7 @@ class Record(models.Model):
return
self
.
desc
()
return
self
.
desc
()
def
desc
(
self
):
def
desc
(
self
):
a
=
self
.
get_data
()
return
u' '
.
join
([
self
.
fqdn
,
self
.
type
,
self
.
address
])
return
(
u' '
.
join
([
a
[
'name'
],
a
[
'type'
],
a
[
'address'
]])
if
a
else
unicode
(
_
(
'(empty)'
)))
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
full_clean
()
self
.
full_clean
()
...
@@ -725,17 +723,6 @@ class Record(models.Model):
...
@@ -725,17 +723,6 @@ class Record(models.Model):
else
:
else
:
return
self
.
domain
.
name
return
self
.
domain
.
name
def
get_data
(
self
):
name
=
self
.
fqdn
address
=
self
.
address
if
not
address
or
not
name
:
return
None
else
:
return
{
'name'
:
name
,
'type'
:
self
.
type
,
'ttl'
:
self
.
ttl
,
'address'
:
address
}
@models.permalink
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.record'
,
None
,
{
'pk'
:
self
.
pk
})
return
(
'network.record'
,
None
,
{
'pk'
:
self
.
pk
})
...
...
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