Skip to content

Commit ca84ed4

Browse files
committed
Add -quiet and -q flags
1 parent 455db50 commit ca84ed4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cmd/sclient/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ func main() {
4747

4848
flag.Usage = usage
4949
insecure := flag.Bool("k", false, "ignore bad TLS/SSL/HTTPS certificates")
50+
quiet := flag.Bool("q", false, "don't output connection established messages")
5051
servername := flag.String("servername", "", "specify a servername different from <remote> (to disable SNI use an IP as <remote> and do use this option)")
5152
flag.BoolVar(insecure, "insecure", false, "ignore bad TLS/SSL/HTTPS certificates")
53+
flag.BoolVar(quiet, "quiet", false, "don't output connection established messages")
5254
flag.Parse()
5355
remotestr := flag.Arg(0)
5456
localstr := flag.Arg(1)
@@ -69,6 +71,7 @@ func main() {
6971
LocalAddress: "localhost",
7072
InsecureSkipVerify: *insecure,
7173
ServerName: *servername,
74+
Quiet: *quiet,
7275
}
7376

7477
remote := strings.Split(remotestr, ":")

sclient.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Tunnel struct {
1818
LocalPort int
1919
InsecureSkipVerify bool
2020
ServerName string
21+
Quiet bool
2122
}
2223

2324
// 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) {
150151
}
151152

152153
if "stdio" == conn.RemoteAddr().Network() {
153-
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n",
154-
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String())
154+
if t.Quiet == false {
155+
fmt.Fprintf(os.Stdout, "(connected to %s:%d and reading from %s)\n",
156+
t.RemoteAddress, t.RemotePort, conn.RemoteAddr().String())
157+
}
155158
} else {
156159
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n",
157160
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort)

0 commit comments

Comments
 (0)