Last active
July 2, 2018 12:20
-
-
Save nl5887/c913043f7fbbef221a2445fefb865eca to your computer and use it in GitHub Desktop.
Connects two outgoing connections
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "net" | |
| "os" | |
| ) | |
| func main() { | |
| if len(os.Args) != 3 { | |
| fmt.Println("proxy src dst") | |
| os.Exit(1) | |
| } | |
| fmt.Println("Connecting to ", os.Args[1]) | |
| conn2, err := net.Dial("tcp", os.Args[1]) | |
| if err != nil { | |
| fmt.Println(err) | |
| os.Exit(1) | |
| } | |
| fmt.Println("Connected to ", os.Args[1]) | |
| fmt.Println("Connecting to ", os.Args[2]) | |
| conn, err := net.Dial("tcp", os.Args[2]) | |
| if err != nil { | |
| fmt.Println(err) | |
| os.Exit(1) | |
| } | |
| fmt.Println("Connected to ", os.Args[2]) | |
| go io.Copy(conn2, conn) | |
| io.Copy(conn, io.TeeReader(conn2, os.Stdout)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment