mirror of
https://git.robbyzambito.me/zaprus/
synced 2026-02-04 11:44:49 +00:00
Start adding connection message
This commit is contained in:
@@ -123,7 +123,7 @@ const Relay = struct {
|
||||
pub fn toBytes(self: Relay, buf: []u8) []u8 {
|
||||
var out: Writer = .fixed(buf);
|
||||
out.writeInt(u16, @intFromEnum(PacketType.relay), .big) catch unreachable;
|
||||
out.writeInt(u16, @intCast(self.payload.len), .big) catch unreachable; // Length field, but unread. Will switch to checksum
|
||||
out.writeInt(u16, @intCast(self.payload.len + 4), .big) catch unreachable; // Length field, but unread. Will switch to checksum
|
||||
out.writeAll(&self.dest.bytes) catch unreachable;
|
||||
out.writeAll(self.payload) catch unreachable;
|
||||
return out.buffered();
|
||||
@@ -177,7 +177,7 @@ const Connection = struct {
|
||||
pub fn toBytes(self: Connection, buf: []u8) []u8 {
|
||||
var out: Writer = .fixed(buf);
|
||||
out.writeInt(u16, @intFromEnum(PacketType.connection), .big) catch unreachable;
|
||||
out.writeInt(u16, undefined, .big) catch unreachable; // Saprus length field, unread.
|
||||
out.writeInt(u16, @intCast(self.payload.len + 14), .big) catch unreachable; // Saprus length field, unread.
|
||||
out.writeInt(u16, self.src, .big) catch unreachable;
|
||||
out.writeInt(u16, self.dest, .big) catch unreachable;
|
||||
out.writeInt(u32, self.seq, .big) catch unreachable;
|
||||
|
||||
Reference in New Issue
Block a user