Bug fixes

This commit is contained in:
Windneiro
2026-01-08 21:57:12 +05:00
parent 113a3432fa
commit f3e37a91c6
3 changed files with 11 additions and 11 deletions

View File

@@ -1,11 +1,11 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
// Стандартные настройки для текущей системы (когда просто делаешь zig build run)
// Standard target options for the current system (when just doing zig build run)
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Основной исполняемый файл
// Main executable file
const exe = b.addExecutable(.{
.name = "vzor",
.root_source_file = b.path("src/main.zig"),
@@ -15,16 +15,16 @@ pub fn build(b: *std.Build) void {
b.installArtifact(exe);
// Команда для запуска (zig build run)
// Command to run (zig build run)
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// --- Кросс-компиляция (Build All) ---
// --- Cross-compilation (Build All) ---
const build_all_step = b.step("build-all", "Build for all platforms");
// Список таргетов, которые нам нужны
// List of targets
const targets = [_]std.Target.Query{
.{ .cpu_arch = .x86_64, .os_tag = .linux },
.{ .cpu_arch = .x86_64, .os_tag = .windows },

View File

@@ -13,14 +13,14 @@ pub fn main() !void {
const stdout = std.io.getStdOut().writer();
const start_time = utils.getTimestampMs();
// Получаем аргументы командной строки
// Getting command line arguments
var args = try std.process.argsWithAllocator(allocator);
defer args.deinit();
// Пропускаем имя самой программы (первый аргумент)
// Skip the name of the program itself (first argument)
_ = args.next();
// Если аргумент передан — используем его, иначе дефолт
// If an argument is passed — use it, otherwise default
const target = args.next() orelse "127.0.0.1";
try stdout.print(config.UI.welcome, .{ config.APP_NAME, config.APP_VERSION });

View File

@@ -67,7 +67,7 @@ pub fn scanPort(allocator: std.mem.Allocator, ip: []const u8, port: u16, timeout
pub fn scanRangeParallel(allocator: std.mem.Allocator, ip: []const u8, ports: []const u16) ![]ScanResult {
const results = try allocator.alloc(ScanResult, ports.len);
// Инициализируем результаты дефолтными значениями
// Initialize results with default values
for (results) |*r| {
r.* = .{ .port = 0, .is_open = false };
}
@@ -78,10 +78,10 @@ pub fn scanRangeParallel(allocator: std.mem.Allocator, ip: []const u8, ports: []
for (ports, 0..) |port, i| {
threads[i] = try std.Thread.spawn(.{}, struct {
fn worker(alloc: std.mem.Allocator, ip_addr: []const u8, p: u16, res_ptr: *ScanResult) void {
// Записываем результат напрямую в память по указателю
// We write the result directly into memory using the pointer
res_ptr.* = scanPort(alloc, ip_addr, p, config.DEFAULT_TIMEOUT_MS) catch |err| {
res_ptr.* = .{ .port = p, .is_open = false, .error_msg = @errorName(err) };
return; // Просто выходим, ничего не возвращая
return; // We just leave without returning anything
};
}
}.worker, .{ allocator, ip, port, &results[i] });