Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
0920478b
authored
Jan 07, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prettier rules
parent
6c1ecdc2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
firewall/models.py
+9
-9
No files found.
firewall/models.py
View file @
0920478b
...
...
@@ -36,8 +36,8 @@ class Rule(models.Model):
para
=
"sport=
%
s
%
s"
%
(
self
.
sport
,
para
)
if
(
self
.
proto
):
para
=
"proto=
%
s
%
s"
%
(
self
.
proto
,
para
)
para
=
'<span style="color: #00FF00;">'
+
para
return
'<span style="color: #FF0000;">['
+
self
.
r_type
+
']</span> '
+
(
self
.
vlan_l
()
+
'<span style="color: #0000FF;">→</span>'
+
self
.
r_type
if
self
.
direction
==
'1'
else
self
.
r_type
+
'<span style="color: #0000FF;">→
</span>'
+
self
.
vlan_l
())
+
' '
+
para
+
' '
+
self
.
description
para
=
u
'<span style="color: #00FF00;">'
+
para
return
u'<span style="color: #FF0000;">['
+
self
.
r_type
+
u']</span> '
+
(
self
.
vlan_l
()
+
u'<span style="color: #0000FF;"> ▸ </span>'
+
self
.
r_type
if
self
.
direction
==
'1'
else
self
.
r_type
+
u'<span style="color: #0000FF;"> ▸
</span>'
+
self
.
vlan_l
())
+
' '
+
para
+
' '
+
self
.
description
color_desc
.
allow_tags
=
True
def
desc
(
self
):
...
...
@@ -48,7 +48,7 @@ class Rule(models.Model):
para
=
"sport=
%
s
%
s"
%
(
self
.
sport
,
para
)
if
(
self
.
proto
):
para
=
"proto=
%
s
%
s"
%
(
self
.
proto
,
para
)
return
'['
+
self
.
r_type
+
'] '
+
(
self
.
vlan_l
()
+
'
→'
+
self
.
r_type
if
self
.
direction
==
'1'
else
self
.
r_type
+
'→
'
+
self
.
vlan_l
())
+
' '
+
para
+
' '
+
self
.
description
return
'['
+
self
.
r_type
+
'] '
+
(
self
.
vlan_l
()
+
'
▸ '
+
self
.
r_type
if
self
.
direction
==
'1'
else
self
.
r_type
+
' ▸
'
+
self
.
vlan_l
())
+
' '
+
para
+
' '
+
self
.
description
def
vlan_l
(
self
):
retval
=
[]
for
vl
in
self
.
vlan
.
all
():
...
...
@@ -76,18 +76,18 @@ class Vlan(models.Model):
def
__unicode__
(
self
):
return
self
.
name
def
net_ipv6
(
self
):
return
self
.
net6
+
"/"
+
str
(
self
.
prefix6
)
return
self
.
net6
+
"/"
+
unicode
(
self
.
prefix6
)
def
net_ipv4
(
self
):
return
self
.
net4
+
"/"
+
str
(
self
.
prefix4
)
return
self
.
net4
+
"/"
+
unicode
(
self
.
prefix4
)
def
rules_l
(
self
):
retval
=
[]
for
rl
in
self
.
rules
.
all
():
retval
.
append
(
str
(
rl
))
retval
.
append
(
unicode
(
rl
))
return
', '
.
join
(
retval
)
def
snat_to_l
(
self
):
retval
=
[]
for
rl
in
self
.
snat_to
.
all
():
retval
.
append
(
str
(
rl
))
retval
.
append
(
unicode
(
rl
))
return
', '
.
join
(
retval
)
class
Group
(
models
.
Model
):
...
...
@@ -128,7 +128,7 @@ class Host(models.Model):
def
rules_l
(
self
):
retval
=
[]
for
rl
in
self
.
rules
.
all
():
retval
.
append
(
str
(
rl
.
color_desc
()))
retval
.
append
(
unicode
(
rl
.
color_desc
()))
return
'<br>'
.
join
(
retval
)
rules_l
.
allow_tags
=
True
def
enable_net
(
self
):
...
...
@@ -141,7 +141,7 @@ class Host(models.Model):
for
host
in
Host
.
objects
.
filter
(
pub_ipv4
=
self
.
pub_ipv4
):
if
host
.
rules
.
filter
(
nat
=
True
,
proto
=
proto
,
dport
=
public
):
raise
ValidationError
(
"A
%
s
%
s port mar hasznalva"
%
(
proto
,
public
))
rule
=
Rule
(
direction
=
'1'
,
owner
=
self
.
owner
,
description
=
"
%
s
%
s
%
s→
%
s"
%
(
self
.
hostname
,
proto
,
public
,
private
),
dport
=
public
,
proto
=
proto
,
nat
=
True
,
accept
=
True
,
r_type
=
"host"
,
nat_dport
=
private
)
rule
=
Rule
(
direction
=
'1'
,
owner
=
self
.
owner
,
description
=
u"
%
s
%
s
%
s ▸
%
s"
%
(
self
.
hostname
,
proto
,
public
,
private
),
dport
=
public
,
proto
=
proto
,
nat
=
True
,
accept
=
True
,
r_type
=
"host"
,
nat_dport
=
private
)
rule
.
full_clean
()
rule
.
save
()
rule
.
vlan
.
add
(
Vlan
.
objects
.
get
(
name
=
"PUB"
))
...
...
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