npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anygram

v0.2.2

Published

Datagram forwarding behind NAT

Downloads

24

Readme

AnyGram

Datagram forwarding behind NAT

Anygram uses STUN to get the mapped address, IRC to signal peers.

Install

npm -g install anygram@latest

CLI

Server

anygram -n [serverNick] -m server -P [serverPort]

Client

anygram -n [clientNick] -m client -s [serverNick] -p [clientPort] -P 
[serverPort]

The commands above will forward packets to 127.0.0.1:clientPort@client to 127.0.0.1:serverPort@server. For more options, see anygram --help

To run the commands forever, consider using forever

API

var anygram = require('anygram')(config);

The config options is also listed in anygram --help

In AnyGram, all sockets are UDP sockets.

anygram.punch(socket)

Returns a promise of socket. socket.rinfo may change if the remote NAT is symmetric. The punching process usually succeeds if not both NATs are symmetric.

socket is a UDP socket plus two attributes linfo and rinfo, obtained by calling anygram.stun

The rinfo.punchTime attribute also indicates when to start punching. This option is to make sure both sides start punching at the same time in spite of the (sometimes huge) IRC time lag.

anygram.stun(stunServer)

Returns a promise of socket. socket.linfo will include the mapped port, address and the NAT type.

stunServer is the hostname of a stun server listening at 3478

anygram.irc(config)

Returns an IRC client.

The config should specify the name and pass(if any) of your IRC account. The IRC server's host and port are optional. The client will send PING packets at the keepalive interval.

anygram.connect(irc, to, rinfo)

Returns a promise of socket.

irc is the IRC client

to is the name of the peer you are connecting to

rinfo(optional) is specified if you already got peer's rinfo

anygram.createServer(irc, onconn, onerr)

Start listening on the irc client for incoming connections

onconn is called when connected with a peer successfully

onerr is called on error

anygram.send(socket, msg, lport, rport)

Sends msg with 4 bytes header (lport and rport)

anygram.onrecv(socket, cb)

Parses received messages to cb(msg, lport, rport)

Notice that the rport@remote will become lport@local and vice versa.

Credits