no message

This commit is contained in:
Roee Gadot 2021-04-28 17:54:32 +03:00
parent 00949d885a
commit b01fe9c918
5 changed files with 48 additions and 29 deletions

View File

@ -14,3 +14,4 @@ LICENSE
.git/
.github/
build/
**/node_modules/

44
Dockerfile Normal file
View File

@ -0,0 +1,44 @@
FROM node:14-slim AS site-build
WORKDIR /ui-build
COPY ui ./
RUN npm i
RUN npm run build
FROM golang:1.16-alpine AS builder
# Set necessary environment variables needed for our image.
ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64
RUN apk add libpcap-dev gcc g++ make
# Move to tapper working directory (/tap-build).
WORKDIR /tap-build
COPY tap/go.mod tap/go.sum ./
RUN go mod download
# Copy and build tapper code
COPY tap/src ./
RUN go build -ldflags="-s -w" -o passivetapper .
# Move to api working directory (/api-build).
WORKDIR /api-build
COPY api/go.mod api/go.sum ./
RUN go mod download
# Copy and build api code
COPY api .
RUN go build -ldflags="-s -w" -o apiserver .
FROM alpine:3.13.5
RUN apk add parallel libpcap-dev
RUN apk add tcpdump
# Copy binary and config files from /build to root folder of scratch container.
COPY --from=builder ["/api-build/apiserver", "/"]
COPY --from=builder ["/tap-build/passivetapper", "/"]
COPY --from=site-build ["/ui-build/build", "/site"]
# parallel will exit if one of the executables exits, ensuring this container does not run without one of the processes
ENV HOST_MODE="1"
CMD parallel --halt now,done=1 ::: './apiserver' './passivetapper -i any -hardump -hardir /tmp/up9hars -harentriesperfile 10'

View File

@ -1,29 +0,0 @@
FROM golang:1.16 AS builder
# Move to working directory (/site).
WORKDIR /build
# Copy and download dependency using go mod.
COPY go.mod go.sum ./
RUN go mod download
# Copy the code into the container.
COPY . .
# Set necessary environmet variables needed for our image and site the API server.
ENV GOOS=linux GOARCH=amd64
RUN go build -ldflags="-s -w" -o apiserver .
FROM golang:1.16
# Copy binary and config files from /site to root folder of scratch container.
COPY --from=builder ["/build/apiserver", "/"]
# Export necessary port.
EXPOSE 8899
COPY site /go/site
COPY entries.db /go/entries.db
# Command to run when starting the container.
ENTRYPOINT ["/apiserver"]

View File

@ -41,6 +41,7 @@ func StartReadingFiles(workingDir string) {
utils.CheckErr(decErr)
for _, entry := range inputHar.Log.Entries {
time.Sleep(time.Millisecond * 250)
SaveHarToDb(*entry, "")
}
rmErr := os.Remove(inputFilePath)

View File

@ -84,6 +84,8 @@ func (factory *tcpStreamFactory) WaitGoRoutines() {
}
func (factory *tcpStreamFactory) shouldTap(dstIP string, dstPort int) bool {
return true
if hostMode {
return inArrayString(hostAppAddresses, fmt.Sprintf("%s:%d", dstIP, dstPort))
} else {