Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
github.com/libp2p/go-libp2p-http
HTTP on top of libp2p
Package p2phttp
allows to serve HTTP endpoints and make HTTP requests through libp2p using Go's standard "http" and "net" stack.
Instead of the regular "host:port" addressing, p2phttp
uses a Peer ID and lets libp2p take care of the routing, thus taking advantage of features like multi-routes, NAT transversal and stream multiplexing over a single connection.
This package is a library that uses Go modules for dependency management.
Full documentation can be read at Godoc. The important bits follow.
A simple http.Server
on libp2p works as:
listener, _ := gostream.Listen(host1, p2phttp.DefaultP2PProtocol)
defer listener.Close()
go func() {
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hi!"))
})
server := &http.Server{}
server.Serve(listener)
}
The listener is provided by https://github.com/libp2p/go-libp2p-gostream .
A client just needs to be initialized with a custom libp2p host-based transport to perform requests to such server:
tr := &http.Transport{}
tr.RegisterProtocol("libp2p", p2phttp.NewTransport(clientHost))
client := &http.Client{Transport: tr}
res, err := client.Get("libp2p://Qmaoi4isbcTbFfohQyn28EiYM5CDWQx9QRCjDh3CTeiY7P/hello")
PRs accepted.
MIT © Protocol Labs, Inc.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.