didenko / pald

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PALD - port allocator daemon

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

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:

keytypedefaultdescription
port_listenuint1649200A port on which the pald process will listen for port queries and allocation requests
port_minuint1649201The lowest (first) port available for allocation
port_maxuint1649999The highest (last) port available for allocation
dump_filestring~/.pald/dumpThe default dump file location where the service will persist the state while down

HTTP interface

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

actionURLparam=value
Query/getservice=name
200 - a found port number
404 - an error message if there is no port registered with the requested service
400 - an error message in case of all other errors
Register/setservice=name
200 - an assigned port number
412 - registration failed because no more port numbers available in the configured range
400 - an error message in case of all other errors
Delete/delport=number
200 - OK as a success indication (including port not found)
400 - an error message in case of all other errors

Porting to other platforms

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.

About

License:Other


Languages

Language:Go 100.0%