* add download trakcer page
This commit is contained in:
parent
c1402e2777
commit
4cb737761a
|
|
@ -0,0 +1,32 @@
|
|||
ActiveAdmin.register JamRuby::DownloadTracker, :as => 'DownloadTrackers' do
|
||||
|
||||
menu :label => 'Download Trackers', :parent => 'JamTracks'
|
||||
|
||||
config.batch_actions = false
|
||||
config.filters = true
|
||||
config.per_page = 50
|
||||
|
||||
filter :remote_ip
|
||||
|
||||
index do
|
||||
column 'User' do |oo| oo.user ? link_to(oo.user.email, oo.user.admin_url, {:title => oo.user.email}) : '' end
|
||||
column 'Remote IP' do |oo| oo.remote_ip end
|
||||
column 'Blacklisted?' do |oo| IpBlacklist.listed(oo.remote_ip) ? 'Yes' : 'No' end
|
||||
column "" do |oo|
|
||||
link_to 'Blacklist This IP', "download_trackers/#{oo.id}/blacklist_by_ip"
|
||||
end
|
||||
end
|
||||
|
||||
member_action :blacklist_by_ip, :method => :get do
|
||||
tracker = DownloadTracker.find(params[:id])
|
||||
|
||||
if !IpBlacklist.listed(tracker.remote_ip)
|
||||
ip = IpBlacklist.new
|
||||
ip.remote_ip = tracker.remote_ip
|
||||
ip.save!
|
||||
end
|
||||
|
||||
redirect_to admin_download_trackers_path, :notice => "IP address #{tracker.remote_ip} blacklisted."
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -97,6 +97,7 @@ module JamRuby
|
|||
body = "IP Address: #{remote_ip}\n"
|
||||
body << "Download Count: #{violation['count']}\n"
|
||||
body << "Add to blacklist: #{IpBlacklist.admin_url}"
|
||||
body << "Check Activity: #{IpBlacklist.admin_activity_url(remote_ip)}"
|
||||
|
||||
AdminMailer.alerts({
|
||||
subject:"Single IP Access Violation. IP:#{remote_ip}",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ module JamRuby
|
|||
APP_CONFIG.admin_root_url + "/admin/ip_blacklists/"
|
||||
end
|
||||
|
||||
def self.admin_activity_url(remote_ip)
|
||||
APP_CONFIG.admin_root_url + "/admin/download_trackers?q[remote_ip_equals]=#{URI.escape(remote_ip)}&commit=Filter&order=id_desc"
|
||||
end
|
||||
|
||||
def admin_url
|
||||
APP_CONFIG.admin_root_url + "/admin/ip_blacklists/" + id
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ BackendToFrontend = {
|
|||
}
|
||||
|
||||
BackendToFrontendFPS = {
|
||||
|
||||
0: 30,
|
||||
1: 24,
|
||||
2: 20,
|
||||
|
|
|
|||
Loading…
Reference in New Issue