Skip to content

Conversation

MarcoPolo
Copy link

Played around with this a bit and added a module to handle the .well-known/libp2p/protocols endpoint. The underlying idea is this enables other peers who discover us to understand what protocols we support and how to reach them. In a standard server/client deployment there is a lot of coordination on what protocol is where. With the well-known resource we can avoid this coordination and allow peers to learn about each other in a similar way to the identify protocol.

Example Caddyfile Usage:

:4002 {
	# Site-specific options
	bind multiaddr:/ip4/0.0.0.0/udp/4002/quic-v1/webtransport
	bind 127.0.0.1
	bind ::1

    handle / {
        respond "Hello World"
    }

	route /.well-known/libp2p/* {
		well_known-libp2p {
                        # Tell peers where our protocols are mounted
			/hello/0.0.1 => /
		}
	}
	respond "I am 4002"
}
$  curl 127.0.0.1:4002/.well-known/libp2p/protocols
{"/hello/0.0.1":{"path":"/"}}

Note that the user has to explicitly advertise protocols. I think this is okay, but could be better. I'm just not very familiar with caddy. Maybe it's possible to mark other routes/handlers with a decorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant