Skip to content

Instantly share code, notes, and snippets.

@zoff99
Created March 11, 2024 19:55
Show Gist options
  • Save zoff99/f8d605514a89d995c526bd6577a49051 to your computer and use it in GitHub Desktop.
Save zoff99/f8d605514a89d995c526bd6577a49051 to your computer and use it in GitHub Desktop.
tox_127_0_0_1
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c
index ef44d3b55..769f7f0b7 100644
--- a/toxcore/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
@@ -153,6 +153,21 @@ static Broadcast_Info *fetch_broadcast_info(const Network *ns)
return nullptr;
}
+ IP *ip = &broadcast->ips[broadcast->count];
+ ip->family = net_family_ipv4();
+ ip->ip.v4.uint8[0] = 127;
+ ip->ip.v4.uint8[1] = 0;
+ ip->ip.v4.uint8[2] = 0;
+ ip->ip.v4.uint8[3] = 1;
+ ++broadcast->count;
+ printf("fetch_broadcast_info:127.0.0.1:%d.%d.%d.%d\n",
+ ip->ip.v4.uint8[0],
+ ip->ip.v4.uint8[1],
+ ip->ip.v4.uint8[2],
+ ip->ip.v4.uint8[3]
+ );
+
+
/* `ifc.ifc_len` is set by the `ioctl()` to the actual length used.
* On usage of the complete array the call should be repeated with
* a larger array, not done (640kB and 16 interfaces shall be
@@ -181,6 +196,13 @@ static Broadcast_Info *fetch_broadcast_info(const Network *ns)
ip->family = net_family_ipv4();
ip->ip.v4.uint32 = sock4->sin_addr.s_addr;
+ printf("fetch_broadcast_info:%d.%d.%d.%d\n",
+ ip->ip.v4.uint8[0],
+ ip->ip.v4.uint8[1],
+ ip->ip.v4.uint8[2],
+ ip->ip.v4.uint8[3]
+ );
+
if (ip->ip.v4.uint32 == 0) {
continue;
}
@@ -368,6 +390,20 @@ bool lan_discovery_send(const Networking_Core *net, const Broadcast_Info *broadc
/* IPv4 broadcast (has to be IPv4-in-IPv6 mapping if socket is IPv6 */
ip_port.ip = broadcast_ip(net_family(net), net_family_ipv4());
+ ip_port.ip.family = net_family_ipv4();
+ ip_port.ip.ip.v4.uint8[0] = 127;
+ ip_port.ip.ip.v4.uint8[1] = 0;
+ ip_port.ip.ip.v4.uint8[2] = 0;
+ ip_port.ip.ip.v4.uint8[3] = 1;
+
+
+ printf("lan_discovery_send:%d.%d.%d.%d\n",
+ ip_port.ip.ip.v4.uint8[0],
+ ip_port.ip.ip.v4.uint8[1],
+ ip_port.ip.ip.v4.uint8[2],
+ ip_port.ip.ip.v4.uint8[3]
+ );
+
if (ip_isset(&ip_port.ip) && sendpacket(net, &ip_port, data, 1 + CRYPTO_PUBLIC_KEY_SIZE) > 0) {
res = true;
}
diff --git a/toxcore/network.c b/toxcore/network.c
index e19cac865..1e1e3ada3 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -1233,7 +1233,15 @@ Networking_Core *new_networking_ex(
addr4->sin_family = AF_INET;
addr4->sin_port = 0;
fill_addr4(&ip->ip.v4, &addr4->sin_addr);
-
+ // ------- zzzzzzzzzzzz ----------
+ // ------- zzzzzzzzzzzz ----------
+ // ------- zzzzzzzzzzzz ----------
+ // net_family_ipv4();
+ struct in_addr *addr = &addr4->sin_addr;
+ addr->s_addr = htonl(INADDR_LOOPBACK);
+ // ------- zzzzzzzzzzzz ----------
+ // ------- zzzzzzzzzzzz ----------
+ // ------- zzzzzzzzzzzz ----------
portptr = &addr4->sin_port;
} else if (net_family_is_ipv6(temp->family)) {
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr.addr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment