Giter VIP home page Giter VIP logo

gotunnel's Introduction

Build Status

gotunnel

gotunnel is a secure tcp tunnel software. It can use tcp or udp connectioin as low level tunnel.

gotunnel could be added to any c/s system using tcp protocol. Make system structure evolve from

client <--------------> server

to

client <-> gotunnel <--------------> gotunnel <-> server

to gain gotunnel's valuable features, such as secure and persistent.

build

go install github.com/xjdrew/gotunnel

Usage

usage: bin/gotunnel
  -backend string
        backend address (default "127.0.0.1:1234")
  -listen string
        listen address (default ":8001")
  -log uint
        log level (default 1)
  -secret string
        tunnel secret (default "the answer to life, the universe and everything")
  -timeout int
        tunnel read/write timeout (default 3)
  -tunnels uint
        low level tunnel count, 0 if work as server

some options:

  • secret: for authentication and exchanging encryption key
  • tunnels: 0 means gotunnel will and as server; Any value larger than 0 means gotunnel will work as client, and build tunnels tcp connections to server.
  • timeout: if can't read a packet body in timeout seconds, will recreate this tunnel. It's useful if theres is a critical firewall between gotunnel client and server.

Example

Suppose you have a squid server, and you use it as a http proxy. Usually, you will start the server:

$ squid3 -a 8080

and use it on your pc:

curl --proxy server:8080 http://example.com

It works fine but all traffic between your server and pc is plaintext, so someone can monitor you easily. In this case, gotunnel could help to encrypt your traffic.

First, on your server, resart squid to listen on a local port, for example 127.0.0.1:3128. Then start gotunnel server listen on 8080 and use 127.0.0.1:3128 as backend.

$ ./gotunnel -listen=:8001 -backend=127.0.0.1:3128 -secret="your secret" -log=10 

Second, on your pc, start gotunnel client:

$ ./gotunnel -tunnels=100 -listen="127.0.0.1:8080" -backend="server:8001" -secret="your secret" -log=10 

Then you can use squid3 on you local port as before, but all your traffic is encrypted.

Besides that, you don't need to create and destory tcp connection between your pc and server, because gotunnel use long-live tcp connections as low tunnel. In most cases, it would be faster.

licence

The MIT License (MIT)

Copyright (c) 2015 xjdrew

gotunnel's People

Contributors

cofyc avatar kr1sten0 avatar mapx avatar rmrf avatar t0350 avatar xjdrew 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  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  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

gotunnel's Issues

连接出现错误?

服务端(centos x64):gotunnel -tunnels=0 -listen=:443 -backend=127.0.0.1:8888 secret="123" -log=10
客户端(centos x64或win7 x64):gotunnel -tunnels=100 -listen="127.0.0.1:8080" -backend="...:443" -secret="123" -log=10
统一错误:
read token failed(...:12362):read tcp ...:12362: connection reset by peer
read token failed(serverip:55374):EOF
能帮忙看一下吗?

程序崩溃

大流量跑一段时间后崩溃了..

goroutine 177166 [semacquire]:
sync.runtime_Syncsemacquire(0xc820e68010)
    /usr/local/go/src/runtime/sema.go:237 +0x201
sync.(*Cond).Wait(0xc820e68000)
    /usr/local/go/src/sync/cond.go:62 +0x9b
github.com/xjdrew/gotunnel/tunnel.(*LinkBuffer).Pop(0xc820e68280, 0x0, 0x0, 0x0, 0x3)
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/link_buffer.go:83 +0x1b6
github.com/xjdrew/gotunnel/tunnel.(*Link).pumpOut(0xc820e682c0)
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/link.go:103 +0xb5
created by github.com/xjdrew/gotunnel/tunnel.(*Link).Pump
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/link.go:131 +0xfe

goroutine 177128 [semacquire]:
sync.runtime_Semacquire(0xc82054cdb0)
    /usr/local/go/src/runtime/sema.go:43 +0x26
sync.(*WaitGroup).Wait(0xc82054cda4)
    /usr/local/go/src/sync/waitgroup.go:126 +0xb4
github.com/xjdrew/gotunnel/tunnel.(*Link).Pump(0xc82054cd80, 0xc820026230)
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/link.go:133 +0x11c
github.com/xjdrew/gotunnel/tunnel.(*Client).handleConn(0xc82000a240, 0xc8206ba160, 0xc820026230)
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/client.go:108 +0x2d9
created by github.com/xjdrew/gotunnel/tunnel.(*Client).listen
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/client.go:139 +0x520

goroutine 177129 [IO wait]:
net.runtime_pollWait(0x7f28b8c33120, 0x72, 0xc82000e1a0)
    /usr/local/go/src/runtime/netpoll.go:157 +0x60
net.(*pollDesc).Wait(0xc820697800, 0x72, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a
net.(*pollDesc).WaitRead(0xc820697800, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:78 +0x36
net.(*netFD).Read(0xc8206977a0, 0xc83a29a000, 0x4000, 0x4000, 0x0, 0x7f28b8c2d050, 0xc82000e1a0)
    /usr/local/go/src/net/fd_unix.go:232 +0x23a
net.(*conn).Read(0xc820026230, 0xc83a29a000, 0x4000, 0x4000, 0x0, 0x0, 0x0)
    /usr/local/go/src/net/net.go:172 +0xe4
bufio.(*Reader).fill(0xc820c8def0)
    /usr/local/go/src/bufio/bufio.go:97 +0x1e9
bufio.(*Reader).Read(0xc820c8def0, 0xc83a298000, 0x2000, 0x2000, 0x2000, 0x0, 0x0)
    /usr/local/go/src/bufio/bufio.go:207 +0x260
github.com/xjdrew/gotunnel/tunnel.(*Link).pumpIn(0xc82054cd80)
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/link.go:75 +0x183
created by github.com/xjdrew/gotunnel/tunnel.(*Link).Pump
    /root/gospace/src/github.com/xjdrew/gotunnel/tunnel/link.go:128 +0xb5

Can not create tunnel

15/08/27 21:16:26.551670 create tunnel: 192.168.11.9:45061 <-> 45...5:8001
2015/08/27 21:16:26.606621 challenge(45.
..5:8001), len 32, [121 212 42 211 5 203 39 198 30 25 134 235 255 173 191 58 54 199 198 4 177 84 190 129 148 94 113 84 151 255 222 13]
2015/08/27 21:16:26.606749 exchange challenge failed(45..
.**5:8001)

怎么翻不了墙呢?

hi。
我服务器端和客户端都设置好了,怎么翻不了墙呢?

客户端的运行情况:
yudeMacBook-Air:~ yuming$ ps aux|grep go tunnel
yuming 520 0.0 0.1 573395136 6180 ?? S 1:41下午 0:00.19 /Users/yuming/gotunnel/bin/gotunnel -listen=127.0.0.1:7070 -backend=23.xx.yy.zz:8001 -secret=ilovepeide -tunnels=100
yuming 577 0.0 0.0 2441988 656 s000 S+ 2:17下午 0:00.01 grep gotunnel
yudeMacBook-Air:~ yuming$

服务器端的运行情况:
root@VM:# ps aux|grep go tunnel
root 1784 0.0 6.2 199376 16372 ? Sl Oct24 0:01 ./gotunnel -listen=:8001 -backend=127.0.0.1:3128 -secret=ilovepeide -tunnels=0
root 11244 0.0 0.3 8812 844 pts/3 S+ 02:20 0:00 grep --color=auto gotunnel
root@VM:
#
root@VM:/go/bin# netstat -anp|grep 3128
tcp6 0 0 :::3128 :::* LISTEN 1140/squid3
root@VM:
/go/bin#

设置firefox的socks5代理为127.0.0.1:7070,但是就是翻不了墙,为什么呢?

https?

这个支持https吗?
速度比SS快吗?

Compile Error in Debian Linux

$ uname -a
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux
$ sudo apt-get install golang -y
$ go version
go version go1.3.3 linux/amd64

$ curl -fsSL https://github.com/xjdrew/gotunnel/raw/master/install.sh|bash
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 api.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 buffer.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 cache.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 ccc.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 channel.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 common.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 core.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 epoll.cpp -c
epoll.cpp:110:69: warning: unused parameter ‘events’ [-Wunused-parameter]
 int CEPoll::add_ssock(const int eid, const SYSSOCKET& s, const int* events)
                                                                     ^
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 list.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 md5.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 packet.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 queue.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 window.cpp -c
g++ -fPIC -Wall -Wextra -DLinux -finline-functions -O3 -fno-strict-aliasing -fvisibility=hidden -DAMD64 udt_wrap.cpp -c
ar -rcs libudt.a api.o buffer.o cache.o ccc.o channel.o common.o core.o epoll.o list.o md5.o packet.o queue.o window.o udt_wrap.o
# github.com/xjdrew/go-udtwrapper/udt
../../udt/fd_rw.go:37: unknown net.OpError field 'Source' in struct literal
gotunnel is in gospace/bin/, go and run

$ ls gospace/
libudt.a  pkg/      src/

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.