Types
NetworkInterfaceProvider = proc (addrFamily: AddressFamily): seq[ InterfaceAddress] {....gcsafe, raises: [].}
- Source Edit
WildcardAddressResolverService = ref object of Service networkInterfaceProvider: NetworkInterfaceProvider ## Provides a list of network addresses. addressMapper: AddressMapper ## An implementation of an address mapper that takes a list of listen addresses and expands each wildcard address ## to the respective list of interface addresses. As an example, if the listen address is 0.0.0.0:4001 ## and the machine has 2 interfaces with IPs 172.217.11.174 and 64.233.177.113, the address mapper will ## expand the wildcard address to 172.217.11.174:4001 and 64.233.177.113:4001.
- Service used to resolve wildcard addresses of the type "0.0.0.0" for IPv4 or "::" for IPv6. When used with a Switch, this service will be automatically set up and stopped when the switch starts and stops. This is facilitated by adding the service to the switch's list of services using the .withServices(@[svc]) method in the SwitchBuilder. Source Edit
Procs
proc getProtocolArgument(ma: MultiAddress; codec: MultiCodec): MaResult[ seq[byte]] {....raises: [], tags: [].}
- Source Edit
proc new(T: typedesc[WildcardAddressResolverService]; networkInterfaceProvider: NetworkInterfaceProvider = getAddresses): T:type {. ...raises: [].}
-
This procedure initializes a new WildcardAddressResolverService with the provided network interface provider.
Parameters:
- T: The type descriptor for WildcardAddressResolverService.
- networkInterfaceProvider: A provider that offers access to network interfaces. Defaults to a new instance of NetworkInterfaceProvider.
Returns:
- A new instance of WildcardAddressResolverService.
Methods
method run(self: WildcardAddressResolverService; switch: Switch): Future[void] {. public(), stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [], tags: [RootEffect].}
-
Runs the WildcardAddressResolverService for a given switch.
It updates the peer information for the provided switch by running the registered address mapper. Any other address mappers that are registered with the switch will also be run.
Source Edit method setup(self: WildcardAddressResolverService; switch: Switch): Future[bool] {. stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [], tags: [RootEffect].}
-
Sets up the WildcardAddressResolverService.
This method adds the address mapper to the peer's list of address mappers.
Parameters:
- self: The instance of WildcardAddressResolverService being set up.
- switch: The switch context in which the service operates.
Returns:
- A Future[bool] that resolves to true if the setup was successful, otherwise false.
method stop(self: WildcardAddressResolverService; switch: Switch): Future[bool] {. public(), stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [], tags: [RootEffect].}
-
Stops the WildcardAddressResolverService.
Handles the shutdown process of the WildcardAddressResolverService for a given switch. It removes the address mapper from the switch's list of address mappers. It then updates the peer information for the provided switch. Any wildcard address wont be resolved anymore.
Parameters:
- self: The instance of the WildcardAddressResolverService.
- switch: The Switch object associated with the service.
Returns:
- A future that resolves to true if the service was successfully stopped, otherwise false.