mirror of
https://github.com/telekom-security/tpotce.git
synced 2025-04-19 21:52:27 +00:00
bump glutton, tune down noisy log
This commit is contained in:
parent
b9fb3d4695
commit
42c19e4d81
4 changed files with 95 additions and 25 deletions
|
@ -1,8 +1,8 @@
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
#
|
||||||
# Include dist
|
# Include dist
|
||||||
ADD dist/ /root/dist/
|
ADD dist/ /root/dist/
|
||||||
|
#
|
||||||
# Setup apk
|
# Setup apk
|
||||||
RUN apk -U --no-cache add \
|
RUN apk -U --no-cache add \
|
||||||
build-base \
|
build-base \
|
||||||
|
@ -13,32 +13,32 @@ RUN apk -U --no-cache add \
|
||||||
libnetfilter_queue-dev \
|
libnetfilter_queue-dev \
|
||||||
libcap \
|
libcap \
|
||||||
libpcap-dev && \
|
libpcap-dev && \
|
||||||
|
#
|
||||||
# Setup go, glutton
|
# Setup go, glutton
|
||||||
export GOPATH=/opt/go/ && \
|
export GOPATH=/opt/go/ && \
|
||||||
go get -d github.com/mushorg/glutton && \
|
export GO111MODULE=on && \
|
||||||
cd /opt/go/src/github.com/satori/ && \
|
mkdir -p /opt/go && \
|
||||||
rm -rf go.uuid && \
|
cd /opt/go/ && \
|
||||||
git clone https://github.com/satori/go.uuid && \
|
git clone https://github.com/mushorg/glutton && \
|
||||||
cd go.uuid && \
|
cd /opt/go/glutton/ && \
|
||||||
git checkout v1.2.0 && \
|
mv /root/dist/system.go /opt/go/glutton/ && \
|
||||||
mv /root/dist/system.go /opt/go/src/github.com/mushorg/glutton/ && \
|
go mod download && \
|
||||||
cd /opt/go/src/github.com/mushorg/glutton/ && \
|
|
||||||
make build && \
|
make build && \
|
||||||
cd / && \
|
cd / && \
|
||||||
mkdir -p /opt/glutton && \
|
mkdir -p /opt/glutton && \
|
||||||
mv /opt/go/src/github.com/mushorg/glutton/bin /opt/glutton/ && \
|
mv /opt/go/glutton/bin /opt/glutton/ && \
|
||||||
mv /opt/go/src/github.com/mushorg/glutton/config /opt/glutton/ && \
|
mv /opt/go/glutton/config /opt/glutton/ && \
|
||||||
mv /opt/go/src/github.com/mushorg/glutton/rules /opt/glutton/ && \
|
mv /opt/go/glutton/rules /opt/glutton/ && \
|
||||||
|
ln -s /sbin/xtables-legacy-multi /sbin/xtables-multi && \
|
||||||
setcap cap_net_admin,cap_net_raw=+ep /opt/glutton/bin/server && \
|
setcap cap_net_admin,cap_net_raw=+ep /opt/glutton/bin/server && \
|
||||||
setcap cap_net_admin,cap_net_raw=+ep /sbin/xtables-multi && \
|
setcap cap_net_admin,cap_net_raw=+ep /sbin/xtables-legacy-multi && \
|
||||||
|
#
|
||||||
# Setup user, groups and configs
|
# Setup user, groups and configs
|
||||||
addgroup -g 2000 glutton && \
|
addgroup -g 2000 glutton && \
|
||||||
adduser -S -s /bin/ash -u 2000 -D -g 2000 glutton && \
|
adduser -S -s /bin/ash -u 2000 -D -g 2000 glutton && \
|
||||||
mkdir -p /var/log/glutton && \
|
mkdir -p /var/log/glutton && \
|
||||||
mv /root/dist/rules.yaml /opt/glutton/rules/ && \
|
mv /root/dist/rules.yaml /opt/glutton/rules/ && \
|
||||||
|
#
|
||||||
# Clean up
|
# Clean up
|
||||||
apk del --purge build-base \
|
apk del --purge build-base \
|
||||||
git \
|
git \
|
||||||
|
@ -47,8 +47,8 @@ RUN apk -U --no-cache add \
|
||||||
rm -rf /var/cache/apk/* \
|
rm -rf /var/cache/apk/* \
|
||||||
/opt/go \
|
/opt/go \
|
||||||
/root/dist
|
/root/dist
|
||||||
|
#
|
||||||
# Start glutton
|
# Start glutton
|
||||||
WORKDIR /opt/glutton
|
WORKDIR /opt/glutton
|
||||||
USER glutton:glutton
|
USER glutton:glutton
|
||||||
CMD exec bin/server -i $(/sbin/ip address | grep '^2: ' | awk '{ print $2 }' | tr -d [:punct:]) -l /var/log/glutton/glutton.log
|
CMD exec bin/server -i $(/sbin/ip address | grep '^2: ' | awk '{ print $2 }' | tr -d [:punct:]) -l /var/log/glutton/glutton.log > /dev/null 2>&1
|
||||||
|
|
54
docker/glutton/Dockerfile.old
Normal file
54
docker/glutton/Dockerfile.old
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
FROM alpine
|
||||||
|
#
|
||||||
|
# Include dist
|
||||||
|
ADD dist/ /root/dist/
|
||||||
|
#
|
||||||
|
# Setup apk
|
||||||
|
RUN apk -U --no-cache add \
|
||||||
|
build-base \
|
||||||
|
git \
|
||||||
|
go \
|
||||||
|
g++ \
|
||||||
|
iptables-dev \
|
||||||
|
libnetfilter_queue-dev \
|
||||||
|
libcap \
|
||||||
|
libpcap-dev && \
|
||||||
|
#
|
||||||
|
# Setup go, glutton
|
||||||
|
export GOPATH=/opt/go/ && \
|
||||||
|
go get -d github.com/mushorg/glutton && \
|
||||||
|
cd /opt/go/src/github.com/satori/ && \
|
||||||
|
rm -rf go.uuid && \
|
||||||
|
git clone https://github.com/satori/go.uuid && \
|
||||||
|
cd go.uuid && \
|
||||||
|
git checkout v1.2.0 && \
|
||||||
|
mv /root/dist/system.go /opt/go/src/github.com/mushorg/glutton/ && \
|
||||||
|
cd /opt/go/src/github.com/mushorg/glutton/ && \
|
||||||
|
make build && \
|
||||||
|
cd / && \
|
||||||
|
mkdir -p /opt/glutton && \
|
||||||
|
mv /opt/go/src/github.com/mushorg/glutton/bin /opt/glutton/ && \
|
||||||
|
mv /opt/go/src/github.com/mushorg/glutton/config /opt/glutton/ && \
|
||||||
|
mv /opt/go/src/github.com/mushorg/glutton/rules /opt/glutton/ && \
|
||||||
|
setcap cap_net_admin,cap_net_raw=+ep /opt/glutton/bin/server && \
|
||||||
|
setcap cap_net_admin,cap_net_raw=+ep /sbin/xtables-multi && \
|
||||||
|
#
|
||||||
|
# Setup user, groups and configs
|
||||||
|
addgroup -g 2000 glutton && \
|
||||||
|
adduser -S -s /bin/ash -u 2000 -D -g 2000 glutton && \
|
||||||
|
mkdir -p /var/log/glutton && \
|
||||||
|
mv /root/dist/rules.yaml /opt/glutton/rules/ && \
|
||||||
|
#
|
||||||
|
# Clean up
|
||||||
|
apk del --purge build-base \
|
||||||
|
git \
|
||||||
|
go \
|
||||||
|
g++ && \
|
||||||
|
rm -rf /var/cache/apk/* \
|
||||||
|
/opt/go \
|
||||||
|
/root/dist
|
||||||
|
#
|
||||||
|
# Start glutton
|
||||||
|
WORKDIR /opt/glutton
|
||||||
|
USER glutton:glutton
|
||||||
|
CMD exec bin/server -i $(/sbin/ip address | grep '^2: ' | awk '{ print $2 }' | tr -d [:punct:]) -l /var/log/glutton/glutton.log > /dev/null 2>&1
|
27
docker/glutton/dist/system.go
vendored
27
docker/glutton/dist/system.go
vendored
|
@ -1,6 +1,7 @@
|
||||||
package glutton
|
package glutton
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -10,13 +11,19 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func countOpenFiles() int {
|
func countOpenFiles() (int, error) {
|
||||||
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("lsof -p %v", os.Getpid())).Output()
|
if runtime.GOOS == "linux" {
|
||||||
if err != nil {
|
if isCommandAvailable("lsof") {
|
||||||
log.Fatal(err)
|
out, err := exec.Command("/bin/sh", "-c", fmt.Sprintf("lsof -p %d", os.Getpid())).Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
lines := strings.Split(string(out), "\n")
|
||||||
|
return len(lines) - 1, nil
|
||||||
|
}
|
||||||
|
return 0, errors.New("lsof command does not exist. Kindly run sudo apt install lsof")
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(out), "\n")
|
return 0, errors.New("Operating system type not supported for this command")
|
||||||
return len(lines) - 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func countRunningRoutines() int {
|
func countRunningRoutines() int {
|
||||||
|
@ -36,3 +43,11 @@ func (g *Glutton) startMonitor(quit chan struct{}) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isCommandAvailable(name string) bool {
|
||||||
|
cmd := exec.Command("/bin/sh", "-c", "command -v "+name)
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
tmpfs:
|
tmpfs:
|
||||||
- /var/lib/glutton:uid=2000,gid=2000
|
- /var/lib/glutton:uid=2000,gid=2000
|
||||||
|
- /run:uid=2000,gid=2000
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
|
|
Loading…
Reference in a new issue