Skip to content

Commit

Permalink
加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuwenqiang committed Mar 21, 2021
1 parent 854e747 commit 6f38c06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
bin
4 changes: 4 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* server:插件将从local收到的包进行处理后,转发给server
* local:插件将local将要发出的包进行处理后,再向server发出
*/

package main

import (
Expand Down
6 changes: 3 additions & 3 deletions tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func tcpTun(addr, server, target string, shadow func(net.Conn) net.Conn) {
tcpLocal(addr, server, shadow, func(net.Conn) (socks.Addr, error) { return tgt, nil })
}

// Listen on addr and proxy to server to reach target from getAddr.
// tcpLocal Listen on addr and proxy to server to reach target from getAddr.
func tcpLocal(addr, server string, shadow func(net.Conn) net.Conn, getAddr func(net.Conn) (socks.Addr, error)) {
l, err := net.Listen("tcp", addr)
if err != nil {
Expand Down Expand Up @@ -150,10 +150,10 @@ func relay(left, right net.Conn) error {
wg.Add(1)
go func() {
defer wg.Done()
_, err1 = io.Copy(right, left)
_, err1 = io.Copy(right, left) //let right = left
right.SetReadDeadline(time.Now().Add(wait)) // unblock read on right
}()
_, err = io.Copy(left, right)
_, err = io.Copy(left, right) //let left = right
left.SetReadDeadline(time.Now().Add(wait)) // unblock read on left
wg.Wait()
if err1 != nil && !errors.Is(err1, os.ErrDeadlineExceeded) { // requires Go 1.15+
Expand Down

0 comments on commit 6f38c06

Please sign in to comment.