Skip to content

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

Notifications You must be signed in to change notification settings

Teletunnel/forward-addr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published