Fix checksum issue

This commit is contained in:
2026-01-24 10:38:52 -05:00
parent a81c4b3175
commit 157afa13b1
3 changed files with 22 additions and 1 deletions

View File

@@ -95,12 +95,15 @@ pub fn connect(self: Client, io: Io, payload: []const u8) !SaprusConnection {
},
};
log.debug("Setting bpf filter to port {}", .{connection.connection.src});
try self.socket.attachSaprusPortFilter(connection.connection.src);
log.debug("bpf set", .{});
var connection_buf: [2048]u8 = undefined;
var connection_bytes = connection.toBytes(&connection_buf);
headers.setPayloadLen(connection_bytes.len);
log.debug("Building full message", .{});
var full_msg = blk: {
var msg_buf: [2048]u8 = undefined;
var msg_w: Writer = .fixed(&msg_buf);
@@ -108,17 +111,21 @@ pub fn connect(self: Client, io: Io, payload: []const u8) !SaprusConnection {
msg_w.writeAll(connection_bytes) catch unreachable;
break :blk msg_w.buffered();
};
log.debug("Built full message. Sending message", .{});
try self.socket.send(full_msg);
var res_buf: [4096]u8 = undefined;
// Ignore response from sentinel, just accept that we got one.
log.debug("Awaiting handshake response", .{});
_ = try self.socket.receive(&res_buf);
try io.sleep(.fromMilliseconds(40), .real);
headers.udp.dst_port = udp_dest_port;
headers.ip.id = rand.int(u16);
headers.setPayloadLen(connection_bytes.len);
log.debug("Building final handshake message", .{});
full_msg = blk: {
var msg_buf: [2048]u8 = undefined;
var msg_w: Writer = .fixed(&msg_buf);
@@ -140,3 +147,4 @@ const EthIpUdp = @import("./EthIpUdp.zig").EthIpUdp;
const std = @import("std");
const Io = std.Io;
const Writer = std.Io.Writer;
const log = std.log;