diff --git a/Dockerfile b/Dockerfile index 5675bc910..304684627 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,8 +42,8 @@ RUN go build -ldflags="-s -w \ -X 'mizuserver/pkg/version.SemVer=${SEM_VER}'" -o mizuagent . # Download Basenine executable, verify the sha1sum and move it to a directory in $PATH -ADD https://github.com/up9inc/basenine/releases/download/v0.2.11/basenine_linux_amd64 ./basenine_linux_amd64 -ADD https://github.com/up9inc/basenine/releases/download/v0.2.11/basenine_linux_amd64.sha256 ./basenine_linux_amd64.sha256 +ADD https://github.com/up9inc/basenine/releases/download/v0.2.12/basenine_linux_amd64 ./basenine_linux_amd64 +ADD https://github.com/up9inc/basenine/releases/download/v0.2.12/basenine_linux_amd64.sha256 ./basenine_linux_amd64.sha256 RUN shasum -a 256 -c basenine_linux_amd64.sha256 RUN chmod +x ./basenine_linux_amd64 diff --git a/agent/go.mod b/agent/go.mod index c2b10a534..06108bf9b 100644 --- a/agent/go.mod +++ b/agent/go.mod @@ -16,7 +16,7 @@ require ( github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/up9inc/basenine/client/go v0.0.0-20211121072216-04366911881c + github.com/up9inc/basenine/client/go v0.0.0-20211125004153-d0e8aec03fea github.com/up9inc/mizu/shared v0.0.0 github.com/up9inc/mizu/tap v0.0.0 github.com/up9inc/mizu/tap/api v0.0.0 diff --git a/agent/go.sum b/agent/go.sum index 1d18d281a..30e473925 100644 --- a/agent/go.sum +++ b/agent/go.sum @@ -450,8 +450,8 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/up9inc/basenine/client/go v0.0.0-20211121072216-04366911881c h1:GJsCVhDKjV/k3mNG255VN7hAQ7fxyNgX5T+VJyzoOQ0= -github.com/up9inc/basenine/client/go v0.0.0-20211121072216-04366911881c/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI= +github.com/up9inc/basenine/client/go v0.0.0-20211125004153-d0e8aec03fea h1:GpJGO2PNTS/S0j2E1yqBi3ST/VXfokzuOrTQyaYgWnA= +github.com/up9inc/basenine/client/go v0.0.0-20211125004153-d0e8aec03fea/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvVn1ZaTIVp+3vuYAXFe3OJEvjbUYJLaA= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= diff --git a/debug.Dockerfile b/debug.Dockerfile index 68176ffae..b6af5df92 100644 --- a/debug.Dockerfile +++ b/debug.Dockerfile @@ -37,8 +37,8 @@ COPY agent . RUN go build -gcflags="all=-N -l" -o mizuagent . # Download Basenine executable, verify the sha1sum and move it to a directory in $PATH -ADD https://github.com/up9inc/basenine/releases/download/v0.2.11/basenine_linux_amd64 ./basenine_linux_amd64 -ADD https://github.com/up9inc/basenine/releases/download/v0.2.11/basenine_linux_amd64.sha256 ./basenine_linux_amd64.sha256 +ADD https://github.com/up9inc/basenine/releases/download/v0.2.12/basenine_linux_amd64 ./basenine_linux_amd64 +ADD https://github.com/up9inc/basenine/releases/download/v0.2.12/basenine_linux_amd64.sha256 ./basenine_linux_amd64.sha256 RUN shasum -a 256 -c basenine_linux_amd64.sha256 RUN chmod +x ./basenine_linux_amd64 diff --git a/ui/src/components/Filters.tsx b/ui/src/components/Filters.tsx index 734bb126e..87463085a 100644 --- a/ui/src/components/Filters.tsx +++ b/ui/src/components/Filters.tsx @@ -13,7 +13,7 @@ interface FiltersProps { setQuery: any backgroundColor: string ws: any - openWebSocket: (query: string) => void; + openWebSocket: (query: string, resetEntriesBuffer: boolean) => void; } export const Filters: React.FC = ({query, setQuery, backgroundColor, ws, openWebSocket}) => { @@ -33,7 +33,7 @@ interface QueryFormProps { setQuery: any backgroundColor: string ws: any - openWebSocket: (query: string) => void; + openWebSocket: (query: string, resetEntriesBuffer: boolean) => void; } const style = { @@ -63,8 +63,8 @@ export const QueryForm: React.FC = ({query, setQuery, background } const handleSubmit = (e) => { - ws.close() - openWebSocket(query) + ws.close(); + openWebSocket(query, true); e.preventDefault(); } diff --git a/ui/src/components/TrafficPage.tsx b/ui/src/components/TrafficPage.tsx index f741c39e3..13175f236 100644 --- a/ui/src/components/TrafficPage.tsx +++ b/ui/src/components/TrafficPage.tsx @@ -66,6 +66,7 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS const [queriedCurrent, setQueriedCurrent] = useState(0); const [queriedTotal, setQueriedTotal] = useState(0); + const [leftOff, setLeftOff] = useState(0); const [startTime, setStartTime] = useState(0); @@ -100,16 +101,30 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS const listEntry = useRef(null); - const openWebSocket = (query) => { - setFocusedEntryId(null); - setEntries([]); - setEntriesBuffer([]); + const openWebSocket = (query: string, resetEntriesBuffer: boolean) => { + if (resetEntriesBuffer) { + setFocusedEntryId(null); + setEntries([]); + setEntriesBuffer([]); + } else { + setEntriesBuffer(entries); + } ws.current = new WebSocket(MizuWebsocketURL); ws.current.onopen = () => { - ws.current.send(query) setConnection(ConnectionStatus.Connected); + ws.current.send(query); + } + ws.current.onclose = () => { + setConnection(ConnectionStatus.Closed); + } + ws.current.onerror = (event) => { + console.error("WebSocket error:", event); + if (query) { + openWebSocket(`(${query}) and leftOff(${leftOff})`, false); + } else { + openWebSocket(`leftOff(${leftOff})`, false); + } } - ws.current.onclose = () => setConnection(ConnectionStatus.Closed); } if (ws.current) { @@ -161,6 +176,7 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS case "queryMetadata": setQueriedCurrent(message.data.current); setQueriedTotal(message.data.total); + setLeftOff(message.data.leftOff); setEntries(entriesBuffer); break; case "startTime": @@ -184,7 +200,7 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS useEffect(() => { (async () => { - openWebSocket("rlimit(100)"); + openWebSocket("leftOff(-1)", true); try{ const tapStatusResponse = await api.tapStatus(); setTappingStatus(tapStatusResponse); @@ -232,8 +248,11 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS if (connection === ConnectionStatus.Connected) { ws.current.close(); } else { - openWebSocket(query); - setConnection(ConnectionStatus.Connected); + if (query) { + openWebSocket(`(${query}) and leftOff(${leftOff})`, false); + } else { + openWebSocket(`leftOff(${leftOff})`, false); + } } }