Git Product home page Git Product logo

gotunnel's Introduction

Gotunnel - server your local server/directory over the internet

Gotunnel makes your localhost server or directory accessible on the net. It supports HTTP/S and WebSocket.

Assuming your server is running on port 3000, on your laptop. Run ./gotunnel -p "3000" (from the checkedout repository, see installation) and that would make it accessible on a subdomain at localtunnel.net.

$ ./gotunnel -p 3000
Setting Gotunnel server localtunnel.net:34000 with local server on 3000

Connect to vxyz.localtunnel.net

If you would like to serve a directory on the internet (think python -m SimpleHTTPServer 8000 over the internet), then run:

$ ./gotunnel -fs -p <some port> -d <path to dir>

The server is running on ec2 small instance, so although free, might not be able to handle much load. You can deploy the server on your own machine (ec2 instance etc), and connect the client to it. More below.

Installation

If you are on Mac OS X, just checkout the repository. The client binary that comes with the repo, should work.

git clone https://github.com/ciju/gotunnel

If you are on some other OS, or the above didn't work. First install Go. Then clone the repo, and build the client. Ex:

git clone https://github.com/ciju/gotunnel
go get
make

Client Options

$ ./gotunnel
Usage: ./gotunnel [OPTIONS]

Options:
  -d="": The directory to serve. To be used with -fs.
  -fs=false: Server files in the current directory. Use -p to specify the port.
  -p="": port
  -r="localtunnel.net:34000": the remote gotunnel server host/ip:port
  -sc=false: Skip version check
  -sub="": request subdomain to serve on

Running your own server

Install golang, and compile the server with command.

go get
go build server.go

Run the server with custom options. Usage: ./server [OPTIONS]

Options:
  -a="localtunnel.net": the address to be used by the users
  -p="32000": Access the tunnel sites on this port.
  -x="0.0.0.0:34000": Port for clients to connect to

Limitations

  • If making connections to ports like 34000 are not allowed by your n/w then the client might not work.

  • Connection pooling might not be possible. Working at the TCP level, we loose the ability of knowing when an HTTP/S or websocket request has finished, except when TCP connection ends.

TODO

  • statistics
  • better error handling
  • make it faster

LICENSE

MIT

Sponsored by ActiveSphere

gotunnel's People

Contributors

ciju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gotunnel's Issues

Websocket doesn't work

i compiled everything then i tried the code on localhost.

What i did:

I opened a websocket server on 127.0.0.1:8082

run the go server as follows:

./server -p "8083" -x "127.0.0.1:8084"

So, as far as i understood it listens for go clients it tunnels to on 127.0.0.1:8084 and accepts websockets connections on 8083

Then i run a client as follows:

./client -p 8082 -r "127.0.0.1:8084" -sc

It should alert the server (127.0.0.1:8084) that it must tunnels to this client, and the client redirects everything on the websocket server on 127.0.0.1:8082

I Have run a piece of code from the browser that opens a websocket on 127.0.0.1:8083 and this is the error it appears on the go server shell:
2021-04-01 17:34:12.560030599 +0200 CEST - Request: %!(EXTRA string=127.0.0.1:8083 <-> 127.0.0.1:34044) 2021-04-01 17:34:12.560093315 +0200 CEST - H: bytes%!(EXTRA int=537) 2021-04-01 17:34:12.560152436 +0200 CEST - Request: host: localtunnel.net 127.0.0.1:8083 2021-04-01 17:34:12.560192542 +0200 CEST - Router: id for host%!(EXTRA string=, string=127.0.0.1:8083) 2021-04-01 17:34:12.560203094 +0200 CEST - Router: for id: %!(EXTRA string=, string=Router: map[g:0xc82007fd40]) 2021-04-01 17:34:12.560206414 +0200 CEST - Request: coundn't find proxy for%!(EXTRA string=127.0.0.1:8083)

It does not proxy anything to the go client :/

OS: Ubuntu 16.04 lts

From the Chrome developer console this appears:
WebSocket connection to 'ws://127.0.0.1:8083/' failed: Error during WebSocket handshake: net::ERR_INVALID_HTTP_RESPONSE

Error while building client

I am on ubuntu 12.10 and when trying to build the client after installing go on machine, I am getting this error.

gtclient/gtclient.go:11:2: import "github.com/ciju/gotunnel/log": cannot find package
gtclient/gtclient.go:12:2: import "github.com/ciju/gotunnel/protocol": cannot find package
gtclient/gtclient.go:13:2: import "github.com/ciju/gotunnel/rwtunnel": cannot find package
client.go:12:2: import "github.com/ciju/vercheck": cannot find package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.