fix proot

This commit is contained in:
anlicheng 2026-04-21 17:44:52 +08:00
parent 8db7cb5b11
commit ebdbd3f84f
7 changed files with 32 additions and 289 deletions

View File

@ -260,8 +260,8 @@
-ifndef('DEVICEMAPPING_PB_H'). -ifndef('DEVICEMAPPING_PB_H').
-define('DEVICEMAPPING_PB_H', true). -define('DEVICEMAPPING_PB_H', true).
-record('DeviceMapping', -record('DeviceMapping',
{host_path = <<>> :: unicode:chardata() | undefined, % = 1, optional {path_on_host = <<>> :: unicode:chardata() | undefined, % = 1, optional
container_path = <<>> :: unicode:chardata() | undefined, % = 2, optional path_in_container = <<>> :: unicode:chardata() | undefined, % = 2, optional
cgroup_permissions = <<>> :: unicode:chardata() | undefined % = 3, optional cgroup_permissions = <<>> :: unicode:chardata() | undefined % = 3, optional
}). }).
-endif. -endif.

View File

@ -1,134 +0,0 @@
syntax = "proto3";
message ContainerRef {
string id = 1;
string name = 2;
}
message ContainerRequest {
message List {
bool all = 1;
}
message Deploy {
uint32 task_id = 1;
ContainerDeployParams params = 2;
}
message Start {
ContainerRef target = 1;
}
message Stop {
ContainerRef target = 1;
uint32 timeout_seconds = 2;
}
message Kill {
ContainerRef target = 1;
string signal = 2;
}
message Remove {
ContainerRef target = 1;
bool force = 2;
bool remove_volumes = 3;
}
message Config {
ContainerRef target = 1;
bytes config = 2;
}
oneof action {
List list = 10;
Deploy deploy = 11;
Start start = 12;
Stop stop = 13;
Kill kill = 14;
Remove remove = 15;
Config config = 16;
}
}
message ContainerDeployParams {
string container_name = 1;
string container_dir = 2;
DockerCreateOptions create = 3;
}
message DockerCreateOptions {
DockerContainerConfig config = 1;
DockerHostConfig host_config = 2;
DockerNetworkingConfig networking_config = 3;
}
message DockerContainerConfig {
string image = 1;
repeated string cmd = 2;
repeated string entrypoint = 3;
repeated string env = 4;
map<string, string> labels = 5;
repeated string volumes = 6;
string user = 7;
string working_dir = 8;
string hostname = 9;
repeated DockerExposedPort exposed_ports = 10;
Healthcheck healthcheck = 11;
}
message DockerHostConfig {
repeated string binds = 1;
string network_mode = 2;
RestartPolicy restart_policy = 3;
bool privileged = 4;
repeated string cap_add = 5;
repeated string cap_drop = 6;
repeated DeviceMapping devices = 7;
uint64 memory = 8;
uint64 memory_reservation = 9;
uint64 nano_cpus = 10;
uint64 cpu_shares = 11;
repeated Ulimit ulimits = 12;
map<string, string> tmpfs = 13;
map<string, string> sysctls = 14;
repeated string extra_hosts = 15;
}
message DockerNetworkingConfig {
repeated DockerNetworkEndpoint endpoints = 1;
}
message DockerNetworkEndpoint {
string name = 1;
}
message DockerExposedPort {
uint32 container_port = 1;
string protocol = 2; // tcp / udp
}
message Healthcheck {
repeated string test = 1;
uint64 interval_ns = 2;
uint64 timeout_ns = 3;
uint32 retries = 4;
}
message RestartPolicy {
string name = 1; // no, always, unless-stopped, on-failure
uint32 maximum_retry_count = 2;
}
message DeviceMapping {
string host_path = 1;
string container_path = 2;
string cgroup_permissions = 3; // rwm
}
message Ulimit {
string name = 1;
uint64 soft = 2;
uint64 hard = 3;
}

View File

@ -1,69 +0,0 @@
syntax = "proto3";
import "docker.proto";
//
message RequestFrame {
uint32 packet_id = 1;
oneof body {
AuthRequest auth_request = 2;
ContainerRequest container_request = 3;
}
}
message ReplyFrame {
uint32 packet_id = 1;
oneof reply {
ReplyResult result = 2;
ReplyError error = 3;
}
}
message ReplyResult {
bytes data = 1;
}
message ReplyError {
int32 code = 1;
string message = 2;
}
message CastFrame {
oneof body {
Pub pub = 1;
Command command = 2;
Data data = 3;
TaskEventStream event_stream = 4;
}
}
// message定义
message AuthRequest {
bytes uuid = 1;
bytes username = 2;
bytes salt = 3;
bytes token = 4;
int32 timestamp = 5;
}
message Pub {
bytes topic = 1;
int32 qos = 2;
bytes content = 3;
}
message Command {
int32 command_type = 1;
bytes command = 2;
}
message Data {
bytes route_key = 1;
bytes metric = 2;
}
message TaskEventStream {
int32 task_id = 1;
bytes type = 2;
bytes stream = 3;
}

View File

@ -1,54 +0,0 @@
syntax = "proto3";
// ws_channel efka
// JSON //
message ServiceRequest {
uint32 packet_id = 1;
message Register {
string service_id = 1;
}
message Subscribe {
string topic = 1;
}
oneof request {
Register register = 10;
Subscribe subscribe = 11;
}
}
message ServiceReply {
uint32 packet_id = 1;
message Error {
int32 code = 1;
string message = 2;
}
oneof reply {
bytes result = 10;
Error error = 11;
}
}
message ServiceCast {
message MetricData {
bytes route_key = 1;
bytes metric = 2;
}
message TopicEvent {
string topic = 1;
bytes content = 2;
}
oneof body {
TopicEvent topic_event = 10;
MetricData metric_data = 11;
}
}

View File

@ -8,8 +8,8 @@
% 核心:强制指定 proto 路径 + 输出到你的 apps/sdlan % 核心:强制指定 proto 路径 + 输出到你的 apps/sdlan
% ====================== % ======================
{gpb_opts, [ {gpb_opts, [
{i, "proto"}, % proto 文件路径 {i, "../proto"}, % 共享 proto 文件路径
{src_dirs, ["proto"]}, % 源码目录(必须) {src_dirs, ["../proto"]}, % 源码目录(必须)
{f, ["message.proto", "service.proto"]}, {f, ["message.proto", "service.proto"]},
recursive, % 递归查找 proto 文件 recursive, % 递归查找 proto 文件
{module_name_suffix, "_pb"}, % 生成模块后缀 {module_name_suffix, "_pb"}, % 生成模块后缀

View File

@ -241,8 +241,8 @@ build_devices(Devices) when is_list(Devices) ->
<<"PathInContainer">> => to_binary(ContainerPath), <<"PathInContainer">> => to_binary(ContainerPath),
<<"CgroupPermissions">> => device_permissions(Permissions) <<"CgroupPermissions">> => device_permissions(Permissions)
} || #'DeviceMapping'{ } || #'DeviceMapping'{
host_path = HostPath, path_on_host = HostPath,
container_path = ContainerPath, path_in_container = ContainerPath,
cgroup_permissions = Permissions cgroup_permissions = Permissions
} <- Devices], } <- Devices],
#{<<"Devices">> => DevObjs} #{<<"Devices">> => DevObjs}

View File

@ -1029,7 +1029,7 @@ encode_msg_RestartPolicy(#'RestartPolicy'{name = F1, maximum_retry_count = F2},
encode_msg_DeviceMapping(Msg, TrUserData) -> encode_msg_DeviceMapping(Msg, <<>>, TrUserData). encode_msg_DeviceMapping(Msg, TrUserData) -> encode_msg_DeviceMapping(Msg, <<>>, TrUserData).
encode_msg_DeviceMapping(#'DeviceMapping'{host_path = F1, container_path = F2, cgroup_permissions = F3}, Bin, TrUserData) -> encode_msg_DeviceMapping(#'DeviceMapping'{path_on_host = F1, path_in_container = F2, cgroup_permissions = F3}, Bin, TrUserData) ->
B1 = if F1 == undefined -> Bin; B1 = if F1 == undefined -> Bin;
true -> true ->
begin begin
@ -3590,18 +3590,18 @@ skip_64_RestartPolicy(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData)
decode_msg_DeviceMapping(Bin, TrUserData) -> dfp_read_field_def_DeviceMapping(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). decode_msg_DeviceMapping(Bin, TrUserData) -> dfp_read_field_def_DeviceMapping(Bin, 0, 0, 0, id(<<>>, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
dfp_read_field_def_DeviceMapping(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_host_path(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_DeviceMapping(<<10, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_path_on_host(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_DeviceMapping(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_container_path(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_DeviceMapping(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_path_in_container(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_DeviceMapping(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_cgroup_permissions(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_DeviceMapping(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_cgroup_permissions(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
dfp_read_field_def_DeviceMapping(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #'DeviceMapping'{host_path = F@_1, container_path = F@_2, cgroup_permissions = F@_3}; dfp_read_field_def_DeviceMapping(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #'DeviceMapping'{path_on_host = F@_1, path_in_container = F@_2, cgroup_permissions = F@_3};
dfp_read_field_def_DeviceMapping(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_DeviceMapping(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData). dfp_read_field_def_DeviceMapping(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_DeviceMapping(Other, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData).
dg_read_field_def_DeviceMapping(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_DeviceMapping(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_DeviceMapping(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_DeviceMapping(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
dg_read_field_def_DeviceMapping(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_DeviceMapping(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, TrUserData) ->
Key = X bsl N + Acc, Key = X bsl N + Acc,
case Key of case Key of
10 -> d_field_DeviceMapping_host_path(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 10 -> d_field_DeviceMapping_path_on_host(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
18 -> d_field_DeviceMapping_container_path(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_DeviceMapping_path_in_container(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
26 -> d_field_DeviceMapping_cgroup_permissions(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_DeviceMapping_cgroup_permissions(Rest, 0, 0, 0, F@_1, F@_2, F@_3, TrUserData);
_ -> _ ->
case Key band 7 of case Key band 7 of
@ -3612,15 +3612,15 @@ dg_read_field_def_DeviceMapping(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2
5 -> skip_32_DeviceMapping(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData) 5 -> skip_32_DeviceMapping(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, TrUserData)
end end
end; end;
dg_read_field_def_DeviceMapping(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #'DeviceMapping'{host_path = F@_1, container_path = F@_2, cgroup_permissions = F@_3}. dg_read_field_def_DeviceMapping(<<>>, 0, 0, _, F@_1, F@_2, F@_3, _) -> #'DeviceMapping'{path_on_host = F@_1, path_in_container = F@_2, cgroup_permissions = F@_3}.
d_field_DeviceMapping_host_path(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_DeviceMapping_host_path(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_DeviceMapping_path_on_host(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_DeviceMapping_path_on_host(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_DeviceMapping_host_path(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) -> d_field_DeviceMapping_path_on_host(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, {NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_DeviceMapping(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData). dfp_read_field_def_DeviceMapping(RestF, 0, 0, F, NewFValue, F@_2, F@_3, TrUserData).
d_field_DeviceMapping_container_path(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_DeviceMapping_container_path(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData); d_field_DeviceMapping_path_in_container(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_DeviceMapping_path_in_container(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, TrUserData);
d_field_DeviceMapping_container_path(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) -> d_field_DeviceMapping_path_in_container(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end, {NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_DeviceMapping(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData). dfp_read_field_def_DeviceMapping(RestF, 0, 0, F, F@_1, NewFValue, F@_3, TrUserData).
@ -4320,15 +4320,15 @@ merge_msg_RestartPolicy(#'RestartPolicy'{name = PFname, maximum_retry_count = PF
end}. end}.
-compile({nowarn_unused_function,merge_msg_DeviceMapping/3}). -compile({nowarn_unused_function,merge_msg_DeviceMapping/3}).
merge_msg_DeviceMapping(#'DeviceMapping'{host_path = PFhost_path, container_path = PFcontainer_path, cgroup_permissions = PFcgroup_permissions}, merge_msg_DeviceMapping(#'DeviceMapping'{path_on_host = PFpath_on_host, path_in_container = PFpath_in_container, cgroup_permissions = PFcgroup_permissions},
#'DeviceMapping'{host_path = NFhost_path, container_path = NFcontainer_path, cgroup_permissions = NFcgroup_permissions}, _) -> #'DeviceMapping'{path_on_host = NFpath_on_host, path_in_container = NFpath_in_container, cgroup_permissions = NFcgroup_permissions}, _) ->
#'DeviceMapping'{host_path = #'DeviceMapping'{path_on_host =
if NFhost_path =:= undefined -> PFhost_path; if NFpath_on_host =:= undefined -> PFpath_on_host;
true -> NFhost_path true -> NFpath_on_host
end, end,
container_path = path_in_container =
if NFcontainer_path =:= undefined -> PFcontainer_path; if NFpath_in_container =:= undefined -> PFpath_in_container;
true -> NFcontainer_path true -> NFpath_in_container
end, end,
cgroup_permissions = cgroup_permissions =
if NFcgroup_permissions =:= undefined -> PFcgroup_permissions; if NFcgroup_permissions =:= undefined -> PFcgroup_permissions;
@ -4953,12 +4953,12 @@ v_submsg_DeviceMapping(Msg, Path, TrUserData) -> v_msg_DeviceMapping(Msg, Path,
-compile({nowarn_unused_function,v_msg_DeviceMapping/3}). -compile({nowarn_unused_function,v_msg_DeviceMapping/3}).
-dialyzer({nowarn_function,v_msg_DeviceMapping/3}). -dialyzer({nowarn_function,v_msg_DeviceMapping/3}).
v_msg_DeviceMapping(#'DeviceMapping'{host_path = F1, container_path = F2, cgroup_permissions = F3}, Path, TrUserData) -> v_msg_DeviceMapping(#'DeviceMapping'{path_on_host = F1, path_in_container = F2, cgroup_permissions = F3}, Path, TrUserData) ->
if F1 == undefined -> ok; if F1 == undefined -> ok;
true -> v_type_string(F1, [host_path | Path], TrUserData) true -> v_type_string(F1, [path_on_host | Path], TrUserData)
end, end,
if F2 == undefined -> ok; if F2 == undefined -> ok;
true -> v_type_string(F2, [container_path | Path], TrUserData) true -> v_type_string(F2, [path_in_container | Path], TrUserData)
end, end,
if F3 == undefined -> ok; if F3 == undefined -> ok;
true -> v_type_string(F3, [cgroup_permissions | Path], TrUserData) true -> v_type_string(F3, [cgroup_permissions | Path], TrUserData)
@ -5249,8 +5249,8 @@ get_msg_defs() ->
#field{name = retries, fnum = 4, rnum = 5, type = uint32, occurrence = optional, opts = []}]}, #field{name = retries, fnum = 4, rnum = 5, type = uint32, occurrence = optional, opts = []}]},
{{msg, 'RestartPolicy'}, [#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = maximum_retry_count, fnum = 2, rnum = 3, type = uint32, occurrence = optional, opts = []}]}, {{msg, 'RestartPolicy'}, [#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = maximum_retry_count, fnum = 2, rnum = 3, type = uint32, occurrence = optional, opts = []}]},
{{msg, 'DeviceMapping'}, {{msg, 'DeviceMapping'},
[#field{name = host_path, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = path_on_host, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
#field{name = container_path, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = path_in_container, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = cgroup_permissions, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]}, #field{name = cgroup_permissions, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]},
{{msg, 'Ulimit'}, {{msg, 'Ulimit'},
[#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
@ -5445,8 +5445,8 @@ find_msg_def('Healthcheck') ->
#field{name = retries, fnum = 4, rnum = 5, type = uint32, occurrence = optional, opts = []}]; #field{name = retries, fnum = 4, rnum = 5, type = uint32, occurrence = optional, opts = []}];
find_msg_def('RestartPolicy') -> [#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = maximum_retry_count, fnum = 2, rnum = 3, type = uint32, occurrence = optional, opts = []}]; find_msg_def('RestartPolicy') -> [#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, #field{name = maximum_retry_count, fnum = 2, rnum = 3, type = uint32, occurrence = optional, opts = []}];
find_msg_def('DeviceMapping') -> find_msg_def('DeviceMapping') ->
[#field{name = host_path, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = path_on_host, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},
#field{name = container_path, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []}, #field{name = path_in_container, fnum = 2, rnum = 3, type = string, occurrence = optional, opts = []},
#field{name = cgroup_permissions, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}]; #field{name = cgroup_permissions, fnum = 3, rnum = 4, type = string, occurrence = optional, opts = []}];
find_msg_def('Ulimit') -> find_msg_def('Ulimit') ->
[#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []}, [#field{name = name, fnum = 1, rnum = 2, type = string, occurrence = optional, opts = []},