代码拉取完成,页面将自动刷新
同步操作将从 狂奔的蜗牛./shadowtunnel 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
"strings"
"time"
encryptconn "bitbucket.org/goproxy/proxy/net/common/transport/encrypt"
clienttransport "bitbucket.org/goproxy/proxy/net/transport/client"
srvtransport "bitbucket.org/goproxy/proxy/net/transport/server"
utils "bitbucket.org/goproxy/proxy/utils"
)
const (
VERSION = "1.0"
)
var (
listenAddr string
forwardAddr string
timeout int
compress bool
method string
password string
listen srvtransport.ServerChannel
l = log.New(os.Stderr, "", log.LstdFlags)
err error
inboundEncrypt bool
outboundEncrypt bool
version bool
)
func main() {
flag.StringVar(&listenAddr, "l", ":50000", "local listen address, such as : 0.0.0.0:33000")
flag.StringVar(&method, "m", "aes-192-cfb", "method of encrypt/decrypt, these below are supported :\n"+strings.Join(encryptconn.GetCipherMethods(), ","))
flag.StringVar(&password, "p", "shadowtunnel", "password of encrypt/decrypt")
flag.StringVar(&forwardAddr, "f", "", "forward address,such as : 127.0.0.1:8080")
flag.IntVar(&timeout, "t", 3, "connection timeout seconds")
flag.BoolVar(&compress, "c", true, "compress traffic")
flag.BoolVar(&inboundEncrypt, "e", false, "inbound connection is encrypted")
flag.BoolVar(&outboundEncrypt, "E", false, "outbound connection is encrypted")
flag.BoolVar(&version, "v", false, "show version")
flag.Parse()
if version {
fmt.Println(VERSION)
return
}
if forwardAddr == "" || listenAddr == "" {
flag.Usage()
return
}
listen = srvtransport.NewServerChannelHost(listenAddr, l)
if inboundEncrypt {
err = listen.ListenTCPS(method, password, compress, callback)
} else {
err = listen.ListenTCP(callback)
}
if err != nil {
l.Fatal(err)
}
l.Printf("shadowtunnel listen on : %s", (*listen.Listener).Addr())
select {}
}
func callback(conn net.Conn) {
defer func() {
if e := recover(); e != nil {
l.Printf("connection handler crashed :\n%s", err)
}
}()
remoteAddr := conn.RemoteAddr()
var outconn net.Conn
if outboundEncrypt {
outconn, err = clienttransport.TCPSConnectHost(forwardAddr, method, password, compress, timeout*1000)
} else {
outconn, err = net.DialTimeout("tcp", forwardAddr, time.Duration(timeout)*time.Second)
}
if err != nil {
l.Printf("%s <--> %s, error: %s", remoteAddr, forwardAddr, err)
conn.Close()
return
}
utils.IoBind(conn, outconn, func(err interface{}) {
l.Printf("%s <--> %s released", remoteAddr, forwardAddr)
}, l)
l.Printf("%s <--> %s connected", remoteAddr, forwardAddr)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。