Skip to content

@pumpkin-plugins/port-mapping API / mapper / PortMapper

Class: PortMapper ​

Defined in: tools/port-mapping/src/mapper.ts:87

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:101

Creates a mapper that does nothing until a mapping is requested.

Parameters ​

net ​

Network

options ​

MapperOptions

Returns ​

PortMapper

Methods ​

info() ​

info(): MapperInfo

Defined in: tools/port-mapping/src/mapper.ts:142

What has been learned about the network so far.

Returns ​

MapperInfo


mappings() ​

mappings(): object[]

Defined in: tools/port-mapping/src/mapper.ts:132

Every mapping that was requested, with its state.

Returns ​

object[]


release() ​

release(key): void

Defined in: tools/port-mapping/src/mapper.ts:125

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:186

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:111

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 ​

MappingSpec

Returns ​

MappingState

The state right now.


state() ​

state(key): MappingState | undefined

Defined in: tools/port-mapping/src/mapper.ts:137

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:154

Moves the work forward. Call it every game tick.

Returns ​

void

Pumpkin Plugins documentation