Add -quiet and -q flags
This commit is contained in:
parent
455db50928
commit
ca84ed48de
|
@ -47,8 +47,10 @@ func main() {
|
||||||
|
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
insecure := flag.Bool("k", false, "ignore bad TLS/SSL/HTTPS certificates")
|
insecure := flag.Bool("k", false, "ignore bad TLS/SSL/HTTPS certificates")
|
||||||
|
quiet := flag.Bool("q", false, "don't output connection established messages")
|
||||||
servername := flag.String("servername", "", "specify a servername different from <remote> (to disable SNI use an IP as <remote> and do use this option)")
|
servername := flag.String("servername", "", "specify a servername different from <remote> (to disable SNI use an IP as <remote> and do use this option)")
|
||||||
flag.BoolVar(insecure, "insecure", false, "ignore bad TLS/SSL/HTTPS certificates")
|
flag.BoolVar(insecure, "insecure", false, "ignore bad TLS/SSL/HTTPS certificates")
|
||||||
|
flag.BoolVar(quiet, "quiet", false, "don't output connection established messages")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
remotestr := flag.Arg(0)
|
remotestr := flag.Arg(0)
|
||||||
localstr := flag.Arg(1)
|
localstr := flag.Arg(1)
|
||||||
|
@ -69,6 +71,7 @@ func main() {
|
||||||
LocalAddress: "localhost",
|
LocalAddress: "localhost",
|
||||||
InsecureSkipVerify: *insecure,
|
InsecureSkipVerify: *insecure,
|
||||||
ServerName: *servername,
|
ServerName: *servername,
|
||||||
|
Quiet: *quiet,
|
||||||
}
|
}
|
||||||
|
|
||||||
remote := strings.Split(remotestr, ":")
|
remote := strings.Split(remotestr, ":")
|
||||||
|
|
|
@ -18,6 +18,7 @@ type Tunnel struct {
|
||||||
LocalPort int
|
LocalPort int
|
||||||
InsecureSkipVerify bool
|
InsecureSkipVerify bool
|
||||||
ServerName string
|
ServerName string
|
||||||
|
Quiet 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
|
||||||
|
@ -150,8 +151,10 @@ func (t *Tunnel) handleConnection(remote string, conn netReadWriteCloser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if "stdio" == conn.RemoteAddr().Network() {
|
if "stdio" == conn.RemoteAddr().Network() {
|
||||||
|
if t.Quiet == false {
|
||||||
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n",
|
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n",
|
||||||
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String())
|
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n",
|
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n",
|
||||||
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort)
|
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort)
|
||||||
|
|
Loading…
Reference in New Issue