phantom_proxy 1.2.17 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -12
- data/.rbenv-gemsets +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +2 -3
- data/LICENSE.txt +22 -0
- data/Rakefile +2 -0
- data/bin/phantom_proxy +45 -52
- data/lib/phantom_proxy/helper/http.rb +46 -0
- data/lib/phantom_proxy/helper/jsonizer.rb +46 -0
- data/lib/phantom_proxy/helper/logable.rb +36 -0
- data/lib/phantom_proxy/helper/status_info.rb +42 -0
- data/lib/phantom_proxy/helper/template_renderer.rb +43 -0
- data/lib/phantom_proxy/phantomjs/phantomjs.rb +105 -0
- data/lib/phantom_proxy/proxy/proxy_api.rb +86 -0
- data/lib/phantom_proxy/router/app_router.rb +72 -0
- data/lib/phantom_proxy/scripts/proxy.js +93 -93
- data/lib/phantom_proxy/service.rb +21 -0
- data/lib/phantom_proxy/status/status_api.rb +43 -0
- data/lib/phantom_proxy/version.rb +3 -0
- data/lib/phantom_proxy.rb +95 -12
- data/phantom_proxy.gemspec +27 -26
- data/templates/views/error_page.erb +18 -0
- data/templates/views/status_page.erb +46 -0
- metadata +139 -86
- data/lib/phantom_proxy/config.ru +0 -10
- data/lib/phantom_proxy/install/etc/init.d/phproxy +0 -193
- data/lib/phantom_proxy/install/etc/phantom_proxy/config/example_config +0 -3
- data/lib/phantom_proxy/phantomjs.rb +0 -106
- data/lib/phantom_proxy/phantomjs_control_panel.rb +0 -58
- data/lib/phantom_proxy/phantomjsserver.rb +0 -194
- data/lib/phantom_proxy/web/control_panel.html +0 -44
- data/spec/test +0 -2
- data/tmp/.keep +0 -0
- data/tmp/run +0 -5
metadata
CHANGED
@@ -1,115 +1,168 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: phantom_proxy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 17
|
10
|
-
version: 1.2.17
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Suddani
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.1
|
20
|
+
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: goliath
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: journey
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.1
|
35
62
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: ruby-hmac
|
39
63
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ruby-hmac
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
50
75
|
version: 0.4.0
|
51
76
|
type: :runtime
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.4.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
description: This is a phyntonjs Proxy it allows you to fetch webpages and execute
|
112
|
+
javascript in them.
|
113
|
+
email:
|
114
|
+
- suddani@googlemail.com
|
115
|
+
executables:
|
56
116
|
- phantom_proxy
|
57
117
|
extensions: []
|
58
|
-
|
59
118
|
extra_rdoc_files: []
|
60
|
-
|
61
|
-
files:
|
119
|
+
files:
|
62
120
|
- .gitignore
|
121
|
+
- .rbenv-gemsets
|
63
122
|
- .ruby-version
|
64
123
|
- Gemfile
|
124
|
+
- LICENSE.txt
|
65
125
|
- README.rdoc
|
126
|
+
- Rakefile
|
66
127
|
- bin/phantom_proxy
|
67
128
|
- lib/phantom_proxy.rb
|
68
|
-
- lib/phantom_proxy/
|
69
|
-
- lib/phantom_proxy/
|
70
|
-
- lib/phantom_proxy/
|
71
|
-
- lib/phantom_proxy/
|
72
|
-
- lib/phantom_proxy/
|
73
|
-
- lib/phantom_proxy/
|
129
|
+
- lib/phantom_proxy/helper/http.rb
|
130
|
+
- lib/phantom_proxy/helper/jsonizer.rb
|
131
|
+
- lib/phantom_proxy/helper/logable.rb
|
132
|
+
- lib/phantom_proxy/helper/status_info.rb
|
133
|
+
- lib/phantom_proxy/helper/template_renderer.rb
|
134
|
+
- lib/phantom_proxy/phantomjs/phantomjs.rb
|
135
|
+
- lib/phantom_proxy/proxy/proxy_api.rb
|
136
|
+
- lib/phantom_proxy/router/app_router.rb
|
74
137
|
- lib/phantom_proxy/scripts/proxy.js
|
75
|
-
- lib/phantom_proxy/
|
138
|
+
- lib/phantom_proxy/service.rb
|
139
|
+
- lib/phantom_proxy/status/status_api.rb
|
140
|
+
- lib/phantom_proxy/version.rb
|
76
141
|
- phantom_proxy.gemspec
|
77
|
-
-
|
78
|
-
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
142
|
+
- templates/views/error_page.erb
|
143
|
+
- templates/views/status_page.erb
|
144
|
+
homepage: ''
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
84
148
|
post_install_message:
|
85
149
|
rdoc_options: []
|
86
|
-
|
87
|
-
require_paths:
|
150
|
+
require_paths:
|
88
151
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
hash: 3
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
107
162
|
requirements: []
|
108
|
-
|
109
163
|
rubyforge_project:
|
110
|
-
rubygems_version:
|
164
|
+
rubygems_version: 2.0.14
|
111
165
|
signing_key:
|
112
|
-
specification_version:
|
166
|
+
specification_version: 4
|
113
167
|
summary: This is a phantomjs Proxy
|
114
168
|
test_files: []
|
115
|
-
|
data/lib/phantom_proxy/config.ru
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
#! /bin/bash
|
2
|
-
### BEGIN INIT INFO
|
3
|
-
# Provides: phantom_proxy
|
4
|
-
# Required-Start: $remote_fs $syslog
|
5
|
-
# Required-Stop: $remote_fs $syslog
|
6
|
-
# Default-Start: 3 4 5
|
7
|
-
# Default-Stop: 0 1 2 6
|
8
|
-
# Short-Description: This script starts the phantom proxy
|
9
|
-
# Description: With this script you can automaticly start phantom_proxy
|
10
|
-
# instances. The script should be placed in /etc/init.d/phproxy
|
11
|
-
### END INIT INFO
|
12
|
-
|
13
|
-
### README
|
14
|
-
#
|
15
|
-
# You can put a configfile at
|
16
|
-
# /etc/phantom_proxy/config
|
17
|
-
# or
|
18
|
-
# put several files into a folder at /etc/phantom_proxy/config
|
19
|
-
# all files are loaded and one instance is created per file(CAUTION!! you have to set a unique PP_PID_NAME for each instance)
|
20
|
-
#
|
21
|
-
# Options you can set are:
|
22
|
-
# PP_PID_NAME: The name of the process
|
23
|
-
# PP_PORT: The port to run the proxy on (3003)
|
24
|
-
# PP_HOST: The host to run the proxy on (127.0.0.1)
|
25
|
-
# PP_HMAC: The hmac key to secure the server
|
26
|
-
#
|
27
|
-
# Example config file could look like the following:
|
28
|
-
#
|
29
|
-
# PP_PID_NAME="phantom_proxy_instance"
|
30
|
-
# PP_PORT=3002
|
31
|
-
# PP_HMAC="abcdefghi"
|
32
|
-
#
|
33
|
-
# End Example
|
34
|
-
#
|
35
|
-
### End README
|
36
|
-
|
37
|
-
PP_NAME=phantom_proxy
|
38
|
-
|
39
|
-
PP_PID_NAME="phantom_proxy"
|
40
|
-
|
41
|
-
PP_HMAC="none"
|
42
|
-
|
43
|
-
PP_USER_STANDARD=experteer
|
44
|
-
PP_USER=experteer
|
45
|
-
|
46
|
-
PP_LOG()
|
47
|
-
{
|
48
|
-
local log_dir="/tmp/$PP_NAME"
|
49
|
-
|
50
|
-
#create PP_LOG folder
|
51
|
-
if [ ! -d $log_dir ]
|
52
|
-
then
|
53
|
-
mkdir -p $log_dir
|
54
|
-
fi
|
55
|
-
|
56
|
-
echo $log_dir
|
57
|
-
}
|
58
|
-
|
59
|
-
PP_CONFIG()
|
60
|
-
{
|
61
|
-
echo "/etc/$PP_NAME/config"
|
62
|
-
}
|
63
|
-
|
64
|
-
PP_LOG_FILE()
|
65
|
-
{
|
66
|
-
echo "$(PP_LOG)/$PP_PID_NAME.log"
|
67
|
-
}
|
68
|
-
|
69
|
-
PP_PID()
|
70
|
-
{
|
71
|
-
echo "/tmp/pids/$PP_PID_NAME.pid"
|
72
|
-
}
|
73
|
-
|
74
|
-
PP_PORT=3003
|
75
|
-
|
76
|
-
PP_HOST=localhost
|
77
|
-
|
78
|
-
PP_OPTIONS()
|
79
|
-
{
|
80
|
-
if [ $PP_HMAC == "none" ]
|
81
|
-
then
|
82
|
-
echo "-p $PP_PORT -a $PP_HOST -P $(PP_PID) -l $(PP_LOG_FILE) -d"
|
83
|
-
else
|
84
|
-
echo "-p $PP_PORT -a $PP_HOST -P $(PP_PID) -l $(PP_LOG_FILE) -d -hmac $PP_HMAC"
|
85
|
-
fi
|
86
|
-
}
|
87
|
-
|
88
|
-
load_config_file()
|
89
|
-
{
|
90
|
-
PP_HMAC="none"
|
91
|
-
if [ -e $1 ]
|
92
|
-
then
|
93
|
-
echo "Loaded Configfile: $1"
|
94
|
-
source $1
|
95
|
-
fi
|
96
|
-
}
|
97
|
-
|
98
|
-
run_for_configs()
|
99
|
-
{
|
100
|
-
PP_USER=$PP_USER_STANDARD
|
101
|
-
|
102
|
-
cfg_folder=$(PP_CONFIG)
|
103
|
-
echo "Check config $cfg_folder"
|
104
|
-
if [ -d $cfg_folder ]; then
|
105
|
-
echo "Config folder: $cfg_folder"
|
106
|
-
for i in $( ls $cfg_folder) ; do
|
107
|
-
load_config_file "$cfg_folder/$i"
|
108
|
-
#run the given method
|
109
|
-
$1
|
110
|
-
sleep 2
|
111
|
-
done
|
112
|
-
return
|
113
|
-
elif [ -e $cfg_folder ]; then
|
114
|
-
echo "Config file"
|
115
|
-
load_config_file $cfg_folder
|
116
|
-
#run the given method
|
117
|
-
$1
|
118
|
-
return
|
119
|
-
fi
|
120
|
-
echo "No config detect using standard"
|
121
|
-
$1
|
122
|
-
}
|
123
|
-
|
124
|
-
do_start()
|
125
|
-
{
|
126
|
-
if [ -e $(PP_PID) ]
|
127
|
-
then
|
128
|
-
echo "Service $PP_NAME already running abort"
|
129
|
-
return
|
130
|
-
fi
|
131
|
-
echo "Starting $PP_NAME service"
|
132
|
-
sudo su -c "$PP_NAME $(PP_OPTIONS)" $PP_USER
|
133
|
-
}
|
134
|
-
|
135
|
-
do_stop()
|
136
|
-
{
|
137
|
-
if [ -e $(PP_PID) ]
|
138
|
-
then
|
139
|
-
echo "Stopping $PP_NAME service"
|
140
|
-
pp_id=$(cat $(PP_PID))
|
141
|
-
echo "Stopping $PP_NAME service: $pp_id"
|
142
|
-
kill $pp_id
|
143
|
-
return
|
144
|
-
fi
|
145
|
-
|
146
|
-
echo "Error $PP_NAME service isn't running"
|
147
|
-
}
|
148
|
-
|
149
|
-
do_restart()
|
150
|
-
{
|
151
|
-
do_stop
|
152
|
-
sleep 5
|
153
|
-
do_start
|
154
|
-
}
|
155
|
-
|
156
|
-
do_status()
|
157
|
-
{
|
158
|
-
echo "Checking status"
|
159
|
-
if [ -e $(PP_PID) ]
|
160
|
-
then
|
161
|
-
pp_id=$(cat $(PP_PID))
|
162
|
-
if [ `ps -p $pp_id | grep -c $PP_NAME` -ne 1 ] ; then
|
163
|
-
echo "failed - no process"
|
164
|
-
return 2
|
165
|
-
else
|
166
|
-
echo "Found PID: $pp_id"
|
167
|
-
return 0
|
168
|
-
fi
|
169
|
-
return
|
170
|
-
fi
|
171
|
-
echo "$PP_NAME is not running"
|
172
|
-
}
|
173
|
-
|
174
|
-
case "$1" in
|
175
|
-
start)
|
176
|
-
run_for_configs do_start
|
177
|
-
;;
|
178
|
-
stop)
|
179
|
-
run_for_configs do_stop
|
180
|
-
;;
|
181
|
-
restart)
|
182
|
-
run_for_configs do_restart
|
183
|
-
;;
|
184
|
-
status)
|
185
|
-
run_for_configs do_status
|
186
|
-
;;
|
187
|
-
*)
|
188
|
-
echo "Usage: $PP_NAME {start|stop|status|restart}" >&2
|
189
|
-
exit 3
|
190
|
-
;;
|
191
|
-
esac
|
192
|
-
|
193
|
-
:
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
|
-
module PhantomJSProxy
|
4
|
-
class PhantomJS
|
5
|
-
attr_accessor :dom
|
6
|
-
attr_accessor :image
|
7
|
-
attr_accessor :ready
|
8
|
-
|
9
|
-
def initialize()
|
10
|
-
@ready = 503
|
11
|
-
end
|
12
|
-
|
13
|
-
def getUrl(url, pictureOnly=true, loadIFrames=true)
|
14
|
-
puts("PhantomJS: "+url)
|
15
|
-
@ready = 503
|
16
|
-
|
17
|
-
pictureFile = nil
|
18
|
-
picture = "none"
|
19
|
-
|
20
|
-
loadFrames = "false"
|
21
|
-
|
22
|
-
if loadIFrames
|
23
|
-
loadFrames = "true"
|
24
|
-
end
|
25
|
-
|
26
|
-
if pictureOnly
|
27
|
-
if !File.directory?("/tmp/phantom_proxy")
|
28
|
-
Dir.mkdir("/tmp/phantom_proxy")
|
29
|
-
end
|
30
|
-
pictureFile = Tempfile.new(["phantom_proxy/page", ".png"])
|
31
|
-
picture = pictureFile.path
|
32
|
-
end
|
33
|
-
|
34
|
-
url_args = ""
|
35
|
-
url_args_ = []
|
36
|
-
|
37
|
-
if /\?/.match(url)
|
38
|
-
url_args = url.split('?')[1]
|
39
|
-
url = url.split('?')[0]
|
40
|
-
|
41
|
-
if url_args
|
42
|
-
url_args_ = url_args.split('&')
|
43
|
-
url_args = url_args_.join(' ')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
@dom = invokePhantomJS(SCRIPT, [picture, loadFrames, "\""+url+"\"", url_args_.length, url_args])
|
48
|
-
|
49
|
-
puts("Opened page: "+ /Open page: (.*?) END/.match(@dom)[1])
|
50
|
-
|
51
|
-
@ready = 503
|
52
|
-
dom_text = "Failed to load page"
|
53
|
-
|
54
|
-
if /DONE_LOADING_URL/.match(@dom)
|
55
|
-
puts("LOAD_DOM_TEXT")
|
56
|
-
dom_text = getDOMText @dom
|
57
|
-
puts("LOAD_DOM_TEXT_DONE")
|
58
|
-
if pictureOnly && File.exist?(picture)
|
59
|
-
puts("File is there")
|
60
|
-
@image = IO::File.open(picture, "rb") {|f| f.read }
|
61
|
-
pictureFile.close!
|
62
|
-
else
|
63
|
-
puts("No file to load at: "+picture)
|
64
|
-
@image = ""
|
65
|
-
end
|
66
|
-
@ready = 200
|
67
|
-
end
|
68
|
-
if /URL_ERROR_CODE/.match(@dom)
|
69
|
-
puts("LOAD_ERROR_CODE")
|
70
|
-
@ready = getHTTPCode @dom
|
71
|
-
puts("LOAD_ERROR_CODE_DONE: #{@ready}")
|
72
|
-
end
|
73
|
-
@dom = dom_text
|
74
|
-
return @dom
|
75
|
-
end
|
76
|
-
|
77
|
-
def getDOMText data
|
78
|
-
tmp = data.split('PHANTOMJS_DOMDATA_WRITE:')[1];
|
79
|
-
tmp = tmp.split('PHANTOMJS_DOMDATA_END')[0]
|
80
|
-
tmp
|
81
|
-
end
|
82
|
-
|
83
|
-
def getHTTPCode data
|
84
|
-
tmp = data.split('URL_ERROR_CODE: ')[1];
|
85
|
-
tmp = tmp.split('URL_ERROR_CODE_END')[0]
|
86
|
-
#tmp = /FAILED_LOADING_URL: (.*?)FAILED_LOADING_URL_END/.match(data)[1]
|
87
|
-
tmp.to_i
|
88
|
-
end
|
89
|
-
|
90
|
-
def getAsImageResponse(type='png')
|
91
|
-
return "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type: image/"+type+"\r\n\r\n"+@image;
|
92
|
-
end
|
93
|
-
|
94
|
-
def invokePhantomJS(script, args)
|
95
|
-
argString = " "+args.join(" ")
|
96
|
-
puts("Call phantomJS with: "+argString)
|
97
|
-
out = ""
|
98
|
-
|
99
|
-
IO.popen(PHANTOMJS_BIN+" --ignore-ssl-errors=yes --web-security=false "+script+argString) {|io|
|
100
|
-
out = io.readlines.join
|
101
|
-
}
|
102
|
-
#puts("PHANTOMJS_OUT: "+out)
|
103
|
-
return out
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module PhantomJSProxy
|
2
|
-
class PhantomJSControlPanel
|
3
|
-
def initialize
|
4
|
-
@start_time = Time.new
|
5
|
-
@total_requests = 0
|
6
|
-
@special_requests = Hash.new
|
7
|
-
@special_requests.default = 0
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_accessor :start_time
|
11
|
-
|
12
|
-
attr_accessor :total_requests
|
13
|
-
attr_accessor :route_requests
|
14
|
-
attr_accessor :html_requests
|
15
|
-
attr_accessor :picture_requests
|
16
|
-
attr_accessor :special_requests
|
17
|
-
|
18
|
-
def show
|
19
|
-
add_special_request "@control_requests"
|
20
|
-
|
21
|
-
resp = Rack::Response.new([], 200, {
|
22
|
-
'Content-Type' => 'text/html'
|
23
|
-
}) { |r|
|
24
|
-
r.write(load_html)
|
25
|
-
}
|
26
|
-
resp.finish
|
27
|
-
end
|
28
|
-
|
29
|
-
def add_request
|
30
|
-
@total_requests = @total_requests+1
|
31
|
-
end
|
32
|
-
|
33
|
-
def add_special_request type
|
34
|
-
@special_requests[type] = @special_requests[type]+1
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
def load_html
|
39
|
-
insert_value IO.read(CONTROL_PANEL)
|
40
|
-
end
|
41
|
-
|
42
|
-
def insert_value html
|
43
|
-
info_data = ""
|
44
|
-
info_data << create_entry("Running since", start_time.ctime)
|
45
|
-
info_data << create_entry("Total requests", total_requests.to_s)
|
46
|
-
special_requests.each { |key, value|
|
47
|
-
info_data << create_entry(key, special_requests[key].to_s)
|
48
|
-
}
|
49
|
-
html["@control_panel_data"] = info_data
|
50
|
-
|
51
|
-
html
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_entry name, value
|
55
|
-
"<div class='name'>#{name}:</div><div class='value' id='#{name}'>#{value}</div><div class='divider'></div>"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|