Skip to content

Commit

Permalink
silence more output, fix minor output bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal committed Jun 22, 2021
1 parent 66f2d41 commit 8ba42a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions cmd/sclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ func ver() string {
}

func usage() {
fmt.Fprintf(os.Stderr, "\nsclient %s\n"+
fmt.Fprintf(os.Stderr, "\n%s\n"+
"\nusage: sclient <remote> <local>\n"+
"\n"+
" ex: sclient example.com 3000\n"+
" (sclient example.com:443 localhost:3000)\n"+
"\n"+
" ex: sclient example.com:8443 0.0.0.0:4080\n"+
"\n"+
" ex: sclient example.com:443 -\n"+
"\n", ver())
flag.PrintDefaults()
fmt.Println()
Expand All @@ -46,7 +48,7 @@ func main() {
}

flag.Usage = usage
insecure := flag.Bool("k", false, "ignore bad TLS/SSL/HTTPS certificates")
insecure := flag.Bool("k", false, "alias for --insecure")
silent := flag.Bool("s", false, "alias of --silent")
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")
Expand Down
16 changes: 9 additions & 7 deletions sclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ func (t *Tunnel) DialAndListen() error {
return err
}

fmt.Fprintf(os.Stdout, "[listening] %s:%d <= %s:%d\n",
t.RemoteAddress, t.RemotePort, t.LocalAddress, t.LocalPort)
if !t.Silent {
fmt.Fprintf(os.Stdout, "[listening] %s:%d <= %s:%d\n",
t.RemoteAddress, t.RemotePort, t.LocalAddress, t.LocalPort)
}

for {
conn, err := ln.Accept()
Expand Down Expand Up @@ -150,14 +152,14 @@ func (t *Tunnel) handleConnection(remote string, conn netReadWriteCloser) {
return
}

if "stdio" == conn.RemoteAddr().Network() {
if !t.Silent {
if !t.Silent {
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())
} else {
fmt.Fprintf(os.Stdout, "[connect] %s => %s:%d\n",
strings.Replace(conn.RemoteAddr().String(), "[::1]:", "localhost:", 1), t.RemoteAddress, t.RemotePort)
}
} else {
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")
Expand Down

0 comments on commit 8ba42a0

Please sign in to comment.