update glutton

This commit is contained in:
t3chn0m4g3 2018-09-03 13:33:54 +00:00
parent 7c66579baa
commit 0abb518177
2 changed files with 0 additions and 45 deletions

View file

@ -23,7 +23,6 @@ RUN apk -U --no-cache add \
cd go.uuid && \
git checkout v1.2.0 && \
mv /root/dist/system.go /opt/go/src/github.com/mushorg/glutton/ && \
mv /root/dist/tcp.go /opt/go/src/github.com/mushorg/glutton/ && \
cd /opt/go/src/github.com/mushorg/glutton/ && \
make build && \
cd / && \

View file

@ -1,44 +0,0 @@
package glutton
import (
"context"
"encoding/hex"
"fmt"
"net"
"strconv"
"github.com/kung-foo/freki"
"go.uber.org/zap"
)
// HandleTCP takes a net.Conn and peeks at the data send
func (g *Glutton) HandleTCP(ctx context.Context, conn net.Conn) (err error) {
defer func() {
err = conn.Close()
if err != nil {
g.logger.Error(fmt.Sprintf("[log.tcp ] error: %v", err))
}
}()
host, port, err := net.SplitHostPort(conn.RemoteAddr().String())
if err != nil {
g.logger.Error(fmt.Sprintf("[log.tcp ] error: %v", err))
}
ck := freki.NewConnKeyByString(host, port)
md := g.processor.Connections.GetByFlow(ck)
buffer := make([]byte, 1024)
n, err := conn.Read(buffer)
if err != nil {
g.logger.Error(fmt.Sprintf("[log.tcp ] error: %v", err))
}
if n > 0 && n < 1024 {
g.logger.Info(
fmt.Sprintf("Packet got handled by TCP handler"),
zap.String("dest_port", strconv.Itoa(int(md.TargetPort))),
zap.String("src_ip", host),
zap.String("src_port", port),
zap.String("handler", "tcp"),
zap.String("payload_hex", hex.EncodeToString(buffer[0:n])),
)
}
return err
}