Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial implementation #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: initial implementation #1

wants to merge 2 commits into from

Conversation

aschmahmann
Copy link
Owner

@aschmahmann aschmahmann commented Jun 17, 2024

WIP, but example Caddyfile:

{
	auto_https off
	servers {
        protocols h1 h2
    }
	libp2p {
		private_key ed25519key.pem
		advertise_amino true
	}
}

http://example.com:4002 {
	# Site-specific options
	bind multiaddr:/ip4/0.0.0.0/udp/4002/quic-v1/webtransport
	# Other site configuration
	respond "I am 4002"
}

Caddy can be built locally with:
xcaddy.exe build --with github.com/aschmahmann/caddy-libp2p-listener=.

@MarcoPolo
Copy link

MarcoPolo commented Jun 17, 2024

Can we make this a proper multiaddr uri:
bind multiaddr:/ip4/0.0.0.0/udp/4002/quic-v1/webtransport

multiformats/multiaddr#171

@MarcoPolo
Copy link

Can we register the well known handler somehow?

@aschmahmann
Copy link
Owner Author

Can we make this a proper multiaddr uri:

I don't think so in that I think the bind semantics require namespaces to have // like the unix one here https://caddyserver.com/docs/caddyfile/directives/bind, but I'm not sure.

@aschmahmann
Copy link
Owner Author

Can we register the well known handler somehow?

I was thinking about this, but it depends on how we want to use it. Out of the box there's no utility to the well known handler since there are no protocols registered by default. What were you thinking?

@aschmahmann
Copy link
Owner Author

I don't think so in that I think the bind semantics require namespaces to have // like the unix one here https://caddyserver.com/docs/caddyfile/directives/bind, but I'm not sure.

Actually might be possible looking at some of the valid example from here: https://caddyserver.com/docs/conventions#network-addresses

Although it's possible we'd have to do some hacks like make the namespace multiaddr: rather than multiaddr and internally add a / to the multiaddr before decoding into bytes.


func init() {
//caddy.RegisterModule(new(LL))
caddy.RegisterNetwork("multiaddr:", registerMultiaddrURI)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoPolo this (along with the hack to add a / to the returned address) seems to allow passing multiaddr URIs. A bit gross, but seems ok

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.

2 participants