forked from cory/tildefriends
Don't assume we don't have to DNS lookup broadcasts.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4022 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
9ef9dadbb8
commit
6ba41f03da
11
src/ssb.c
11
src/ssb.c
@ -2352,20 +2352,13 @@ static bool _tf_ssb_parse_broadcast(const char* in_broadcast, tf_ssb_broadcast_t
|
|||||||
char public_key_str[45] = { 0 };
|
char public_key_str[45] = { 0 };
|
||||||
int port = 0;
|
int port = 0;
|
||||||
static_assert(sizeof(out_broadcast->host) == 256, "host field size");
|
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_family = AF_INET;
|
||||||
out_broadcast->addr.sin_port = htons((uint16_t)port);
|
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);
|
int r = base64c_decode((const uint8_t*)public_key_str, strlen(public_key_str), out_broadcast->pub, crypto_sign_PUBLICKEYBYTES);
|
||||||
return r != -1;
|
return r != -1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("pton failed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strncmp(in_broadcast, "ws:", 3) == 0)
|
else if (strncmp(in_broadcast, "ws:", 3) == 0)
|
||||||
{
|
{
|
||||||
printf("Unsupported broadcast: %s\n", in_broadcast);
|
printf("Unsupported broadcast: %s\n", in_broadcast);
|
||||||
@ -2378,7 +2371,7 @@ void tf_ssb_connect_str(tf_ssb_t* ssb, const char* address)
|
|||||||
tf_ssb_broadcast_t broadcast = { 0 };
|
tf_ssb_broadcast_t broadcast = { 0 };
|
||||||
if (_tf_ssb_parse_broadcast(address, &broadcast))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user