Another round of cleanups, performance improvements, locking fixes, and other last minute changes - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit b638c150a0aaba8a71813689e92dc00b4c9aaf95
(DIR) parent 44b5a9182697deb00f117d396f4deefb352a3455
(HTM) Author: HD Moore <hd_moore@rapid7.com>
Date: Fri, 6 Mar 2009 02:26:56 +0000
Another round of cleanups, performance improvements, locking fixes, and other last minute changes
Diffstat:
M web/app/controllers/analyze_contro… | 30 +++++++++++-------------------
M web/app/controllers/dial_results_c… | 86 ++++++++++---------------------
M web/app/views/analyze/index.html.e… | 8 ++++++--
M web/app/views/analyze/view.html.erb | 1 -
M web/app/views/dial_results/analyze… | 4 +---
M web/app/views/dial_results/index.h… | 8 ++++++--
M web/app/views/dial_results/view.ht… | 1 -
M web/app/views/home/about.html.erb | 8 ++++----
8 files changed, 56 insertions(+), 90 deletions(-)
---
(DIR) diff --git a/web/app/controllers/analyze_controller.rb b/web/app/controllers/analyze_controller.rb
@@ -20,29 +20,21 @@ class AnalyzeController < ApplicationController
:conditions => [ 'completed = ? and processed = ? and busy = ?', true, true, false ]
)
- @results_all = DialResult.find_all_by_dial_job_id(
- @job_id,
- :conditions => [ 'completed = ? and processed = ? and busy = ?', true, true, false ]
- )
-
+
@g1 = Ezgraphix::Graphic.new(:c_type => 'col3d', :div_name => 'calls_pie1')
- @g1.render_options(:caption => 'Detected Lines by Type', :y_name => 'Lines')
-
- @g2 = Ezgraphix::Graphic.new(:c_type => 'pie2d', :div_name => 'calls_pie2')
- @g2.render_options(:caption => 'Ring Time')
-
+ @g1.render_options(:caption => 'Detected Lines by Type', :y_name => 'Lines', :w => 700, :h => 300)
+
+ ltypes = DialResult.find( :all, :select => 'DISTINCT line_type' ).map{|r| r.line_type}
res_types = {}
- res_rings = {}
-
- @results_all.each do |r|
- res_rings[ r.ringtime ] ||= 0
- res_rings[ r.ringtime ] += 1
- res_types[ r.line_type.capitalize.to_sym ] ||= 0
- res_types[ r.line_type.capitalize.to_sym ] += 1
+
+ ltypes.each do |k|
+ next if not k
+ res_types[k.capitalize.to_sym] = DialResult.count(
+ :conditions => ['dial_job_id = ? and line_type = ?', @job_id, k]
+ )
end
@g1.data = res_types
- @g2.data = res_rings
end
# GET /dial_results/1/resource?id=XXX&type=YYY
@@ -50,7 +42,7 @@ class AnalyzeController < ApplicationController
ctype = 'text/html'
cpath = nil
- res = DialResult.find_by_id(params[:result_id])
+ res = DialResult.find(params[:result_id])
if(res and res.processed and res.rawfile)
case params[:type]
when 'big_sig'
(DIR) diff --git a/web/app/controllers/dial_results_controller.rb b/web/app/controllers/dial_results_controller.rb
@@ -20,12 +20,8 @@ class DialResultsController < ApplicationController
# GET /dial_results/1/reanalyze
def reanalyze
- DialResult.find_all_by_dial_job_id(params[:id]).each do |r|
- r.processed = false
- r.processed_at = 0
- r.save
- end
- j = DialJob.find_by_id(params[:id])
+ DialResult.update_all(['processed = ?', false], ['dial_job_id = ?', params[:id]])
+ j = DialJob.find(params[:id])
j.processed = false
j.save
@@ -38,32 +34,34 @@ class DialResultsController < ApplicationController
@job_id = params[:id]
@job = DialJob.find(@job_id)
- @dial_data_total = DialResult.find_all_by_dial_job_id(
- @job_id,
- :conditions => [ 'completed = ? and busy = ?', true, false ]
- ).length
+ if(@job.processed)
+ redirect_to :controller => 'analyze', :action => 'view', :id => @job_id
+ return
+ end
- @dial_data_done_set = DialResult.find_all_by_dial_job_id(
- @job_id,
- :conditions => [ 'processed = ?', true]
+ @dial_data_total = DialResult.count(
+ :conditions => [ 'dial_job_id = ? and completed = ?', @job_id, true ]
+ )
+
+ @dial_data_done = DialResult.count(
+ :conditions => [ 'dial_job_id = ? and processed = ?', @job_id, true ]
)
- @dial_data_done = @dial_data_done_set.length
@g1 = Ezgraphix::Graphic.new(:c_type => 'col3d', :div_name => 'calls_pie1')
- @g1.render_options(:caption => 'Detected Lines by Type', :y_name => 'Lines')
+ @g1.render_options(:caption => 'Detected Lines by Type', :y_name => 'Lines', :w => 700, :h => 300)
- @g2 = Ezgraphix::Graphic.new(:c_type => 'pie2d', :div_name => 'calls_pie2')
- @g2.render_options(:caption => 'Analysis Progress')
-
+ ltypes = DialResult.find( :all, :select => 'DISTINCT line_type' ).map{|r| r.line_type}
res_types = {}
- @dial_data_done_set.each do |r|
- res_types[ r.line_type.capitalize.to_sym ] ||= 0
- res_types[ r.line_type.capitalize.to_sym ] += 1
+
+ ltypes.each do |k|
+ next if not k
+ res_types[k.capitalize.to_sym] = DialResult.count(
+ :conditions => ['dial_job_id = ? and line_type = ?', @job_id, k]
+ )
end
@g1.data = res_types
- @g2.data = {:Remaining => @dial_data_total-@dial_data_done, :Complete => @dial_data_done}
-
+
@dial_data_todo = DialResult.paginate_all_by_dial_job_id(
@job_id,
:page => params[:page],
@@ -71,11 +69,6 @@ class DialResultsController < ApplicationController
:per_page => 50,
:conditions => [ 'completed = ? and processed = ? and busy = ?', true, false, false ]
)
-
- if(@job.processed)
- redirect_to :controller => 'analyze', :action => 'view', :id => @job_id
- return
- end
if(@dial_data_todo.length > 0)
WarVOX::JobManager.schedule(::WarVOX::Jobs::Analysis, @job_id)
@@ -93,38 +86,15 @@ class DialResultsController < ApplicationController
)
if(@dial_results)
- @g1 = Ezgraphix::Graphic.new(:c_type => 'pie2d', :div_name => 'calls_pie1')
- @g1.render_options(:caption => 'Call Results')
-
- @g2 = Ezgraphix::Graphic.new(:c_type => 'pie2d', :div_name => 'calls_pie2')
- @g2.render_options(:caption => 'Call Length')
-
- res = {
- :Timeout => 0,
- :Busy => 0,
- :Answered => 0
+ @g1 = Ezgraphix::Graphic.new(:c_type => 'col3d', :div_name => 'calls_pie1')
+ @g1.render_options(:caption => 'Call Results', :w => 700, :h => 300)
+
+ @g1.data = {
+ :Timeout => DialResult.count(:conditions =>['dial_job_id = ? and completed = ?', params[:id], false]),
+ :Busy => DialResult.count(:conditions =>['dial_job_id = ? and busy = ?', params[:id], true]),
+ :Answered => DialResult.count(:conditions =>['dial_job_id = ? and completed = ?', params[:id], true]),
}
- sec = {}
-
- @dial_results.each do |r|
- sec[r.seconds] ||= 0
- sec[r.seconds] += 1
-
- if(not r.completed)
- res[:Timeout] += 1
- next
- end
- if(r.busy)
- res[:Busy] += 1
- next
- end
- res[:Answered] += 1
- end
-
- @g1.data = res
- @g2.data = sec
end
-
respond_to do |format|
format.html # index.html.erb
(DIR) diff --git a/web/app/views/analyze/index.html.erb b/web/app/views/analyze/index.html.erb
@@ -16,10 +16,14 @@
<td><%=h dial_job.id %></td>
<td><%=h dial_job.range %></td>
<td><%=h dial_job.cid_mask %></td>
- <td><%=h DialResult.find(:all, :conditions => ['dial_job_id = ? and processed = ?', dial_job.id, true]).length.to_s + "/" + dial_job.dial_results.length.to_s %></td>
+ <td><%=h (
+ DialResult.count(:conditions => ['dial_job_id = ? and processed = ?', dial_job.id, true]).to_s +
+ "/" +
+ DialResult.count(:conditions => ['dial_job_id = ?', dial_job.id]).to_s
+ )%></td>
<td><%=h dial_job.started_at.localtime.strftime("%Y-%m-%d %H:%M:%S %Z") %></td>
<td><%= link_to 'View', view_analyze_path(dial_job) %></td>
- <td><%= link_to 'ReProcess', reanalyze_dial_result_path(dial_job), :confirm => 'Process this job again?' %></td>
+ <td><%= link_to 'ReAnalyze', reanalyze_dial_result_path(dial_job), :confirm => 'Process this job again?' %></td>
</tr>
<% end %>
</table>
(DIR) diff --git a/web/app/views/analyze/view.html.erb b/web/app/views/analyze/view.html.erb
@@ -3,7 +3,6 @@
<table width='100%' align='center' border=0 cellspacing=0 cellpadding=6>
<tr>
<td align='center'><%= render_ezgraphix @g1 %></td>
- <td align='center'><%= render_ezgraphix @g2 %></td>
</tr>
</table>
(DIR) diff --git a/web/app/views/dial_results/analyze.html.rb b/web/app/views/dial_results/analyze.html.rb
@@ -1,15 +1,13 @@
<% if @dial_data_todo.length > 0 %>
<h1 class='title'>
- Analyzing Calls ( completed <%= @dial_data_done %> of <%= @dial_data_total %>
- - <%= @dial_data_total-@dial_data_done %> left )...
+ Analyzing Audio for <%= @dial_data_total-@dial_data_done %> of <%= @dial_data_total %> Calls...
</h1>
<table width='100%' align='center' border=0 cellspacing=0 cellpadding=6>
<tr>
<% if @dial_data_done > 0 %>
<td align='center'><%= render_ezgraphix @g1 %></td>
- <td align='center'><%= render_ezgraphix @g2 %></td>
<% end %>
</tr>
</table>
(DIR) diff --git a/web/app/views/dial_results/index.html.erb b/web/app/views/dial_results/index.html.erb
@@ -6,8 +6,8 @@
<th>ID</th>
<th>Range</th>
<th>CID</th>
+ <th>Answered</th>
<th>Time</th>
- <th>Started</th>
</tr>
<% @completed_jobs.sort{|a,b| b.id <=> a.id}.each do |dial_job| %>
@@ -15,7 +15,11 @@
<td><%=h dial_job.id %></td>
<td><%=h dial_job.range %></td>
<td><%=h dial_job.cid_mask %></td>
- <td><%=h dial_job.seconds %></td>
+ <td><%=h (
+ DialResult.count(:conditions => ['dial_job_id = ? and completed = ?', dial_job.id, true]).to_s +
+ "/" +
+ DialResult.count(:conditions => ['dial_job_id = ?', dial_job.id]).to_s
+ )%></td>
<td><%=h dial_job.started_at.localtime.strftime("%Y-%m-%d %H:%M:%S %Z") %></td>
<td><%= link_to 'View', view_dial_result_path(dial_job) %></td>
<% if(dial_job.processed) %>
(DIR) diff --git a/web/app/views/dial_results/view.html.erb b/web/app/views/dial_results/view.html.erb
@@ -7,7 +7,6 @@
<table width='100%' align='center' border=0 cellspacing=0 cellpadding=6>
<tr>
<td align='center'><%= render_ezgraphix @g1 %></td>
- <td align='center'><%= render_ezgraphix @g2 %></td>
</tr>
</table>
(DIR) diff --git a/web/app/views/home/about.html.erb b/web/app/views/home/about.html.erb
@@ -28,7 +28,7 @@ team can be reached by email at warvox[at]metasploit.com.
<td valign="top" align="right" class="header_item">
Providers:
</td>
- <td><%= Provider.find(:all).length %></td>
+ <td><%= Provider.count %></td>
</tr>
@@ -36,21 +36,21 @@ team can be reached by email at warvox[at]metasploit.com.
<td valign="top" align="right" class="header_item">
Active Jobs:
</td>
- <td><%= DialJob.find_all_by_status('active').length %></td>
+ <td><%= DialJob.count(:conditions => ['status = ?', 'active']) %></td>
</tr>
<tr>
<td valign="top" align="right" class="header_item">
Total Jobs:
</td>
- <td><%= DialJob.find(:all).length %></td>
+ <td><%= DialJob.count %></td>
</tr>
<tr>
<td valign="top" align="right" class="header_item">
Results:
</td>
- <td><%= DialResult.find(:all).length %></td>
+ <td><%= DialResult.count %></td>
</tr>
</table>