summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go')
-rw-r--r--vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go84
1 files changed, 0 insertions, 84 deletions
diff --git a/vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go b/vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go
deleted file mode 100644
index d1babedb..00000000
--- a/vendor/github.com/pkg/sftp/examples/buffered-write-benchmark/main.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// buffered-write-benchmark benchmarks the peformance of writing
-// a single large []byte on the client to /dev/null on the server via io.Copy.
-package main
-
-import (
- "flag"
- "fmt"
- "log"
- "net"
- "os"
- "syscall"
- "time"
-
- "golang.org/x/crypto/ssh"
- "golang.org/x/crypto/ssh/agent"
-
- "github.com/pkg/sftp"
-)
-
-var (
- USER = flag.String("user", os.Getenv("USER"), "ssh username")
- HOST = flag.String("host", "localhost", "ssh server hostname")
- PORT = flag.Int("port", 22, "ssh server port")
- PASS = flag.String("pass", os.Getenv("SOCKSIE_SSH_PASSWORD"), "ssh password")
- SIZE = flag.Int("s", 1<<15, "set max packet size")
-)
-
-func init() {
- flag.Parse()
-}
-
-func main() {
- var auths []ssh.AuthMethod
- if aconn, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {
- auths = append(auths, ssh.PublicKeysCallback(agent.NewClient(aconn).Signers))
-
- }
- if *PASS != "" {
- auths = append(auths, ssh.Password(*PASS))
- }
-
- config := ssh.ClientConfig{
- User: *USER,
- Auth: auths,
- HostKeyCallback: ssh.InsecureIgnoreHostKey(),
- }
- addr := fmt.Sprintf("%s:%d", *HOST, *PORT)
- conn, err := ssh.Dial("tcp", addr, &config)
- if err != nil {
- log.Fatalf("unable to connect to [%s]: %v", addr, err)
- }
- defer conn.Close()
-
- c, err := sftp.NewClient(conn, sftp.MaxPacket(*SIZE))
- if err != nil {
- log.Fatalf("unable to start sftp subsytem: %v", err)
- }
- defer c.Close()
-
- w, err := c.OpenFile("/dev/null", syscall.O_WRONLY)
- if err != nil {
- log.Fatal(err)
- }
- defer w.Close()
-
- f, err := os.Open("/dev/zero")
- if err != nil {
- log.Fatal(err)
- }
- defer f.Close()
-
- const size = 1e9
-
- log.Printf("writing %v bytes", size)
- t1 := time.Now()
- n, err := w.Write(make([]byte, size))
- if err != nil {
- log.Fatal(err)
- }
- if n != size {
- log.Fatalf("copy: expected %v bytes, got %d", size, n)
- }
- log.Printf("wrote %v bytes in %s", size, time.Since(t1))
-}