chore: initialise Go rewrite

This commit is contained in:
Muhammad Nauman Raza 2024-12-13 10:24:51 +00:00
parent 90570ab3e1
commit 23b5d00df5
Signed by: devraza
GPG key ID: 91EAD6081011574B
8 changed files with 3 additions and 99 deletions

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module devraza/sage
go 1.23.3

View file

@ -1,2 +0,0 @@
run:
nix-shell --command "cd nurse && cargo run"

16
nurse/Cargo.lock generated
View file

@ -1,16 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "owo-colors"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f"
[[package]]
name = "sage"
version = "0.1.0"
dependencies = [
"owo-colors",
]

View file

@ -1,14 +0,0 @@
[package]
name = "sage"
version = "0.1.0"
edition = "2021"
[dependencies]
owo-colors = "4.0.0"
[profile.release]
strip = true # Strip debug symbols
opt-level = "z" # Optimise for size
lto = true # Enable link type optimisation
codegen-units = 1 # Reduce parallel code generation units
panic = "abort" # Abort on panic!

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 Muhammad Nauman Raza
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,7 +0,0 @@
# sage
A collection of utilities for home labs.
## Dependencies
You'll need the following installed for `sage` to function properly
- netcat (`nc`)

View file

@ -1,28 +0,0 @@
use owo_colors::OwoColorize;
use std::fs;
use std::process::Command;
fn main() -> std::io::Result<()> {
let file: Vec<String> = fs::read_to_string("../nurse.txt")
.unwrap()
.lines()
.map(String::from)
.collect();
for port in &file[1..file.len()] {
let netcat = Command::new("nc")
.arg("-vz")
.arg(&file[0])
.arg(port)
.output()?;
let splitted = std::str::from_utf8(&netcat.stderr[..]).unwrap().split(" ");
let collection = &splitted.collect::<Vec<&str>>();
if collection[7] == "succeeded!\n" {
println!("{} {} {}", "".green(), collection[2], collection[4]);
} else {
println!("{} {} {}", "".red(), collection[3], collection[6]);
}
}
Ok(())
}

View file

@ -1,11 +0,0 @@
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.mkShellNoCC {
packages = with pkgs; [
hping
tcpdump
netcat
];
}