Reorganize packages

This commit is contained in:
2021-10-21 12:36:01 +02:00
parent a71ff52ab4
commit 94e7faae78
15 changed files with 24 additions and 24 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
package honeypot
package ssh
type ActionType int

View File

@@ -1,4 +1,4 @@
package honeypot
package ssh
import (
"net"

View File

@@ -1,4 +1,4 @@
package honeypot
package ssh
import (
_ "embed"

View File

@@ -1,4 +1,4 @@
package honeypot
package ssh
import (
"context"
@@ -12,9 +12,9 @@ import (
"github.uio.no/torjus/apiary/config"
"github.com/gliderlabs/ssh"
sshlib "github.com/gliderlabs/ssh"
"github.com/google/uuid"
"github.uio.no/torjus/apiary/honeypot/store"
"github.uio.no/torjus/apiary/honeypot/ssh/store"
"github.uio.no/torjus/apiary/models"
"go.uber.org/zap"
)
@@ -22,7 +22,7 @@ import (
type HoneypotServer struct {
Logger *zap.SugaredLogger
sshServer *ssh.Server
sshServer *sshlib.Server
attemptStore store.LoginAttemptStore
attemptsCallbacks []func(l models.LoginAttempt)
@@ -35,7 +35,7 @@ func NewHoneypotServer(cfg config.HoneypotConfig, store store.LoginAttemptStore)
hs.attemptStore = store
hs.Logger = zap.NewNop().Sugar()
hs.sshServer = &ssh.Server{
hs.sshServer = &sshlib.Server{
Addr: cfg.ListenAddr,
PasswordHandler: hs.passwordHandler,
ConnCallback: hs.connCallback,
@@ -75,7 +75,7 @@ func (hs *HoneypotServer) AddLoginCallback(c func(l models.LoginAttempt)) {
hs.attemptsCallbacks = append(hs.attemptsCallbacks, c)
}
func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool {
func (hs *HoneypotServer) passwordHandler(ctx sshlib.Context, password string) bool {
sessUUID, ok := ctx.Value("uuid").(uuid.UUID)
if !ok {
hs.Logger.Warn("Unable to get session UUID")
@@ -114,7 +114,7 @@ func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool
return false
}
func (s *HoneypotServer) connCallback(ctx ssh.Context, conn net.Conn) net.Conn {
func (s *HoneypotServer) connCallback(ctx sshlib.Context, conn net.Conn) net.Conn {
throttledConn := newThrottledConn(conn)
throttledConn.SetSpeed(s.throttleSpeed)
ctx.SetValue("uuid", throttledConn.ID)
@@ -122,7 +122,7 @@ func (s *HoneypotServer) connCallback(ctx ssh.Context, conn net.Conn) net.Conn {
return throttledConn
}
func handler(session ssh.Session) {
func handler(session sshlib.Session) {
_, _ = io.WriteString(session, "[root@hostname ~]#")
session.Exit(1)
}

View File

@@ -3,7 +3,7 @@ package store_test
import (
"testing"
"github.uio.no/torjus/apiary/honeypot/store"
"github.uio.no/torjus/apiary/honeypot/ssh/store"
)
func TestCacheStore(t *testing.T) {

View File

@@ -3,7 +3,7 @@ package store_test
import (
"testing"
"github.uio.no/torjus/apiary/honeypot/store"
"github.uio.no/torjus/apiary/honeypot/ssh/store"
)
func TestMemoryStore(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"os"
"testing"
"github.uio.no/torjus/apiary/honeypot/store"
"github.uio.no/torjus/apiary/honeypot/ssh/store"
)
func TestPostgresStore(t *testing.T) {

View File

@@ -7,7 +7,7 @@ import (
"time"
"github.com/google/uuid"
"github.uio.no/torjus/apiary/honeypot/store"
"github.uio.no/torjus/apiary/honeypot/ssh/store"
"github.uio.no/torjus/apiary/models"
)