{"id":25406003,"url":"https://github.com/shixiaofeia/gopacket-http","last_synced_at":"2026-01-14T22:14:59.429Z","repository":{"id":242610082,"uuid":"809861400","full_name":"shixiaofeia/gopacket-http","owner":"shixiaofeia","description":"监听网卡流量, 过滤并组装HTTP请求和响应, 供旁路分析, 抓包等用途","archived":false,"fork":false,"pushed_at":"2024-09-14T02:57:05.000Z","size":16,"stargazers_count":37,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T21:45:03.157Z","etag":null,"topics":["go","gopacket","http","tcpdump"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shixiaofeia.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":"2024-06-03T15:32:50.000Z","updated_at":"2025-08-01T10:27:01.000Z","dependencies_parsed_at":"2024-06-04T02:07:54.046Z","dependency_job_id":"a6c3c1c5-d793-4658-8d0e-5edea1de662c","html_url":"https://github.com/shixiaofeia/gopacket-http","commit_stats":null,"previous_names":["shixiaofeia/gopacket-http"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shixiaofeia/gopacket-http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shixiaofeia%2Fgopacket-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shixiaofeia%2Fgopacket-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shixiaofeia%2Fgopacket-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shixiaofeia%2Fgopacket-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shixiaofeia","download_url":"https://codeload.github.com/shixiaofeia/gopacket-http/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shixiaofeia%2Fgopacket-http/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","gopacket","http","tcpdump"],"created_at":"2025-02-16T05:04:10.206Z","updated_at":"2026-01-14T22:14:59.399Z","avatar_url":"https://github.com/shixiaofeia.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# gopacket-http\n\n\u003cp\u003e\n\u003ca href=\"https://github.com/shixiaofeia/gopacket-http\"\u003e\n    \u003cimg src=\"https://badgen.net/badge/Github/gopacket-http?icon=github\" alt=\"\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/shixiaofeia/gopacket-http/LICENSE\"\u003e\n    \u003cimg alt=\"GitHub\" src=\"https://img.shields.io/github/license/shixiaofeia/gopacket-http?style=flat-square\"\u003e\n\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/github/go-mod/go-version/shixiaofeia/gopacket-http.svg?style=flat-square\" alt=\"\"\u003e\n\u003cimg alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/shixiaofeia/gopacket-http?style=flat-square\"\u003e\n\u003cimg alt=\"GitHub Repo stars\" src=\"https://img.shields.io/github/stars/shixiaofeia/gopacket-http?style=social\"\u003e\n\u003c/p\u003e\n\n监听网卡流量, 过滤并组装HTTP请求和响应, 供旁路分析, 抓包等用途\n\n参考项目 [netgraph](https://github.com/ga0/netgraph)\n\n## 使用\n\n1. 安装libpcap-dev 和 gcc\n\n```sh\n# Ubuntu\nsudo apt install -y libpcap-dev gcc\n\n# CentOS\nsudo yum install -y libpcap-devel gcc\n\n# MacOS(Homebrew)\nbrew install libpcap\n\n```\n\n2. 安装gopacket-http\n\n```sh\ngo get -u github.com/shixiaofeia/gopacket-http\n```\n\n3. 在代码中导入\n\n```go\nimport \"github.com/shixiaofeia/gopacket-http/packet\"\n```\n\n## 快速开始\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"github.com/shixiaofeia/gopacket-http/packet\"\n\t\"log\"\n)\n\nvar eventCh = make(chan interface{}, 1024)\n\nfunc main() {\n\tgo handle()\n\tif err := packet.NewPacketHandle(context.Background(), \"en0\", eventCh).Listen(); err != nil {\n\t\tlog.Println(err.Error())\n\t}\n}\n\nfunc handle() {\n\tfor i := range eventCh {\n\t\tdata := i.(packet.Event)\n\t\tlog.Printf(\"request uri: %s, response status: %v\", data.Req.RequestURI, data.Resp.Status)\n\t}\n}\n\n```\n\n\n## 可配置的参数\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"github.com/shixiaofeia/gopacket-http/packet\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n)\n\nvar (\n\teventCh     = make(chan interface{}, 1024)\n\tctx, cancel = context.WithCancel(context.Background())\n)\n\nfunc main() {\n\tgo shutdown()\n\tsrv := packet.NewPacketHandle(ctx, \"en0\", eventCh)\n\tsrv.SetBpf(\"tcp port 80\")     // 设置BPF过滤规则\n\tsrv.SetEventHandle(5, handle) // 设置多协程事件处理,\n\tsrv.SetPromisc(true)          // 设置混杂模式开启状态,\n\tsrv.SetFlushTime(time.Minute) // 设置清理缓存时间\n\tif err := srv.Listen(); err != nil {\n\t\tlog.Println(err.Error())\n\t}\n}\n\nfunc handle(req *http.Request, resp *http.Response) {\n\tlog.Printf(\"request uri: %s, response status: %v\", req.RequestURI, resp.Status)\n}\n\nfunc shutdown() {\n\ttime.Sleep(time.Second * 10)\n\tcancel()\n}\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshixiaofeia%2Fgopacket-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshixiaofeia%2Fgopacket-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshixiaofeia%2Fgopacket-http/lists"}