Skip to content

Commit

Permalink
merge imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Sep 25, 2024
1 parent 1c07bf9 commit 0d1c24f
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 70 deletions.
21 changes: 14 additions & 7 deletions oryx-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ use ratatui::{
},
Frame,
};
use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::{error, thread};
use std::{
error,
sync::{Arc, Mutex},
thread,
time::Duration,
};
use tui_big_text::{BigText, PixelSize};

use crate::alerts::alert::Alert;
use crate::bandwidth::Bandwidth;
use crate::filters::filter::Filter;
use crate::filters::fuzzy::{self, Fuzzy};
use crate::filters::{
filter::Filter,
fuzzy::{self, Fuzzy},
};
use crate::help::Help;
use crate::interface::Interface;
use crate::notification::Notification;
use crate::packets::network::{IpPacket, IpProto};
use crate::packets::packet::AppPacket;
use crate::packets::{
network::{IpPacket, IpProto},
packet::AppPacket,
};
use crate::stats::Stats;

pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;
Expand Down
40 changes: 21 additions & 19 deletions oryx-tui/src/ebpf.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
use std::os::fd::AsRawFd;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::thread::spawn;
use std::time::Duration;
use std::{io, thread};

use aya::maps::ring_buf::RingBufItem;
use aya::maps::{Array, MapData, RingBuf};
use aya::programs::{tc, SchedClassifier, TcAttachType};
use aya::{include_bytes_aligned, Bpf};
use mio::{Events, Interest, Poll, Registry, Token};
use oryx_common::protocols::Protocol;
use oryx_common::RawPacket;

use crate::event::Event;
use crate::notification::{Notification, NotificationLevel};
use mio::event::Source;
use mio::unix::SourceFd;
use std::{
io,
os::fd::AsRawFd,
sync::{atomic::AtomicBool, Arc},
thread::{self, spawn},
time::Duration,
};

use aya::{
include_bytes_aligned,
maps::{ring_buf::RingBufItem, Array, MapData, RingBuf},
programs::{tc, SchedClassifier, TcAttachType},
Bpf,
};
use oryx_common::{protocols::Protocol, RawPacket};

use crate::{
event::Event,
notification::{Notification, NotificationLevel},
};
use mio::{event::Source, unix::SourceFd, Events, Interest, Poll, Registry, Token};

pub struct Ebpf;

Expand Down
9 changes: 5 additions & 4 deletions oryx-tui/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::app::AppResult;
use crate::notification::Notification;
use crate::{app::AppResult, notification::Notification};
use crossterm::event::{self, Event as CrosstermEvent, KeyEvent, KeyEventKind, MouseEvent};
use std::thread;
use std::time::{Duration, Instant};
use std::{
thread,
time::{Duration, Instant},
};

#[derive(Clone)]
pub enum Event {
Expand Down
18 changes: 12 additions & 6 deletions oryx-tui/src/export.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use std::fs::{create_dir, OpenOptions};
use std::io::prelude::*;
use std::os::unix::fs::chown;
use std::{
fs::{create_dir, OpenOptions},
io::prelude::*,
os::unix::fs::chown,
};

use crate::app::AppResult;
use crate::packets::network::{IpPacket, IpProto};
use crate::packets::packet::AppPacket;
use crate::{
app::AppResult,
packets::{
network::{IpPacket, IpProto},
packet::AppPacket,
},
};

pub fn export(packets: &[AppPacket]) -> AppResult<()> {
let uid = unsafe { libc::geteuid() };
Expand Down
Empty file removed oryx-tui/src/infos.rs
Empty file.
3 changes: 1 addition & 2 deletions oryx-tui/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ use ratatui::{
};

use std::{
ffi::CStr,
fs::{self},
net::{IpAddr, Ipv4Addr, Ipv6Addr},
path::PathBuf,
};

use std::ffi::CStr;

use crate::app::FocusedBlock;

#[derive(Debug, Clone)]
Expand Down
13 changes: 7 additions & 6 deletions oryx-tui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use std::io;

use clap::{crate_description, crate_version, Command};
use oryx_tui::app::{App, AppResult, TICK_RATE};
use oryx_tui::event::{Event, EventHandler};
use oryx_tui::handler::handle_key_events;
use oryx_tui::tui::Tui;
use ratatui::backend::CrosstermBackend;
use ratatui::Terminal;
use oryx_tui::{
app::{App, AppResult, TICK_RATE},
event::{Event, EventHandler},
handler::handle_key_events,
tui::Tui,
};
use ratatui::{backend::CrosstermBackend, Terminal};

fn main() -> AppResult<()> {
Command::new("oryx")
Expand Down
7 changes: 4 additions & 3 deletions oryx-tui/src/packets/network.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use core::fmt::Display;
use core::{
fmt::Display,
net::{Ipv4Addr, Ipv6Addr},
};
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
style::{Style, Stylize},
Expand All @@ -7,8 +10,6 @@ use ratatui::{
Frame,
};

use core::net::{Ipv4Addr, Ipv6Addr};

use super::transport::{TcpPacket, UdpPacket};

#[derive(Debug, Copy, Clone)]
Expand Down
13 changes: 6 additions & 7 deletions oryx-tui/src/packets/packet.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use core::fmt::Display;

use core::net::Ipv4Addr;
use std::mem;
use std::{fmt::Display, mem, net::Ipv4Addr};

use network_types::ip::IpHdr;
use oryx_common::{ProtoHdr, RawPacket};

use super::link::{ArpPacket, ArpType, MacAddr};
use super::network::{IcmpPacket, IcmpType, IpPacket, IpProto, Ipv4Packet, Ipv6Packet};
use super::transport::{TcpPacket, UdpPacket};
use super::{
link::{ArpPacket, ArpType, MacAddr},
network::{IcmpPacket, IcmpType, IpPacket, IpProto, Ipv4Packet, Ipv6Packet},
transport::{TcpPacket, UdpPacket},
};

#[derive(Debug, Copy, Clone)]
pub enum AppPacket {
Expand Down
18 changes: 11 additions & 7 deletions oryx-tui/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
use dns_lookup::lookup_addr;
use std::collections::HashMap;
use std::net::{IpAddr, Ipv4Addr};
use std::{
collections::HashMap,
net::{IpAddr, Ipv4Addr},
};

use ratatui::layout::{Alignment, Constraint, Direction, Flex, Layout, Rect};
use ratatui::style::{Color, Style};
use ratatui::text::Line;
use ratatui::{
layout::{Alignment, Constraint, Direction, Flex, Layout, Rect},
style::{Color, Style},
text::Line,
widgets::{Bar, BarChart, BarGroup, Block, Padding},
Frame,
};

use crate::packets::network::{IpPacket, IpProto};
use crate::packets::packet::AppPacket;
use crate::packets::{
network::{IpPacket, IpProto},
packet::AppPacket,
};

#[derive(Debug)]
pub struct Stats {
Expand Down
20 changes: 11 additions & 9 deletions oryx-tui/src/tui.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::app::{App, AppResult};
use crate::event::EventHandler;
use crate::ui;
use crossterm::event::{DisableMouseCapture, EnableMouseCapture};
use crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen};
use ratatui::backend::Backend;
use ratatui::Terminal;
use std::io;
use std::panic;
use crate::{
app::{App, AppResult},
event::EventHandler,
ui,
};
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
terminal::{self, EnterAlternateScreen, LeaveAlternateScreen},
};
use ratatui::{backend::Backend, Terminal};
use std::{io, panic};

#[derive(Debug)]
pub struct Tui<B: Backend> {
Expand Down

0 comments on commit 0d1c24f

Please sign in to comment.