forked from w910820618/shadowsocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa246d1
commit da0c32a
Showing
5 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"io" | ||
"log" | ||
"net" | ||
"os" | ||
) | ||
|
||
var local = flag.String("local", "", "please enter monitor ip, example: 192.168.0.104:8805") | ||
var target = flag.String("target", "", "please enter target ip, example : 192.168.1.105:8806") | ||
|
||
func main() { | ||
|
||
l, err := net.Listen("tcp", *local) | ||
if err != nil { | ||
fmt.Println(err, err.Error()) | ||
os.Exit(0) | ||
} | ||
|
||
for { | ||
s_conn, err := l.Accept() | ||
log.Println("接收到 " + s_conn.RemoteAddr().String() + " 发送请求") | ||
if err != nil { | ||
continue | ||
} | ||
|
||
d_tcpAddr, _ := net.ResolveTCPAddr("tcp4", *target) | ||
d_conn, err := net.DialTCP("tcp", nil, d_tcpAddr) | ||
log.Println("向 " + *target + " 发送请求") | ||
if err != nil { | ||
fmt.Println(err) | ||
s_conn.Write([]byte("can't connect " + *target)) | ||
s_conn.Close() | ||
continue | ||
} | ||
go io.Copy(s_conn, d_conn) | ||
go io.Copy(d_conn, s_conn) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.