transx/main.go

40 lines
876 B
Go
Raw Permalink Normal View History

// main.go
package main
import (
"flag"
"fmt"
"github.com/TransX/cli"
"github.com/TransX/log"
2015-11-18 23:16:57 +08:00
"github.com/TransX/protocol"
// "github.com/davecheney/profile"
"net/http"
_ "net/http/pprof"
"strconv"
)
func tunnel() {
2015-11-18 23:16:57 +08:00
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)
trans.Start(strconv.Itoa(cli.ListenPort), cli.DestIP, strconv.Itoa(cli.DestPort), cli.EncryptSide)
} else {
trans.Start("1200", "192.168.0.120", "8118", "client")
}
}
func main() {
// defer profile.Start(profile.CPUProfile).Stop()
flag.Parse()
fmt.Println("Hello World!")
2015-11-21 16:54:04 +08:00
log.LogTo(cli.LogTo, "INFO")
if cli.ProfilePort != 0 {
go func() {
http.ListenAndServe("0.0.0.0:"+strconv.Itoa(cli.ProfilePort), nil)
}()
}
tunnel()
}