|
|
@ -1,6 +1,6 @@
|
|
|
|
package network
|
|
|
|
package network
|
|
|
|
|
|
|
|
|
|
|
|
import(
|
|
|
|
import (
|
|
|
|
//Builtin
|
|
|
|
//Builtin
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
@ -16,16 +16,16 @@ import(
|
|
|
|
|
|
|
|
|
|
|
|
type ProxyType string
|
|
|
|
type ProxyType string
|
|
|
|
|
|
|
|
|
|
|
|
const(
|
|
|
|
const (
|
|
|
|
PROXY_CLIENT ProxyType = "client"
|
|
|
|
PROXY_CLIENT ProxyType = "client"
|
|
|
|
PROXY_SERVER ProxyType = "server"
|
|
|
|
PROXY_SERVER ProxyType = "server"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type ProtoType string
|
|
|
|
type ProtoType string
|
|
|
|
|
|
|
|
|
|
|
|
const(
|
|
|
|
const (
|
|
|
|
PROTO_TCP ProtoType = "tcp"
|
|
|
|
PROTO_TCP ProtoType = "tcp"
|
|
|
|
PROTO_UDP ProtoType = "udp"
|
|
|
|
PROTO_UDP ProtoType = "udp"
|
|
|
|
PROTO_SOCKET ProtoType = "socket"
|
|
|
|
PROTO_SOCKET ProtoType = "socket"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -146,7 +146,7 @@ func nsSocketListener(fd uintptr, proto ProtoType, lAddr string) (net.Listener,
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Connect/Server
|
|
|
|
* Connect/Server
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log *logging.Logger, ready sync.WaitGroup) (error) {
|
|
|
|
func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log *logging.Logger, ready sync.WaitGroup) error {
|
|
|
|
rConn, err := socketConnect(pid, proto, rAddr)
|
|
|
|
rConn, err := socketConnect(pid, proto, rAddr)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Error("Socket: %+v.", err)
|
|
|
|
log.Error("Socket: %+v.", err)
|
|
|
@ -159,7 +159,7 @@ func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newProxyServer(pid int, proto ProtoType, dest string, port int, log *logging.Logger, ready sync.WaitGroup) (error) {
|
|
|
|
func newProxyServer(pid int, proto ProtoType, dest string, port int, log *logging.Logger, ready sync.WaitGroup) error {
|
|
|
|
if dest == "" {
|
|
|
|
if dest == "" {
|
|
|
|
dest = "127.0.0.1"
|
|
|
|
dest = "127.0.0.1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|