mirror of
https://git.robbyzambito.me/zaprus
synced 2026-02-04 08:24:52 +00:00
Fix reconnection
Was failing to reconnect due to trying to reuse the same socket that already had a BPF filter on it.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
const RawSocket = @This();
|
||||
|
||||
const is_debug = builtin.mode == .Debug;
|
||||
|
||||
fd: i32,
|
||||
sockaddr_ll: std.posix.sockaddr.ll,
|
||||
mac: [6]u8,
|
||||
@@ -70,7 +72,7 @@ pub fn init() !RawSocket {
|
||||
const bind_ret = std.os.linux.bind(socket, @ptrCast(&sockaddr_ll), @sizeOf(@TypeOf(sockaddr_ll)));
|
||||
if (bind_ret != 0) return error.BindError;
|
||||
|
||||
const timeout: std.os.linux.timeval = .{ .sec = 600, .usec = 0 };
|
||||
const timeout: std.os.linux.timeval = .{ .sec = 60 * if (is_debug) 1 else 10, .usec = 0 };
|
||||
const timeout_ret = std.os.linux.setsockopt(socket, std.os.linux.SOL.SOCKET, std.os.linux.SO.RCVTIMEO, @ptrCast(&timeout), @sizeOf(@TypeOf(timeout)));
|
||||
if (timeout_ret != 0) return error.SetTimeoutError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user