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
479d49b1
authored
Feb 20, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: blacklist api added
parent
6df60690
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletions
+14
-1
firewall/models.py
+6
-0
firewall/views.py
+8
-1
No files found.
firewall/models.py
View file @
479d49b1
...
@@ -328,6 +328,12 @@ class Blacklist(models.Model):
...
@@ -328,6 +328,12 @@ class Blacklist(models.Model):
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
modified_at
=
models
.
DateTimeField
(
auto_now
=
True
)
modified_at
=
models
.
DateTimeField
(
auto_now
=
True
)
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
full_clean
()
super
(
Blacklist
,
self
)
.
save
(
*
args
,
**
kwargs
)
def
__unicode__
(
self
):
return
self
.
ipv4
def
send_task
(
sender
,
instance
,
created
,
**
kwargs
):
def
send_task
(
sender
,
instance
,
created
,
**
kwargs
):
from
firewall.tasks
import
ReloadTask
from
firewall.tasks
import
ReloadTask
ReloadTask
.
apply_async
(
args
=
[
sender
.
__name__
])
ReloadTask
.
apply_async
(
args
=
[
sender
.
__name__
])
...
...
firewall/views.py
View file @
479d49b1
...
@@ -39,6 +39,14 @@ def firewall_api(request):
...
@@ -39,6 +39,14 @@ def firewall_api(request):
if
data
[
"password"
]
!=
"bdmegintelrontottaanetet"
:
if
data
[
"password"
]
!=
"bdmegintelrontottaanetet"
:
raise
Exception
(
_
(
"Wrong password."
))
raise
Exception
(
_
(
"Wrong password."
))
if
command
==
"blacklist"
:
obj
,
created
=
Blacklist
.
objects
.
get_or_create
(
ipv4
=
data
[
"ip"
])
if
created
:
obj
.
reason
=
data
[
"reason"
]
obj
.
snort_message
=
data
[
"snort_message"
]
obj
.
save
()
return
HttpResponse
(
_
(
"OK"
));
if
not
(
data
[
"vlan"
]
==
"vm-net"
or
data
[
"vlan"
]
==
"war"
):
if
not
(
data
[
"vlan"
]
==
"vm-net"
or
data
[
"vlan"
]
==
"war"
):
raise
Exception
(
_
(
"Only vm-net and war can be used."
))
raise
Exception
(
_
(
"Only vm-net and war can be used."
))
...
@@ -75,7 +83,6 @@ def firewall_api(request):
...
@@ -75,7 +83,6 @@ def firewall_api(request):
else
:
else
:
raise
Exception
(
_
(
"Unknown command."
))
raise
Exception
(
_
(
"Unknown command."
))
reload_firewall_lock
()
except
(
ValidationError
,
IntegrityError
,
AttributeError
,
Exception
)
as
e
:
except
(
ValidationError
,
IntegrityError
,
AttributeError
,
Exception
)
as
e
:
return
HttpResponse
(
_
(
"Something went wrong!
\n
%
s
\n
"
)
%
e
);
return
HttpResponse
(
_
(
"Something went wrong!
\n
%
s
\n
"
)
%
e
);
except
:
except
:
...
...
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