mirror of
https://github.com/wweir/sower.git
synced 2024-04-21 12:42:15 +00:00
Clean code
This commit is contained in:
@@ -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
|
||||
|
||||
+4
-1
@@ -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)
|
||||
|
||||
+4
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user