Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
5ddfcee8
提交
5ddfcee8
authored
4月 06, 2025
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CLI works on PLC server
上级
57f366e2
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
62 行增加
和
4 行删除
+62
-4
Cargo.lock
roboplc-cli/Cargo.lock
+15
-4
Cargo.toml
roboplc-cli/Cargo.toml
+4
-0
config.rs
roboplc-cli/src/config.rs
+24
-0
main.rs
roboplc-cli/src/main.rs
+19
-0
没有找到文件。
roboplc-cli/Cargo.lock
浏览文件 @
5ddfcee8
...
...
@@ -864,9 +864,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "openssl"
version = "0.10.
64
"
version = "0.10.
72
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f
"
checksum = "
fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da
"
dependencies = [
"bitflags 2.5.0",
"cfg-if",
...
...
@@ -894,14 +894,24 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "300.4.2+3.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168ce4e058f975fe43e89d9ccf78ca668601887ae736090aacc23ae353c298e2"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.10
2
"
version = "0.9.10
7
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2
"
checksum = "
8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07
"
dependencies = [
"cc",
"libc",
"openssl-src",
"pkg-config",
"vcpkg",
]
...
...
@@ -1071,6 +1081,7 @@ dependencies = [
"dirs",
"futures-util",
"once_cell",
"openssl",
"prettytable-rs",
"serde",
"serde_json",
...
...
roboplc-cli/Cargo.toml
浏览文件 @
5ddfcee8
...
...
@@ -33,6 +33,7 @@ bma-ts = { version = "0.1.14", features = ["serde", "chrono"] }
prettytable-rs
=
"0.10.0"
chrono
=
"0.4.39"
url
=
"2.5.4"
openssl
=
"0.10.72"
[target.'cfg(windows)'.dependencies]
ansi_term
=
"0.12.1"
...
...
@@ -42,3 +43,6 @@ termios = "0.3.3"
[profile.release]
strip
=
true
[features]
openssl-vendored
=
["openssl/vendored"]
roboplc-cli/src/config.rs
浏览文件 @
5ddfcee8
...
...
@@ -85,3 +85,27 @@ pub fn get_global_remote(url: &str) -> Option<Remote> {
}
}
}
#[derive(Deserialize)]
pub
struct
ServerConfig
{
pub
http
:
ServerHttpConfig
,
pub
aaa
:
ServerAaaConfig
,
}
impl
ServerConfig
{
pub
fn
load
()
->
Result
<
Self
,
Box
<
dyn
std
::
error
::
Error
>>
{
let
s
=
fs
::
read_to_string
(
"/etc/roboplc/manager.toml"
)
?
;
let
config
:
ServerConfig
=
toml
::
from_str
(
&
s
)
?
;
Ok
(
config
)
}
}
#[derive(Deserialize)]
pub
struct
ServerHttpConfig
{
pub
bind
:
String
,
}
#[derive(Deserialize)]
pub
struct
ServerAaaConfig
{
pub
management_key
:
Option
<
String
>
,
}
roboplc-cli/src/main.rs
浏览文件 @
5ddfcee8
...
...
@@ -91,6 +91,25 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
project
::
create
(
maybe_url
,
maybe_key
,
maybe_timeout
,
&
opts
)
?
;
return
Ok
(());
}
if
maybe_url
.is_none
()
{
// we may be on a server, try parsing local manager.toml
let
server_config
=
match
config
::
ServerConfig
::
load
()
{
Ok
(
config
)
=>
config
,
Err
(
e
)
=>
{
return
Err
(
format!
(
r
"URL not specified in options or robo.toml, also tried to load the server /etc/roboplc/manager.toml but failed with {}"
,
e
)
.into
());
}
};
if
maybe_key
.is_none
()
{
maybe_key
=
server_config
.aaa.management_key
;
}
let
mut
sp
=
server_config
.http.bind
.splitn
(
2
,
':'
);
let
mut
host
=
sp
.next
()
.unwrap
();
let
port
=
sp
.next
()
.unwrap_or
(
"7700"
);
if
host
==
"0.0.0.0"
{
host
=
"127.0.0.1"
;
}
maybe_url
=
Some
(
format!
(
"http://{}:{}"
,
host
,
port
));
}
let
url
=
maybe_url
.ok_or
(
"URL not specified"
)
?
;
let
key
=
if
let
Some
(
k
)
=
maybe_key
{
k
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论