添加代理与节点的注册与端口分配接口功能

This commit is contained in:
2025-05-13 09:29:13 +08:00
parent 957d9ef443
commit 60df1548f0
17 changed files with 692 additions and 464 deletions

View File

@@ -538,13 +538,14 @@ comment on column proxy.created_at is '创建时间';
comment on column proxy.updated_at is '更新时间';
comment on column proxy.deleted_at is '删除时间';
-- node
drop table if exists node cascade;
create table node (
-- edge
drop table if exists edge cascade;
create table edge (
id serial primary key,
proxy_id int references proxy (id)
on update cascade
on delete cascade,
type int not null,
version int not null,
name varchar(255) not null unique,
host varchar(255) not null,
@@ -559,29 +560,31 @@ create table node (
updated_at timestamp default current_timestamp,
deleted_at timestamp
);
create index node_isp_index on node (isp);
create index node_prov_index on node (prov);
create index node_city_index on node (city);
create index node_proxy_id_index on node (proxy_id);
create index node_deleted_at_index on node (deleted_at);
create index edge_proxy_id_index on edge (proxy_id);
create index edge_type_index on edge (type);
create index edge_isp_index on edge (isp);
create index edge_prov_index on edge (prov);
create index edge_city_index on edge (city);
create index edge_deleted_at_index on edge (deleted_at);
-- node表字段注释
comment on table node is '节点表';
comment on column node.id is '节点ID';
comment on column node.version is '节点版本';
comment on column node.name is '节点名称';
comment on column node.host is '节点地址';
comment on column node.isp is '运营商0-未知1-电信2-联通3-移动';
comment on column node.prov is '省份';
comment on column node.city is '城市';
comment on column node.proxy_id is '代理ID';
comment on column node.proxy_port is '代理端口';
comment on column node.status is '节点状态0-离线1-正常';
comment on column node.rtt is '延迟';
comment on column node.loss is '丢包率';
comment on column node.created_at is '创建时间';
comment on column node.updated_at is '更新时间';
comment on column node.deleted_at is '删除时间';
-- edge表字段注释
comment on table edge is '节点表';
comment on column edge.id is '节点ID';
comment on column edge.type is '节点类型1-自建';
comment on column edge.version is '节点版本';
comment on column edge.name is '节点名称';
comment on column edge.host is '节点地址';
comment on column edge.isp is '运营商0-未知1-电信2-联通3-移动';
comment on column edge.prov is '省份';
comment on column edge.city is '城市';
comment on column edge.proxy_id is '代理ID';
comment on column edge.proxy_port is '代理端口';
comment on column edge.status is '节点状态0-离线1-正常';
comment on column edge.rtt is '最近平均延迟';
comment on column edge.loss is '最近丢包率';
comment on column edge.created_at is '创建时间';
comment on column edge.updated_at is '更新时间';
comment on column edge.deleted_at is '删除时间';
-- whitelist
drop table if exists whitelist cascade;
@@ -620,12 +623,12 @@ create table channel (
proxy_id int not null references proxy (id) --
on update cascade --
on delete set null,
node_id int references node (id) --
edge_id int references edge (id) --
on update cascade --
on delete set null,
proxy_host varchar(255) not null default '',
proxy_port int not null,
node_host varchar(255),
edge_host varchar(255),
protocol int,
auth_ip bool not null default false,
auth_pass bool not null default false,
@@ -638,10 +641,10 @@ create table channel (
);
create index channel_user_id_index on channel (user_id);
create index channel_proxy_id_index on channel (proxy_id);
create index channel_node_id_index on channel (node_id);
create index channel_edge_id_index on channel (edge_id);
create index channel_proxy_host_index on channel (proxy_host);
create index channel_proxy_port_index on channel (proxy_port);
create index channel_node_host_index on channel (node_host);
create index channel_edge_host_index on channel (edge_host);
create index channel_auth_ip_index on channel (auth_ip);
create index channel_auth_pass_index on channel (auth_pass);
create index channel_username_index on channel (username);
@@ -653,10 +656,10 @@ comment on table channel is '通道表';
comment on column channel.id is '通道ID';
comment on column channel.user_id is '用户ID';
comment on column channel.proxy_id is '代理ID';
comment on column channel.node_id is '节点ID';
comment on column channel.edge_id is '节点ID';
comment on column channel.proxy_host is '代理地址';
comment on column channel.proxy_port is '转发端口';
comment on column channel.node_host is '节点地址';
comment on column channel.edge_host is '节点地址';
comment on column channel.protocol is '协议类型1-http2-https3-socks5';
comment on column channel.auth_ip is 'IP认证';
comment on column channel.auth_pass is '密码认证';