Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
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
Hide 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):
class
RecordAdmin
(
admin
.
ModelAdmin
):
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
list_display
=
(
'name'
,
'type'
,
'address'
,
'ttl'
,
'host'
,
'owner'
)
class
BlacklistAdmin
(
admin
.
ModelAdmin
):
...
...
circle/firewall/fw.py
View file @
aa53d585
...
...
@@ -355,23 +355,22 @@ def dns():
models
.
settings
[
'dns_ttl'
]))
for
r
in
models
.
Record
.
objects
.
all
():
d
=
r
.
get_data
()
if
d
[
'type'
]
==
'A'
:
DNS
.
append
(
"+
%
s:
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]))
elif
d
[
'type'
]
==
'AAAA'
:
if
r
.
type
==
'A'
:
DNS
.
append
(
"+
%
s:
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
elif
r
.
type
==
'AAAA'
:
DNS
.
append
(
":
%
s:28:
%
s:
%
s"
%
(
d
[
'name'
],
ipv6_to_octal
(
d
[
'address'
]),
d
[
'ttl'
]
))
elif
d
[
'type'
]
==
'NS'
:
DNS
.
append
(
"&
%
s::
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]
))
elif
d
[
'type'
]
==
'CNAME'
:
DNS
.
append
(
"C
%
s:
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]
))
elif
d
[
'type'
]
==
'MX'
:
mx
=
d
[
'address'
]
.
split
(
':'
,
2
)
(
r
.
fqdn
,
ipv6_to_octal
(
r
.
address
),
r
.
ttl
))
elif
r
.
type
==
'NS'
:
DNS
.
append
(
"&
%
s::
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
elif
r
.
type
==
'CNAME'
:
DNS
.
append
(
"C
%
s:
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
elif
r
.
type
==
'MX'
:
mx
=
r
.
address
.
split
(
':'
,
2
)
DNS
.
append
(
"@
%(fqdn)
s::
%(mx)
s:
%(dist)
s:
%(ttl)
s"
%
{
'fqdn'
:
d
[
'name'
]
,
'mx'
:
mx
[
1
],
'dist'
:
mx
[
0
],
'ttl'
:
d
[
'ttl'
]
})
elif
d
[
'type'
]
==
'PTR'
:
DNS
.
append
(
"^
%
s:
%
s:
%
s"
%
(
d
[
'name'
],
d
[
'address'
],
d
[
'ttl'
]
))
{
'fqdn'
:
r
.
fqdn
,
'mx'
:
mx
[
1
],
'dist'
:
mx
[
0
],
'ttl'
:
r
.
ttl
})
elif
r
.
type
==
'PTR'
:
DNS
.
append
(
"^
%
s:
%
s:
%
s"
%
(
r
.
fqdn
,
r
.
address
,
r
.
ttl
))
return
DNS
...
...
circle/firewall/models.py
View file @
aa53d585
...
...
@@ -687,9 +687,7 @@ class Record(models.Model):
return
self
.
desc
()
def
desc
(
self
):
a
=
self
.
get_data
()
return
(
u' '
.
join
([
a
[
'name'
],
a
[
'type'
],
a
[
'address'
]])
if
a
else
unicode
(
_
(
'(empty)'
)))
return
u' '
.
join
([
self
.
fqdn
,
self
.
type
,
self
.
address
])
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
full_clean
()
...
...
@@ -725,17 +723,6 @@ class Record(models.Model):
else
:
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
def
get_absolute_url
(
self
):
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