Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
72942021
Commit
72942021
authored
Dec 19, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ids) change download buffering
parent
d9387089
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
downloader.py
src/opnsense/scripts/suricata/lib/downloader.py
+10
-5
No files found.
src/opnsense/scripts/suricata/lib/downloader.py
View file @
72942021
...
@@ -32,7 +32,6 @@ import syslog
...
@@ -32,7 +32,6 @@ import syslog
import
tarfile
import
tarfile
import
gzip
import
gzip
import
zipfile
import
zipfile
import
shutil
import
tempfile
import
tempfile
import
requests
import
requests
...
@@ -122,10 +121,16 @@ class Downloader(object):
...
@@ -122,10 +121,16 @@ class Downloader(object):
frm_url
=
url
.
replace
(
'//'
,
'/'
)
.
replace
(
':/'
,
'://'
)
frm_url
=
url
.
replace
(
'//'
,
'/'
)
.
replace
(
':/'
,
'://'
)
# stream to temp file
# stream to temp file
if
frm_url
not
in
self
.
_download_cache
:
if
frm_url
not
in
self
.
_download_cache
:
req
=
requests
.
get
(
url
=
frm_url
,
stream
=
True
)
req
=
requests
.
get
(
url
=
frm_url
,
stream
=
True
,
verify
=
False
)
if
req
.
status_code
==
200
:
if
req
.
status_code
==
200
:
src
=
tempfile
.
NamedTemporaryFile
()
src
=
tempfile
.
NamedTemporaryFile
(
'wb+'
,
10240
)
shutil
.
copyfileobj
(
req
.
raw
,
src
)
while
True
:
data
=
req
.
raw
.
read
(
10240
)
if
not
data
:
break
else
:
src
.
write
(
data
)
src
.
seek
(
0
)
self
.
_download_cache
[
frm_url
]
=
src
self
.
_download_cache
[
frm_url
]
=
src
# process rules from tempfile (prevent duplicate download for files within an archive)
# process rules from tempfile (prevent duplicate download for files within an archive)
...
@@ -134,7 +139,7 @@ class Downloader(object):
...
@@ -134,7 +139,7 @@ class Downloader(object):
target_filename
=
'
%
s/
%
s'
%
(
self
.
_target_dir
,
filename
)
target_filename
=
'
%
s/
%
s'
%
(
self
.
_target_dir
,
filename
)
save_data
=
self
.
_unpack
(
self
.
_download_cache
[
frm_url
],
url
,
url_filename
)
save_data
=
self
.
_unpack
(
self
.
_download_cache
[
frm_url
],
url
,
url_filename
)
save_data
=
self
.
filter
(
save_data
,
input_filter
)
save_data
=
self
.
filter
(
save_data
,
input_filter
)
open
(
target_filename
,
'w
b'
)
.
write
(
save_data
)
open
(
target_filename
,
'w
'
,
buffering
=
10240
)
.
write
(
save_data
)
except
IOError
:
except
IOError
:
syslog
.
syslog
(
syslog
.
LOG_ERR
,
'cannot write to
%
s'
%
target_filename
)
syslog
.
syslog
(
syslog
.
LOG_ERR
,
'cannot write to
%
s'
%
target_filename
)
return
None
return
None
...
...
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