README.md in sniffer-0.2.0 vs README.md in sniffer-0.3.0
- old
+ new
@@ -41,34 +41,10 @@
Or install it yourself as:
$ gem install sniffer
-## Configuration
-
-Sniffer default options:
-
-```ruby
-Sniffer.config do |c|
- c.logger = Logger.new($stdout),
- c.severity = Logger::Severity::DEBUG,
- # HTTP options to log
- c.log = {
- request_url: true,
- request_headers: true,
- request_body: true,
- request_method: true,
- response_status: true,
- response_headers: true,
- response_body: true,
- timing: true
- },
- c.store = true, # save requests/responses to Sniffer.data
- c.enabled = false # Sniffer disabled by default
-end
-```
-
## Usage
Here's some simple examples to get you started:
```ruby
@@ -141,11 +117,68 @@
```
D, [2017-10-26T16:47:14.007152 #59511] DEBUG -- : {"port":80,"host":"example.com","query":"/?lang=ruby&author=matz","rq_connection":"close","method":"get","request_body":"","status":200,"rs_accept_ranges":"bytes","rs_cache_control":"max-age=604800","rs_content_type":"text/html","rs_date":"Thu, 26 Oct 2017 13:47:13 GMT","rs_etag":"\"359670651+gzip\"","rs_expires":"Thu, 02 Nov 2017 13:47:13 GMT","rs_last_modified":"Fri, 09 Aug 2013 23:54:35 GMT","rs_server":"ECS (lga/1385)","rs_vary":"Accept-Encoding","rs_x_cache":"HIT","rs_content_length":"1270","rs_connection":"close","timing":0.513012999901548,"response_body":"OK"}
```
where `rq_xxx` is request header and `rs_xxx` - response header
+## Configuration
+Sniffer default options:
+
+```ruby
+Sniffer.config do |c|
+ c.logger = Logger.new($stdout),
+ c.severity = Logger::Severity::DEBUG,
+ # HTTP options to log
+ c.log = {
+ request_url: true,
+ request_headers: true,
+ request_body: true,
+ request_method: true,
+ response_status: true,
+ response_headers: true,
+ response_body: true,
+ timing: true
+ },
+ c.store = true, # save requests/responses to Sniffer.data
+ c.enabled = false # Sniffer disabled by default
+ c.url_whitelist = nil
+ c.url_blacklist = nil
+end
+```
+
+### Whitelist
+
+You can add specific host url to whitelist as regexp or string. Sniffer will store only requests that matched.
+
+```ruby
+Sniffer.config.url_whitelist = /whitelisted.com/
+
+HTTP.get('http://example.com')
+Sniffer.data[0].to_h
+# => {}
+
+HTTP.get('http://whitelisted.com/')
+Sniffer.data[0].to_h
+# => {{:request=>{:host=>"whitelisted.com", ....}}
+```
+
+### Blacklist
+
+You can add specific host url to blacklist as regexp or string. Sniffer will ignore all matched requests.
+
+```ruby
+Sniffer.config.url_blacklist = /blacklisted.com/
+
+HTTP.get('http://blacklisted.com')
+Sniffer.data[0].to_h
+# => {}
+
+HTTP.get('http://example.com')
+Sniffer.data[0].to_h
+# => {{:request=>{:host=>"example.com", ...}}
+```
+
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -158,9 +191,10 @@
* [Sergey Ponomarev](https://github.com/sponomarev)
* [Salahutdinov Dmitry](https://github.com/dsalahutdinov)
* [Stanislav Chereshkevich](https://github.com/dissident)
* [Anatoliy Kurichev](https://github.com/russo-matrosso)
+* [Dmitriy Ivliev](https://github.com/moofkit)
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).