Skip to content

Commit b30a6a2

Browse files
committed
Fix IPv6 address formatting in historical mode and increase API limit
- Add formatAddress helper to properly format IPv6 addresses as [ipv6]:port instead of ipv6:port which broke the extractIP parser - Increase stored flow logs API limit from 10000 to 50000 to prevent cutting off records in larger time ranges
1 parent 2224552 commit b30a6a2

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

frontend/src/lib/services/tailscale-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const tailscaleService = {
9494
},
9595

9696
// New methods for stored historical data
97-
async getStoredFlowLogs(start: Date, end: Date, limit = 10000): Promise<StoredFlowLogsResponse> {
97+
async getStoredFlowLogs(start: Date, end: Date, limit = 50000): Promise<StoredFlowLogsResponse> {
9898
const startISO = start.toISOString();
9999
const endISO = end.toISOString();
100100
return api.get<StoredFlowLogsResponse>(

frontend/src/lib/stores/network-store.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ function convertStoredLogsToNetworkLogs(storedLogs: any[]): NetworkLog[] {
250250
// Convert to NetworkLog format
251251
const networkLogs: NetworkLog[] = [];
252252

253+
// Helper to format IP:port correctly for IPv4 and IPv6
254+
const formatAddress = (ip: string, port: number): string => {
255+
if (ip.includes(':')) {
256+
// IPv6: use [ip]:port format
257+
return `[${ip}]:${port}`;
258+
}
259+
// IPv4: use ip:port format
260+
return `${ip}:${port}`;
261+
};
262+
253263
for (const [, logs] of grouped) {
254264
if (logs.length === 0) continue;
255265

@@ -267,8 +277,8 @@ function convertStoredLogsToNetworkLogs(storedLogs: any[]): NetworkLog[] {
267277
for (const log of logs) {
268278
const traffic = {
269279
proto: log.protocol,
270-
src: `${log.srcIp}:${log.srcPort}`,
271-
dst: `${log.dstIp}:${log.dstPort}`,
280+
src: formatAddress(log.srcIp, log.srcPort),
281+
dst: formatAddress(log.dstIp, log.dstPort),
272282
txBytes: log.txBytes,
273283
rxBytes: log.rxBytes,
274284
txPkts: log.txPkts,

0 commit comments

Comments
 (0)