Skip to content

Commit

Permalink
chore(deps): internalize deleted dependency
Browse files Browse the repository at this point in the history
github.com/sabban/bastion no longer exists

The code has been replaced by https://github.com/moul/bastion/blob/master/pkg/logchannel/logchannel.go
  • Loading branch information
libvoid committed Jan 29, 2024
1 parent 19c4fb0 commit d3abf74
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
1 change: 0 additions & 1 deletion go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/bastion/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/gliderlabs/ssh"
"github.com/pkg/errors"
"github.com/sabban/bastion/pkg/logchannel"
"moul.io/sshportal/pkg/utils"
gossh "golang.org/x/crypto/ssh"
)

Expand Down
54 changes: 54 additions & 0 deletions pkg/utils/logchannel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package utils

import (
"encoding/binary"
"io"
"syscall"
"time"

"golang.org/x/crypto/ssh"
)

type logChannel struct {
channel ssh.Channel
writer io.WriteCloser
}

func writeTTYRecHeader(fd io.Writer, length int) {
t := time.Now()

tv := syscall.NsecToTimeval(t.UnixNano())

binary.Write(fd, binary.LittleEndian, int32(tv.Sec))

Check failure on line 22 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `binary.Write` is not checked (errcheck)
binary.Write(fd, binary.LittleEndian, int32(tv.Usec))

Check failure on line 23 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `binary.Write` is not checked (errcheck)
binary.Write(fd, binary.LittleEndian, int32(length))

Check failure on line 24 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `binary.Write` is not checked (errcheck)
}

func New(channel ssh.Channel, writer io.WriteCloser) *logChannel {

Check warning on line 27 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unexported-return: exported func New returns unexported type *utils.logChannel, which can be annoying to use (revive)
return &logChannel{
channel: channel,
writer: writer,
}
}

func (l *logChannel) Read(data []byte) (int, error) {
return l.Read(data)

Check failure on line 35 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA5007: infinite recursive call (staticcheck)
}

func (l *logChannel) Write(data []byte) (int, error) {
writeTTYRecHeader(l.writer, len(data))
l.writer.Write(data)

Check failure on line 40 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `l.writer.Write` is not checked (errcheck)

return l.channel.Write(data)
}

func (l *logChannel) LogWrite(data []byte) (int, error) {
writeTTYRecHeader(l.writer, len(data))
return l.writer.Write(data)
}

func (l *logChannel) Close() error {
l.writer.Close()

return l.channel.Close()
}

Check failure on line 54 in pkg/utils/logchannel.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)

0 comments on commit d3abf74

Please sign in to comment.