丢点更新上去

This commit is contained in:
shenjack 2024-08-17 21:02:52 +08:00
parent 8c52d898ff
commit 4da93570c9
Signed by: shenjack
GPG Key ID: 7B1134A979775551
4 changed files with 16 additions and 7 deletions

View File

@ -10,7 +10,7 @@ use crate::config::IcaConfig;
use crate::error::{ClientResult, IcaError}; use crate::error::{ClientResult, IcaError};
use crate::StopGetter; use crate::StopGetter;
const ICA_PROTOCOL_VERSION: &str = "2.12.11"; const ICA_PROTOCOL_VERSION: &str = "2.12.12";
pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientResult<(), IcaError> { pub async fn start_ica(config: &IcaConfig, stop_reciver: StopGetter) -> ClientResult<(), IcaError> {
let span = span!(Level::INFO, "Icalingua Client"); let span = span!(Level::INFO, "Icalingua Client");

View File

@ -7,7 +7,7 @@ use ed25519_dalek::{Signature, Signer, SigningKey};
use rust_socketio::asynchronous::Client; use rust_socketio::asynchronous::Client;
use rust_socketio::Payload; use rust_socketio::Payload;
use serde_json::Value; use serde_json::Value;
use tracing::{debug, info, span, warn, Level}; use tracing::{debug, info, span, warn, event, Level};
/// "安全" 的 发送一条消息 /// "安全" 的 发送一条消息
pub async fn send_message(client: &Client, message: &SendMessage) -> bool { pub async fn send_message(client: &Client, message: &SendMessage) -> bool {
@ -56,7 +56,7 @@ async fn inner_sign(payload: Payload, client: Client) -> ClientResult<(), IcaErr
let (auth_key, version) = (&require_data[0], &require_data[1]); let (auth_key, version) = (&require_data[0], &require_data[1]);
info!("auth_key: {:?}, server_version: {:?}", auth_key, version); event!(Level::INFO, "服务器发过来的待签名key: {:?}, 服务端版本号: {:?}", auth_key, version);
// 判定和自己的兼容版本号是否 一致 // 判定和自己的兼容版本号是否 一致
let server_protocol_version = version let server_protocol_version = version
.get("protocolVersion") .get("protocolVersion")
@ -81,15 +81,15 @@ async fn inner_sign(payload: Payload, client: Client) -> ClientResult<(), IcaErr
let private_key = MainStatus::global_config().ica().private_key.clone(); let private_key = MainStatus::global_config().ica().private_key.clone();
let array_key: [u8; 32] = hex::decode(private_key) let array_key: [u8; 32] = hex::decode(private_key)
.expect("Not a vaild pub key") .expect("配置文件设置的私钥不是一个有效的私钥, 无法使用hex解析")
.try_into() .try_into()
.expect("Not a vaild pub key"); .expect("配置文件设置的私钥不是一个有效的私钥, 无法转换为[u8; 32]数组");
let signing_key: SigningKey = SigningKey::from_bytes(&array_key); let signing_key: SigningKey = SigningKey::from_bytes(&array_key);
let signature: Signature = signing_key.sign(salt.as_slice()); let signature: Signature = signing_key.sign(salt.as_slice());
// 发送签名 // 发送签名
let sign = signature.to_bytes().to_vec(); let sign = signature.to_bytes().to_vec();
client.emit("auth", sign).await.expect("Faild to send signin data"); client.emit("auth", sign).await.expect("发送签名信息失败");
Ok(()) Ok(())
} }

View File

@ -29,6 +29,10 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const ICA_VERSION: &str = "1.6.1"; pub const ICA_VERSION: &str = "1.6.1";
pub const TAILCHAT_VERSION: &str = "1.2.1"; pub const TAILCHAT_VERSION: &str = "1.2.1";
/// 是否为稳定版本
/// 会在 release 的时候设置为 true
pub const STABLE: bool = false;
#[macro_export] #[macro_export]
macro_rules! async_callback_with_state { macro_rules! async_callback_with_state {
($f:expr, $state:expr) => {{ ($f:expr, $state:expr) => {{
@ -69,7 +73,10 @@ async fn main() {
let span = span!(Level::INFO, "Shenbot Main"); let span = span!(Level::INFO, "Shenbot Main");
let _enter = span.enter(); let _enter = span.enter();
event!(Level::INFO, "shenbot-async-rs v{} starting", VERSION); event!(Level::INFO, "shenbot-rs v{} starting", VERSION);
if !STABLE {
event!(Level::WARN, "这是一个开发版本, 有问题记得找 shenjack");
}
let bot_config = BotConfig::new_from_cli(); let bot_config = BotConfig::new_from_cli();
MainStatus::static_init(bot_config); MainStatus::static_init(bot_config);

View File

@ -6,6 +6,8 @@
- 现在会在插件加载时警告你的插件原来定义了 `CONFIG_DATA` 这一项 - 现在会在插件加载时警告你的插件原来定义了 `CONFIG_DATA` 这一项
- `IcaNewMessage` 添加了新的 api - `IcaNewMessage` 添加了新的 api
- `get_sender_name` 获取发送人昵称 - `get_sender_name` 获取发送人昵称
- `ica` 兼容版本号 `2.12.11` -> `2.12.12`
- 加入了 `STABLE` 信息, 用于标记稳定版本
## 0.6.10 ## 0.6.10