[#607] network: Support URI address strings

Make Address.FromString method to parse URI addresses and enable TLS for TLS
schemes.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-24 15:25:11 +03:00 committed by Leonard Lyubich
parent 43eff09944
commit 6f861b6489
3 changed files with 45 additions and 5 deletions

View file

@ -14,12 +14,15 @@ func TestAddress_TLSEnabled(t *testing.T) {
{"/dns4/localhost/tcp/8080", false},
{"/dns4/localhost/tcp/8080/tls", true},
{"/tls/dns4/localhost/tcp/8080", true},
{"grpc://localhost:8080", false},
{"grpcs://localhost:8080", true},
}
var addr Address
for _, test := range testCases {
addr := Address{
ma: buildMultiaddr(test.input, t),
}
err := addr.FromString(test.input)
require.NoError(t, err)
require.Equal(t, test.wantTLS, addr.TLSEnabled(), test.input)
}