Skip to content

Commit 2349b80

Browse files
committed
0.1.7
1 parent a8ea308 commit 2349b80

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pbbot-rq"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub enum RCError {
1717
Timeout,
1818
#[error("client_not_found error")]
1919
ClientNotFound,
20+
#[error("protocol_not_supported error")]
21+
ProtocolNotSupported,
2022
#[error("io error, {0}")]
2123
IO(#[from] io::Error),
2224
#[error("websocket error, {0}")]
@@ -39,6 +41,7 @@ impl IntoResponse for RCError {
3941
fn into_response(self) -> Response {
4042
let code = match self {
4143
Self::ClientNotFound => StatusCode::BAD_REQUEST,
44+
Self::ProtocolNotSupported => StatusCode::BAD_REQUEST,
4245
_ => StatusCode::INTERNAL_SERVER_ERROR,
4346
};
4447
(code, self.to_string()).into_response()

src/handler/qrcode.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ pub struct CreateClientResp {
7272
pub async fn create(Json(req): Json<CreateClientReq>) -> RCResult<Json<CreateClientResp>> {
7373
let rand_seed = req.device_seed.unwrap_or_else(rand::random);
7474
let device = Device::random_with_rng(&mut StdRng::seed_from_u64(rand_seed));
75-
let protocol = Protocol::from_u8(req.protocol);
75+
let protocol = match Protocol::from_u8(req.protocol) {
76+
Protocol::MacOS => Protocol::MacOS,
77+
Protocol::AndroidWatch => Protocol::AndroidWatch,
78+
_ => return Err(RCError::ProtocolNotSupported),
79+
};
7680
let (sender, receiver) = tokio::sync::broadcast::channel(10);
7781
let cli = Arc::new(Client::new(device, get_version(protocol), sender));
7882
let stream = tokio::net::TcpStream::connect(cli.get_address())

0 commit comments

Comments
 (0)