Skip to content
This repository has been archived by the owner on Oct 2, 2022. It is now read-only.

Commit

Permalink
0.9.1: SSHServer update
Browse files Browse the repository at this point in the history
This release adds support for the keyboard-interactive authentication and bumps [sshserver](https://github.com/containerssh/sshserver) to 0.9.16.
  • Loading branch information
Janos Pasztor committed Jan 13, 2021
1 parent e2781b7 commit 54d6f72
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.9.1: SSHServer update

This release adds support for the keyboard-interactive authentication and bumps [sshserver](https://github.com/containerssh/sshserver) to 0.9.16.

## 0.9.0: Initial port

This release is the initial port for metrics from ContainerSSH version 0.3.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.14
require (
github.com/containerssh/geoip v0.9.4
github.com/containerssh/metrics v0.9.6
github.com/containerssh/sshserver v0.9.14
github.com/containerssh/sshserver v0.9.16
github.com/stretchr/testify v1.6.1
)
114 changes: 114 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
github.com/containerssh/geoip v0.9.3 h1:RDj46uxB3Ew7qoTHCUClBDkqULRZJOLxYf/VqPgEuK8=
github.com/containerssh/geoip v0.9.3/go.mod h1:8fyg4eUrKKY0FDyS7GofI6OO7UXDoG1icRtVAHb510k=
github.com/containerssh/geoip v0.9.4 h1:ugkbESJpitdObbSHdYNQfpoFJOlvxwNCX2ZHHnlVJzA=
github.com/containerssh/geoip v0.9.4/go.mod h1:JxyH+hKj7LfoXWmOMR5lQVrNJCpy42N3GNWSPEguq24=
github.com/containerssh/http v0.9.2 h1:ZvGaQy/xxNE+UGavsyp2bYwagz9/s+c11wVQoCQXRY4=
github.com/containerssh/http v0.9.2/go.mod h1:ZuPYt0qDhZ4FRWRf/gUyG/VChNRIMd4N7gSA3Qs3SCI=
github.com/containerssh/http v0.9.4 h1:jgzT8T8hT/gE3PEpdeQl1fC1cm+cAuT7raP8UxEpNPQ=
github.com/containerssh/http v0.9.4/go.mod h1:KTBEbXRSdllIGOb+O6AURBCG+9vCEyo6AI+JCrI94Cw=
github.com/containerssh/http v0.9.5 h1:rkC47g5TShbIls2rSZbFT5SCLNDWeWziAcRb9FLw1YU=
github.com/containerssh/http v0.9.5/go.mod h1:EHEDmrTsA7S0JUnCHVAj1kN0JsQFcbwiTgz9S/uO3tc=
github.com/containerssh/log v0.9.2/go.mod h1:05pgNm7IgFKt+qbZiUhtuJw2B4j3ynn2vSv5j2JA7hA=
github.com/containerssh/log v0.9.6 h1:K3/RjrKnTfT1jBe+9PxMdFrZkLSmXQapZD4wcSFGe5w=
github.com/containerssh/log v0.9.6/go.mod h1:P/tea/If6kzzfqlZdmqNp5SOpD6CD/OvmvcOK+vbweI=
github.com/containerssh/log v0.9.7 h1:T1FxnEtGMbyJJ7C66dDr6k2RwTnSpVGE5U5apr5pB78=
github.com/containerssh/log v0.9.7/go.mod h1:NBMzkhOLZ4z45ShSBKQ/Ij6Hqqg15DgOKy6HlSITx0s=
github.com/containerssh/log v0.9.8 h1:DJfM/um/kXvs2acCWAvSotuwSuiGEsnheFJp6n7wKAI=
github.com/containerssh/log v0.9.8/go.mod h1:NBMzkhOLZ4z45ShSBKQ/Ij6Hqqg15DgOKy6HlSITx0s=
github.com/containerssh/log v0.9.9 h1:JNgeUs5PxCy1qT80RgNSjGBHsS6ukwsKRsZphVJ4yLY=
github.com/containerssh/log v0.9.9/go.mod h1:NBMzkhOLZ4z45ShSBKQ/Ij6Hqqg15DgOKy6HlSITx0s=
github.com/containerssh/metrics v0.9.3 h1:OIXMw4eFi6xbFKtiuwamz2FCa2gFOXOtTHXqGYZzsX0=
github.com/containerssh/metrics v0.9.3/go.mod h1:n5Itoucb/uFRAUevBfnyKFw+il52uYVbDFmV/smgias=
github.com/containerssh/metrics v0.9.6 h1:m4Q6IM8zZsghYCV978ZMqh9TQ6dkLWHDyYA5nHU2kpk=
github.com/containerssh/metrics v0.9.6/go.mod h1:yClAiBuFrIrmxQLyU/AjR1XNbqPIHg+m/Hb2EZrVtRE=
github.com/containerssh/service v0.9.0 h1:JUHqiK12tclq7EWQYGRTfgKKw6fhHs0gxlKWTvVwFlQ=
github.com/containerssh/service v0.9.0/go.mod h1:otAKYF1MWy2eB0K7Sk7YQIECQMTHR3yikbyS1UstGpY=
github.com/containerssh/sshserver v0.9.14 h1:cIc11NbzF2QfnO5SVSgYH6YTBeIORUd9x0chzvaEfrQ=
github.com/containerssh/sshserver v0.9.14/go.mod h1:GOr/SHQvoJpt/yoztX0a9QfKMbixd42GrLZk6YASSvw=
github.com/containerssh/sshserver v0.9.16 h1:vnvYbu2m1Hdzq5mHF883fAz3h6KzD0gYlxyyWIS+vfs=
github.com/containerssh/sshserver v0.9.16/go.mod h1:cMdDoIt0l24KsoaSQezS0aA/891j/gf4QiPjRyDYvyY=
github.com/containerssh/structutils v0.9.0 h1:pz4xl5ZrPnpdSx7B/ru8Fj3oU3vOtx1jprIuSkm5s7o=
github.com/containerssh/structutils v0.9.0/go.mod h1:zirdwNXan3kuTpsJp9Gl3W6VQz0fexqMySqxmfviSjw=
github.com/containerssh/unixutils v0.9.0 h1:9Bh2UiQW6DIuVW6upc1uUU38tKK1IUn2hxZqi9w3cQc=
github.com/containerssh/unixutils v0.9.0/go.mod h1:k1Z/lsIUK95UzrlqRw2JWDDi6LGeL7wG+V+N+TWkCbU=
github.com/creasty/defaults v1.5.1 h1:j8WexcS3d/t4ZmllX4GEkl4wIB/trOr035ajcLHCISM=
github.com/creasty/defaults v1.5.1/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.3 h1:twObb+9XcuH5B9V1TBCvvvZoO6iEdILi2a76PYn5rJI=
github.com/google/uuid v1.1.3/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.4 h1:0ecGp3skIrHWPNGPJDaBIghfA6Sp7Ruo2Io8eLKzWm0=
github.com/google/uuid v1.1.4/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gordonklaus/ineffassign v0.0.0-20200809085317-e36bfde3bb78/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-shellwords v1.0.10 h1:Y7Xqm8piKOO3v10Thp7Z36h4FYFjt5xB//6XvOrs2Gw=
github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oschwald/geoip2-golang v1.4.0 h1:5RlrjCgRyIGDz/mBmPfnAF4h8k0IAcRv9PvrpOfz+Ug=
github.com/oschwald/geoip2-golang v1.4.0/go.mod h1:8QwxJvRImBH+Zl6Aa6MaIcs5YdlZSTKtzmPGzQqi9ng=
github.com/oschwald/maxminddb-golang v1.6.0 h1:KAJSjdHQ8Kv45nFIbtoLGrGWqHFajOIm7skTyz/+Dls=
github.com/oschwald/maxminddb-golang v1.6.0/go.mod h1:DUJFucBg2cvqx42YmDa/+xHvb0elJtOm3o4aFQ/nb/w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494 h1:wSmWgpuccqS2IOfmYrbRiUgv+g37W5suLLLxwwniTSc=
github.com/qdm12/reprint v0.0.0-20200326205758-722754a53494/go.mod h1:yipyliwI08eQ6XwDm1fEwKPdF/xdbkiHtrU+1Hg+vc4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604=
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201231184435-2d18734c6014 h1:joucsQqXmyBVxViHCPFjG3hx8JzIFSaym3l3MM/Jsdg=
golang.org/x/sys v0.0.0-20201231184435-2d18734c6014/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20201105001634-bc3cf281b174/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
24 changes: 24 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type metricsNetworkHandler struct {
disconnected bool
}

func (m *metricsNetworkHandler) OnShutdown(shutdownContext context.Context) {
m.backend.OnShutdown(shutdownContext)
}

func (m *metricsNetworkHandler) OnAuthPassword(username string, password []byte) (
response sshserver.AuthResponse,
reason error,
Expand Down Expand Up @@ -90,6 +94,26 @@ func (m *metricsNetworkHandler) OnAuthPubKey(username string, pubKey string) (
return response, reason
}

func (m *metricsNetworkHandler) OnAuthKeyboardInteractive(
user string,
challenge func(
instruction string,
questions sshserver.KeyboardInteractiveQuestions,
) (answers sshserver.KeyboardInteractiveAnswers, err error),
) (response sshserver.AuthResponse, reason error) {
label := metrics.Label("authtype", "keyboard-interactive")
response, reason = m.backend.OnAuthKeyboardInteractive(user, challenge)
switch response {
case sshserver.AuthResponseSuccess:
m.handler.authSuccessMetric.Increment(m.client.IP, label)
case sshserver.AuthResponseFailure:
m.handler.authFailureMetric.Increment(m.client.IP, label)
case sshserver.AuthResponseUnavailable:
m.handler.authBackendFailureMetric.Increment(label)
}
return response, reason
}

func (m *metricsNetworkHandler) OnHandshakeFailed(reason error) {
m.handler.handshakeFailedMetric.Increment(m.client.IP)
m.backend.OnHandshakeFailed(reason)
Expand Down
71 changes: 42 additions & 29 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package metricsintegration_test
import (
"context"
"fmt"
"io"
"net"
"testing"

Expand Down Expand Up @@ -162,6 +161,9 @@ type dummyBackendHandler struct {
authResponse sshserver.AuthResponse
}

func (d *dummyBackendHandler) OnClose() {
}

func (d *dummyBackendHandler) OnReady() error {
return nil
}
Expand Down Expand Up @@ -194,6 +196,16 @@ func (d *dummyBackendHandler) OnAuthPubKey(_ string, _ string) (
return d.authResponse, nil
}

func (d *dummyBackendHandler) OnAuthKeyboardInteractive(
_ string,
_ func(
instruction string,
questions sshserver.KeyboardInteractiveQuestions,
) (answers sshserver.KeyboardInteractiveAnswers, err error),
) (response sshserver.AuthResponse, reason error) {
return d.authResponse, nil
}

func (d *dummyBackendHandler) OnHandshakeFailed(_ error) {

}
Expand All @@ -216,15 +228,28 @@ func (d *dummyBackendHandler) OnUnsupportedChannel(_ uint64, _ string, _ []byte)
func (d *dummyBackendHandler) OnSessionChannel(
_ uint64,
_ []byte,
session sshserver.SessionChannel,
) (channel sshserver.SessionChannelHandler, failureReason sshserver.ChannelRejection) {
return d, nil
return &dummySession{
session: session,
}, nil
}

type dummySession struct {
session sshserver.SessionChannel
}

func (d *dummySession) OnClose() {
}

func (d *dummySession) OnShutdown(_ context.Context) {
}

func (d *dummyBackendHandler) OnUnsupportedChannelRequest(_ uint64, _ string, _ []byte) {
func (d *dummySession) OnUnsupportedChannelRequest(_ uint64, _ string, _ []byte) {

}

func (d *dummyBackendHandler) OnFailedDecodeChannelRequest(
func (d *dummySession) OnFailedDecodeChannelRequest(
_ uint64,
_ string,
_ []byte,
Expand All @@ -233,11 +258,11 @@ func (d *dummyBackendHandler) OnFailedDecodeChannelRequest(

}

func (d *dummyBackendHandler) OnEnvRequest(_ uint64, _ string, _ string) error {
func (d *dummySession) OnEnvRequest(_ uint64, _ string, _ string) error {
return fmt.Errorf("env not supported")
}

func (d *dummyBackendHandler) OnPtyRequest(
func (d *dummySession) OnPtyRequest(
_ uint64,
_ string,
_ uint32,
Expand All @@ -249,62 +274,50 @@ func (d *dummyBackendHandler) OnPtyRequest(
return fmt.Errorf("PTY not supported")
}

func (d *dummyBackendHandler) OnExecRequest(
func (d *dummySession) OnExecRequest(
_ uint64,
exec string,
_ io.Reader,
stdout io.Writer,
_ io.Writer,
exit func(exitStatus sshserver.ExitStatus),
) error {
go func() {
_, err := stdout.Write([]byte(fmt.Sprintf("Exec request received: %s", exec)))
_, err := d.session.Stdout().Write([]byte(fmt.Sprintf("Exec request received: %s", exec)))
if err != nil {
exit(2)
d.session.ExitStatus(2)
} else {
exit(0)
d.session.ExitStatus(0)
}
}()
return nil
}

func (d *dummyBackendHandler) OnShell(
func (d *dummySession) OnShell(
_ uint64,
_ io.Reader,
_ io.Writer,
_ io.Writer,
_ func(exitStatus sshserver.ExitStatus),
) error {
return fmt.Errorf("shell not supported")
}

func (d *dummyBackendHandler) OnSubsystem(
func (d *dummySession) OnSubsystem(
_ uint64,
subsystem string,
_ io.Reader,
stdout io.Writer,
_ io.Writer,
exit func(exitStatus sshserver.ExitStatus),
) error {
if subsystem != "sftp" {
return fmt.Errorf("subsystem not supported")
}
go func() {
_, err := stdout.Write([]byte(fmt.Sprintf("Subsystem request received: %s", subsystem)))
_, err := d.session.Stdout().Write([]byte(fmt.Sprintf("Subsystem request received: %s", subsystem)))
if err != nil {
exit(2)
d.session.ExitStatus(2)
} else {
exit(0)
d.session.ExitStatus(0)
}
}()
return nil
}

func (d *dummyBackendHandler) OnSignal(_ uint64, _ string) error {
func (d *dummySession) OnSignal(_ uint64, _ string) error {
return fmt.Errorf("signal not supported")
}

func (d *dummyBackendHandler) OnWindow(
func (d *dummySession) OnWindow(
_ uint64,
_ uint32,
_ uint32,
Expand Down

0 comments on commit 54d6f72

Please sign in to comment.