Skip to content

Commit

Permalink
feat: add support for protocol version 8
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Jan 10, 2025
1 parent b3bcec6 commit 07f3803
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion installed-tests/fixtures/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const ChannelService = GObject.registerClass({
deviceId: this.id,
deviceName: this.name,
deviceType: 'desktop',
protocolVersion: 7,
protocolVersion: 8,
incomingCapabilities: [],
outgoingCapabilities: [],
tcpPort: this.port,
Expand Down
2 changes: 1 addition & 1 deletion installed-tests/fixtures/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function generateIdentity(params = {}) {
'deviceId': GLib.uuid_string_random(),
'deviceName': 'Test Device',
'deviceType': getDeviceType(),
'protocolVersion': 7,
'protocolVersion': 8,
'incomingCapabilities': [],
'outgoingCapabilities': [],
},
Expand Down
18 changes: 17 additions & 1 deletion src/service/backends/lan.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export const ChannelService = GObject.registerClass({
certificate: this.certificate,
host: packet.body.tcpHost,
port: packet.body.tcpPort,
identity: packet,
identity: new Core.Packet(packet),
});

// Check if channel is already open with this address
Expand Down Expand Up @@ -730,6 +730,14 @@ export const Channel = GObject.registerClass({
throw new Error('missing deviceId');

this._connection = await this._encryptClient(connection);

// Starting with protocol version 8, the devices are expected to
// exchange identity packets again after TLS negotiation to
// prevent a number of spoofing attacks
if (this.identity.body.protocolVersion >= 8) {
await this.sendPacket(this.backend.identity.serialize());
this.identity = await this.readPacket();
}
} catch (e) {
this.close();
throw e;
Expand All @@ -754,6 +762,14 @@ export const Channel = GObject.registerClass({
this.cancellable);

this._connection = await this._encryptServer(connection);

// Starting with protocol version 8, the devices are expected to
// exchange identity packets again after TLS negotiation to
// prevent a number of spoofing attacks
if (this.identity.body.protocolVersion >= 8) {
await this.sendPacket(this.backend.identity.serialize());
this.identity = await this.readPacket();
}
} catch (e) {
this.close();
throw e;
Expand Down
2 changes: 1 addition & 1 deletion src/service/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export const ChannelService = GObject.registerClass({
deviceId: this.id,
deviceName: this.name,
deviceType: _getDeviceType(),
protocolVersion: 7,
protocolVersion: 8,
incomingCapabilities: [],
outgoingCapabilities: [],
},
Expand Down

0 comments on commit 07f3803

Please sign in to comment.