Skip to content

Commit

Permalink
feat(qsign): add qsign client support
Browse files Browse the repository at this point in the history
  • Loading branch information
LovesAsuna committed Sep 16, 2023
1 parent 6b34fb8 commit 8733c72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions proc_qq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ proc_qq_codegen = { path = "../proc_qq_codegen" }
bytes = "1"
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
ricq = { git = "https://github.com/lz1998/ricq.git", rev = "5182cb7" }
ricq-core = { git = "https://github.com/lz1998/ricq.git", rev = "5182cb7" }
ricq = { git = "https://github.com/lz1998/ricq.git", branch = "master" }
ricq-core = { git = "https://github.com/lz1998/ricq.git", branch = "master" }
anyhow = "1.0"
serde = "1.0"
serde_json = "1.0"
Expand Down
12 changes: 12 additions & 0 deletions proc_qq/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use futures::future::BoxFuture;
use futures::FutureExt;
use rand::prelude::IteratorRandom;
use ricq::ext::common::after_login;
use ricq::qsign::QSignClient;
use ricq_core::binary::{BinaryReader, BinaryWriter};
use ricq_core::command::wtlogin::{
LoginDeviceLocked, LoginNeedCaptcha, LoginResponse, LoginSuccess, LoginUnknownStatus,
Expand Down Expand Up @@ -544,6 +545,7 @@ pub fn bytes_to_token(token: Vec<u8>) -> Token {

/// 用于构建客户端
pub struct ClientBuilder {
qsign_client: Option<Arc<QSignClient>>,
device_source: DeviceSource,
version: &'static Version,
authentication: Option<Authentication>,
Expand All @@ -564,6 +566,7 @@ impl ClientBuilder {
// 构造
pub fn new() -> Self {
Self {
qsign_client: None,
device_source: DeviceSource::default(),
version: &ANDROID_PHONE,
authentication: None,
Expand All @@ -581,6 +584,12 @@ impl ClientBuilder {
}
}

/// 设置签名服务器
pub fn qsign<S: Into<Option<Arc<QSignClient>>>>(mut self, h: S) -> Self {
self.qsign_client = h.into();
self
}

/// 设置模块
pub fn modules<S: Into<Arc<Vec<Module>>>>(mut self, h: S) -> Self {
self.modules_vec = h.into();
Expand Down Expand Up @@ -657,6 +666,9 @@ impl ClientBuilder {
JsonString(json_string) => parse_device_json(json_string)?,
},
self.version.clone(),
self.qsign_client
.clone()
.with_context(|| "您必须设置签名服务器")?,
ClientHandler {
modules: self.modules_vec.clone(),
result_handlers: self.result_handlers_vec.clone(),
Expand Down

0 comments on commit 8733c72

Please sign in to comment.