test database privilige and index + delete ep packets
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 1m4s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 1m4s
This commit is contained in:
@@ -159,6 +159,12 @@ export const fetchPackets = async (limit = 100): Promise<any> => {
|
|||||||
return res.data;
|
return res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const clearPackets = async (): Promise<any> => {
|
||||||
|
// limit default mirrors OpenAPI default
|
||||||
|
const res = await api.delete('/packets/packets');
|
||||||
|
return res.data;
|
||||||
|
};
|
||||||
|
|
||||||
/* -------------------------
|
/* -------------------------
|
||||||
Firewall
|
Firewall
|
||||||
------------------------- */
|
------------------------- */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// src/components/PacketViewer.tsx
|
// src/components/PacketViewer.tsx
|
||||||
import { DownloadOutlined, SyncOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, DownloadOutlined, SyncOutlined } from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
message,
|
message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { fetchPackets } from '../api/apiClient';
|
import { clearPackets, fetchPackets } from '../api/apiClient';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@@ -434,6 +434,7 @@ export default function PacketViewer(): ReactElement {
|
|||||||
<Switch checked={!paused} onChange={(checked) => handlePauseToggle(!checked ? true : false)} />
|
<Switch checked={!paused} onChange={(checked) => handlePauseToggle(!checked ? true : false)} />
|
||||||
|
|
||||||
<Button icon={<SyncOutlined />} onClick={handleRefresh} loading={statusLoading} />
|
<Button icon={<SyncOutlined />} onClick={handleRefresh} loading={statusLoading} />
|
||||||
|
<Button onClick={() => clearPackets()} danger icon={<DeleteOutlined />} />
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
@@ -89,9 +89,17 @@ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO $DB_USER;
|
|||||||
-- Grant sequence permissions (needed for SERIAL / BIGSERIAL)
|
-- Grant sequence permissions (needed for SERIAL / BIGSERIAL)
|
||||||
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO $DB_USER;
|
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO $DB_USER;
|
||||||
|
|
||||||
|
-- Change ownership to ensure the user can manage the table
|
||||||
|
ALTER TABLE packets OWNER TO $DB_USER;
|
||||||
|
ALTER SEQUENCE packets_id_seq OWNER TO $DB_USER;
|
||||||
|
|
||||||
-- Ensure future tables & sequences also get permissions
|
-- Ensure future tables & sequences also get permissions
|
||||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO $DB_USER;
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO $DB_USER;
|
||||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO $DB_USER;
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO $DB_USER;
|
||||||
|
|
||||||
|
-- Create indexes for faster queries
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_packets_timestamp ON packets(timestamp DESC);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_packets_src_ip ON packets(src_ip);
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Done. PostgreSQL is ready for LAN + localhost connections."
|
echo "Done. PostgreSQL is ready for LAN + localhost connections."
|
||||||
|
|||||||
Reference in New Issue
Block a user