packages feed

hsns 0.5.1 → 0.5.2

raw patch · 2 files changed

+28/−6 lines, 2 files

Files

Hsns.hs view
@@ -1,4 +1,4 @@---run as root, otherwise you'll fail with an device error+-- written by austin seipp, 2007 module Main where import System.Console.GetOpt import System.Environment@@ -16,6 +16,7 @@   + -- our packet output format data PacketFmt = PacketFmt {                    ascii       :: String,@@ -29,7 +30,7 @@     hexadecimal = h } -hsnsVersion = "hsns: the haskell network sniffer, version 0.5.1"+hsnsVersion = "hsns: the haskell network sniffer, version 0.5.2"  formatData :: PacketFmt -> IO () formatData pf = do@@ -39,20 +40,41 @@     mapM_ (printf "%02.2x ") (fmtHex y)     printf "\t\t%s\n" x     formatData (initPktFmt x' y')-  return ()++  -- this will be called with x' and y' are finally empty,+  -- but data still remains in our buffer++  -- note: z is the difference between how many characters+  -- we output on a 'complete' line (30) and how many+  -- we're outputting for this 'incomplete' line (every+  -- hex byte is of length 2 plus the trailing space+  if (length x < 10 && length y < 10) then do+        mapM_ (printf "%02.2x ") (fmtHex y)+        let z = 30 - (3 * (length $ fmtHex y)) +        fmtIrregular z+        printf "\t%s\n" x+        return ()+   else return ()  where   a = ascii pf   h = hexadecimal pf   fmtHex :: [Word8] -> [Int]   fmtHex bytes = [ (read $ show y) | y <- bytes] :: [Int]-  +  fmtIrregular :: Int -> IO ()+  fmtIrregular z = do+    printf "\t"+    if (z-8) > 0 then+      fmtIrregular (z - 8)+     else+      return ()+ captcha :: PCap.PktHdr -> Ptr Word8 -> IO () captcha pkth datap = do   a  <- peekArray (fromIntegral (PCap.caplen pkth)) datap   s  <- return $ map (\x -> if (x >= 32 && x <= 126) then x else 46) a   s' <- return $ map (\x -> chr (read $ show x)) s   formatData (initPktFmt s' a)-  printf "\n"+  printf "\n\n"   hFlush stdout  starter :: HsnsOpts -> IO ()
hsns.cabal view
@@ -1,5 +1,5 @@ Name:                hsns-Version:             0.5.1+Version:             0.5.2 Description:         a network sniffer written in a purely fun language Synopsis:            the haskell network sniffer Category:            Network