Giter Site home page Giter Site logo

pald's Introduction

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.

pald's People

Contributors

didenko avatar

Watchers

 avatar  avatar

pald's Issues

Output format

JSON or text/plain? JSON seems to be more flexible. In this case though the output would be great is processed by shell scripts as curl output, for which text/plain fits better.

Daemon verbs are broken

Specifically, sudo bin/pald status panics:

panic: Unsupported Config Type ""

goroutine 1 [running]:
main.init·1()
    /Users/vlad/Code/pald/src/github.com/didenko/pald/cmd/pald/pald.go:107 +0x353
main.init()
    /Users/vlad/Code/pald/src/github.com/didenko/pald/cmd/pald/pald.go:133 +0x6a

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

Aware to actual ports in use

When allocating or fixing a port optionally test that the port is not in actual use on the system (platform-dependant)

Dynamic port allocations only

Fixed port assignments are scope creep for now. They complicate unnecessarily and pull the mind to complexity swamp.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.