netkitty 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,11 @@ export interface IPcapReaderOptions {
|
|
|
8
8
|
filename: string;
|
|
9
9
|
watch?: boolean;
|
|
10
10
|
chunkSize?: number;
|
|
11
|
+
onPacket?: (pcapPacketInfo: IPcapPacketInfo) => Promise<void> | void;
|
|
12
|
+
onStart?: () => Promise<void> | void;
|
|
13
|
+
onStop?: () => Promise<void> | void;
|
|
14
|
+
onDone?: () => Promise<void> | void;
|
|
15
|
+
onError?: (err: Error) => void;
|
|
11
16
|
}
|
|
12
17
|
export declare class PcapReader extends EventEmitter {
|
|
13
18
|
protected readonly filename: string;
|
|
@@ -19,9 +24,25 @@ export declare class PcapReader extends EventEmitter {
|
|
|
19
24
|
protected offset: number;
|
|
20
25
|
protected readDone: boolean;
|
|
21
26
|
protected readBufferFileHandle: FileHandle | null;
|
|
27
|
+
protected onPacket?: (pcapPacketInfo: IPcapPacketInfo) => Promise<void> | void;
|
|
28
|
+
protected onStart?: () => Promise<void> | void;
|
|
29
|
+
protected onStop?: () => Promise<void> | void;
|
|
30
|
+
protected onDone?: () => Promise<void> | void;
|
|
31
|
+
protected onError?: (err: Error) => void;
|
|
32
|
+
protected paused: boolean;
|
|
22
33
|
protected get readStream(): ReadStream;
|
|
23
34
|
protected get writeStream(): WriteStream;
|
|
24
35
|
constructor(options: IPcapReaderOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Pause read
|
|
38
|
+
* @protected
|
|
39
|
+
*/
|
|
40
|
+
protected pauseRead(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Resume read
|
|
43
|
+
* @protected
|
|
44
|
+
*/
|
|
45
|
+
protected resumeRead(): void;
|
|
25
46
|
/**
|
|
26
47
|
* Initialize reader
|
|
27
48
|
* @protected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PcapReader.d.ts","sourceRoot":"","sources":["../../../src/lib/pcap/PcapReader.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAC,UAAU,EAAuB,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AAC/C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAA;AAE5D,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"PcapReader.d.ts","sourceRoot":"","sources":["../../../src/lib/pcap/PcapReader.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAC,UAAU,EAAuB,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AAC/C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAA;AAE5D,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpE,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACnC,MAAM,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AAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IAChE,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAM9D,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,cAAc,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI;IACpF,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IACjE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IAClE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IACjE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI;IAClE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;CAK1E"}
|
|
@@ -22,9 +22,36 @@ class PcapReader extends events_1.default {
|
|
|
22
22
|
this.offset = 0;
|
|
23
23
|
this.readDone = false;
|
|
24
24
|
this.readBufferFileHandle = null;
|
|
25
|
+
this.paused = false;
|
|
25
26
|
this.filename = options.filename;
|
|
26
27
|
this.watch = !!options.watch;
|
|
27
28
|
this.chunkSize = options.chunkSize ? options.chunkSize : this.chunkSize;
|
|
29
|
+
if (options.onPacket)
|
|
30
|
+
this.onPacket = options.onPacket;
|
|
31
|
+
if (options.onStart)
|
|
32
|
+
this.onStart = options.onStart;
|
|
33
|
+
if (options.onStop)
|
|
34
|
+
this.onStop = options.onStop;
|
|
35
|
+
if (options.onDone)
|
|
36
|
+
this.onDone = options.onDone;
|
|
37
|
+
if (options.onError)
|
|
38
|
+
this.onError = options.onError;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Pause read
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
pauseRead() {
|
|
45
|
+
this.readStream.pause();
|
|
46
|
+
this.paused = true;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resume read
|
|
50
|
+
* @protected
|
|
51
|
+
*/
|
|
52
|
+
resumeRead() {
|
|
53
|
+
this.readStream.resume();
|
|
54
|
+
this.paused = false;
|
|
28
55
|
}
|
|
29
56
|
/**
|
|
30
57
|
* Initialize reader
|
|
@@ -34,11 +61,20 @@ class PcapReader extends events_1.default {
|
|
|
34
61
|
this.duplexPair = new duplexpair_1.default();
|
|
35
62
|
this.parser = PcapParser_1.PcapParser.parse(this.readStream);
|
|
36
63
|
this.parser
|
|
37
|
-
.on('packet', (pcapPacketInfo) => {
|
|
64
|
+
.on('packet', async (pcapPacketInfo) => {
|
|
38
65
|
this.index = pcapPacketInfo.index;
|
|
39
66
|
this.emit('packet', pcapPacketInfo);
|
|
67
|
+
if (this.onPacket) {
|
|
68
|
+
this.pauseRead();
|
|
69
|
+
await this.onPacket(pcapPacketInfo);
|
|
70
|
+
this.resumeRead();
|
|
71
|
+
}
|
|
40
72
|
})
|
|
41
|
-
.on('error', (err) =>
|
|
73
|
+
.on('error', (err) => {
|
|
74
|
+
this.emit('error', err);
|
|
75
|
+
if (this.onError)
|
|
76
|
+
this.onError(err);
|
|
77
|
+
});
|
|
42
78
|
}
|
|
43
79
|
/**
|
|
44
80
|
* Reset reader
|
|
@@ -49,6 +85,7 @@ class PcapReader extends events_1.default {
|
|
|
49
85
|
this.parser?.removeAllListeners();
|
|
50
86
|
this.index = 0;
|
|
51
87
|
this.offset = 0;
|
|
88
|
+
this.paused = false;
|
|
52
89
|
this.initReader();
|
|
53
90
|
}
|
|
54
91
|
/**
|
|
@@ -102,6 +139,10 @@ class PcapReader extends events_1.default {
|
|
|
102
139
|
this.once('stop', () => read = false);
|
|
103
140
|
let isReachEnd = false;
|
|
104
141
|
while (read || !isReachEnd) {
|
|
142
|
+
if (this.paused) {
|
|
143
|
+
await new Promise(resolve => setTimeout(resolve, 1));
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
105
146
|
isReachEnd = await this.readBuffer();
|
|
106
147
|
if (isReachEnd) {
|
|
107
148
|
await new Promise(resolve => setTimeout(resolve, 1));
|
|
@@ -111,6 +152,8 @@ class PcapReader extends events_1.default {
|
|
|
111
152
|
this.readBufferFileHandle = null;
|
|
112
153
|
this.readDone = true;
|
|
113
154
|
this.emit('done');
|
|
155
|
+
if (this.onDone)
|
|
156
|
+
await this.onDone();
|
|
114
157
|
});
|
|
115
158
|
}
|
|
116
159
|
/**
|
|
@@ -123,6 +166,10 @@ class PcapReader extends events_1.default {
|
|
|
123
166
|
let stopped = false;
|
|
124
167
|
this.once('stop', () => stopped = true);
|
|
125
168
|
while (!isReachEnd && !stopped) {
|
|
169
|
+
if (this.paused) {
|
|
170
|
+
await new Promise(resolve => setTimeout(resolve, 1));
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
126
173
|
isReachEnd = await this.readBuffer();
|
|
127
174
|
}
|
|
128
175
|
this.readDone = true;
|
|
@@ -131,6 +178,8 @@ class PcapReader extends events_1.default {
|
|
|
131
178
|
await this.readBufferFileHandle?.close();
|
|
132
179
|
this.readBufferFileHandle = null;
|
|
133
180
|
this.emit('done');
|
|
181
|
+
if (this.onDone)
|
|
182
|
+
await this.onDone();
|
|
134
183
|
});
|
|
135
184
|
}
|
|
136
185
|
/**
|
|
@@ -157,6 +206,8 @@ class PcapReader extends events_1.default {
|
|
|
157
206
|
async start() {
|
|
158
207
|
await this.reset();
|
|
159
208
|
this.emit('start');
|
|
209
|
+
if (this.onStart)
|
|
210
|
+
await this.onStart();
|
|
160
211
|
if (this.watch) {
|
|
161
212
|
this.continualRead();
|
|
162
213
|
}
|
|
@@ -172,6 +223,8 @@ class PcapReader extends events_1.default {
|
|
|
172
223
|
this.emit('stop');
|
|
173
224
|
if (!this.readDone)
|
|
174
225
|
await new Promise(resolve => this.once('done', resolve));
|
|
226
|
+
if (this.onStop)
|
|
227
|
+
await this.onStop();
|
|
175
228
|
}
|
|
176
229
|
if (this.duplexPair) {
|
|
177
230
|
await new Promise(resolve => {
|
package/package.json
CHANGED
|
@@ -9,6 +9,11 @@ export interface IPcapReaderOptions {
|
|
|
9
9
|
filename: string
|
|
10
10
|
watch?: boolean
|
|
11
11
|
chunkSize?: number
|
|
12
|
+
onPacket?: (pcapPacketInfo: IPcapPacketInfo) => Promise<void> | void
|
|
13
|
+
onStart?: () => Promise<void> | void
|
|
14
|
+
onStop?: () => Promise<void> | void
|
|
15
|
+
onDone?: () => Promise<void> | void
|
|
16
|
+
onError?: (err: Error) => void
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export class PcapReader extends EventEmitter {
|
|
@@ -31,6 +36,18 @@ export class PcapReader extends EventEmitter {
|
|
|
31
36
|
|
|
32
37
|
protected readBufferFileHandle: FileHandle | null = null
|
|
33
38
|
|
|
39
|
+
protected onPacket?: (pcapPacketInfo: IPcapPacketInfo) => Promise<void> | void
|
|
40
|
+
|
|
41
|
+
protected onStart?: () => Promise<void> | void
|
|
42
|
+
|
|
43
|
+
protected onStop?: () => Promise<void> | void
|
|
44
|
+
|
|
45
|
+
protected onDone?: () => Promise<void> | void
|
|
46
|
+
|
|
47
|
+
protected onError?: (err: Error) => void
|
|
48
|
+
|
|
49
|
+
protected paused: boolean = false
|
|
50
|
+
|
|
34
51
|
protected get readStream(): ReadStream {
|
|
35
52
|
return this.duplexPair.socket2
|
|
36
53
|
}
|
|
@@ -44,6 +61,29 @@ export class PcapReader extends EventEmitter {
|
|
|
44
61
|
this.filename = options.filename
|
|
45
62
|
this.watch = !!options.watch
|
|
46
63
|
this.chunkSize = options.chunkSize ? options.chunkSize : this.chunkSize
|
|
64
|
+
if (options.onPacket) this.onPacket = options.onPacket
|
|
65
|
+
if (options.onStart) this.onStart = options.onStart
|
|
66
|
+
if (options.onStop) this.onStop = options.onStop
|
|
67
|
+
if (options.onDone) this.onDone = options.onDone
|
|
68
|
+
if (options.onError) this.onError = options.onError
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Pause read
|
|
73
|
+
* @protected
|
|
74
|
+
*/
|
|
75
|
+
protected pauseRead(): void {
|
|
76
|
+
this.readStream.pause()
|
|
77
|
+
this.paused = true
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Resume read
|
|
82
|
+
* @protected
|
|
83
|
+
*/
|
|
84
|
+
protected resumeRead(): void {
|
|
85
|
+
this.readStream.resume()
|
|
86
|
+
this.paused = false
|
|
47
87
|
}
|
|
48
88
|
|
|
49
89
|
/**
|
|
@@ -54,11 +94,19 @@ export class PcapReader extends EventEmitter {
|
|
|
54
94
|
this.duplexPair = new DuplexPair()
|
|
55
95
|
this.parser = PcapParser.parse(this.readStream)
|
|
56
96
|
this.parser
|
|
57
|
-
.on('packet', (pcapPacketInfo: IPcapPacketInfo): void => {
|
|
97
|
+
.on('packet', async (pcapPacketInfo: IPcapPacketInfo): Promise<void> => {
|
|
58
98
|
this.index = pcapPacketInfo.index
|
|
59
99
|
this.emit('packet', pcapPacketInfo)
|
|
100
|
+
if (this.onPacket) {
|
|
101
|
+
this.pauseRead()
|
|
102
|
+
await this.onPacket(pcapPacketInfo)
|
|
103
|
+
this.resumeRead()
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.on('error', (err: Error): void => {
|
|
107
|
+
this.emit('error', err)
|
|
108
|
+
if (this.onError) this.onError(err)
|
|
60
109
|
})
|
|
61
|
-
.on('error', (err: Error): boolean => this.emit('error', err))
|
|
62
110
|
}
|
|
63
111
|
|
|
64
112
|
/**
|
|
@@ -70,6 +118,7 @@ export class PcapReader extends EventEmitter {
|
|
|
70
118
|
this.parser?.removeAllListeners()
|
|
71
119
|
this.index = 0
|
|
72
120
|
this.offset = 0
|
|
121
|
+
this.paused = false
|
|
73
122
|
this.initReader()
|
|
74
123
|
}
|
|
75
124
|
|
|
@@ -124,6 +173,10 @@ export class PcapReader extends EventEmitter {
|
|
|
124
173
|
this.once('stop', (): boolean => read = false)
|
|
125
174
|
let isReachEnd: boolean = false
|
|
126
175
|
while (read || !isReachEnd) {
|
|
176
|
+
if (this.paused) {
|
|
177
|
+
await new Promise(resolve => setTimeout(resolve, 1))
|
|
178
|
+
continue
|
|
179
|
+
}
|
|
127
180
|
isReachEnd = await this.readBuffer()
|
|
128
181
|
if (isReachEnd) {
|
|
129
182
|
await new Promise(resolve => setTimeout(resolve, 1))
|
|
@@ -133,6 +186,7 @@ export class PcapReader extends EventEmitter {
|
|
|
133
186
|
this.readBufferFileHandle = null
|
|
134
187
|
this.readDone = true
|
|
135
188
|
this.emit('done')
|
|
189
|
+
if (this.onDone) await this.onDone()
|
|
136
190
|
})
|
|
137
191
|
}
|
|
138
192
|
|
|
@@ -146,6 +200,10 @@ export class PcapReader extends EventEmitter {
|
|
|
146
200
|
let stopped: boolean = false
|
|
147
201
|
this.once('stop', (): boolean => stopped = true)
|
|
148
202
|
while (!isReachEnd && !stopped) {
|
|
203
|
+
if (this.paused) {
|
|
204
|
+
await new Promise(resolve => setTimeout(resolve, 1))
|
|
205
|
+
continue
|
|
206
|
+
}
|
|
149
207
|
isReachEnd = await this.readBuffer()
|
|
150
208
|
}
|
|
151
209
|
this.readDone = true
|
|
@@ -153,6 +211,7 @@ export class PcapReader extends EventEmitter {
|
|
|
153
211
|
await this.readBufferFileHandle?.close()
|
|
154
212
|
this.readBufferFileHandle = null
|
|
155
213
|
this.emit('done')
|
|
214
|
+
if (this.onDone) await this.onDone()
|
|
156
215
|
})
|
|
157
216
|
}
|
|
158
217
|
|
|
@@ -181,6 +240,7 @@ export class PcapReader extends EventEmitter {
|
|
|
181
240
|
public async start(): Promise<void> {
|
|
182
241
|
await this.reset()
|
|
183
242
|
this.emit('start')
|
|
243
|
+
if (this.onStart) await this.onStart()
|
|
184
244
|
if (this.watch) {
|
|
185
245
|
this.continualRead()
|
|
186
246
|
} else {
|
|
@@ -195,6 +255,7 @@ export class PcapReader extends EventEmitter {
|
|
|
195
255
|
if (this.parser) {
|
|
196
256
|
this.emit('stop')
|
|
197
257
|
if (!this.readDone) await new Promise(resolve => this.once('done', resolve))
|
|
258
|
+
if (this.onStop) await this.onStop()
|
|
198
259
|
}
|
|
199
260
|
if (this.duplexPair) {
|
|
200
261
|
await new Promise<void>(resolve => {
|