pald
is a very simple, intentionally feature-poor local daemon aimed to keep registry of port allocations on a local system. Due to the lack of time to address security concerns pald
only listens on localhost interfaces currently.
It is expected to operate on the port range of 49152-65535, as specified in Section 6 of RFC-6335. Any contiguous range of valid port numbers to be allocated can be specified in configuration.
Configuration is read from either system-wide and user-specific config.ext files. The state of assigned services persisted in the dump
file in a location for user-specific configuration file. Configuratoin file location reflects executable name.
Dump file format is undecided yet and likely will be changed in the future.
Configuration file expected to be in the TOML or othe formats as implemented by the Viper
package used in pald
. Here is what can be specified in the config file:
key | type | default | description |
---|---|---|---|
port_listen | uint16 | 49200 | A port on which the pald process will listen for port queries and allocation requests |
port_min | uint16 | 49201 | The lowest (first) port available for allocation |
port_max | uint16 | 49999 | The highest (last) port available for allocation |
dump_file | string | ~/.pald/dump | The default dump file location where the service will persist the state while down |
All requests are available as either HTTP GET or HTTP POST, e.g.
http://localhost:49200/get?service=service-name
REPLY=`curl -d service=service-name -o - -s -f http://localhost:49200/get`
echo $?
echo $REPLY
Three URLs are currently supported (with HTTP reply codes):
action | URL | param=value |
---|---|---|
Query | /get | service=name |
200 - a found port number404 - an error message if there is no port registered with the requested service400 - an error message in case of all other errors | ||
Register | /set | service=name |
200 - an assigned port number412 - registration failed because no more port numbers available in the configured range400 - an error message in case of all other errors | ||
Delete | /del | port=number |
200 - OK as a success indication (including port not found)400 - an error message in case of all other errors |
At this time pald
is only compatible with Mac OS X, but it is easy to fix. Please, add an appropriate internal\platform\specific_<platform>.go
file for your platform and send me a pull request.