diff --git a/README.md b/README.md index fbae1cc..8161ee0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Yet another cross platform transparent proxy tool | | relay service| | | +-----+---------------------+ | | | | | - | | parsr http(s) target url | | + | | parse http(s) target url | | | | | | | +---------------------------+ | | shadow service | @@ -23,7 +23,7 @@ Yet another cross platform transparent proxy tool | | | | shadow service | | | relay service | dns | - | | server | + | | service | | | | | 127.0.0.1 or other | | | | @@ -41,7 +41,7 @@ Yet another cross platform transparent proxy tool 1. install server on `server node` by `make server` 2. write config file, example: [conf/sower.toml](https://github.com/wweir/sower/blob/master/conf/sower.toml) 3. install client on `client node` by `make client` -4. add `127.0.0.1` as you first domain server +4. add `127.0.0.1` as you first domain name server ## todo - [x] authenticate diff --git a/parse/addr.go b/parse/parse_addr.go similarity index 100% rename from parse/addr.go rename to parse/parse_addr.go diff --git a/proxy/client.go b/proxy/client.go index 0b01c79..ad64f7c 100644 --- a/proxy/client.go +++ b/proxy/client.go @@ -16,6 +16,7 @@ type Client interface { func StartClient(netType, server, cipher, password string) { var connCh = listenLocal([]string{":80", ":443"}) + var client Client switch netType { case QUIC.String(): @@ -24,9 +25,11 @@ func StartClient(netType, server, cipher, password string) { client = kcp.NewClient() case TCP.String(): client = tcp.NewClient() + default: + glog.Fatalln("invalid net type: " + netType) } - glog.Infoln("Client started.") + glog.Infoln("Client started.") for { conn := <-connCh glog.V(1).Infof("new conn from (%s) to (%s)", conn.RemoteAddr(), server) diff --git a/proxy/server.go b/proxy/server.go index d8dea42..891c9ec 100644 --- a/proxy/server.go +++ b/proxy/server.go @@ -25,6 +25,8 @@ func StartServer(netType, port, cipher, password string) { server = kcp.NewServer(password) case TCP.String(): server = tcp.NewServer() + default: + glog.Fatalln("invalid net type: " + netType) } if port == "" { @@ -37,8 +39,8 @@ func StartServer(netType, port, cipher, password string) { if err != nil { glog.Fatalf("listen %v fail: %s", port, err) } - glog.Infoln("Server started.") + glog.Infoln("Server started.") for { conn := <-connCh conn = shadow.Shadow(conn, cipher, password) @@ -57,6 +59,7 @@ func handle(conn net.Conn) { rc, err := net.Dial("tcp", addr) if err != nil { + conn.Close() glog.Warningln(err) return }