From 54cd925ab2b26a9fe0f1f7a0986340d6b3b1746f Mon Sep 17 00:00:00 2001 From: "dmy@lab" Date: Wed, 18 Nov 2015 23:16:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=BB=84=E7=BB=87=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benckmark.go | 5 +++-- main.go | 5 +++-- constant.go => protocol/constant.go | 2 +- tcp.go => protocol/tcp.go | 2 +- tunnel.go => protocol/tunnel.go | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) rename constant.go => protocol/constant.go (81%) rename tcp.go => protocol/tcp.go (99%) rename tunnel.go => protocol/tunnel.go (99%) diff --git a/benckmark.go b/benckmark.go index bc217db..e87e0ec 100644 --- a/benckmark.go +++ b/benckmark.go @@ -2,6 +2,7 @@ package main import ( llog "github.com/TransX/log" + "github.com/TransX/protocol" "github.com/davecheney/profile" "io/ioutil" "log" @@ -15,12 +16,12 @@ var mux sync.Mutex var benchSeed int func transClient() { - t := NewTransTCP() + t := protocol.NewTransTCP() t.Start("1200", "127.0.0.1", "1201", "client") } func transServer() { - t := NewTransTCP() + t := protocol.NewTransTCP() t.Start("1201", "192.168.56.101", "80", "server") } diff --git a/main.go b/main.go index 7c75cf1..e2413c5 100644 --- a/main.go +++ b/main.go @@ -6,12 +6,13 @@ import ( "fmt" "github.com/TransX/cli" "github.com/TransX/log" + "github.com/TransX/protocol" "github.com/davecheney/profile" "strconv" ) func tunnel() { - trans := NewTransTCP() + trans := protocol.NewTransTCP() log.Info("%s side is encrypted.", cli.EncryptSide) if cli.DestPort != 0 { log.Info("Listening on 0.0.0.0:%d. Forward %s:%d", cli.ListenPort, cli.DestIP, cli.DestPort) @@ -22,7 +23,7 @@ func tunnel() { } -func main() { +func main1() { defer profile.Start(profile.CPUProfile).Stop() flag.Parse() fmt.Println("Hello World!") diff --git a/constant.go b/protocol/constant.go similarity index 81% rename from constant.go rename to protocol/constant.go index ef96390..a61cc4f 100644 --- a/constant.go +++ b/protocol/constant.go @@ -1,4 +1,4 @@ -package main +package protocol type Direction int diff --git a/tcp.go b/protocol/tcp.go similarity index 99% rename from tcp.go rename to protocol/tcp.go index 847d18b..74fdaad 100644 --- a/tcp.go +++ b/protocol/tcp.go @@ -1,4 +1,4 @@ -package main +package protocol import ( "errors" diff --git a/tunnel.go b/protocol/tunnel.go similarity index 99% rename from tunnel.go rename to protocol/tunnel.go index c45fbe1..0c4476a 100644 --- a/tunnel.go +++ b/protocol/tunnel.go @@ -1,4 +1,4 @@ -package main +package protocol import ( "bytes"