[#549] network/Address: Add TLS

There is no TLS protocol support in
`go-multiaddr` library, but there is
public function that can register any
protocol that can be implemented outside
the library. Also `TLSEnabled` function
for parsing TLS protocol from
`network.Address` was added.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-05-21 15:16:07 +03:00 committed by Alex Vanin
parent 33bef46f31
commit f267fbc56a
4 changed files with 191 additions and 0 deletions

View file

@ -31,6 +31,22 @@ type LocalAddressSource interface {
LocalAddress() *Address
}
// Encapsulate wraps this Address around another. For example:
//
// /ip4/1.2.3.4 encapsulate /tcp/80 = /ip4/1.2.3.4/tcp/80
//
func (a *Address) Encapsulate(addr *Address) {
a.ma = a.ma.Encapsulate(addr.ma)
}
// Decapsulate removes an Address wrapping. For example:
//
// /ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = /tcp/80
//
func (a *Address) Decapsulate(addr *Address) {
a.ma = a.ma.Decapsulate(addr.ma)
}
// String returns multiaddr string
func (a Address) String() string {
return a.ma.String()