Class: Net::NATPMP::Client
- Inherits:
-
Object
- Object
- Net::NATPMP::Client
- Includes:
- Constants
- Defined in:
- lib/net/natpmp/client.rb
Overview
Client class
Constant Summary
Constants included from Constants
Net::NATPMP::Constants::BASE_DELAY, Net::NATPMP::Constants::DEFAULT_INSIDE_PORT, Net::NATPMP::Constants::DEFAULT_LIFETIME, Net::NATPMP::Constants::DEFAULT_OUTSIDE_PORT, Net::NATPMP::Constants::DEFAULT_PROTO, Net::NATPMP::Constants::MAX_WAIT, Net::NATPMP::Constants::OP_CODES, Net::NATPMP::Constants::PROTO_CODES, Net::NATPMP::Constants::RESULT_CODES, Net::NATPMP::Constants::RESULT_CODES_DESC, Net::NATPMP::Constants::VERSION
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#destroy_mapping(port: 0, proto: DEFAULT_PROTO) ⇒ Object
Destroys a port mapping on the gateway.
-
#external_address ⇒ Object
Replies with the external address of the gateway.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
-
#map_port(proto: DEFAULT_PROTO, inside_port: DEFAULT_INSIDE_PORT, outside_port: DEFAULT_OUTSIDE_PORT, lifetime: DEFAULT_LIFETIME) ⇒ Object
Maps a port on the gateway.
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
11 12 13 |
# File 'lib/net/natpmp/client.rb', line 11 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/net/natpmp/client.rb', line 9 def config @config end |
Instance Method Details
#destroy_mapping(port: 0, proto: DEFAULT_PROTO) ⇒ Object
Destroys a port mapping on the gateway
37 38 39 |
# File 'lib/net/natpmp/client.rb', line 37 def destroy_mapping(port: 0, proto: DEFAULT_PROTO) MappingRequest.req(@config, proto: proto, inside_port: port, outside_port: 0, lifetime: 0) end |
#external_address ⇒ Object
Replies with the external address of the gateway
16 17 18 |
# File 'lib/net/natpmp/client.rb', line 16 def external_address ExternalAddressRequest.req(@config) end |
#map_port(proto: DEFAULT_PROTO, inside_port: DEFAULT_INSIDE_PORT, outside_port: DEFAULT_OUTSIDE_PORT, lifetime: DEFAULT_LIFETIME) ⇒ Object
Maps a port on the gateway
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/net/natpmp/client.rb', line 21 def map_port( proto: DEFAULT_PROTO, inside_port: DEFAULT_INSIDE_PORT, outside_port: DEFAULT_OUTSIDE_PORT, lifetime: DEFAULT_LIFETIME ) MappingRequest.req( @config, proto: proto, inside_port: inside_port, outside_port: outside_port, lifetime: lifetime ) end |