Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Changed to endpoint selection #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jorropo
Copy link

@Jorropo Jorropo commented Jun 13, 2019

Now you can use ws/endpoint to choose your end point.
So a regular address looks like that :

/ip4/127.0.0.1/tcp/4002/ws/libp2p

This pr is for #46 because nobody want to use the root of his website for connection.
With this you can put it under /ipfs if you want.

Since this is a non retrocompatible modification, I'm making the same change on the javascript ws transport.

Notes :
the listener doesn't care about wich url you used, he treat your connection and just set the path you choosed.

To Do :

@Jorropo Jorropo force-pushed the selectable-endpoint branch 2 times, most recently from 303a9e8 to c3621a5 Compare June 13, 2019 06:52
@Stebalien Stebalien requested a review from raulk June 13, 2019 07:17
@raulk
Copy link
Member

raulk commented Jun 14, 2019

@lgierth how are we doing with supporting dictionary values (key/value) in multiaddrs, and with delimited values? (necessary for this issue)

@ghost
Copy link

ghost commented Jun 15, 2019

What is endpoint selection?

@ghost
Copy link

ghost commented Jun 15, 2019

Just guessing, but is it about binding multiple libp2p nodes to the same port? That'd sound like it could already be achieved with the existing /p2p protocol.

@ghost
Copy link

ghost commented Jun 15, 2019

Oh, I see, the TLS ServerName part. #46 (comment)

@Jorropo
Copy link
Author

Jorropo commented Jun 15, 2019

@lgierth yes, I was thinking of maybe creating a list of '"global" variable for each multiaddr, they could be domain, port, synced, ip, ...
And instead of dealing manualy with tcp you specify a list of compatible entry protocol and list of produced protocol and instead of giving you the whole ma and saying, now do your shit, maybe something like building a conn object with tcp, then creating a new ws transport exploiting the conn generated by tcp, and some protocol like ipX or dnsX would not be some real transport but probably more some setuping protocol and when passing to next one (tcp or udp, ...) they would use the global variable (ip, domain) to produce a conn object used by ws.
So example :

  • dns4
    • Its an entry point (could build a new connection from nothing)
    • Produce a ip4 object
    • Set the domain value of the ma
    • use a domain address as parameters
  • tcp
    • use a synced conn object or ipX as entry point
    • Produce an synced conn (conn is async while synced conn is synced (udp vs tcp)) or a tcp conn object
    • use the port as parameters if building from ipX
    • can proxy tcp and dnsX (and produce synced conn inderectly via an other tcp transport) using a more ipX and port
  • ws
    • use a synced conn object as entry point
    • Produce a synced conn object
    • use the domain global address
    • take the entry point as parameters
  • p2p
    • take a conn object is input
    • take node id as parameters
    • its an app, (that mean it handle code by its own do to more things than transport), can be considerated as stop point

Also, synced conn can be seemlessly transformed to conn but invert isn't possible.
The goal of this is to be able to build crazy things like tcp over ethernet or http over quic over udp. But mostly without more works, the goal of this is to delay most of the work to libp2p at the compilation.
And we may can think further of with p2p-cicuit, basing on an allready existing p2p connection to build a new p2p-circuit.
Also each transport should include if they add an in muxer or/and out muxer (using multiple in to produce an out and invertly), and maybe use a generic muxer interface where custom muxer not in the transport can fit in. If that someday makes into libp2p it could maybe looks like that :

/dns4/example.org/tcp|mplex/4001/wss/libp2p/p2p/Qmxxx
/dns4/example.org/tcp|mplex/4001/p2p/Qmxxx

And for these both ma, libp2p will use the same tcp connection for regular tcp and wss by injecting mplex via an multiplexer interface (here that point less because browser will not understand and will probably not support mplex).

So how could it looks like in the code :

package ws
import .... // here do your import
// here do your transcoder
var WsProtocol = ma.Protocol{
	Code:       477,
	Name:       "ws",
	VCode:      ma.CodeToVarint(477),
	Size:           -1,
	Transcoder: WsTranscoder,
	CanUse:      [
		ma.Input{ // add many input for each input type supported, priority is set by the receiver transport with lower index = higher priority
			Id: 1, // id for synced conn
			Params; [
				ma.Params{ // The params use the transcoder, if required is set tu false that mean nil is forwarded to the transcoder and no params is expected (example, tcp over ethernet, tcp params is port but there isn't any port for ethernet, so tcp transport would use the conn object build by ethernet and don't use any params)
					Required: true,
				},
				ma.Value{ // Value is shared for the whole multiaddr with a classic reading from left to right (updating the value for each new transport if needed)
					Value: 0, // Variable are predefined (in libp2p) and in my example 0 is domain
					Level: 1, // there is 3 level, 0 not needed (you could also not put it but can be usefull for background automation), 1 optional (but better if present), 2 required
				},
			],
		},
	],
	CanProduce: [
		ma.Output{
			Id: 1,
		},
	],
	// No need to specify proxy since its desactivated by default and ws doensn't support that
}

@Jorropo Jorropo force-pushed the selectable-endpoint branch 3 times, most recently from 34d16ce to 6b40a08 Compare July 8, 2019 23:01
Now you can use ws/endpoint to choose your end point.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants