实现云端控制的动态节点分配逻辑

This commit is contained in:
2025-03-28 10:03:29 +08:00
parent e337a9c08e
commit e61f0bef32
16 changed files with 1313 additions and 138 deletions

View File

@@ -380,34 +380,72 @@ comment on column client_permission_link.deleted_at is '删除时间';
-- region 节点信息
-- ====================
-- proxy
drop table if exists proxy cascade;
create table proxy (
id serial primary key,
version int not null,
name varchar(255) not null unique,
host varchar(255) not null,
type int not null default 0,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
);
create index proxy_name_index on proxy (name);
create index proxy_host_index on proxy (host);
-- proxy表字段注释
comment on table proxy is '代理服务表';
comment on column proxy.id is '代理服务ID';
comment on column proxy.version is '代理服务版本';
comment on column proxy.name is '代理服务名称';
comment on column proxy.host is '代理服务地址';
comment on column proxy.type is '代理服务类型0-自有1-三方';
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 (
id serial primary key,
name varchar(255) not null unique,
version int not null,
fwd_port int not null,
isp varchar(255) not null,
prov varchar(255) not null,
city varchar(255) not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
name varchar(255) not null unique,
host varchar(255) not null,
isp varchar(255) not null,
prov varchar(255) not null,
city varchar(255) not null,
proxy_id int references proxy (id)
on update cascade
on delete cascade,
proxy_port int,
status int not null default 0,
rtt int default 0,
loss int default 0,
created_at timestamp default current_timestamp,
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);
-- node表字段注释
comment on table node is '节点表';
comment on column node.id is '节点ID';
comment on column node.name is '节点名称';
comment on column node.version is '节点版本';
comment on column node.fwd_port is '转发端口';
comment on column node.name is '节点名称';
comment on column node.host is '节点地址';
comment on column node.isp is '运营商';
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 '节点状态1-正常0-离线';
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 '删除时间';
@@ -440,37 +478,45 @@ comment on column whitelist.deleted_at is '删除时间';
drop table if exists channel cascade;
create table channel (
id serial primary key,
user_id int not null references "user" (id)
user_id int not null references "user" (id)
on update cascade
on delete cascade,
node_id int references node (id) --
on update cascade --
on delete set null,
user_host varchar(255) not null,
node_port int,
auth_ip bool not null default false,
auth_pass bool not null default false,
proxy_id int not null references proxy (id) --
on update cascade --
on delete set null,
node_id int references node (id) --
on update cascade --
on delete set null,
proxy_port int not null,
protocol varchar(255),
user_host varchar(255),
node_host varchar(255),
auth_ip bool not null default false,
auth_pass bool not null default false,
username varchar(255) unique,
password varchar(255),
expiration timestamp not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
expiration timestamp not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
);
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_user_host_index on channel (user_host);
create index channel_node_port_index on channel (node_port);
create index channel_proxy_port_index on channel (proxy_port);
create index channel_node_host_index on channel (node_host);
create index channel_expiration_index on channel (expiration);
-- channel表字段注释
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.user_host is '用户地址';
comment on column channel.node_port is '节点端口';
comment on column channel.proxy_port is '转发端口';
comment on column channel.node_host is '节点地址';
comment on column channel.auth_ip is 'IP认证';
comment on column channel.auth_pass is '密码认证';
comment on column channel.protocol is '协议';