localtunnel

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2017 License: MIT Imports: 6 Imported by: 2

README

localtunnel

Travis

localtunnel is a localtunnel client written in Golang.

localtunnel allows you to expose your localhost to the world for easy testing and sharing!

Installing

Download and put the binary somewhere in your path.

Building from source
git clone http://github.com/jweslley/localtunnel
make build

Usage

Exposing a local port

Assuming your local server is running on port 8000, just use the lt command to start the tunnel.

lt -p 8000

Thats it! A tunnel will be created and the command output will be something like:

your url is: https://dlaaazhqwd.localtunnel.me

This URL can be used and shared to access your local service from anywhere in the world!

You can restart your local server all you want, lt is smart enough to detect this and reconnect once it is back.

Exposing a local port with a custom subdomain

You also can access your service with a custom subdomain. To this, you need the -s option:

lt -p 8000 -s ltdemo

Output:

your url is: https://ltdemo.localtunnel.me
Finishing the tunnel

To finish the tunnel just interrupt the program (Ctrl-C).

API - GoDoc

The localtunnel client is also usable through an API (for test integration, automation, etc).

Creating a tunnel for a local port
import "github.com/jweslley/localtunnel"

...

var port := 8000
var tunnel := localtunnel.NewLocalTunnel(port)
var err := tunnel.Open()
if (err != nil) {
	fmt.Printf("your url is: %s\n", tunnel.URL())
}

...

tunnel.Close()
Creating a tunnel for a local port with a custom subdomain
import "github.com/jweslley/localtunnel"

...

var port := 8000
var subdomain := "ltdemo"
var tunnel := localtunnel.NewLocalTunnel(port)
var err := tunnel.OpenAs(ltdemo)
if (err != nil) {
	fmt.Printf("your url is: %s\n", tunnel.URL())
}

...

tunnel.Close()

For more information, check out the documentation.

Bugs and Feedback

If you discover any bugs or have some idea, feel free to create an issue on GitHub:

http://github.com/jweslley/localtunnel/issues

License

MIT license. Copyright (c) 2016 Jonhnny Weslley http://jonhnnyweslley.net

See the LICENSE file provided with the source distribution for full details.

Documentation

Overview

Package localtunnel implements a client library for https://localtunnel.me

localtunnel allows you to expose your localhost to the world for easy testing and sharing!

Exposing a local port:

import "github.com/jweslley/localtunnel"

...

var port := 8000
var tunnel := localtunnel.NewLocalTunnel(port)
var err := tunnel.Open()
if (err != nil) {
	fmt.Printf("your url is: %s\n", tunnel.URL())
}

...

tunnel.Close()

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = NewClient("https://localtunnel.me")

DefaultClient is the default Client and is used by NewLocalTunnel and NewTunnel.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client is an localtunnel client.

func NewClient

func NewClient(url string) *Client

NewClient returns a client using the given end point.

func (*Client) NewLocalTunnel

func (c *Client) NewLocalTunnel(port int) *Tunnel

NewLocalTunnel create a tunnel for a server in a given port from localhost.

func (*Client) NewTunnel

func (c *Client) NewTunnel(host string, port int) *Tunnel

NewTunnel create a tunnel for a server in a given host and port.

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields
}

Tunnel forwards remote requests to another server, typically to a port on localhost.

func NewLocalTunnel

func NewLocalTunnel(port int) *Tunnel

NewLocalTunnel create a tunnel for a server in a given port from localhost using the DefaultClient.

func NewTunnel

func NewTunnel(host string, port int) *Tunnel

NewTunnel create a tunnel for a server in a given host and port using the DefaultClient.

func (*Tunnel) Close

func (t *Tunnel) Close()

Close closes all tunnel's connections.

func (*Tunnel) Closing

func (t *Tunnel) Closing() <-chan struct{}

Closing is a channel which is closed when the tunnel is closed.

func (*Tunnel) LocalHost

func (t *Tunnel) LocalHost() string

func (*Tunnel) LocalPort

func (t *Tunnel) LocalPort() int

func (*Tunnel) MaxConn

func (t *Tunnel) MaxConn() int

MaxConn is the maximum number of connections allowed.

func (*Tunnel) Open

func (t *Tunnel) Open() error

Open setup the tunnel creating connections between the remote and local servers.

func (*Tunnel) OpenAs

func (t *Tunnel) OpenAs(subdomain string) error

Open setup the tunnel creating connections between the remote and local servers with a custom subdomain.

func (*Tunnel) RemoteHost

func (t *Tunnel) RemoteHost() string

func (*Tunnel) RemotePort

func (t *Tunnel) RemotePort() int

func (*Tunnel) Subdomain

func (t *Tunnel) Subdomain() string

func (*Tunnel) URL

func (t *Tunnel) URL() string

URL at which the localtunnel is exposed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL