Page MenuHomePhabricator

D12859.diff
No OneTemporary

D12859.diff

diff --git a/keyserver/src/socket/tunnelbroker.js b/keyserver/src/socket/tunnelbroker.js
--- a/keyserver/src/socket/tunnelbroker.js
+++ b/keyserver/src/socket/tunnelbroker.js
@@ -12,8 +12,8 @@
tunnelbrokerHeartbeatTimeout,
} from 'lib/shared/timeouts.js';
import type { TunnelbrokerClientMessageToDevice } from 'lib/tunnelbroker/tunnelbroker-context.js';
+import type { MessageSentStatus } from 'lib/types/tunnelbroker/device-to-tunnelbroker-request-status-types.js';
import type { MessageReceiveConfirmation } from 'lib/types/tunnelbroker/message-receive-confirmation-types.js';
-import type { MessageSentStatus } from 'lib/types/tunnelbroker/message-to-device-request-status-types.js';
import type { MessageToDeviceRequest } from 'lib/types/tunnelbroker/message-to-device-request-types.js';
import {
deviceToTunnelbrokerMessageTypes,
@@ -337,7 +337,7 @@
}
} else if (
message.type ===
- tunnelbrokerToDeviceMessageTypes.MESSAGE_TO_DEVICE_REQUEST_STATUS
+ tunnelbrokerToDeviceMessageTypes.DEVICE_TO_TUNNELBROKER_REQUEST_STATUS
) {
for (const status: MessageSentStatus of message.clientMessageIDs) {
if (status.type === 'Success') {
diff --git a/lib/tunnelbroker/tunnelbroker-context.js b/lib/tunnelbroker/tunnelbroker-context.js
--- a/lib/tunnelbroker/tunnelbroker-context.js
+++ b/lib/tunnelbroker/tunnelbroker-context.js
@@ -12,7 +12,7 @@
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { tunnelbrokerHeartbeatTimeout } from '../shared/timeouts.js';
import { isWebPlatform } from '../types/device-types.js';
-import type { MessageSentStatus } from '../types/tunnelbroker/message-to-device-request-status-types.js';
+import type { MessageSentStatus } from '../types/tunnelbroker/device-to-tunnelbroker-request-status-types.js';
import type { MessageToDeviceRequest } from '../types/tunnelbroker/message-to-device-request-types.js';
import type { MessageToTunnelbrokerRequest } from '../types/tunnelbroker/message-to-tunnelbroker-request-types.js';
import {
@@ -279,7 +279,7 @@
}
} else if (
message.type ===
- tunnelbrokerToDeviceMessageTypes.MESSAGE_TO_DEVICE_REQUEST_STATUS
+ tunnelbrokerToDeviceMessageTypes.DEVICE_TO_TUNNELBROKER_REQUEST_STATUS
) {
for (const status: MessageSentStatus of message.clientMessageIDs) {
if (status.type === 'Success') {
diff --git a/lib/types/tunnelbroker/message-to-device-request-status-types.js b/lib/types/tunnelbroker/device-to-tunnelbroker-request-status-types.js
rename from lib/types/tunnelbroker/message-to-device-request-status-types.js
rename to lib/types/tunnelbroker/device-to-tunnelbroker-request-status-types.js
--- a/lib/types/tunnelbroker/message-to-device-request-status-types.js
+++ b/lib/types/tunnelbroker/device-to-tunnelbroker-request-status-types.js
@@ -48,13 +48,13 @@
}),
]);
-export type MessageToDeviceRequestStatus = {
+export type DeviceToTunnelbrokerRequestStatus = {
+type: 'MessageToDeviceRequestStatus',
+clientMessageIDs: $ReadOnlyArray<MessageSentStatus>,
};
-export const messageToDeviceRequestStatusValidator: TInterface<MessageToDeviceRequestStatus> =
- tShape<MessageToDeviceRequestStatus>({
+export const messageToDeviceRequestStatusValidator: TInterface<DeviceToTunnelbrokerRequestStatus> =
+ tShape<DeviceToTunnelbrokerRequestStatus>({
type: tString('MessageToDeviceRequestStatus'),
clientMessageIDs: t.list(messageSentStatusValidator),
});
diff --git a/lib/types/tunnelbroker/messages.js b/lib/types/tunnelbroker/messages.js
--- a/lib/types/tunnelbroker/messages.js
+++ b/lib/types/tunnelbroker/messages.js
@@ -3,11 +3,11 @@
import type { TUnion } from 'tcomb';
import t from 'tcomb';
-import { type MessageReceiveConfirmation } from './message-receive-confirmation-types.js';
import {
- type MessageToDeviceRequestStatus,
messageToDeviceRequestStatusValidator,
-} from './message-to-device-request-status-types.js';
+ type DeviceToTunnelbrokerRequestStatus,
+} from './device-to-tunnelbroker-request-status-types.js';
+import { type MessageReceiveConfirmation } from './message-receive-confirmation-types.js';
import { type MessageToDeviceRequest } from './message-to-device-request-types.js';
import {
type MessageToDevice,
@@ -77,14 +77,14 @@
// Messages sent from Tunnelbroker to Device.
export const tunnelbrokerToDeviceMessageTypes = Object.freeze({
CONNECTION_INITIALIZATION_RESPONSE: 'ConnectionInitializationResponse',
- MESSAGE_TO_DEVICE_REQUEST_STATUS: 'MessageToDeviceRequestStatus',
+ DEVICE_TO_TUNNELBROKER_REQUEST_STATUS: 'MessageToDeviceRequestStatus',
MESSAGE_TO_DEVICE: 'MessageToDevice',
HEARTBEAT: 'Heartbeat',
});
export type TunnelbrokerToDeviceMessage =
| ConnectionInitializationResponse
- | MessageToDeviceRequestStatus
+ | DeviceToTunnelbrokerRequestStatus
| MessageToDevice
| Heartbeat;
diff --git a/services/commtest/src/tunnelbroker/socket.rs b/services/commtest/src/tunnelbroker/socket.rs
--- a/services/commtest/src/tunnelbroker/socket.rs
+++ b/services/commtest/src/tunnelbroker/socket.rs
@@ -7,8 +7,8 @@
use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
use tunnelbroker_messages::{
ConnectionInitializationMessage, ConnectionInitializationResponse,
- ConnectionInitializationStatus, DeviceTypes, Heartbeat, MessageSentStatus,
- MessageToDeviceRequest, MessageToDeviceRequestStatus,
+ ConnectionInitializationStatus, DeviceToTunnelbrokerRequestStatus,
+ DeviceTypes, Heartbeat, MessageSentStatus, MessageToDeviceRequest,
TunnelbrokerToDeviceMessage,
};
@@ -76,7 +76,7 @@
socket.send(Message::Text(serialized_request)).await?;
if let Some(Ok(response)) = socket.next().await {
- let confirmation: MessageToDeviceRequestStatus =
+ let confirmation: DeviceToTunnelbrokerRequestStatus =
serde_json::from_str(response.to_text().unwrap())?;
if confirmation
.client_message_ids
diff --git a/services/commtest/tests/tunnelbroker_sender_confirmation_tests.rs b/services/commtest/tests/tunnelbroker_sender_confirmation_tests.rs
--- a/services/commtest/tests/tunnelbroker_sender_confirmation_tests.rs
+++ b/services/commtest/tests/tunnelbroker_sender_confirmation_tests.rs
@@ -3,7 +3,7 @@
use futures_util::{SinkExt, StreamExt};
use tokio_tungstenite::tungstenite::Message;
use tunnelbroker_messages::{
- MessageSentStatus, MessageToDeviceRequest, MessageToDeviceRequestStatus,
+ DeviceToTunnelbrokerRequestStatus, MessageSentStatus, MessageToDeviceRequest,
};
/// Tests of responses sent from Tunnelberoker to client
@@ -34,7 +34,7 @@
.expect("Failed to send message");
if let Some(Ok(response)) = sender_socket.next().await {
- let expected_response = MessageToDeviceRequestStatus {
+ let expected_response = DeviceToTunnelbrokerRequestStatus {
client_message_ids: vec![MessageSentStatus::Success(client_message_id)],
};
let expected_payload = serde_json::to_string(&expected_response).unwrap();
@@ -60,7 +60,7 @@
.expect("Failed to send message");
if let Some(Ok(response)) = sender_socket.next().await {
- let expected_response = MessageToDeviceRequestStatus {
+ let expected_response = DeviceToTunnelbrokerRequestStatus {
client_message_ids: vec![MessageSentStatus::SerializationError(message)],
};
let expected_payload = serde_json::to_string(&expected_response).unwrap();
@@ -80,7 +80,7 @@
.expect("Failed to send message");
if let Some(Ok(response)) = sender_socket.next().await {
- let expected_response = MessageToDeviceRequestStatus {
+ let expected_response = DeviceToTunnelbrokerRequestStatus {
client_message_ids: vec![MessageSentStatus::InvalidRequest],
};
let expected_payload = serde_json::to_string(&expected_response).unwrap();
diff --git a/services/tunnelbroker/src/websockets/mod.rs b/services/tunnelbroker/src/websockets/mod.rs
--- a/services/tunnelbroker/src/websockets/mod.rs
+++ b/services/tunnelbroker/src/websockets/mod.rs
@@ -20,8 +20,8 @@
use tokio::net::TcpListener;
use tracing::{debug, error, info, trace};
use tunnelbroker_messages::{
- ConnectionInitializationStatus, Heartbeat, MessageSentStatus,
- MessageToDeviceRequestStatus,
+ ConnectionInitializationStatus, DeviceToTunnelbrokerRequestStatus, Heartbeat,
+ MessageSentStatus,
};
type BoxedError = Box<dyn std::error::Error + Send + Sync + 'static>;
@@ -265,7 +265,7 @@
let Some(message_status) = session.handle_websocket_frame_from_device(msg).await else {
continue;
};
- let request_status = MessageToDeviceRequestStatus {
+ let request_status = DeviceToTunnelbrokerRequestStatus {
client_message_ids: vec![message_status]
};
if let Ok(response) = serde_json::to_string(&request_status) {
@@ -276,7 +276,7 @@
}
_ => {
error!("Client sent invalid message type");
- let confirmation = MessageToDeviceRequestStatus {client_message_ids: vec![MessageSentStatus::InvalidRequest]};
+ let confirmation = DeviceToTunnelbrokerRequestStatus {client_message_ids: vec![MessageSentStatus::InvalidRequest]};
if let Ok(response) = serde_json::to_string(&confirmation) {
session.send_message_to_device(Message::text(response)).await;
} else {
diff --git a/shared/tunnelbroker_messages/src/messages/message_to_device_request_status.rs b/shared/tunnelbroker_messages/src/messages/message_to_device_request_status.rs
--- a/shared/tunnelbroker_messages/src/messages/message_to_device_request_status.rs
+++ b/shared/tunnelbroker_messages/src/messages/message_to_device_request_status.rs
@@ -10,7 +10,7 @@
}
// NOTE: Keep this in sync with
-// lib/types/tunnelbroker/message-to-device-request-status-types.js
+// lib/types/tunnelbroker/device-to-tunnelbroker-request-status-types.js
#[derive(Serialize, Deserialize, PartialEq, Debug)]
#[serde(tag = "type", content = "data")]
pub enum MessageSentStatus {
@@ -32,10 +32,14 @@
}
// NOTE: Keep this in sync with
-// lib/types/tunnelbroker/message-to-device-request-status-types.js
+// lib/types/tunnelbroker/device-to-tunnelbroker-request-status-types.js
#[derive(Serialize, Deserialize, PartialEq, Debug)]
-#[serde(tag = "type", rename_all = "camelCase")]
-pub struct MessageToDeviceRequestStatus {
+#[serde(
+ tag = "type",
+ rename = "MessageToDeviceRequestStatus",
+ rename_all = "camelCase"
+)]
+pub struct DeviceToTunnelbrokerRequestStatus {
#[serde(rename = "clientMessageIDs")]
pub client_message_ids: Vec<MessageSentStatus>,
}
@@ -57,9 +61,10 @@
]
}"#;
- let request =
- serde_json::from_str::<MessageToDeviceRequestStatus>(example_payload)
- .unwrap();
+ let request = serde_json::from_str::<DeviceToTunnelbrokerRequestStatus>(
+ example_payload,
+ )
+ .unwrap();
let expected_client_message_ids = vec![
MessageSentStatus::Success("id123".to_string()),
@@ -82,9 +87,10 @@
"clientMessageIDs": []
}"#;
- let request =
- serde_json::from_str::<MessageToDeviceRequestStatus>(example_payload)
- .unwrap();
+ let request = serde_json::from_str::<DeviceToTunnelbrokerRequestStatus>(
+ example_payload,
+ )
+ .unwrap();
let expected_client_message_ids: Vec<MessageSentStatus> = Vec::new();
assert_eq!(request.client_message_ids, expected_client_message_ids);
diff --git a/shared/tunnelbroker_messages/src/messages/mod.rs b/shared/tunnelbroker_messages/src/messages/mod.rs
--- a/shared/tunnelbroker_messages/src/messages/mod.rs
+++ b/shared/tunnelbroker_messages/src/messages/mod.rs
@@ -54,7 +54,7 @@
#[serde(untagged)]
pub enum TunnelbrokerToDeviceMessage {
ConnectionInitializationResponse(ConnectionInitializationResponse),
- MessageToDeviceRequestStatus(MessageToDeviceRequestStatus),
+ DeviceToTunnelbrokerRequestStatus(DeviceToTunnelbrokerRequestStatus),
MessageToDevice(MessageToDevice),
Heartbeat(Heartbeat),
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 2:39 PM (17 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2576392
Default Alt Text
D12859.diff (11 KB)

Event Timeline