-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
27 lines (19 loc) · 858 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { fileToFrames } from "./read.ts";
import { frameToLayers } from "./layers.ts";
import { layerToEthernet } from "./ethernet.ts";
import { layerToIP } from "./ip.ts";
import { layerToHTTP } from "./http.ts";
import { layerToTCP } from "./tcp.ts";
import { write } from "./write.ts";
if ( Deno.args[ 0 ] ) {
const frames = await fileToFrames( Deno.args[ 0 ] );
const layers = frames.map( frameToLayers )
.map( ( { Ethernet, IP, TCP, HTTP } ) => ( {
...( Ethernet ? { Ethernet: layerToEthernet( Ethernet ) } : null ),
...( IP ? { IP: layerToIP( IP ) } : null ),
...( TCP ? { TCP: layerToTCP( TCP ) } : null ),
...( HTTP ? { HTTP: layerToHTTP( HTTP ) } : null )
} ) );
write( layers );
} else
console.log( "Usage : deno run --allow-read --unstable main.ts <trace.txt> [ > <output.txt> ]" );