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

lan-tunnel

v3.1.0

Published

🖇Library for exposing server from local network to the internet.

Downloads

3

Readme

lan-tunnel

🖇Library for exposing server from local network to the internet.

Why

When you need to access your raspberry pi or a automation hub from the internet, but port forwarding or public IP is not an option.

How it works

Consists of two parts:

  • Proxy server Forwards incoming internet requests through a tunnel to your LAN. Needs to be run on your own server accessible from the internet, VPS or something like heroku.
  • Client Is run from within your LAN. It serves as a glue between your app and the proxy by opening a pool of keep-alive sockets connection both and passes Can be a part of your app or a separate process.

Your app (web server) doesn't need to change. It just responds to its usual port.

TL;DR

          PROXY SERVER         TUNNEL         LAN APP
 available on internet    exposes the app     inaccessible from internet
 at https://you.com:80   through tunnelPort   at http://localhost:80
                    |                          |
                    |                          | Your app connects to proxy
                    | <----------------------- | and opens keep-alive tunnel
                    |                          | sockets for handling requests
                    |                          |
    GET request     |                          |
you.com/index.html  |   pass request to app    |
------------------> |   localhost/index.html   |
                    | -----------------------> |
                    |                          | Your app serves /index.html
    proxy serves    |   pass /index.html back  |
    /index.html     | <----------------------- |
<------------------ |                          |
                    |                          |

Installation

npm install lan-tunnel

Usage

Check out the extended example.

Proxy server running on the remote machine

import {createProxyServer} from 'lan-tunnel'

createProxyServer({
  // Port where you can access the app from internet
  proxyPort: 80,
  // Internal port for communicating between the proxy and your local app
  tunnelPort: 8010,
  // OPTIONAL: Certificate to make the server HTTPS instead of simple HTTP.
  key:  fs.readFileSync('../../ssl.key'),
  cert: fs.readFileSync('../../ssl.cert'),
  // OPTIONAL: Encryption of TCP tunnels
  tunnelEncryption: {
    key: 'abcdefghijklmnopqrstuvwxyzABCDEF',
    iv: '1234567890123456',
    cipher: 'aes-256-ctr',
  },
})

Client side running in your local network

import {exposeThroughProxy} from 'lan-tunnel'

// Include this in your app, or run separately
exposeThroughProxy({
  // The internet proxy server at which the app will be exposed
  proxyHost: 'your-proxy-server.com',
  proxyPort: 80,
  tunnelPort: 8010,
  // Your app
  appPort: 8080
  // OPTIONAL: Encryption of TCP tunnels
  tunnelEncryption: {...}
})

// your typical web server listening on the appPort.
const app = express()
app.listen(8080)

Client code can also run standalone on a different machine if you define appHost.

License

MIT, Mike Kovařík, Mutiny.cz