• Stars
    star
    319
  • Rank 131,491 (Top 3 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tunnel proxy package in Go

Tunnel GoDoc Go Report Card Build Status

Tunnel is a server/client package that enables to proxy public connections to your local machine over a tunnel connection from the local machine to the public server. What this means is, you can share your localhost even if it doesn't have a Public IP or if it's not reachable from outside.

It uses the excellent yamux package to multiplex connections between server and client.

The project is under active development, please vendor it if you want to use it.

Usage

The tunnel package consists of two parts. The server and the client.

Server is the public facing part. It's type that satisfies the http.Handler. So it's easily pluggable into existing servers.

Let assume that you setup your DNS service so all *.example.com domains route to your server at the public IP 203.0.113.0. Let us first create the server part:

package main

import (
	"net/http"

	"github.com/koding/tunnel"
)

func main() {
	cfg := &tunnel.ServerConfig{}
	server, _ := tunnel.NewServer(cfg)
	server.AddHost("sub.example.com", "1234")
	http.ListenAndServe(":80", server)
}

Once you create the server, you just plug it into your server. The only detail here is to map a virtualhost to a secret token. The secret token is the only part that needs to be known for the client side.

Let us now create the client side part:

package main

import "github.com/koding/tunnel"

func main() {
	cfg := &tunnel.ClientConfig{
		Identifier: "1234",
		ServerAddr: "203.0.113.0:80",
	}

	client, err := tunnel.NewClient(cfg)
	if err != nil {
		panic(err)
	}

	client.Start()
}

The Start() method is by default blocking. As you see you, we just passed the server address and the secret token.

Now whenever someone hit sub.example.com, the request will be proxied to the machine where client is running and hit the local server running 127.0.0.1:80 (assuming there is one). If someone hits sub.example.com:3000 (assume your server is running at this port), it'll be routed to 127.0.0.1:3000

That's it.

There are many options that can be changed, such as a static local address for your client. Have alook at the documentation

Protocol

The server/client protocol is written in the spec.md file. Please have a look for more detail.

License

The BSD 3-Clause License - see LICENSE for more details

More Repositories

1

kite

Micro-service framework in Go
Go
3,260
star
2

koding

The Simplest Way to Manage Your Entire Dev Infrastructure!
Go
2,122
star
3

multiconfig

Load configuration from multiple sources in Go
Go
454
star
4

websocketproxy

WebSocket reverse proxy handler for Go
Go
426
star
5

awesome-fuse-fs

Resources related to FUSE (filesystem in user space).
292
star
6

kd

UI Framework for web applications.
CoffeeScript
114
star
7

cache

Caching package for Go
Go
89
star
8

kite.js

Kite client in JavaScript
JavaScript
75
star
9

kdlearn

The source for Learn Koding, a Community Documentation site for Koding.com
CSS
44
star
10

vagrantutil

A toolset to manage Vagrant boxes in Go
Go
43
star
11

rabbitmq

Wrapper for Go's AMQP package
Go
41
star
12

logging

Simple logging package in Go
Go
29
star
13

kpm-scripts

Koding Package Manager Scripts
Shell
24
star
14

redis

Wrapper for redis functions
Go
17
star
15

koding-kubernetes

Run Koding with Kubernetes
16
star
16

terraform

A fork of Terraform
Go
15
star
17

Teamwork

Koding's official collaboration app
10
star
18

koding-system-stacks

Koding VM Images
Shell
9
star
19

kite-healthcheck

JavaScript
6
star
20

rabbitapi

Implementation of RabbitMq Management HTTP Api in Go
Go
6
star
21

docker-compose

5
star
22

hackathon.submit

Sample submission repository for Koding Global Virtual Hackathon.
5
star
23

styleguide-coffeescript

This is the guide we use for developing our own apps internally at Koding.
4
star
24

stacks

Example Koding Stack Scripts
4
star
25

kd-atom

Work locally in your cloud resources
JavaScript
4
star
26

kdhelp

KDHelp is a help bin for Koding VMs
CoffeeScript
4
star
27

shortcuts

CoffeeScript
3
star
28

docker-base

Shell
3
star
29

kdc

CoffeeScript
3
star
30

file

File related utils for Go
Go
3
star
31

packer

Packer templates for Koding's infra
Shell
3
star
32

awspurge

Go
2
star
33

pubnub

PubNub go-client wrapper
Go
2
star
34

eb-deploy

Wercker step for deploying elastic beanstalk
Shell
2
star
35

styleguide-content-sharing

Guide to Social Media Image Sizes, sharing rules etc.
2
star
36

tf_kafka

WIP - Terraform Template for Kafka Cluster.
HCL
2
star
37

docker-singular

Shell
2
star
38

coffee-unused

Find unused variables and imports in CoffeeScript files
CoffeeScript
2
star
39

playgrounds

JavaScript
2
star
40

qfunction

Make sure specified function runs one at a time
CoffeeScript
2
star
41

koding-gitlab

Koding With Gitlab in Google Container Engine
HCL
2
star
42

kloud-provider-example

Go
1
star
43

druid-packer

Packer templates for Druid
Shell
1
star
44

step-s3put

Fork of https://github.com/rioki/step-s3put that uploads to s3 using --acl-private
Shell
1
star
45

tf_druid

Terraform Druid Templates
HCL
1
star
46

backoff

backoff
JavaScript
1
star
47

eventexporter

Go
1
star
48

kodingemail

Go
1
star
49

docker-rabbitmq

1
star
50

kd-react

React components of KD framework views
CoffeeScript
1
star
51

keyconfig

CoffeeScript
1
star
52

gulp-kd-pistachio-compiler

pistachio compiler for KD's own templates
JavaScript
1
star
53

asgd

Listen ASG events and change local configuration files.
Go
1
star
54

sshkey

Package sshkey provides public and private key pair for ssh usage.
Go
1
star