feature: Adds basic TCP support for SSHAppBackend.
This commit is contained in:
parent
432d457ad7
commit
15176831e6
5 changed files with 622 additions and 172 deletions
30
backend/sshappbackend/gaslighter/gaslighter.go
Normal file
30
backend/sshappbackend/gaslighter/gaslighter.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package gaslighter
|
||||
|
||||
import "io"
|
||||
|
||||
type Gaslighter struct {
|
||||
Byte byte
|
||||
HasGaslit bool
|
||||
ProxiedReader io.Reader
|
||||
}
|
||||
|
||||
func (gaslighter *Gaslighter) Read(p []byte) (n int, err error) {
|
||||
if gaslighter.HasGaslit {
|
||||
return gaslighter.ProxiedReader.Read(p)
|
||||
}
|
||||
|
||||
if len(p) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
p[0] = gaslighter.Byte
|
||||
gaslighter.HasGaslit = true
|
||||
|
||||
if len(p) > 1 {
|
||||
n, err := gaslighter.ProxiedReader.Read(p[1:])
|
||||
|
||||
return n + 1, err
|
||||
} else {
|
||||
return 1, nil
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue