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 +4 -4
- data/README.md +9 -11
- data/lib/stun/client.rb +6 -2
- data/lib/stun/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52bddb10f4448adc3b54028bbe5215b55857250f9e04b13e85e7aa3137cf14b3
|
4
|
+
data.tar.gz: 8025826614dfea4833b943014864831529ffd0e5b9d8cc4eb9d591976e2d2bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70bf71bf4075d66014efabdb02f3450ede2498789f5ec271292cbd404c18dfa4b41e72d67ed391deca02bb02bbfbf437e77f1c1ad4c154370e4aac7e62272b05
|
7
|
+
data.tar.gz: 9c1f8ac959e9a3b80b40eb3d41879865f6945a073233202d06aee7643cff35eb28d20b910f7542d998e8035dfd0790c88ef55df8ce2d07832566b132e560ad93
|
data/README.md
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
# Stun
|
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
|
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
|
17
|
+
$ gem install stun
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
21
|
TODO: Write usage instructions here
|
26
22
|
|
27
|
-
|
23
|
+
```ruby
|
24
|
+
require 'stun'
|
28
25
|
|
29
|
-
|
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/
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/inclooder/stun.
|
36
34
|
|
37
35
|
## License
|
38
36
|
|
data/lib/stun/client.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/stun/version.rb
CHANGED