{"id":19952654,"url":"https://github.com/qxip/log2pcap","last_synced_at":"2025-07-04T07:34:21.040Z","repository":{"id":190859998,"uuid":"683477660","full_name":"QXIP/log2pcap","owner":"QXIP","description":"Generate PCAP files from Buffers \u0026 Co","archived":false,"fork":false,"pushed_at":"2023-08-28T09:53:28.000Z","size":115,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T15:16:44.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QXIP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-26T17:42:20.000Z","updated_at":"2023-08-27T14:10:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"c190c45f-c60d-4f90-918f-3c410d3f22e5","html_url":"https://github.com/QXIP/log2pcap","commit_stats":null,"previous_names":["qxip/log2pcap"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/QXIP/log2pcap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Flog2pcap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Flog2pcap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Flog2pcap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Flog2pcap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QXIP","download_url":"https://codeload.github.com/QXIP/log2pcap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Flog2pcap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263469112,"owners_count":23471456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T01:14:00.050Z","updated_at":"2025-07-04T07:34:20.983Z","avatar_url":"https://github.com/QXIP.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/sipcapture/homer7-docker/assets/1423657/36a8e515-ab0e-482b-bf49-2156e290c764\" height=150\u003e\n\n# log2pcap\n\nGenerate PCAP files from Log Buffers \u0026amp; Co\n\n## Usage\n\n\n\n```javascript\nconst log2pcap = require(\"log2pcap\");\nvar pcapFile = log2pcap.encodePcap([\n    {\n        srcIp: \"127.0.0.1\",\n        srcPort: 5060,\n        dstIp: \"127.0.0.2\",\n        dstPort: 5080,\n        proto: 17,\n        data: Buffer.from(\"HELLO\"),\n    },\n    {\n        srcIp: \"127.0.0.2\",\n        srcPort: 5080,\n        dstIp: \"127.0.0.1\",\n        dstPort: 5060,\n        proto: 17,\n        data: Buffer.from(\"WORLD\"),\n    },\n]);\n```\n## Browser version\n\n _**Build bundle to import**_\n\n\n\n```bash\n# _This will generate the bundle to use at your browser application_\nnpm run build\n```\n\nFrom this **bundle** we could use two functions:\n\n-   writePcap _that writes the object data into a ready to generate pcap data_\n\n-   generator _that generates the pcap data into a blob_\n\n-   after this generation we need to write a download function at browser.\n\n### Sample usage (incluided at **index.html** file from this repo):\n\n```js\n// import bundle\n\u003cscript src=\"bundle.js\"\u003e\u003c/script\u003e\n\n\n// process data\n\u003cscript\u003e\n  const bpc = require(\"browserPcap\");\n\n\n  // sample data object\n\n  let pcapFile = [\n      {\n          srcIp: \"127.0.0.1\",\n          srcPort: 5060,\n          dstIp: \"127.0.0.2\",\n          dstPort: 5080,\n          proto: 17,\n          data: \"HELLO\",\n      },\n      {\n          srcIp: \"127.0.0.2\",\n          srcPort: 5080,\n          dstIp: \"127.0.0.1\",\n          dstPort: 5060,\n          proto: 17,\n          data: \"WORLD\",\n      },\n  ];\n\n\n  // (...)\n  // input with id: file-name\n  const file = document.getElementById(\"file-name\");\n\n  let fileName = file?.value;\n\n  if ( fileName \u0026\u0026 typeof fileName === \"string\" \u0026\u0026 fileName !== \"\") {\n    \n      let pcap = bpc.writePcap(pcapFile);\n\n      if (pcap) {\n          let pcapData = bpc.generator(pcap);\n          var a = document.getElementById(\"a\");\n          var blob = new Blob([pcapData], { type: \"Buffer\" });\n          a.href = URL.createObjectURL(blob);\n          a.download = fileName;\n      }\n  }\n\n```\n\n\n\n### Limitations\n\n-   Only supports TCP (6) and UDP (17) protocols and IPv4\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqxip%2Flog2pcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqxip%2Flog2pcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqxip%2Flog2pcap/lists"}