captive.whump.shanti-portal/tools/captiveportal.pgsql

23 lines
680 B
Plaintext
Raw Permalink Normal View History

2017-03-06 15:35:27 +00:00
-- create type inet_protocol as enum ('tcp', 'udp');
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'inet_protocol') THEN
CREATE TYPE inet_protocol AS enum ('tcp', 'udp');
END IF;
--more types here...
END$$;
2017-03-03 13:54:49 +00:00
create table if not exists authenticated_clients (
2017-03-06 15:35:27 +00:00
client_id uuid NOT NULL unique,
2017-03-03 14:12:19 +00:00
created timestamp NOT NULL,
ip_address inet NOT NULL,
2017-03-06 15:03:57 +00:00
protocol inet_protocol NOT NULL,
2017-03-03 14:12:19 +00:00
enabled boolean NOT NULL,
last_packets bigint default 0,
2017-03-06 15:03:57 +00:00
last_activity timestamp,
2017-09-29 15:44:40 +00:00
expires timestamp DEFAULT NULL,
2017-03-06 15:03:57 +00:00
primary key (client_id, ip_address, protocol)
2017-03-03 13:54:49 +00:00
);
create index if not exists client_ip_address_index on authenticated_clients (ip_address);