diff --git a/src/ssb.c b/src/ssb.c index 2f154d5c..0cea96f4 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -2352,19 +2352,12 @@ static bool _tf_ssb_parse_broadcast(const char* in_broadcast, tf_ssb_broadcast_t char public_key_str[45] = { 0 }; int port = 0; static_assert(sizeof(out_broadcast->host) == 256, "host field size"); - if (sscanf(in_broadcast, "net:%255[0-9.]:%d~shs:%44s", out_broadcast->host, &port, public_key_str) == 3) + if (sscanf(in_broadcast, "net:%255[0-9A-Za-z.-]:%d~shs:%44s", out_broadcast->host, &port, public_key_str) == 3) { - if (uv_inet_pton(AF_INET, out_broadcast->host, &out_broadcast->addr.sin_addr) == 0) - { - out_broadcast->addr.sin_family = AF_INET; - out_broadcast->addr.sin_port = htons((uint16_t)port); - int r = base64c_decode((const uint8_t*)public_key_str, strlen(public_key_str), out_broadcast->pub, crypto_sign_PUBLICKEYBYTES); - return r != -1; - } - else - { - printf("pton failed\n"); - } + out_broadcast->addr.sin_family = AF_INET; + out_broadcast->addr.sin_port = htons((uint16_t)port); + int r = base64c_decode((const uint8_t*)public_key_str, strlen(public_key_str), out_broadcast->pub, crypto_sign_PUBLICKEYBYTES); + return r != -1; } else if (strncmp(in_broadcast, "ws:", 3) == 0) { @@ -2378,7 +2371,7 @@ void tf_ssb_connect_str(tf_ssb_t* ssb, const char* address) tf_ssb_broadcast_t broadcast = { 0 }; if (_tf_ssb_parse_broadcast(address, &broadcast)) { - tf_ssb_connection_create(ssb, broadcast.host, &broadcast.addr, broadcast.pub); + tf_ssb_connect(ssb, broadcast.host, ntohs(broadcast.addr.sin_port), broadcast.pub); } else {