stun 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0432349b210e505023175475962ad5b769c4d4784dd2cae050b1d18b011dd48d
4
- data.tar.gz: 5f88e1c6ffbfa5fb0a999de66ece90d9c7c408718b04fd0b1873222ad078cc36
3
+ metadata.gz: 52bddb10f4448adc3b54028bbe5215b55857250f9e04b13e85e7aa3137cf14b3
4
+ data.tar.gz: 8025826614dfea4833b943014864831529ffd0e5b9d8cc4eb9d591976e2d2bf4
5
5
  SHA512:
6
- metadata.gz: 3aaa137e9a8b45a4ae39b41862b7503bbe4459fada220e20044b2ba41fdf5bfe6ba660c592d8947bf636ae7d8a46440b60167acdebde051c030c410c06ed7045
7
- data.tar.gz: 6617c411813c0e5971c3ee4616d77f2f71ddb3820bb406acc4c2694ccac5da494ec749266561b193ccc95eae031599c7ff7321acf4769455e59fac51f49c7464
6
+ metadata.gz: 70bf71bf4075d66014efabdb02f3450ede2498789f5ec271292cbd404c18dfa4b41e72d67ed391deca02bb02bbfbf437e77f1c1ad4c154370e4aac7e62272b05
7
+ data.tar.gz: 9c1f8ac959e9a3b80b40eb3d41879865f6945a073233202d06aee7643cff35eb28d20b910f7542d998e8035dfd0790c88ef55df8ce2d07832566b132e560ad93
data/README.md CHANGED
@@ -1,15 +1,11 @@
1
- # Stun::Client
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/stun/client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
1
+ # Stun client
6
2
 
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
10
6
 
11
7
  ```ruby
12
- gem 'stun-client'
8
+ gem 'stun'
13
9
  ```
14
10
 
15
11
  And then execute:
@@ -18,21 +14,23 @@ And then execute:
18
14
 
19
15
  Or install it yourself as:
20
16
 
21
- $ gem install stun-client
17
+ $ gem install stun
22
18
 
23
19
  ## Usage
24
20
 
25
21
  TODO: Write usage instructions here
26
22
 
27
- ## Development
23
+ ```ruby
24
+ require 'stun'
28
25
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake respec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+ client = Stun::Client.new(host: '108.177.14.127', port: 19302)
27
+ client.query_address
28
+ ```
30
29
 
31
- 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).
32
30
 
33
31
  ## Contributing
34
32
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/stun-client.
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/inclooder/stun.
36
34
 
37
35
  ## License
38
36
 
@@ -80,7 +80,7 @@ module Stun
80
80
  end
81
81
  end
82
82
 
83
- def initialize(options)
83
+ def initialize(options = {})
84
84
  @host = options.fetch(:host, '108.177.14.127')
85
85
  @port = options.fetch(:port, 19302)
86
86
  end
@@ -93,7 +93,11 @@ module Stun
93
93
  resp = socket.recv(1024)
94
94
 
95
95
  msg = StunMessage.read(resp)
96
- puts "Response #{msg.inspect}"
96
+ attr = msg[:attributes][:attribute_value]
97
+ {
98
+ id: "#{attr[:ip_a]}.#{attr[:ip_b]}.#{attr[:ip_c]}.#{attr[:ip_d]}",
99
+ port: attr[:port]
100
+ }
97
101
  end
98
102
  end
99
103
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stun
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Kluge