Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
EddieIvan01 committed Sep 22, 2020
1 parent 0db18f3 commit d985f23
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Of course, because `iox` is written in Go, the static-link-program is a little l

You can see, all params are uniform. `-l/--local` means listen on a local port; `-r/--remote` means connect to remote host

**Note: after v0.4, `-l` could specify which IP to listen on. If only ports are specified, the default is `0.0.0.0:PORT`**
**Note: after v0.4, `-l/--local` could specify which IP to listen on. If only ports are specified, the default is `0.0.0.0:PORT`**

```
-l 127.0.0.1:9999 -l *127.0.0.1:9999 # 127.0.0.1:9999
Expand Down
2 changes: 1 addition & 1 deletion docs/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

所有的参数都是统一的。`-l/--local`意为监听本地端口;`-r/--remote`意为连接远端主机

**注意: v0.4版本之后, `-l`参数可以指定监听哪个IP。如果只指定了端口,则默认是`0.0.0.0:PORT`**
**注意: v0.4版本之后, `-l/--local`参数可以指定监听哪个IP。如果只指定了端口,则默认是`0.0.0.0:PORT`**

```
-l 127.0.0.1:9999 -l *127.0.0.1:9999 # 127.0.0.1:9999
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const VERSION = "0.4"
func Usage() {
fmt.Printf(
"iox v%v\n"+
" Roaming intranet easier (https://github.com/eddieivan01/iox)\n\n"+
" Access intranet easily (https://github.com/eddieivan01/iox)\n\n"+
"Usage: iox fwd/proxy [-l [*][HOST:]PORT] [-r [*]HOST:PORT] [-k HEX] [-t TIMEOUT] [-u] [-h] [-v]\n\n"+
"Options:\n"+
" -l [*][HOST:]PORT\n"+
Expand Down
32 changes: 13 additions & 19 deletions operate/fwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ import (
"time"
)

func printFwdSuccess(addrA string, addrB string, encA bool, encB bool) {
if encA {
addrA = "*" + addrA
}
if encB {
addrB = "*" + addrB
}
logger.Success("Forward %s traffic between %s and %s", option.PROTOCOL, addrA, addrB)
}

func local2RemoteTCP(local string, remote string, lenc bool, renc bool) {
listener, err := net.Listen("tcp", local)
if err != nil {
Expand All @@ -27,8 +17,6 @@ func local2RemoteTCP(local string, remote string, lenc bool, renc bool) {
}
defer listener.Close()

printFwdSuccess(local, remote, lenc, renc)

for {
logger.Info("Wait for connection on %s", local)

Expand Down Expand Up @@ -110,21 +98,22 @@ func local2RemoteUDP(local string, remote string, lenc bool, renc bool) {
return
}

printFwdSuccess(local, remote, lenc, renc)
netio.ForwardUDP(listenerCtx, remoteCtx)
}

func Local2Remote(local string, remote string, lenc bool, renc bool) {
if option.PROTOCOL == "TCP" {
logger.Success("Forward TCP traffic between %s (encrypted: %v) and %s (encrypted: %v)",
local, lenc, remote, renc)
local2RemoteTCP(local, remote, lenc, renc)
} else {
logger.Success("Forward UDP traffic between %s (encrypted: %v) and %s (encrypted: %v)",
local, lenc, remote, renc)
local2RemoteUDP(local, remote, lenc, renc)
}
}

func local2LocalTCP(localA string, localB string, laenc bool, lbenc bool) {
printFwdSuccess(localA, localB, laenc, lbenc)

var listenerA net.Listener
var listenerB net.Listener

Expand Down Expand Up @@ -252,21 +241,23 @@ func local2LocalUDP(localA string, localB string, laenc bool, lbenc bool) {
return
}

printFwdSuccess(localA, localB, laenc, lbenc)
netio.ForwardUnconnectedUDP(listenerCtxA, listenerCtxB)
}

func Local2Local(localA string, localB string, laenc bool, lbenc bool) {
if option.PROTOCOL == "TCP" {
logger.Success("Forward TCP traffic between %s (encrypted: %v) and %s (encrypted: %v)",
localA, laenc, localB, lbenc)

local2LocalTCP(localA, localB, laenc, lbenc)
} else {
logger.Success("Forward UDP traffic between %s (encrypted: %v) and %s (encrypted: %v)",
localA, laenc, localB, lbenc)
local2LocalUDP(localA, localB, laenc, lbenc)
}
}

func remote2remoteTCP(remoteA string, remoteB string, raenc bool, rbenc bool) {
printFwdSuccess(remoteA, remoteB, raenc, rbenc)

for {
var remoteConnA net.Conn
var remoteConnB net.Conn
Expand Down Expand Up @@ -422,14 +413,17 @@ func remote2remoteUDP(remoteA string, remoteB string, raenc bool, rbenc bool) {
}
}

printFwdSuccess(remoteA, remoteB, raenc, rbenc)
netio.ForwardUDP(remoteCtxA, remoteCtxB)
}

func Remote2Remote(remoteA string, remoteB string, raenc bool, rbenc bool) {
if option.PROTOCOL == "TCP" {
logger.Success("Forward TCP traffic between %s (encrypted: %v) and %s (encrypted: %v)",
remoteA, raenc, remoteB, rbenc)
remote2remoteTCP(remoteA, remoteB, raenc, rbenc)
} else {
logger.Success("Forward UDP traffic between %s (encrypted: %v) and %s (encrypted: %v)",
remoteA, raenc, remoteB, rbenc)
remote2remoteUDP(remoteA, remoteB, raenc, rbenc)
}
}
8 changes: 4 additions & 4 deletions operate/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func ProxyLocal(local string, encrypted bool) {
return
}

logger.Success("Start socks5 server on %s, encrypted: %v", local, encrypted)
logger.Success("Start socks5 server on %s (encrypted: %v)", local, encrypted)

for {
conn, err := listener.Accept()
Expand Down Expand Up @@ -45,7 +45,7 @@ func ProxyRemote(remote string, encrypted bool) {
}
defer session.Close()

logger.Success("Remote socks5 handshake ok, encrypted: %v", encrypted)
logger.Success("Remote socks5 handshake ok (encrypted: %v)", encrypted)

connectRequest := make(chan uint8, MAX_CONNECTION/2)
defer close(connectRequest)
Expand Down Expand Up @@ -145,8 +145,8 @@ func ProxyRemoteL2L(control string, local string, cenc bool, lenc bool) {
defer session.Close()
defer ctlStream.Close()

logger.Success("Reverse socks5 server handshake ok, from %s, encrypted: %v", session.RemoteAddr().String(), cenc)
logger.Success("Socks5 server is listening on %s, encrypted: %v", local, lenc)
logger.Success("Reverse socks5 server handshake ok from %s (encrypted: %v)", session.RemoteAddr().String(), cenc)
logger.Success("Socks5 server is listening on %s (encrypted: %v)", local, lenc)

// handle ctrl+C
{
Expand Down

0 comments on commit d985f23

Please sign in to comment.