From 28aa0f521ea9ae3958522174f892b847e2f8cdca Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Fri, 30 Jul 2021 19:43:22 +0300 Subject: [PATCH] [#735] pkg/network: Delete tls multiaddr implementation Signed-off-by: Pavel Karpy --- pkg/network/tls.go | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/pkg/network/tls.go b/pkg/network/tls.go index 821f482b3..0081d43e6 100644 --- a/pkg/network/tls.go +++ b/pkg/network/tls.go @@ -1,53 +1,20 @@ package network import ( - "fmt" - "github.com/multiformats/go-multiaddr" ) -// There is implementation of TLS protocol for -// github.com/multiformats/go-multiaddr library in this file. -// -// After addition TLS protocol via `multiaddr.AddProtocol` function -// the library is ready to parse "tls" protocol with empty body, e.g.: -// -// "/dns4/localhost/tcp/8080/tls" - const ( tlsProtocolName = "tls" - - // tlsProtocolCode is chosen according to its draft version's code in - // original multiaddr repository: https://github.com/multiformats/multicodec. - tlsProtocolCode = 0x01c0 ) // tls var is used for (un)wrapping other multiaddrs around TLS multiaddr. -var tls multiaddr.Multiaddr - -func init() { - tlsProtocol := multiaddr.Protocol{ - Name: tlsProtocolName, - Code: tlsProtocolCode, - Size: 0, - VCode: multiaddr.CodeToVarint(tlsProtocolCode), - } - - err := multiaddr.AddProtocol(tlsProtocol) - if err != nil { - panic(fmt.Errorf("could not add 'TLS' protocol to multiadd library: %w", err)) - } - - tls, err = multiaddr.NewMultiaddr("/" + tlsProtocolName) - if err != nil { - panic(fmt.Errorf("could not init 'TLS' protocol with multiadd library: %w", err)) - } -} +var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName) // TLSEnabled searches for wrapped TLS protocol in multiaddr. func (a Address) TLSEnabled() bool { for _, protoc := range a.ma.Protocols() { - if protoc.Code == tlsProtocolCode { + if protoc.Code == multiaddr.P_TLS { return true } }