|
@ -18,6 +18,7 @@ type Tunnel struct { |
|
|
LocalPort int |
|
|
LocalPort int |
|
|
InsecureSkipVerify bool |
|
|
InsecureSkipVerify bool |
|
|
ServerName string |
|
|
ServerName string |
|
|
|
|
|
Silent bool |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// DialAndListen will create a test TLS connection to the remote address and then
|
|
|
// DialAndListen will create a test TLS connection to the remote address and then
|
|
@ -45,7 +46,7 @@ func (t *Tunnel) DialAndListen() error { |
|
|
} else { |
|
|
} else { |
|
|
name = "stdin" |
|
|
name = "stdin" |
|
|
} |
|
|
} |
|
|
conn := &stdnet{os.Stdin, os.Stdout, &stdaddr{net.UnixAddr{name, network}}} |
|
|
conn := &stdnet{os.Stdin, os.Stdout, &stdaddr{net.UnixAddr{Name: name, Net: network}}} |
|
|
t.handleConnection(remote, conn) |
|
|
t.handleConnection(remote, conn) |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
@ -57,8 +58,10 @@ func (t *Tunnel) DialAndListen() error { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fmt.Fprintf(os.Stdout, "[listening] %s:%d <= %s:%d\n", |
|
|
if !t.Silent { |
|
|
t.RemoteAddress, t.RemotePort, t.LocalAddress, t.LocalPort) |
|
|
fmt.Fprintf(os.Stdout, "[listening] %s:%d <= %s:%d\n", |
|
|
|
|
|
t.RemoteAddress, t.RemotePort, t.LocalAddress, t.LocalPort) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for { |
|
|
for { |
|
|
conn, err := ln.Accept() |
|
|
conn, err := ln.Accept() |
|
@ -110,7 +113,7 @@ func pipe(r netReadWriteCloser, w netReadWriteCloser, t string) { |
|
|
if nil != err { |
|
|
if nil != err { |
|
|
//fmt.Fprintf(os.Stdout, "[debug] (%s:%d) error reading %s\n", t, count, err)
|
|
|
//fmt.Fprintf(os.Stdout, "[debug] (%s:%d) error reading %s\n", t, count, err)
|
|
|
if io.EOF != err { |
|
|
if io.EOF != err { |
|
|
fmt.Fprintf(os.Stderr, "[read error] (%s:%s) %s\n", t, count, err) |
|
|
fmt.Fprintf(os.Stderr, "[read error] (%s:%d) %s\n", t, count, err) |
|
|
} |
|
|
} |
|
|
r.Close() |
|
|
r.Close() |
|
|
//w.Close()
|
|
|
//w.Close()
|
|
@ -149,12 +152,14 @@ func (t *Tunnel) handleConnection(remote string, conn netReadWriteCloser) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if "stdio" == conn.RemoteAddr().Network() { |
|
|
if !t.Silent { |
|
|
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n", |
|
|
if "stdio" == conn.RemoteAddr().Network() { |
|
|
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String()) |
|
|
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n", |
|
|
} else { |
|
|
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String()) |
|
|
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n", |
|
|
} else { |
|
|
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort) |
|
|
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n", |
|
|
|
|
|
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
go pipe(conn, sclient, "local") |
|
|
go pipe(conn, sclient, "local") |
|
|