net-natpmp 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 +57 -4
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 433a47c9b51a219be471c8f44869894930dd46371a6d46368f65b3f4ff57deba
|
|
4
|
+
data.tar.gz: 0ae1e7cdd3ca82397c35256600b67d9610021f64a5f9600c260ce4bf358a3dd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b632cb1ea81f9d458f1fa323a59d8bd5275ca6a9e9229e36e9385c32f864bbaba5b30f5510d6b5cd59a44b89445ab603d1116f92d70bfce7be3d2f79ef7f61ad
|
|
7
|
+
data.tar.gz: 4f829ff626bdba0f90b808249560a278109c308fed2d604cc7a67b77444db25456f988525d72903373a7a552602c0ad1164bda3dd731ff161cdb9794d1123953
|
data/README.md
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
# net-natpmp
|
|
2
|
-
|
|
2
|
+
This is a NAT-PMP client implementation in ruby which allows to interact with routers that support this feature.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
If follows closely the specifications described in [RFC 6886](https://datatracker.ietf.org/doc/html/rfc6886).
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
require 'net/natpmp'
|
|
10
|
+
|
|
11
|
+
# First we need to create a client instance
|
|
12
|
+
# For now, the gateway needs to be specified manually.
|
|
13
|
+
client = Net::NATPMP.client(gw: '10.2.0.1')
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Specifying the gateway manually is a deliberate choice as it's mainly used to set a port mapping on a router/firewall which is not part of the local network but rather a VPN which allows port forwarding through NAT-PMP. ie. ProtonVPN, PIA, NordVPN, you know the deal.
|
|
17
|
+
|
|
18
|
+
Pulling the local gateway might be a feature added later.
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
# Query the remote gateway for it's external address
|
|
22
|
+
client.external_address
|
|
23
|
+
=> External address: 1.2.3.4
|
|
24
|
+
|
|
25
|
+
# Get the address as a string
|
|
26
|
+
client.external_address.to_s
|
|
27
|
+
=> "1.2.3.4"
|
|
28
|
+
|
|
29
|
+
# Let's set up a port mapping
|
|
30
|
+
# These arguments are the defaults. proto can be :udp or :tcp
|
|
31
|
+
client.map_port(proto: :udp, inside_port: 0, outside_port: 0, lifetime: 7200)
|
|
32
|
+
=> Port mapping: 37351 -> udp:37351 (lifetime: 60)
|
|
33
|
+
# The lifetime in the response is received by the remote gateway
|
|
34
|
+
# In this case, the gateway only allows for 60 second maps
|
|
35
|
+
mapping = _
|
|
36
|
+
=> Port mapping: 37351 -> udp:37351 (lifetime: 60)
|
|
37
|
+
mapping.inside_port
|
|
38
|
+
=> 37351
|
|
39
|
+
mapping.outside_port
|
|
40
|
+
=> 37351
|
|
41
|
+
mapping.proto
|
|
42
|
+
=> :udp
|
|
43
|
+
mapping.lifetime
|
|
44
|
+
=> 60
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
We can also destroy a mapping forcefully without waiting for it to expire
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
# The protocol and port argument must match the mapping protocol
|
|
51
|
+
# and internal port requested initially
|
|
52
|
+
client.destroy_mapping(proto: :udp, port: 37351)
|
|
53
|
+
=> Port mapping: 0 -> udp:37351 (lifetime: 0)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## TODO
|
|
57
|
+
The protocol is extremely simple with only 2 actual querries but it would be useful to implement the following:
|
|
58
|
+
|
|
59
|
+
- Use the local default gateway of the host running the application if the gateway is not specified when creating the `Net::NATPMP` client
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: net-natpmp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Octavian Vaideanu
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-07-
|
|
11
|
+
date: 2024-07-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |2
|
|
14
14
|
A NAT-PMP client for Ruby.
|
|
@@ -27,7 +27,7 @@ files:
|
|
|
27
27
|
- lib/net/natpmp/errors.rb
|
|
28
28
|
- lib/net/natpmp/requests.rb
|
|
29
29
|
- lib/net/natpmp/responses.rb
|
|
30
|
-
homepage: https://
|
|
30
|
+
homepage: https://github.com/oktav/net-natpmp
|
|
31
31
|
licenses:
|
|
32
32
|
- MIT
|
|
33
33
|
metadata: {}
|