Browse Source

Add -quiet and -q flags

pull/2/head
Kevin Chung 3 years ago
parent
commit
ca84ed48de
  1. 3
      cmd/sclient/main.go
  2. 7
      sclient.go

3
cmd/sclient/main.go

@ -47,8 +47,10 @@ func main() {
flag.Usage = usage
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)")
flag.BoolVar(insecure, "insecure", false, "ignore bad TLS/SSL/HTTPS certificates")
flag.BoolVar(quiet, "quiet", false, "don't output connection established messages")
flag.Parse()
remotestr := flag.Arg(0)
localstr := flag.Arg(1)
@ -69,6 +71,7 @@ func main() {
LocalAddress: "localhost",
InsecureSkipVerify: *insecure,
ServerName: *servername,
Quiet: *quiet,
}
remote := strings.Split(remotestr, ":")

7
sclient.go

@ -18,6 +18,7 @@ type Tunnel struct {
LocalPort int
InsecureSkipVerify bool
ServerName string
Quiet bool
}
// 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() {
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n",
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String())
if t.Quiet == false {
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n",
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String())
}
} else {
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n",
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort)

Loading…
Cancel
Save