0.1.2 • Published 6 years ago

forward-addr v0.1.2

Weekly downloads
7
License
MPL-2.0
Repository
github
Last release
6 years ago

forward-addr

A multiaddr-inspired address format for recursivly matching protocols and properties

API

  • .parse(String str)<Object>

Returns a parsed forward-addr

Example:

console.log(fwAddr.parse('/tcp/.port/5323/ssl/.hostname/*.example.com/http/.path/"/myservice"/_ws/stream/'))

/*
Returns:
  [
    {protocol: 'tcp', conditions: {port: {compare: '', value: '5323'}}, action: 'stream'},
    {protocol: 'ssl', conditions: {hostname: {compare: '', value: '*.example.com'}}, action: 'stream'},
    {protocol: 'http', conditions: {path: {compare: '', value: '/myservice'}}, action: 'sub', sub: {
      protocol: 'ws', conditions: {}, action: 'stream'
    }},
  ]
*/
  • .validate(Object parsedAddr, Protocols[] protocols)<Object>

Validates the multiaddr. Throws if it is using invalid combinations of protocols, etc.

Returns a new complete parsed object where missing match fields are filled in and values are properly parsed.

Note that this mutates the parsedAddr Object

  • .match(Object parsedAddr, Object connState)<Number>

Matches a parsed address with a connection state

Returns:

  • 0: Address does not match connection state
  • 1: Address might match connection state, depending on the result of the next protocol detection
  • 2: Address matches connection state
0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago