Better error handling, no use of /data directory - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 14dda8a60d3172d24799205e1c6a0dd44ae6e910
(DIR) parent 360baecf533d8d85d9174b91ecef6c270526edf4
(HTM) Author: HD Moore <hd_moore@rapid7.com>
Date: Fri, 28 Dec 2012 11:14:41 -0600
Better error handling, no use of /data directory
Diffstat:
M lib/warvox/audio/raw.rb | 3 +++
M lib/warvox/jobs/analysis.rb | 2 +-
M lib/warvox/jobs/dialer.rb | 10 +++++-----
3 files changed, 9 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/lib/warvox/audio/raw.rb b/lib/warvox/audio/raw.rb
@@ -189,6 +189,9 @@ class Raw
}.first
end
+ # Purge any empty fft slices
+ ffts.delete(nil)
+
# Map each slice of the audio's FFT with each FFT chunk (8k samples) and then work on it
tops = ffts.map{|x| x.map{|y| y.map{|z|
(DIR) diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb
@@ -114,7 +114,7 @@ class Analysis < Base
end
pfd = IO.popen("#{bin} '#{tmp.path}'")
- out = Marshal.load(pfd.read)
+ out = Marshal.load(pfd.read) rescue nil
pfd.close
return if not out
(DIR) diff --git a/lib/warvox/jobs/dialer.rb b/lib/warvox/jobs/dialer.rb
@@ -90,9 +90,6 @@ class Dialer < Base
end
def start_dialing
- dest = File.join(WarVOX::Config.data_path, @name.to_s)
- FileUtils.mkdir_p(dest)
-
# Scrub all numbers matching the blacklist
list = WarVOX::Config.blacklist_load
list.each do |b|
@@ -124,7 +121,8 @@ class Dialer < Base
Thread.current.kill if not num
Thread.current.kill if not prov
- out = File.join(dest, num+".raw")
+ out_fd = Tempfile.new("rawfile")
+ out = out_fd.path
begin
# Execute and read the output
@@ -182,9 +180,11 @@ class Dialer < Base
File.open(out, "rb") do |fd|
res.audio = fd.read(fd.stat.size)
end
- File.unlink(out)
end
+ out_fd.close
+ ::FileUtils.rm_f(out)
+
@calls << res
rescue ::Exception => e