Class: Net::NATPMP::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/net/natpmp/config.rb

Overview

Provides all necessary configuration with some defaults

Constant Summary collapse

NATPMP_PORT =
5351
BIND_ADDRESS =
'0.0.0.0'
BIND_PORT =
5350

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gw:, port: NATPMP_PORT, bind_address: BIND_ADDRESS, bind_port: BIND_PORT) ⇒ Config

Returns a new instance of Config.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/net/natpmp/config.rb', line 13

def initialize(
  gw:,
  port: NATPMP_PORT,
  bind_address: BIND_ADDRESS,
  bind_port: BIND_PORT
)

  @bind_address = IPAddr.new(bind_address)
  @bind_port = bind_port
  @gw = IPAddr.new(gw)
  @port = port
rescue IPAddr::InvalidAddressError
  raise InvalidParameter, 'Value must be a valid IP Address'
end

Instance Attribute Details

#bind_addressObject (readonly)

Returns the value of attribute bind_address.



11
12
13
# File 'lib/net/natpmp/config.rb', line 11

def bind_address
  @bind_address
end

#bind_portObject (readonly)

Returns the value of attribute bind_port.



11
12
13
# File 'lib/net/natpmp/config.rb', line 11

def bind_port
  @bind_port
end

#gwObject (readonly)

Returns the value of attribute gw.



11
12
13
# File 'lib/net/natpmp/config.rb', line 11

def gw
  @gw
end

#portObject (readonly)

Returns the value of attribute port.



11
12
13
# File 'lib/net/natpmp/config.rb', line 11

def port
  @port
end