@pumpkin-plugins/port-mapping API / mapper / PortMapper
Class: PortMapper
Defined in: tools/port-mapping/src/mapper.ts:110
Keeps a set of ports open on the router: finds the router, opens each port, renews it before the lease ends and closes it when it is released. When this machine already has a public address nothing is opened. Driven by tick, one network operation at a time.
Constructors
Constructor
new PortMapper(
net,options):PortMapper
Defined in: tools/port-mapping/src/mapper.ts:126
Creates a mapper that does nothing until a mapping is requested.
Parameters
net
options
Returns
PortMapper
Methods
info()
info():
MapperInfo
Defined in: tools/port-mapping/src/mapper.ts:175
What has been learned about the network so far.
Returns
mappings()
mappings():
object[]
Defined in: tools/port-mapping/src/mapper.ts:165
Every mapping that was requested, with its state.
Returns
object[]
release()
release(
key):void
Defined in: tools/port-mapping/src/mapper.ts:158
Stops keeping a port open. The router is told on a later tick.
Parameters
key
string
Returns
void
releaseAll()
releaseAll():
Steps<void>
Defined in: tools/port-mapping/src/mapper.ts:220
Closes every open port. Run it to the end when shutting down.
Returns
Steps<void>
request()
request(
key,spec):MappingState
Defined in: tools/port-mapping/src/mapper.ts:136
Asks for a port to be kept open. Asking again with the same spec changes nothing.
Parameters
key
string
Names the mapping, so it can be released.
spec
Returns
The state right now.
state()
state(
key):MappingState|undefined
Defined in: tools/port-mapping/src/mapper.ts:170
The state of a mapping, or undefined when it was never requested.
Parameters
key
string
Returns
MappingState | undefined
tick()
tick():
void
Defined in: tools/port-mapping/src/mapper.ts:187
Moves the work forward. Call it every game tick.
Returns
void