Module: Ronin::Web::Server::Conditions::ClassMethods
- Defined in:
- lib/ronin/web/server/conditions.rb
Overview
Class methods to be added to the application base class.
Instance Method Summary collapse
-
#asn(number) ⇒ Object
protected
Condition to match the AS number of the client's IP address.
-
#asn_name(name) ⇒ Object
protected
Condition to match the company/ISP name of the ASN information for the client's IP address.
-
#browser(matcher) ⇒ Object
protected
Condition to match the browser name from the
User-Agent
header of the request. -
#browser_vendor(matcher) ⇒ Object
protected
Condition to match the browser vendor from the
User-Agent
header of the request. -
#browser_version(matcher) ⇒ Object
protected
Condition to match the browser version from the
User-Agent
header of the request. -
#client_ip(matcher) ⇒ Object
protected
Condition to match the client IP Address that sent the request.
-
#country_code(code) ⇒ Object
protected
Condition to match the country code of the ASN information for the client's IP address.
-
#device_type(matcher) ⇒ Object
protected
Condition to match the device type of the
User-Agent
header of the request. -
#host(matcher) ⇒ Object
protected
Condition for matching the
Host
header. -
#os(matcher) ⇒ Object
protected
Condition to match the OS from the
User-Agent
header of the request. -
#os_version(matcher) ⇒ Object
protected
Condition to match the OS version from the
User-Agent
header of the request. -
#referer(matcher) ⇒ Object
(also: #referrer)
protected
Condition to match the
Referer
header of the request. -
#user_agent(matcher) ⇒ Object
protected
Condition to match the
User-Agent
header of the request.
Instance Method Details
#asn(number) ⇒ Object (protected)
Condition to match the AS number of the client's IP address.
83 84 85 86 87 88 89 |
# File 'lib/ronin/web/server/conditions.rb', line 83 def asn(number) condition do if (record = Support::Network::ASN.query(request.ip)) record.number == number end end end |
#asn_name(name) ⇒ Object (protected)
Condition to match the company/ISP name of the ASN information for the client's IP address.
123 124 125 126 127 128 129 |
# File 'lib/ronin/web/server/conditions.rb', line 123 def asn_name(name) condition do if (record = Support::Network::ASN.query(request.ip)) record.name == name end end end |
#browser(matcher) ⇒ Object (protected)
Condition to match the browser name from the User-Agent
header of
the request.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/ronin/web/server/conditions.rb', line 225 def browser(matcher) case matcher when :chrome condition { request.browser == 'Chrome' } when :firefox condition { request.browser == 'Firefox' } else condition do if (browser = request.browser) matcher === browser end end end end |
#browser_vendor(matcher) ⇒ Object (protected)
Condition to match the browser vendor from the User-Agent
header
of the request.
253 254 255 256 257 258 259 |
# File 'lib/ronin/web/server/conditions.rb', line 253 def browser_vendor(matcher) condition do if (browser_vendor = request.browser_vendor) matcher === browser_vendor end end end |
#browser_version(matcher) ⇒ Object (protected)
Condition to match the browser version from the User-Agent
header
of the request.
Regular expression, exact String, Proc, or any other object which
defines an #===
method.
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/ronin/web/server/conditions.rb', line 287 def browser_version(matcher) case matcher when Array, Set condition do if (browser_version = request.browser_version) matcher.include?(browser_version) end end else condition do if (browser_version = request.browser_version) matcher === browser_version end end end end |
#client_ip(matcher) ⇒ Object (protected)
Condition to match the client IP Address that sent the request.
68 69 70 |
# File 'lib/ronin/web/server/conditions.rb', line 68 def client_ip(matcher) condition { matcher === request.ip } end |
#country_code(code) ⇒ Object (protected)
Condition to match the country code of the ASN information for the client's IP address.
103 104 105 106 107 108 109 |
# File 'lib/ronin/web/server/conditions.rb', line 103 def country_code(code) condition do if (record = Support::Network::ASN.query(request.ip)) record.country_code == country_code end end end |
#device_type(matcher) ⇒ Object (protected)
Condition to match the device type of the User-Agent
header of
the request.
Array of device type Symbols, the exact devicde type Symbol,
Proc, or any other object which defines an #===
method.
324 325 326 327 328 329 330 331 332 333 |
# File 'lib/ronin/web/server/conditions.rb', line 324 def device_type(matcher) condition do if (device_type = request.device_type) case matcher when Array then matcher.include?(device_type) else matcher === device_type end end end end |
#host(matcher) ⇒ Object (protected)
Condition for matching the Host
header.
147 148 149 |
# File 'lib/ronin/web/server/conditions.rb', line 147 def host(matcher) condition { matcher === request.host } end |
#os(matcher) ⇒ Object (protected)
Condition to match the OS from the User-Agent
header of the
request.
Regular expression, exact String, Proc, or any other object which
defines an #===
method.
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/ronin/web/server/conditions.rb', line 374 def os(matcher) case matcher when :android condition { request.from_android_os? } when :ios condition { request.from_ios? } when :linux condition { request.os == 'Linux' } when :windows condition do if (os = request.os) os.start_with?('Windows') end end else condition do if (os = request.os) matcher === os end end end end |
#os_version(matcher) ⇒ Object (protected)
Condition to match the OS version from the User-Agent
header of
the request.
Regular expression, exact String, Proc, or any other object which
defines an #===
method.
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/ronin/web/server/conditions.rb', line 423 def os_version(matcher) case matcher when Array, Set condition do if (os_version = request.os_version) matcher.include?(os_version) end end else condition do if (os_version = request.os_version) matcher === os_version end end end end |
#referer(matcher) ⇒ Object (protected) Also known as: referrer
Condition to match the Referer
header of the request.
167 168 169 170 171 172 173 |
# File 'lib/ronin/web/server/conditions.rb', line 167 def referer(matcher) condition do if (referer = request.referer) matcher === referer end end end |
#user_agent(matcher) ⇒ Object (protected)
Condition to match the User-Agent
header of the request.
189 190 191 192 193 194 195 |
# File 'lib/ronin/web/server/conditions.rb', line 189 def user_agent(matcher) condition do if (user_agent = request.user_agent) matcher === user_agent end end end |