@goodtools/wiregasm 1.3.0 → 1.5.0
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.
- package/dist/main.js +78 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +78 -3
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +120 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wiregasm.data.gz +0 -0
- package/dist/wiregasm.js +4 -4
- package/dist/wiregasm.wasm +0 -0
- package/dist/wiregasm.wasm.gz +0 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -19,16 +19,60 @@ function $parcel$export(e, n, v, s) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
$parcel$export(module.exports, "Wiregasm", () => $882b6d93070905b3$export$c4e6ddb7806910b1);
|
|
22
|
+
var $faefaad95e5fcca0$exports = {};
|
|
23
|
+
|
|
24
|
+
$parcel$export($faefaad95e5fcca0$exports, "PrefSetResult", () => $faefaad95e5fcca0$export$9511720e10589113);
|
|
25
|
+
$parcel$export($faefaad95e5fcca0$exports, "PrefType", () => $faefaad95e5fcca0$export$eeff8db21dc74b3d);
|
|
26
|
+
let $faefaad95e5fcca0$export$9511720e10589113;
|
|
27
|
+
(function(PrefSetResult) {
|
|
28
|
+
PrefSetResult[PrefSetResult["PREFS_SET_OK"] = 0] = "PREFS_SET_OK";
|
|
29
|
+
PrefSetResult[PrefSetResult["PREFS_SET_SYNTAX_ERR"] = 1] = "PREFS_SET_SYNTAX_ERR";
|
|
30
|
+
PrefSetResult[PrefSetResult["PREFS_SET_NO_SUCH_PREF"] = 2] = "PREFS_SET_NO_SUCH_PREF";
|
|
31
|
+
PrefSetResult[PrefSetResult["PREFS_SET_OBSOLETE"] = 3] = "PREFS_SET_OBSOLETE";
|
|
32
|
+
})($faefaad95e5fcca0$export$9511720e10589113 || ($faefaad95e5fcca0$export$9511720e10589113 = {}));
|
|
33
|
+
let $faefaad95e5fcca0$export$eeff8db21dc74b3d;
|
|
34
|
+
(function(PrefType) {
|
|
35
|
+
PrefType[PrefType["PREF_UINT"] = 1] = "PREF_UINT";
|
|
36
|
+
PrefType[PrefType["PREF_BOOL"] = 2] = "PREF_BOOL";
|
|
37
|
+
PrefType[PrefType["PREF_ENUM"] = 4] = "PREF_ENUM";
|
|
38
|
+
PrefType[PrefType["PREF_STRING"] = 8] = "PREF_STRING";
|
|
39
|
+
PrefType[PrefType["PREF_RANGE"] = 16] = "PREF_RANGE";
|
|
40
|
+
PrefType[PrefType["PREF_STATIC_TEXT"] = 32] = "PREF_STATIC_TEXT";
|
|
41
|
+
PrefType[PrefType["PREF_UAT"] = 64] = "PREF_UAT";
|
|
42
|
+
PrefType[PrefType["PREF_SAVE_FILENAME"] = 128] = "PREF_SAVE_FILENAME";
|
|
43
|
+
PrefType[PrefType["PREF_COLOR"] = 256] = "PREF_COLOR";
|
|
44
|
+
PrefType[PrefType["PREF_CUSTOM"] = 512] = "PREF_CUSTOM";
|
|
45
|
+
PrefType[PrefType["PREF_OBSOLETE"] = 1024] = "PREF_OBSOLETE";
|
|
46
|
+
PrefType[PrefType["PREF_DIRNAME"] = 2048] = "PREF_DIRNAME";
|
|
47
|
+
PrefType[PrefType["PREF_DECODE_AS_UINT"] = 4096] = "PREF_DECODE_AS_UINT";
|
|
48
|
+
PrefType[PrefType["PREF_DECODE_AS_RANGE"] = 8192] = "PREF_DECODE_AS_RANGE";
|
|
49
|
+
PrefType[PrefType["PREF_OPEN_FILENAME"] = 16384] = "PREF_OPEN_FILENAME";
|
|
50
|
+
PrefType[PrefType["PREF_PASSWORD"] = 32768] = "PREF_PASSWORD";
|
|
51
|
+
})($faefaad95e5fcca0$export$eeff8db21dc74b3d || ($faefaad95e5fcca0$export$eeff8db21dc74b3d = {}));
|
|
52
|
+
|
|
53
|
+
|
|
22
54
|
var $9ba0f9a5c47c04f2$exports = {};
|
|
23
55
|
|
|
24
56
|
$parcel$export($9ba0f9a5c47c04f2$exports, "vectorToArray", () => $9ba0f9a5c47c04f2$export$4b978bcb0889dc66);
|
|
57
|
+
$parcel$export($9ba0f9a5c47c04f2$exports, "preferenceSetCodeToError", () => $9ba0f9a5c47c04f2$export$a6506e3cba6c4388);
|
|
58
|
+
|
|
25
59
|
function $9ba0f9a5c47c04f2$export$4b978bcb0889dc66(vec) {
|
|
26
60
|
return new Array(vec.size()).fill(0).map((_, id)=>vec.get(id));
|
|
27
61
|
}
|
|
62
|
+
function $9ba0f9a5c47c04f2$export$a6506e3cba6c4388(code) {
|
|
63
|
+
switch(code){
|
|
64
|
+
case (0, $faefaad95e5fcca0$export$9511720e10589113).PREFS_SET_SYNTAX_ERR:
|
|
65
|
+
return "Syntax error in string";
|
|
66
|
+
case (0, $faefaad95e5fcca0$export$9511720e10589113).PREFS_SET_NO_SUCH_PREF:
|
|
67
|
+
return "No such preference";
|
|
68
|
+
case (0, $faefaad95e5fcca0$export$9511720e10589113).PREFS_SET_OBSOLETE:
|
|
69
|
+
return "Preference used to exist but no longer does";
|
|
70
|
+
default:
|
|
71
|
+
return "Unknown error";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
28
74
|
|
|
29
75
|
|
|
30
|
-
var $faefaad95e5fcca0$exports = {};
|
|
31
|
-
|
|
32
76
|
|
|
33
77
|
|
|
34
78
|
class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
@@ -50,6 +94,27 @@ class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
|
50
94
|
this.lib.init();
|
|
51
95
|
this.initialized = true;
|
|
52
96
|
}
|
|
97
|
+
list_modules() {
|
|
98
|
+
return this.lib.listModules();
|
|
99
|
+
}
|
|
100
|
+
list_prefs(module) {
|
|
101
|
+
return this.lib.listPreferences(module);
|
|
102
|
+
}
|
|
103
|
+
apply_prefs() {
|
|
104
|
+
this.lib.applyPreferences();
|
|
105
|
+
}
|
|
106
|
+
set_pref(module, key, value) {
|
|
107
|
+
const ret = this.lib.setPref(module, key, value);
|
|
108
|
+
if (ret.code != (0, $faefaad95e5fcca0$export$9511720e10589113).PREFS_SET_OK) {
|
|
109
|
+
const message = ret.error != "" ? ret.error : (0, $9ba0f9a5c47c04f2$export$a6506e3cba6c4388)(ret.code);
|
|
110
|
+
throw new Error(`Failed to set preference (${module}.${key}): ${message}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
get_pref(module, key) {
|
|
114
|
+
const response = this.lib.getPref(module, key);
|
|
115
|
+
if (response.code != 0) throw new Error(`Failed to get preference (${module}.${key})`);
|
|
116
|
+
return response.data;
|
|
117
|
+
}
|
|
53
118
|
/**
|
|
54
119
|
* Check the validity of a filter expression.
|
|
55
120
|
*
|
|
@@ -57,6 +122,13 @@ class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
|
57
122
|
*/ test_filter(filter) {
|
|
58
123
|
return this.lib.checkFilter(filter);
|
|
59
124
|
}
|
|
125
|
+
complete_filter(filter) {
|
|
126
|
+
const out = this.lib.completeFilter(filter);
|
|
127
|
+
return {
|
|
128
|
+
err: out.err,
|
|
129
|
+
fields: (0, $9ba0f9a5c47c04f2$export$4b978bcb0889dc66)(out.fields)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
60
132
|
reload_lua_plugins() {
|
|
61
133
|
this.lib.reloadLuaPlugins();
|
|
62
134
|
}
|
|
@@ -91,6 +163,9 @@ class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
|
91
163
|
*/ frame(num) {
|
|
92
164
|
return this.session.getFrame(num);
|
|
93
165
|
}
|
|
166
|
+
follow(follow, filter) {
|
|
167
|
+
return this.session.follow(follow, filter);
|
|
168
|
+
}
|
|
94
169
|
destroy() {
|
|
95
170
|
if (this.initialized) {
|
|
96
171
|
if (this.session !== null) {
|
|
@@ -109,8 +184,8 @@ class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
|
109
184
|
return (0, $9ba0f9a5c47c04f2$export$4b978bcb0889dc66)(vec);
|
|
110
185
|
}
|
|
111
186
|
}
|
|
112
|
-
$parcel$exportWildcard(module.exports, $9ba0f9a5c47c04f2$exports);
|
|
113
187
|
$parcel$exportWildcard(module.exports, $faefaad95e5fcca0$exports);
|
|
188
|
+
$parcel$exportWildcard(module.exports, $9ba0f9a5c47c04f2$exports);
|
|
114
189
|
|
|
115
190
|
|
|
116
191
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;ACQO,SAAS,0CAAiB,GAAc,EAAO;IACpD,OAAO,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,KAAO,IAAI,GAAG,CAAC;AAC9D;;ADVA;;;;;AAgBO,MAAM;IAOX,aAAc;QACZ,IAAI,CAAC,WAAW,GAAG,KAAK;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI;IACrB;IAEA;;;;;GAKC,GACD,MAAM,KACJ,MAAsB,EACtB,YAAkC,CAAC,CAAC,EACpC,aAAiC,IAAI,EACrC;QACA,IAAI,IAAI,CAAC,WAAW,EAClB;QAGF,IAAI,CAAC,GAAG,GAAG,MAAM,OAAO;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB;QAC5C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB;QAE9C,IAAI,eAAe,IAAI,EACrB,MAAM,WAAW,IAAI,CAAC,GAAG;QAG3B,IAAI,CAAC,GAAG,CAAC,IAAI;QACb,IAAI,CAAC,WAAW,GAAG,IAAI;IACzB;IAEA;;;;GAIC,GACD,YAAY,MAAc,EAAuB;QAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;IAC9B;IAEA,qBAAqB;QACnB,IAAI,CAAC,GAAG,CAAC,gBAAgB;IAC3B;IAEA,WAAW,IAAY,EAAE,IAA8B,EAAE,OAAe,CAAC,CAAC,EAAE;QAC1E,MAAM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ramesResponse,\n LoadResponse,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n BeforeInitCallback,\n} from \"./types\";\nimport { vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n this.lib.init();\n this.initialized = true;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n","import { Vector } from \"./types\";\n\n/**\n * Converts a Vector to a JS array\n *\n * @param vec Vector\n * @returns JS array of the Vector contents\n */\nexport function vectorToArray<T>(vec: Vector<T>): T[] {\n return new Array(vec.size()).fill(0).map((_, id) => vec.get(id));\n}\n","export interface EmscriptenFileSystem {\n writeFile(\n path: string,\n data: string | ArrayBufferView,\n opts?: { flags?: string | undefined }\n ): void;\n readdir(path: string): string[];\n mkdirTree(path: string, mode?: number);\n mkdir(path: string, mode?: number);\n}\n\nexport interface EmscriptenHeap {\n buffer: ArrayBufferLike;\n}\n\nexport interface EmscriptenModule {\n FS: EmscriptenFileSystem;\n HEAPU8: EmscriptenHeap;\n _malloc(size: number): number;\n}\n\nexport interface Vector<T> {\n size(): number;\n get(index: number): T;\n}\n\nexport interface DataSource {\n name: string;\n data: string;\n}\n\nexport interface ProtoTree {\n label: string;\n filter: string;\n start: number;\n length: number;\n data_source_idx: number;\n tree: Vector<ProtoTree>;\n}\n\nexport interface Frame {\n number: number;\n comments: Vector<string>;\n data_sources: Vector<DataSource>;\n tree: Vector<ProtoTree>;\n}\n\nexport interface FramesResponse {\n frames: Vector<FrameMeta>;\n matched: number;\n}\n\nexport interface FrameMeta {\n number: number;\n comments: boolean;\n ignored: boolean;\n marked: boolean;\n bg: number;\n fg: number;\n columns: Vector<string>;\n}\n\nexport interface LoadSummary {\n filename: string;\n file_type: string;\n file_length: number;\n file_encap_type: string;\n packet_count: number;\n start_time: number;\n stop_time: number;\n elapsed_time: number;\n}\n\nexport interface LoadResponse {\n code: number;\n error: string;\n summary: LoadSummary;\n}\n\nexport interface DissectSession {\n /**\n * Free up any memory used by the session\n */\n delete(): void;\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(): LoadResponse;\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n getFrames(filter: string, skip: number, limit: number): FramesResponse;\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n getFrame(number: number): Frame;\n}\n\nexport interface DissectSessionConstructable {\n new (path: string): DissectSession;\n}\n\nexport interface CheckFilterResponse {\n ok: boolean;\n error: string;\n}\n\nexport interface WiregasmLibOverrides {\n /**\n * If set, this method will be called when the runtime needs to load a file,\n * such as a .wasm WebAssembly file, .mem memory init file, or a file generated\n * by the file packager. The function receives the relative path to the file as\n * configured in build process and a prefix (path to the main JavaScript file’s\n * directory), and should return the actual URL.\n *\n * This lets you host file packages or the .mem file etc. on a different location\n * than the directory of the JavaScript file (which is the default expectation),\n * for example if you want to host them on a CDN.\n *\n * @param path Path of the requested file.\n * @param prefix Prefix of the requested path. May be empty.\n *\n * @returns Path to the requested file.\n */\n locateFile?(path: string, prefix: string): string;\n\n /**\n * Called when something is printed to standard error (stderr)\n *\n * @param error Error content\n */\n printErr?(error: string): void;\n\n /**\n * Called when something is printed to standard output (stdout)\n *\n * @param message Message content\n */\n print?(message: string): void;\n\n /**\n * Called from within the Wiregasm Library to notify\n * about any status updates.\n *\n * @param type Type of the status\n * @param message Message content\n */\n handleStatus?(type: number, message: string): void;\n\n /**\n * If you can fetch the binary yourself, you can set it\n */\n wasmBinary?: ArrayBuffer;\n\n /**\n * If you want to manually manage the download of .data file packages for\n * custom caching, progress reporting and error handling behavior,\n * you can implement this override.\n */\n getPreloadedPackage?(name: string, size: number): ArrayBuffer;\n}\n\nexport interface WiregasmLib extends EmscriptenModule {\n DissectSession: DissectSessionConstructable;\n\n /**\n * Returns the directory where files are uploaded\n *\n * @returns Path of the directory\n */\n getUploadDirectory(): string;\n\n /**\n * Returns the directory where plugins are stored\n *\n * @returns Path of the plugins directory\n */\n getPluginsDirectory(): string;\n\n /**\n * Initialize the library, load preferences and register dissectors\n */\n init(): boolean;\n\n /**\n * Reload lua plugins\n */\n reloadLuaPlugins(): boolean;\n\n /**\n * Clean up any memory associated with the lib\n */\n destroy(): void;\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n checkFilter(filter: string): CheckFilterResponse;\n\n /**\n * Returns the column headers\n */\n getColumns(): Vector<string>;\n\n /**\n * Creates a new file in the upload directory with the supplied data\n *\n * @param file_name Name of the file\n * @param data_ptr Pointer to the data\n * @param length Length of the data\n */\n upload(file_name: string, data_ptr: number, length: number): string;\n}\n\nexport type WiregasmLoader = (\n overrides: WiregasmLibOverrides\n) => Promise<WiregasmLib>;\n\nexport type BeforeInitCallback = (lib: WiregasmLib) => Promise<void>;\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;ACAA,IA+BO;UAAK,aAAa;IAAb,cAAA,cACV,kBAAA,KAAA;IADU,cAAA,cAEV,0BAAA,KAAA;IAFU,cAAA,cAGV,4BAAA,KAAA;IAHU,cAAA,cAIV,wBAAA,KAAA;GAJU,8CAAA;IAOL;UAAK,QAAQ;IAAR,SAAA,SACV,eAAA,KAAA;IADU,SAAA,SAEV,eAAA,KAAA;IAFU,SAAA,SAGV,eAAA,KAAA;IAHU,SAAA,SAIV,iBAAA,KAAA;IAJU,SAAA,SAKV,gBAAA,MAAA;IALU,SAAA,SAMV,sBAAA,MAAA;IANU,SAAA,SAOV,cAAA,MAAA;IAPU,SAAA,SAQV,wBAAA,OAAA;IARU,SAAA,SASV,gBAAA,OAAA;IATU,SAAA,SAUV,iBAAA,OAAA;IAVU,SAAA,SAWV,mBAAA,QAAA;IAXU,SAAA,SA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{\n BeforeInitCallback,\n CheckFilterResponse,\n CompleteField,\n DissectSession,\n Follow,\n Frame,\n FramesResponse,\n LoadResponse,\n Pref,\n PrefModule,\n PrefSetResult,\n Vector,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\n\nimport { preferenceSetCodeToError, vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n this.lib.init();\n this.initialized = true;\n }\n\n list_modules(): Vector<PrefModule> {\n return this.lib.listModules();\n }\n\n list_prefs(module: string): Vector<Pref> {\n return this.lib.listPreferences(module);\n }\n\n apply_prefs() {\n this.lib.applyPreferences();\n }\n\n set_pref(module: string, key: string, value: string) {\n const ret = this.lib.setPref(module, key, value);\n\n if (ret.code != PrefSetResult.PREFS_SET_OK) {\n const message =\n ret.error != \"\" ? ret.error : preferenceSetCodeToError(ret.code);\n throw new Error(\n `Failed to set preference (${module}.${key}): ${message}`\n );\n }\n }\n\n get_pref(module: string, key: string): Pref {\n const response = this.lib.getPref(module, key);\n if (response.code != 0) {\n throw new Error(`Failed to get preference (${module}.${key})`);\n }\n return response.data;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n complete_filter(filter: string): { err: string; fields: CompleteField[] } {\n const out = this.lib.completeFilter(filter);\n return {\n err: out.err,\n fields: vectorToArray(out.fields),\n };\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n follow(follow: string, filter: string): Follow {\n return this.session.follow(follow, filter);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n","export interface EmscriptenFileSystem {\n writeFile(\n path: string,\n data: string | ArrayBufferView,\n opts?: { flags?: string | undefined }\n ): void;\n readdir(path: string): string[];\n mkdirTree(path: string, mode?: number);\n mkdir(path: string, mode?: number);\n}\n\nexport interface EmscriptenHeap {\n buffer: ArrayBufferLike;\n}\n\nexport interface EmscriptenModule {\n FS: EmscriptenFileSystem;\n HEAPU8: EmscriptenHeap;\n _malloc(size: number): number;\n}\n\nexport interface Vector<T> {\n size(): number;\n get(index: number): T;\n}\n\nexport interface DataSource {\n name: string;\n data: string;\n}\n\nexport enum PrefSetResult {\n PREFS_SET_OK, // succeeded\n PREFS_SET_SYNTAX_ERR, // syntax error in string\n PREFS_SET_NO_SUCH_PREF, // no such preference\n PREFS_SET_OBSOLETE, // preference used to exist but no longer does\n}\n\nexport enum PrefType {\n PREF_UINT = 1 << 0,\n PREF_BOOL = 1 << 1,\n PREF_ENUM = 1 << 2,\n PREF_STRING = 1 << 3,\n PREF_RANGE = 1 << 4,\n PREF_STATIC_TEXT = 1 << 5,\n PREF_UAT = 1 << 6,\n PREF_SAVE_FILENAME = 1 << 7,\n PREF_COLOR = 1 << 8, // These are only supported for \"internal\" (non-protocol)\n PREF_CUSTOM = 1 << 9, // use and not as a generic protocol preference\n PREF_OBSOLETE = 1 << 10,\n PREF_DIRNAME = 1 << 11,\n PREF_DECODE_AS_UINT = 1 << 12, // These are only supported for \"internal\" (non-protocol)\n PREF_DECODE_AS_RANGE = 1 << 13, // use and not as a generic protocol preference\n PREF_OPEN_FILENAME = 1 << 14,\n PREF_PASSWORD = 1 << 15, // like string, but never saved to prefs file\n}\n\nexport interface PrefModule {\n name: string;\n title: string;\n description: string;\n use_gui: boolean;\n submodules: Vector<PrefModule>;\n}\n\nexport interface PrefSetResponse {\n code: PrefSetResult;\n error: string;\n}\n\nexport interface PrefResponse {\n code: number;\n data: Pref;\n}\n\nexport interface Pref {\n name: string;\n title: string;\n description: string;\n\n type: PrefType;\n uint_value: number;\n uint_base_value: number;\n bool_value: boolean;\n string_value: string;\n range_value: string;\n}\n\nexport interface ProtoTree {\n label: string;\n filter: string;\n start: number;\n length: number;\n data_source_idx: number;\n type: \"proto\" | \"url\" | \"framenum\" | \"\";\n url?: string;\n fnum?: number;\n tree: Vector<ProtoTree>;\n}\n\nexport interface Frame {\n number: number;\n comments: Vector<string>;\n data_sources: Vector<DataSource>;\n tree: Vector<ProtoTree>;\n follow: Vector<Vector<string>>\n}\n\nexport interface CompleteField {\n field: string;\n type: string;\n name: string;\n}\n\n\nexport interface FramesResponse {\n frames: Vector<FrameMeta>;\n matched: number;\n}\n\nexport interface FollowPayload {\n number: number;\n server: number;\n data: string;\n}\n\nexport interface Follow {\n shost: string;\n sport: string;\n sbytes: number;\n chost: string;\n cport: string;\n cbytes: number;\n payloads: Vector<FollowPayload>;\n}\n\nexport interface FrameMeta {\n number: number;\n comments: boolean;\n ignored: boolean;\n marked: boolean;\n bg: number;\n fg: number;\n columns: Vector<string>;\n}\n\nexport interface LoadSummary {\n filename: string;\n file_type: string;\n file_length: number;\n file_encap_type: string;\n packet_count: number;\n start_time: number;\n stop_time: number;\n elapsed_time: number;\n}\n\nexport interface LoadResponse {\n code: number;\n error: string;\n summary: LoadSummary;\n}\n\nexport interface DissectSession {\n /**\n * Free up any memory used by the session\n */\n delete(): void;\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(): LoadResponse;\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n getFrames(filter: string, skip: number, limit: number): FramesResponse;\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n getFrame(number: number): Frame;\n\n follow(follow: string, filter: string): Follow;\n}\n\nexport interface DissectSessionConstructable {\n new(path: string): DissectSession;\n}\n\nexport interface CheckFilterResponse {\n ok: boolean;\n error: string;\n}\n\nexport interface WiregasmLibOverrides {\n /**\n * If set, this method will be called when the runtime needs to load a file,\n * such as a .wasm WebAssembly file, .mem memory init file, or a file generated\n * by the file packager. The function receives the relative path to the file as\n * configured in build process and a prefix (path to the main JavaScript file’s\n * directory), and should return the actual URL.\n *\n * This lets you host file packages or the .mem file etc. on a different location\n * than the directory of the JavaScript file (which is the default expectation),\n * for example if you want to host them on a CDN.\n *\n * @param path Path of the requested file.\n * @param prefix Prefix of the requested path. May be empty.\n *\n * @returns Path to the requested file.\n */\n locateFile?(path: string, prefix: string): string;\n\n /**\n * Called when something is printed to standard error (stderr)\n *\n * @param error Error content\n */\n printErr?(error: string): void;\n\n /**\n * Called when something is printed to standard output (stdout)\n *\n * @param message Message content\n */\n print?(message: string): void;\n\n /**\n * Called from within the Wiregasm Library to notify\n * about any status updates.\n *\n * @param type Type of the status\n * @param message Message content\n */\n handleStatus?(type: number, message: string): void;\n\n /**\n * If you can fetch the binary yourself, you can set it\n */\n wasmBinary?: ArrayBuffer;\n\n /**\n * If you want to manually manage the download of .data file packages for\n * custom caching, progress reporting and error handling behavior,\n * you can implement this override.\n */\n getPreloadedPackage?(name: string, size: number): ArrayBuffer;\n}\n\nexport interface WiregasmLib extends EmscriptenModule {\n DissectSession: DissectSessionConstructable;\n\n /**\n * Returns the directory where files are uploaded\n *\n * @returns Path of the directory\n */\n getUploadDirectory(): string;\n\n /**\n * Returns the directory where plugins are stored\n *\n * @returns Path of the plugins directory\n */\n getPluginsDirectory(): string;\n\n /**\n * Initialize the library, load preferences and register dissectors\n */\n init(): boolean;\n\n /**\n * List all the preference modules\n \n * @returns List of preference modules\n */\n listModules(): Vector<PrefModule>;\n\n /**\n * List all the preferences for a given module\n *\n * @param module Preference module\n */\n listPreferences(module: string): Vector<Pref>;\n\n /**\n * Apply preferences\n */\n applyPreferences(): void;\n\n /**\n * Set a preference\n *\n * @param module Preference module\n * @param key Preference key\n * @param value Preference value\n */\n setPref(module: string, key: string, value: string): PrefSetResponse;\n\n /**\n * Get a preference\n *\n * @param module Preference module\n * @param key Preference key\n */\n getPref(module: string, key: string): PrefResponse;\n\n /**\n * Reload lua plugins\n */\n reloadLuaPlugins(): boolean;\n\n /**\n * Clean up any memory associated with the lib\n */\n destroy(): void;\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n checkFilter(filter: string): CheckFilterResponse;\n\n completeFilter(filter: string): { err: string; fields: Vector<CompleteField> };\n /**\n * Returns the column headers\n */\n getColumns(): Vector<string>;\n\n /**\n * Creates a new file in the upload directory with the supplied data\n *\n * @param file_name Name of the file\n * @param data_ptr Pointer to the data\n * @param length Length of the data\n */\n upload(file_name: string, data_ptr: number, length: number): string;\n}\n\nexport type WiregasmLoader = (\n overrides: WiregasmLibOverrides\n) => Promise<WiregasmLib>;\n\nexport type BeforeInitCallback = (lib: WiregasmLib) => Promise<void>;\n","import { PrefSetResult, Vector } from \"./types\";\n\n/**\n * Converts a Vector to a JS array\n *\n * @param vec Vector\n * @returns JS array of the Vector contents\n */\nexport function vectorToArray<T>(vec: Vector<T>): T[] {\n return new Array(vec.size()).fill(0).map((_, id) => vec.get(id));\n}\n\nexport function preferenceSetCodeToError(code: number): string {\n switch (code) {\n case PrefSetResult.PREFS_SET_SYNTAX_ERR:\n return \"Syntax error in string\";\n case PrefSetResult.PREFS_SET_NO_SUCH_PREF:\n return \"No such preference\";\n case PrefSetResult.PREFS_SET_OBSOLETE:\n return \"Preference used to exist but no longer does\";\n default:\n return \"Unknown error\";\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,16 +1,60 @@
|
|
|
1
1
|
function $parcel$export(e, n, v, s) {
|
|
2
2
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
3
3
|
}
|
|
4
|
+
var $81c1b644006d48ec$exports = {};
|
|
5
|
+
|
|
6
|
+
$parcel$export($81c1b644006d48ec$exports, "PrefSetResult", () => $81c1b644006d48ec$export$9511720e10589113);
|
|
7
|
+
$parcel$export($81c1b644006d48ec$exports, "PrefType", () => $81c1b644006d48ec$export$eeff8db21dc74b3d);
|
|
8
|
+
let $81c1b644006d48ec$export$9511720e10589113;
|
|
9
|
+
(function(PrefSetResult) {
|
|
10
|
+
PrefSetResult[PrefSetResult["PREFS_SET_OK"] = 0] = "PREFS_SET_OK";
|
|
11
|
+
PrefSetResult[PrefSetResult["PREFS_SET_SYNTAX_ERR"] = 1] = "PREFS_SET_SYNTAX_ERR";
|
|
12
|
+
PrefSetResult[PrefSetResult["PREFS_SET_NO_SUCH_PREF"] = 2] = "PREFS_SET_NO_SUCH_PREF";
|
|
13
|
+
PrefSetResult[PrefSetResult["PREFS_SET_OBSOLETE"] = 3] = "PREFS_SET_OBSOLETE";
|
|
14
|
+
})($81c1b644006d48ec$export$9511720e10589113 || ($81c1b644006d48ec$export$9511720e10589113 = {}));
|
|
15
|
+
let $81c1b644006d48ec$export$eeff8db21dc74b3d;
|
|
16
|
+
(function(PrefType) {
|
|
17
|
+
PrefType[PrefType["PREF_UINT"] = 1] = "PREF_UINT";
|
|
18
|
+
PrefType[PrefType["PREF_BOOL"] = 2] = "PREF_BOOL";
|
|
19
|
+
PrefType[PrefType["PREF_ENUM"] = 4] = "PREF_ENUM";
|
|
20
|
+
PrefType[PrefType["PREF_STRING"] = 8] = "PREF_STRING";
|
|
21
|
+
PrefType[PrefType["PREF_RANGE"] = 16] = "PREF_RANGE";
|
|
22
|
+
PrefType[PrefType["PREF_STATIC_TEXT"] = 32] = "PREF_STATIC_TEXT";
|
|
23
|
+
PrefType[PrefType["PREF_UAT"] = 64] = "PREF_UAT";
|
|
24
|
+
PrefType[PrefType["PREF_SAVE_FILENAME"] = 128] = "PREF_SAVE_FILENAME";
|
|
25
|
+
PrefType[PrefType["PREF_COLOR"] = 256] = "PREF_COLOR";
|
|
26
|
+
PrefType[PrefType["PREF_CUSTOM"] = 512] = "PREF_CUSTOM";
|
|
27
|
+
PrefType[PrefType["PREF_OBSOLETE"] = 1024] = "PREF_OBSOLETE";
|
|
28
|
+
PrefType[PrefType["PREF_DIRNAME"] = 2048] = "PREF_DIRNAME";
|
|
29
|
+
PrefType[PrefType["PREF_DECODE_AS_UINT"] = 4096] = "PREF_DECODE_AS_UINT";
|
|
30
|
+
PrefType[PrefType["PREF_DECODE_AS_RANGE"] = 8192] = "PREF_DECODE_AS_RANGE";
|
|
31
|
+
PrefType[PrefType["PREF_OPEN_FILENAME"] = 16384] = "PREF_OPEN_FILENAME";
|
|
32
|
+
PrefType[PrefType["PREF_PASSWORD"] = 32768] = "PREF_PASSWORD";
|
|
33
|
+
})($81c1b644006d48ec$export$eeff8db21dc74b3d || ($81c1b644006d48ec$export$eeff8db21dc74b3d = {}));
|
|
34
|
+
|
|
35
|
+
|
|
4
36
|
var $fab42eb3dee39b5b$exports = {};
|
|
5
37
|
|
|
6
38
|
$parcel$export($fab42eb3dee39b5b$exports, "vectorToArray", () => $fab42eb3dee39b5b$export$4b978bcb0889dc66);
|
|
39
|
+
$parcel$export($fab42eb3dee39b5b$exports, "preferenceSetCodeToError", () => $fab42eb3dee39b5b$export$a6506e3cba6c4388);
|
|
40
|
+
|
|
7
41
|
function $fab42eb3dee39b5b$export$4b978bcb0889dc66(vec) {
|
|
8
42
|
return new Array(vec.size()).fill(0).map((_, id)=>vec.get(id));
|
|
9
43
|
}
|
|
44
|
+
function $fab42eb3dee39b5b$export$a6506e3cba6c4388(code) {
|
|
45
|
+
switch(code){
|
|
46
|
+
case (0, $81c1b644006d48ec$export$9511720e10589113).PREFS_SET_SYNTAX_ERR:
|
|
47
|
+
return "Syntax error in string";
|
|
48
|
+
case (0, $81c1b644006d48ec$export$9511720e10589113).PREFS_SET_NO_SUCH_PREF:
|
|
49
|
+
return "No such preference";
|
|
50
|
+
case (0, $81c1b644006d48ec$export$9511720e10589113).PREFS_SET_OBSOLETE:
|
|
51
|
+
return "Preference used to exist but no longer does";
|
|
52
|
+
default:
|
|
53
|
+
return "Unknown error";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
10
56
|
|
|
11
57
|
|
|
12
|
-
var $81c1b644006d48ec$exports = {};
|
|
13
|
-
|
|
14
58
|
|
|
15
59
|
|
|
16
60
|
class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
@@ -32,6 +76,27 @@ class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
|
32
76
|
this.lib.init();
|
|
33
77
|
this.initialized = true;
|
|
34
78
|
}
|
|
79
|
+
list_modules() {
|
|
80
|
+
return this.lib.listModules();
|
|
81
|
+
}
|
|
82
|
+
list_prefs(module) {
|
|
83
|
+
return this.lib.listPreferences(module);
|
|
84
|
+
}
|
|
85
|
+
apply_prefs() {
|
|
86
|
+
this.lib.applyPreferences();
|
|
87
|
+
}
|
|
88
|
+
set_pref(module, key, value) {
|
|
89
|
+
const ret = this.lib.setPref(module, key, value);
|
|
90
|
+
if (ret.code != (0, $81c1b644006d48ec$export$9511720e10589113).PREFS_SET_OK) {
|
|
91
|
+
const message = ret.error != "" ? ret.error : (0, $fab42eb3dee39b5b$export$a6506e3cba6c4388)(ret.code);
|
|
92
|
+
throw new Error(`Failed to set preference (${module}.${key}): ${message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
get_pref(module, key) {
|
|
96
|
+
const response = this.lib.getPref(module, key);
|
|
97
|
+
if (response.code != 0) throw new Error(`Failed to get preference (${module}.${key})`);
|
|
98
|
+
return response.data;
|
|
99
|
+
}
|
|
35
100
|
/**
|
|
36
101
|
* Check the validity of a filter expression.
|
|
37
102
|
*
|
|
@@ -39,6 +104,13 @@ class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
|
39
104
|
*/ test_filter(filter) {
|
|
40
105
|
return this.lib.checkFilter(filter);
|
|
41
106
|
}
|
|
107
|
+
complete_filter(filter) {
|
|
108
|
+
const out = this.lib.completeFilter(filter);
|
|
109
|
+
return {
|
|
110
|
+
err: out.err,
|
|
111
|
+
fields: (0, $fab42eb3dee39b5b$export$4b978bcb0889dc66)(out.fields)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
42
114
|
reload_lua_plugins() {
|
|
43
115
|
this.lib.reloadLuaPlugins();
|
|
44
116
|
}
|
|
@@ -73,6 +145,9 @@ class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
|
73
145
|
*/ frame(num) {
|
|
74
146
|
return this.session.getFrame(num);
|
|
75
147
|
}
|
|
148
|
+
follow(follow, filter) {
|
|
149
|
+
return this.session.follow(follow, filter);
|
|
150
|
+
}
|
|
76
151
|
destroy() {
|
|
77
152
|
if (this.initialized) {
|
|
78
153
|
if (this.session !== null) {
|
|
@@ -93,5 +168,5 @@ class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
|
93
168
|
}
|
|
94
169
|
|
|
95
170
|
|
|
96
|
-
export {$149c1bd638913645$export$c4e6ddb7806910b1 as Wiregasm, $fab42eb3dee39b5b$export$4b978bcb0889dc66 as vectorToArray};
|
|
171
|
+
export {$149c1bd638913645$export$c4e6ddb7806910b1 as Wiregasm, $81c1b644006d48ec$export$9511720e10589113 as PrefSetResult, $81c1b644006d48ec$export$eeff8db21dc74b3d as PrefType, $fab42eb3dee39b5b$export$4b978bcb0889dc66 as vectorToArray, $fab42eb3dee39b5b$export$a6506e3cba6c4388 as preferenceSetCodeToError};
|
|
97
172
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;ACQO,SAAS,0CAAiB,GAAc,EAAO;IACpD,OAAO,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,KAAO,IAAI,GAAG,CAAC;AAC9D;;ADVA;;;;;AAgBO,MAAM;IAOX,aAAc;QACZ,IAAI,CAAC,WAAW,GAAG,KAAK;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI;IACrB;IAEA;;;;;GAKC,GACD,MAAM,KACJ,MAAsB,EACtB,YAAkC,CAAC,CAAC,EACpC,aAAiC,IAAI,EACrC;QACA,IAAI,IAAI,CAAC,WAAW,EAClB;QAGF,IAAI,CAAC,GAAG,GAAG,MAAM,OAAO;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB;QAC5C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB;QAE9C,IAAI,eAAe,IAAI,EACrB,MAAM,WAA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AG,IAAI;YACrB,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,OAAO;YAChB,IAAI,CAAC,WAAW,GAAG,KAAK;QAC1B,CAAC;IACH;IAEA;;GAEC,GACD,UAAoB;QAClB,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU;QAE/B,oCAAoC;QACpC,OAAO,CAAA,GAAA,yCAAY,EAAE;IACvB;AACF","sources":["src/index.ts","src/utils.ts","src/types.ts"],"sourcesContent":["import {\n CheckFilterResponse,\n DissectSession,\n Frame,\n FramesResponse,\n LoadResponse,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n BeforeInitCallback,\n} from \"./types\";\nimport { vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n this.lib.init();\n this.initialized = true;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n","import { Vector } from \"./types\";\n\n/**\n * Converts a Vector to a JS array\n *\n * @param vec Vector\n * @returns JS array of the Vector contents\n */\nexport function vectorToArray<T>(vec: Vector<T>): T[] {\n return new Array(vec.size()).fill(0).map((_, id) => vec.get(id));\n}\n","export interface EmscriptenFileSystem {\n writeFile(\n path: string,\n data: string | ArrayBufferView,\n opts?: { flags?: string | undefined }\n ): void;\n readdir(path: string): string[];\n mkdirTree(path: string, mode?: number);\n mkdir(path: string, mode?: number);\n}\n\nexport interface EmscriptenHeap {\n buffer: ArrayBufferLike;\n}\n\nexport interface EmscriptenModule {\n FS: EmscriptenFileSystem;\n HEAPU8: EmscriptenHeap;\n _malloc(size: number): number;\n}\n\nexport interface Vector<T> {\n size(): number;\n get(index: number): T;\n}\n\nexport interface DataSource {\n name: string;\n data: string;\n}\n\nexport interface ProtoTree {\n label: string;\n filter: string;\n start: number;\n length: number;\n data_source_idx: number;\n tree: Vector<ProtoTree>;\n}\n\nexport interface Frame {\n number: number;\n comments: Vector<string>;\n data_sources: Vector<DataSource>;\n tree: Vector<ProtoTree>;\n}\n\nexport interface FramesResponse {\n frames: Vector<FrameMeta>;\n matched: number;\n}\n\nexport interface FrameMeta {\n number: number;\n comments: boolean;\n ignored: boolean;\n marked: boolean;\n bg: number;\n fg: number;\n columns: Vector<string>;\n}\n\nexport interface LoadSummary {\n filename: string;\n file_type: string;\n file_length: number;\n file_encap_type: string;\n packet_count: number;\n start_time: number;\n stop_time: number;\n elapsed_time: number;\n}\n\nexport interface LoadResponse {\n code: number;\n error: string;\n summary: LoadSummary;\n}\n\nexport interface DissectSession {\n /**\n * Free up any memory used by the session\n */\n delete(): void;\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(): LoadResponse;\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n getFrames(filter: string, skip: number, limit: number): FramesResponse;\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n getFrame(number: number): Frame;\n}\n\nexport interface DissectSessionConstructable {\n new (path: string): DissectSession;\n}\n\nexport interface CheckFilterResponse {\n ok: boolean;\n error: string;\n}\n\nexport interface WiregasmLibOverrides {\n /**\n * If set, this method will be called when the runtime needs to load a file,\n * such as a .wasm WebAssembly file, .mem memory init file, or a file generated\n * by the file packager. The function receives the relative path to the file as\n * configured in build process and a prefix (path to the main JavaScript file’s\n * directory), and should return the actual URL.\n *\n * This lets you host file packages or the .mem file etc. on a different location\n * than the directory of the JavaScript file (which is the default expectation),\n * for example if you want to host them on a CDN.\n *\n * @param path Path of the requested file.\n * @param prefix Prefix of the requested path. May be empty.\n *\n * @returns Path to the requested file.\n */\n locateFile?(path: string, prefix: string): string;\n\n /**\n * Called when something is printed to standard error (stderr)\n *\n * @param error Error content\n */\n printErr?(error: string): void;\n\n /**\n * Called when something is printed to standard output (stdout)\n *\n * @param message Message content\n */\n print?(message: string): void;\n\n /**\n * Called from within the Wiregasm Library to notify\n * about any status updates.\n *\n * @param type Type of the status\n * @param message Message content\n */\n handleStatus?(type: number, message: string): void;\n\n /**\n * If you can fetch the binary yourself, you can set it\n */\n wasmBinary?: ArrayBuffer;\n\n /**\n * If you want to manually manage the download of .data file packages for\n * custom caching, progress reporting and error handling behavior,\n * you can implement this override.\n */\n getPreloadedPackage?(name: string, size: number): ArrayBuffer;\n}\n\nexport interface WiregasmLib extends EmscriptenModule {\n DissectSession: DissectSessionConstructable;\n\n /**\n * Returns the directory where files are uploaded\n *\n * @returns Path of the directory\n */\n getUploadDirectory(): string;\n\n /**\n * Returns the directory where plugins are stored\n *\n * @returns Path of the plugins directory\n */\n getPluginsDirectory(): string;\n\n /**\n * Initialize the library, load preferences and register dissectors\n */\n init(): boolean;\n\n /**\n * Reload lua plugins\n */\n reloadLuaPlugins(): boolean;\n\n /**\n * Clean up any memory associated with the lib\n */\n destroy(): void;\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n checkFilter(filter: string): CheckFilterResponse;\n\n /**\n * Returns the column headers\n */\n getColumns(): Vector<string>;\n\n /**\n * Creates a new file in the upload directory with the supplied data\n *\n * @param file_name Name of the file\n * @param data_ptr Pointer to the data\n * @param length Length of the data\n */\n upload(file_name: string, data_ptr: number, length: number): string;\n}\n\nexport type WiregasmLoader = (\n overrides: WiregasmLibOverrides\n) => Promise<WiregasmLib>;\n\nexport type BeforeInitCallback = (lib: WiregasmLib) => Promise<void>;\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;ACAA,IA+BO;UAAK,aAAa;IAAb,cAAA,cACV,kBAAA,KAAA;IADU,cAAA,cAEV,0BAAA,KAAA;IAFU,cAAA,cAGV,4BAAA,KAAA;IAHU,cAAA,cAIV,wBAAA,KAAA;GAJU,8CAAA;IAOL;UAAK,QAAQ;IAAR,SAAA,SACV,eAAA,KAAA;IADU,SAAA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CAAC,OAAO,GAAG,IAAI;YACrB,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,OAAO;YAChB,IAAI,CAAC,WAAW,GAAG,KAAK;QAC1B,CAAC;IACH;IAEA;;GAEC,GACD,UAAoB;QAClB,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU;QAE/B,oCAAoC;QACpC,OAAO,CAAA,GAAA,yCAAY,EAAE;IACvB;AACF","sources":["src/index.ts","src/types.ts","src/utils.ts"],"sourcesContent":["import {\n BeforeInitCallback,\n CheckFilterResponse,\n CompleteField,\n DissectSession,\n Follow,\n Frame,\n FramesResponse,\n LoadResponse,\n Pref,\n PrefModule,\n PrefSetResult,\n Vector,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\n\nimport { preferenceSetCodeToError, vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n this.lib.init();\n this.initialized = true;\n }\n\n list_modules(): Vector<PrefModule> {\n return this.lib.listModules();\n }\n\n list_prefs(module: string): Vector<Pref> {\n return this.lib.listPreferences(module);\n }\n\n apply_prefs() {\n this.lib.applyPreferences();\n }\n\n set_pref(module: string, key: string, value: string) {\n const ret = this.lib.setPref(module, key, value);\n\n if (ret.code != PrefSetResult.PREFS_SET_OK) {\n const message =\n ret.error != \"\" ? ret.error : preferenceSetCodeToError(ret.code);\n throw new Error(\n `Failed to set preference (${module}.${key}): ${message}`\n );\n }\n }\n\n get_pref(module: string, key: string): Pref {\n const response = this.lib.getPref(module, key);\n if (response.code != 0) {\n throw new Error(`Failed to get preference (${module}.${key})`);\n }\n return response.data;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n complete_filter(filter: string): { err: string; fields: CompleteField[] } {\n const out = this.lib.completeFilter(filter);\n return {\n err: out.err,\n fields: vectorToArray(out.fields),\n };\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n follow(follow: string, filter: string): Follow {\n return this.session.follow(follow, filter);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n","export interface EmscriptenFileSystem {\n writeFile(\n path: string,\n data: string | ArrayBufferView,\n opts?: { flags?: string | undefined }\n ): void;\n readdir(path: string): string[];\n mkdirTree(path: string, mode?: number);\n mkdir(path: string, mode?: number);\n}\n\nexport interface EmscriptenHeap {\n buffer: ArrayBufferLike;\n}\n\nexport interface EmscriptenModule {\n FS: EmscriptenFileSystem;\n HEAPU8: EmscriptenHeap;\n _malloc(size: number): number;\n}\n\nexport interface Vector<T> {\n size(): number;\n get(index: number): T;\n}\n\nexport interface DataSource {\n name: string;\n data: string;\n}\n\nexport enum PrefSetResult {\n PREFS_SET_OK, // succeeded\n PREFS_SET_SYNTAX_ERR, // syntax error in string\n PREFS_SET_NO_SUCH_PREF, // no such preference\n PREFS_SET_OBSOLETE, // preference used to exist but no longer does\n}\n\nexport enum PrefType {\n PREF_UINT = 1 << 0,\n PREF_BOOL = 1 << 1,\n PREF_ENUM = 1 << 2,\n PREF_STRING = 1 << 3,\n PREF_RANGE = 1 << 4,\n PREF_STATIC_TEXT = 1 << 5,\n PREF_UAT = 1 << 6,\n PREF_SAVE_FILENAME = 1 << 7,\n PREF_COLOR = 1 << 8, // These are only supported for \"internal\" (non-protocol)\n PREF_CUSTOM = 1 << 9, // use and not as a generic protocol preference\n PREF_OBSOLETE = 1 << 10,\n PREF_DIRNAME = 1 << 11,\n PREF_DECODE_AS_UINT = 1 << 12, // These are only supported for \"internal\" (non-protocol)\n PREF_DECODE_AS_RANGE = 1 << 13, // use and not as a generic protocol preference\n PREF_OPEN_FILENAME = 1 << 14,\n PREF_PASSWORD = 1 << 15, // like string, but never saved to prefs file\n}\n\nexport interface PrefModule {\n name: string;\n title: string;\n description: string;\n use_gui: boolean;\n submodules: Vector<PrefModule>;\n}\n\nexport interface PrefSetResponse {\n code: PrefSetResult;\n error: string;\n}\n\nexport interface PrefResponse {\n code: number;\n data: Pref;\n}\n\nexport interface Pref {\n name: string;\n title: string;\n description: string;\n\n type: PrefType;\n uint_value: number;\n uint_base_value: number;\n bool_value: boolean;\n string_value: string;\n range_value: string;\n}\n\nexport interface ProtoTree {\n label: string;\n filter: string;\n start: number;\n length: number;\n data_source_idx: number;\n type: \"proto\" | \"url\" | \"framenum\" | \"\";\n url?: string;\n fnum?: number;\n tree: Vector<ProtoTree>;\n}\n\nexport interface Frame {\n number: number;\n comments: Vector<string>;\n data_sources: Vector<DataSource>;\n tree: Vector<ProtoTree>;\n follow: Vector<Vector<string>>\n}\n\nexport interface CompleteField {\n field: string;\n type: string;\n name: string;\n}\n\n\nexport interface FramesResponse {\n frames: Vector<FrameMeta>;\n matched: number;\n}\n\nexport interface FollowPayload {\n number: number;\n server: number;\n data: string;\n}\n\nexport interface Follow {\n shost: string;\n sport: string;\n sbytes: number;\n chost: string;\n cport: string;\n cbytes: number;\n payloads: Vector<FollowPayload>;\n}\n\nexport interface FrameMeta {\n number: number;\n comments: boolean;\n ignored: boolean;\n marked: boolean;\n bg: number;\n fg: number;\n columns: Vector<string>;\n}\n\nexport interface LoadSummary {\n filename: string;\n file_type: string;\n file_length: number;\n file_encap_type: string;\n packet_count: number;\n start_time: number;\n stop_time: number;\n elapsed_time: number;\n}\n\nexport interface LoadResponse {\n code: number;\n error: string;\n summary: LoadSummary;\n}\n\nexport interface DissectSession {\n /**\n * Free up any memory used by the session\n */\n delete(): void;\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(): LoadResponse;\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n getFrames(filter: string, skip: number, limit: number): FramesResponse;\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n getFrame(number: number): Frame;\n\n follow(follow: string, filter: string): Follow;\n}\n\nexport interface DissectSessionConstructable {\n new(path: string): DissectSession;\n}\n\nexport interface CheckFilterResponse {\n ok: boolean;\n error: string;\n}\n\nexport interface WiregasmLibOverrides {\n /**\n * If set, this method will be called when the runtime needs to load a file,\n * such as a .wasm WebAssembly file, .mem memory init file, or a file generated\n * by the file packager. The function receives the relative path to the file as\n * configured in build process and a prefix (path to the main JavaScript file’s\n * directory), and should return the actual URL.\n *\n * This lets you host file packages or the .mem file etc. on a different location\n * than the directory of the JavaScript file (which is the default expectation),\n * for example if you want to host them on a CDN.\n *\n * @param path Path of the requested file.\n * @param prefix Prefix of the requested path. May be empty.\n *\n * @returns Path to the requested file.\n */\n locateFile?(path: string, prefix: string): string;\n\n /**\n * Called when something is printed to standard error (stderr)\n *\n * @param error Error content\n */\n printErr?(error: string): void;\n\n /**\n * Called when something is printed to standard output (stdout)\n *\n * @param message Message content\n */\n print?(message: string): void;\n\n /**\n * Called from within the Wiregasm Library to notify\n * about any status updates.\n *\n * @param type Type of the status\n * @param message Message content\n */\n handleStatus?(type: number, message: string): void;\n\n /**\n * If you can fetch the binary yourself, you can set it\n */\n wasmBinary?: ArrayBuffer;\n\n /**\n * If you want to manually manage the download of .data file packages for\n * custom caching, progress reporting and error handling behavior,\n * you can implement this override.\n */\n getPreloadedPackage?(name: string, size: number): ArrayBuffer;\n}\n\nexport interface WiregasmLib extends EmscriptenModule {\n DissectSession: DissectSessionConstructable;\n\n /**\n * Returns the directory where files are uploaded\n *\n * @returns Path of the directory\n */\n getUploadDirectory(): string;\n\n /**\n * Returns the directory where plugins are stored\n *\n * @returns Path of the plugins directory\n */\n getPluginsDirectory(): string;\n\n /**\n * Initialize the library, load preferences and register dissectors\n */\n init(): boolean;\n\n /**\n * List all the preference modules\n \n * @returns List of preference modules\n */\n listModules(): Vector<PrefModule>;\n\n /**\n * List all the preferences for a given module\n *\n * @param module Preference module\n */\n listPreferences(module: string): Vector<Pref>;\n\n /**\n * Apply preferences\n */\n applyPreferences(): void;\n\n /**\n * Set a preference\n *\n * @param module Preference module\n * @param key Preference key\n * @param value Preference value\n */\n setPref(module: string, key: string, value: string): PrefSetResponse;\n\n /**\n * Get a preference\n *\n * @param module Preference module\n * @param key Preference key\n */\n getPref(module: string, key: string): PrefResponse;\n\n /**\n * Reload lua plugins\n */\n reloadLuaPlugins(): boolean;\n\n /**\n * Clean up any memory associated with the lib\n */\n destroy(): void;\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n checkFilter(filter: string): CheckFilterResponse;\n\n completeFilter(filter: string): { err: string; fields: Vector<CompleteField> };\n /**\n * Returns the column headers\n */\n getColumns(): Vector<string>;\n\n /**\n * Creates a new file in the upload directory with the supplied data\n *\n * @param file_name Name of the file\n * @param data_ptr Pointer to the data\n * @param length Length of the data\n */\n upload(file_name: string, data_ptr: number, length: number): string;\n}\n\nexport type WiregasmLoader = (\n overrides: WiregasmLibOverrides\n) => Promise<WiregasmLib>;\n\nexport type BeforeInitCallback = (lib: WiregasmLib) => Promise<void>;\n","import { PrefSetResult, Vector } from \"./types\";\n\n/**\n * Converts a Vector to a JS array\n *\n * @param vec Vector\n * @returns JS array of the Vector contents\n */\nexport function vectorToArray<T>(vec: Vector<T>): T[] {\n return new Array(vec.size()).fill(0).map((_, id) => vec.get(id));\n}\n\nexport function preferenceSetCodeToError(code: number): string {\n switch (code) {\n case PrefSetResult.PREFS_SET_SYNTAX_ERR:\n return \"Syntax error in string\";\n case PrefSetResult.PREFS_SET_NO_SUCH_PREF:\n return \"No such preference\";\n case PrefSetResult.PREFS_SET_OBSOLETE:\n return \"Preference used to exist but no longer does\";\n default:\n return \"Unknown error\";\n }\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,12 +22,65 @@ export interface DataSource {
|
|
|
22
22
|
name: string;
|
|
23
23
|
data: string;
|
|
24
24
|
}
|
|
25
|
+
export enum PrefSetResult {
|
|
26
|
+
PREFS_SET_OK = 0,
|
|
27
|
+
PREFS_SET_SYNTAX_ERR = 1,
|
|
28
|
+
PREFS_SET_NO_SUCH_PREF = 2,
|
|
29
|
+
PREFS_SET_OBSOLETE = 3
|
|
30
|
+
}
|
|
31
|
+
export enum PrefType {
|
|
32
|
+
PREF_UINT = 1,
|
|
33
|
+
PREF_BOOL = 2,
|
|
34
|
+
PREF_ENUM = 4,
|
|
35
|
+
PREF_STRING = 8,
|
|
36
|
+
PREF_RANGE = 16,
|
|
37
|
+
PREF_STATIC_TEXT = 32,
|
|
38
|
+
PREF_UAT = 64,
|
|
39
|
+
PREF_SAVE_FILENAME = 128,
|
|
40
|
+
PREF_COLOR = 256,
|
|
41
|
+
PREF_CUSTOM = 512,
|
|
42
|
+
PREF_OBSOLETE = 1024,
|
|
43
|
+
PREF_DIRNAME = 2048,
|
|
44
|
+
PREF_DECODE_AS_UINT = 4096,
|
|
45
|
+
PREF_DECODE_AS_RANGE = 8192,
|
|
46
|
+
PREF_OPEN_FILENAME = 16384,
|
|
47
|
+
PREF_PASSWORD = 32768
|
|
48
|
+
}
|
|
49
|
+
export interface PrefModule {
|
|
50
|
+
name: string;
|
|
51
|
+
title: string;
|
|
52
|
+
description: string;
|
|
53
|
+
use_gui: boolean;
|
|
54
|
+
submodules: Vector<PrefModule>;
|
|
55
|
+
}
|
|
56
|
+
export interface PrefSetResponse {
|
|
57
|
+
code: PrefSetResult;
|
|
58
|
+
error: string;
|
|
59
|
+
}
|
|
60
|
+
export interface PrefResponse {
|
|
61
|
+
code: number;
|
|
62
|
+
data: Pref;
|
|
63
|
+
}
|
|
64
|
+
export interface Pref {
|
|
65
|
+
name: string;
|
|
66
|
+
title: string;
|
|
67
|
+
description: string;
|
|
68
|
+
type: PrefType;
|
|
69
|
+
uint_value: number;
|
|
70
|
+
uint_base_value: number;
|
|
71
|
+
bool_value: boolean;
|
|
72
|
+
string_value: string;
|
|
73
|
+
range_value: string;
|
|
74
|
+
}
|
|
25
75
|
export interface ProtoTree {
|
|
26
76
|
label: string;
|
|
27
77
|
filter: string;
|
|
28
78
|
start: number;
|
|
29
79
|
length: number;
|
|
30
80
|
data_source_idx: number;
|
|
81
|
+
type: "proto" | "url" | "framenum" | "";
|
|
82
|
+
url?: string;
|
|
83
|
+
fnum?: number;
|
|
31
84
|
tree: Vector<ProtoTree>;
|
|
32
85
|
}
|
|
33
86
|
export interface Frame {
|
|
@@ -35,11 +88,31 @@ export interface Frame {
|
|
|
35
88
|
comments: Vector<string>;
|
|
36
89
|
data_sources: Vector<DataSource>;
|
|
37
90
|
tree: Vector<ProtoTree>;
|
|
91
|
+
follow: Vector<Vector<string>>;
|
|
92
|
+
}
|
|
93
|
+
export interface CompleteField {
|
|
94
|
+
field: string;
|
|
95
|
+
type: string;
|
|
96
|
+
name: string;
|
|
38
97
|
}
|
|
39
98
|
export interface FramesResponse {
|
|
40
99
|
frames: Vector<FrameMeta>;
|
|
41
100
|
matched: number;
|
|
42
101
|
}
|
|
102
|
+
export interface FollowPayload {
|
|
103
|
+
number: number;
|
|
104
|
+
server: number;
|
|
105
|
+
data: string;
|
|
106
|
+
}
|
|
107
|
+
export interface Follow {
|
|
108
|
+
shost: string;
|
|
109
|
+
sport: string;
|
|
110
|
+
sbytes: number;
|
|
111
|
+
chost: string;
|
|
112
|
+
cport: string;
|
|
113
|
+
cbytes: number;
|
|
114
|
+
payloads: Vector<FollowPayload>;
|
|
115
|
+
}
|
|
43
116
|
export interface FrameMeta {
|
|
44
117
|
number: number;
|
|
45
118
|
comments: boolean;
|
|
@@ -89,6 +162,7 @@ export interface DissectSession {
|
|
|
89
162
|
* @param number Frame number
|
|
90
163
|
*/
|
|
91
164
|
getFrame(number: number): Frame;
|
|
165
|
+
follow(follow: string, filter: string): Follow;
|
|
92
166
|
}
|
|
93
167
|
export interface DissectSessionConstructable {
|
|
94
168
|
new (path: string): DissectSession;
|
|
@@ -164,6 +238,37 @@ export interface WiregasmLib extends EmscriptenModule {
|
|
|
164
238
|
* Initialize the library, load preferences and register dissectors
|
|
165
239
|
*/
|
|
166
240
|
init(): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* List all the preference modules
|
|
243
|
+
|
|
244
|
+
* @returns List of preference modules
|
|
245
|
+
*/
|
|
246
|
+
listModules(): Vector<PrefModule>;
|
|
247
|
+
/**
|
|
248
|
+
* List all the preferences for a given module
|
|
249
|
+
*
|
|
250
|
+
* @param module Preference module
|
|
251
|
+
*/
|
|
252
|
+
listPreferences(module: string): Vector<Pref>;
|
|
253
|
+
/**
|
|
254
|
+
* Apply preferences
|
|
255
|
+
*/
|
|
256
|
+
applyPreferences(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Set a preference
|
|
259
|
+
*
|
|
260
|
+
* @param module Preference module
|
|
261
|
+
* @param key Preference key
|
|
262
|
+
* @param value Preference value
|
|
263
|
+
*/
|
|
264
|
+
setPref(module: string, key: string, value: string): PrefSetResponse;
|
|
265
|
+
/**
|
|
266
|
+
* Get a preference
|
|
267
|
+
*
|
|
268
|
+
* @param module Preference module
|
|
269
|
+
* @param key Preference key
|
|
270
|
+
*/
|
|
271
|
+
getPref(module: string, key: string): PrefResponse;
|
|
167
272
|
/**
|
|
168
273
|
* Reload lua plugins
|
|
169
274
|
*/
|
|
@@ -178,6 +283,10 @@ export interface WiregasmLib extends EmscriptenModule {
|
|
|
178
283
|
* @param filter A display filter expression
|
|
179
284
|
*/
|
|
180
285
|
checkFilter(filter: string): CheckFilterResponse;
|
|
286
|
+
completeFilter(filter: string): {
|
|
287
|
+
err: string;
|
|
288
|
+
fields: Vector<CompleteField>;
|
|
289
|
+
};
|
|
181
290
|
/**
|
|
182
291
|
* Returns the column headers
|
|
183
292
|
*/
|
|
@@ -200,6 +309,7 @@ export type BeforeInitCallback = (lib: WiregasmLib) => Promise<void>;
|
|
|
200
309
|
* @returns JS array of the Vector contents
|
|
201
310
|
*/
|
|
202
311
|
export function vectorToArray<T>(vec: Vector<T>): T[];
|
|
312
|
+
export function preferenceSetCodeToError(code: number): string;
|
|
203
313
|
/**
|
|
204
314
|
* Wraps the WiregasmLib lib functionality and manages a single DissectSession
|
|
205
315
|
*/
|
|
@@ -217,12 +327,21 @@ export class Wiregasm {
|
|
|
217
327
|
* @param overrides Overrides
|
|
218
328
|
*/
|
|
219
329
|
init(loader: WiregasmLoader, overrides?: WiregasmLibOverrides, beforeInit?: BeforeInitCallback): Promise<void>;
|
|
330
|
+
list_modules(): Vector<PrefModule>;
|
|
331
|
+
list_prefs(module: string): Vector<Pref>;
|
|
332
|
+
apply_prefs(): void;
|
|
333
|
+
set_pref(module: string, key: string, value: string): void;
|
|
334
|
+
get_pref(module: string, key: string): Pref;
|
|
220
335
|
/**
|
|
221
336
|
* Check the validity of a filter expression.
|
|
222
337
|
*
|
|
223
338
|
* @param filter A display filter expression
|
|
224
339
|
*/
|
|
225
340
|
test_filter(filter: string): CheckFilterResponse;
|
|
341
|
+
complete_filter(filter: string): {
|
|
342
|
+
err: string;
|
|
343
|
+
fields: CompleteField[];
|
|
344
|
+
};
|
|
226
345
|
reload_lua_plugins(): void;
|
|
227
346
|
add_plugin(name: string, data: string | ArrayBufferView, opts?: object): void;
|
|
228
347
|
/**
|
|
@@ -245,6 +364,7 @@ export class Wiregasm {
|
|
|
245
364
|
* @param number Frame number
|
|
246
365
|
*/
|
|
247
366
|
frame(num: number): Frame;
|
|
367
|
+
follow(follow: string, filter: string): Follow;
|
|
248
368
|
destroy(): void;
|
|
249
369
|
/**
|
|
250
370
|
* Returns the column headers
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;IACE,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GACpC,IAAI,CAAC;IACR,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,OAAE;IACvC,KAAK,CAAC,IAAI,EAAE,M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G,eAAe,EAC9B,IAAI,GAAE,MAAW,GAChB,YAAY;IAaf;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,KAAK,SAAI,GAAG,cAAc;IAI3D;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;IAIzB,OAAO;IAYP;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE;CAMpB","sources":["src/src/types.ts","src/src/utils.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,"import {\n CheckFilterResponse,\n DissectSession,\n Frame,\n FramesResponse,\n LoadResponse,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n BeforeInitCallback,\n} from \"./types\";\nimport { vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n this.lib.init();\n this.initialized = true;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
1
|
+
{"mappings":"AAAA;IACE,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GACpC,IAAI,CAAC;IACR,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,OAAE;IACvC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,OAAE;CACpC;AAED;IACE,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;IACE,EAAE,EAAE,oBAAoB,CAAC;IACzB,MAAM,EAAE,cAAc,CAAC;IACv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Z,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,GAAE,MAAW,GAChB,YAAY;IAaf;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,KAAK,SAAI,GAAG,cAAc;IAI3D;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;IAIzB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAI9C,OAAO;IAYP;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE;CAMpB","sources":["src/src/types.ts","src/src/utils.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,"import {\n BeforeInitCallback,\n CheckFilterResponse,\n CompleteField,\n DissectSession,\n Follow,\n Frame,\n FramesResponse,\n LoadResponse,\n Pref,\n PrefModule,\n PrefSetResult,\n Vector,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\n\nimport { preferenceSetCodeToError, vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n pluginsDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(\n loader: WiregasmLoader,\n overrides: WiregasmLibOverrides = {},\n beforeInit: BeforeInitCallback = null\n ) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.pluginsDir = this.lib.getPluginsDirectory();\n\n if (beforeInit !== null) {\n await beforeInit(this.lib);\n }\n\n this.lib.init();\n this.initialized = true;\n }\n\n list_modules(): Vector<PrefModule> {\n return this.lib.listModules();\n }\n\n list_prefs(module: string): Vector<Pref> {\n return this.lib.listPreferences(module);\n }\n\n apply_prefs() {\n this.lib.applyPreferences();\n }\n\n set_pref(module: string, key: string, value: string) {\n const ret = this.lib.setPref(module, key, value);\n\n if (ret.code != PrefSetResult.PREFS_SET_OK) {\n const message =\n ret.error != \"\" ? ret.error : preferenceSetCodeToError(ret.code);\n throw new Error(\n `Failed to set preference (${module}.${key}): ${message}`\n );\n }\n }\n\n get_pref(module: string, key: string): Pref {\n const response = this.lib.getPref(module, key);\n if (response.code != 0) {\n throw new Error(`Failed to get preference (${module}.${key})`);\n }\n return response.data;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n complete_filter(filter: string): { err: string; fields: CompleteField[] } {\n const out = this.lib.completeFilter(filter);\n return {\n err: out.err,\n fields: vectorToArray(out.fields),\n };\n }\n\n reload_lua_plugins() {\n this.lib.reloadLuaPlugins();\n }\n\n add_plugin(name: string, data: string | ArrayBufferView, opts: object = {}) {\n const path = this.pluginsDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n follow(follow: string, filter: string): Follow {\n return this.session.follow(follow, filter);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/wiregasm.data.gz
CHANGED
|
Binary file
|
package/dist/wiregasm.js
CHANGED
|
@@ -8858,10 +8858,10 @@ var _emscripten_stack_get_current = function() {
|
|
|
8858
8858
|
/** @type {function(...*):?} */
|
|
8859
8859
|
var ___cxa_is_pointer_type = createExportWrapper("__cxa_is_pointer_type");
|
|
8860
8860
|
/** @type {function(...*):?} */
|
|
8861
|
-
var dynCall_ii = Module["dynCall_ii"] = createExportWrapper("dynCall_ii");
|
|
8862
|
-
/** @type {function(...*):?} */
|
|
8863
8861
|
var dynCall_iii = Module["dynCall_iii"] = createExportWrapper("dynCall_iii");
|
|
8864
8862
|
/** @type {function(...*):?} */
|
|
8863
|
+
var dynCall_ii = Module["dynCall_ii"] = createExportWrapper("dynCall_ii");
|
|
8864
|
+
/** @type {function(...*):?} */
|
|
8865
8865
|
var dynCall_vi = Module["dynCall_vi"] = createExportWrapper("dynCall_vi");
|
|
8866
8866
|
/** @type {function(...*):?} */
|
|
8867
8867
|
var dynCall_vii = Module["dynCall_vii"] = createExportWrapper("dynCall_vii");
|
|
@@ -8874,6 +8874,8 @@ var dynCall_viiii = Module["dynCall_viiii"] = createExportWrapper("dynCall_viiii
|
|
|
8874
8874
|
/** @type {function(...*):?} */
|
|
8875
8875
|
var dynCall_i = Module["dynCall_i"] = createExportWrapper("dynCall_i");
|
|
8876
8876
|
/** @type {function(...*):?} */
|
|
8877
|
+
var dynCall_iiii = Module["dynCall_iiii"] = createExportWrapper("dynCall_iiii");
|
|
8878
|
+
/** @type {function(...*):?} */
|
|
8877
8879
|
var dynCall_viiiiii = Module["dynCall_viiiiii"] = createExportWrapper("dynCall_viiiiii");
|
|
8878
8880
|
/** @type {function(...*):?} */
|
|
8879
8881
|
var dynCall_v = Module["dynCall_v"] = createExportWrapper("dynCall_v");
|
|
@@ -8882,8 +8884,6 @@ var dynCall_iiiii = Module["dynCall_iiiii"] = createExportWrapper("dynCall_iiiii
|
|
|
8882
8884
|
/** @type {function(...*):?} */
|
|
8883
8885
|
var dynCall_viiiii = Module["dynCall_viiiii"] = createExportWrapper("dynCall_viiiii");
|
|
8884
8886
|
/** @type {function(...*):?} */
|
|
8885
|
-
var dynCall_iiii = Module["dynCall_iiii"] = createExportWrapper("dynCall_iiii");
|
|
8886
|
-
/** @type {function(...*):?} */
|
|
8887
8887
|
var dynCall_dii = Module["dynCall_dii"] = createExportWrapper("dynCall_dii");
|
|
8888
8888
|
/** @type {function(...*):?} */
|
|
8889
8889
|
var dynCall_viid = Module["dynCall_viid"] = createExportWrapper("dynCall_viid");
|
package/dist/wiregasm.wasm
CHANGED
|
Binary file
|
package/dist/wiregasm.wasm.gz
CHANGED
|
Binary file
|