mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
tox.*, Messenger.*:
- initialisation: argument added to enable/disable ipv6 as socket Messenger_test.c: - initialisation: ipv4 hardcoded for now - delegating IP resolution to DHT_bootstrap_ex()
This commit is contained in:
parent
a77253c79b
commit
f932fd400c
|
@ -100,7 +100,8 @@ int main(int argc, char *argv[])
|
|||
exit(0);
|
||||
}
|
||||
|
||||
m = initMessenger();
|
||||
/* IPv6: maybe allow from cmdline --ipv6? sticking to IPv4 for now */
|
||||
m = initMessenger(0);
|
||||
|
||||
if ( !m ) {
|
||||
fputs("Failed to allocate messenger datastructure\n", stderr);
|
||||
|
@ -108,10 +109,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (argc > 3) {
|
||||
IP_Port bootstrap_ip_port;
|
||||
bootstrap_ip_port.port = htons(atoi(argv[2]));
|
||||
bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]);
|
||||
DHT_bootstrap(m->dht, bootstrap_ip_port, hex_string_to_bin(argv[3]));
|
||||
uint16_t port = htons(atoi(argv[2]));
|
||||
DHT_bootstrap_ex(m->dht, argv[1], port, hex_string_to_bin(argv[3]));
|
||||
} else {
|
||||
FILE *file = fopen(argv[1], "rb");
|
||||
|
||||
|
|
|
@ -650,15 +650,21 @@ static void LANdiscovery(Messenger *m)
|
|||
}
|
||||
|
||||
/* Run this at startup. */
|
||||
Messenger *initMessenger(void)
|
||||
Messenger *initMessenger(uint8_t ipv6enabled)
|
||||
{
|
||||
Messenger *m = calloc(1, sizeof(Messenger));
|
||||
|
||||
if ( ! m )
|
||||
return NULL;
|
||||
|
||||
#ifdef NETWORK_IP_PORT_IS_IPV6
|
||||
IPAny ip;
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
ip.family = ipv6enabled ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
IP4 ip;
|
||||
ip.uint32 = 0;
|
||||
#endif
|
||||
m->net = new_networking(ip, PORT);
|
||||
|
||||
if (m->net == NULL) {
|
||||
|
|
|
@ -367,7 +367,7 @@ void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, in
|
|||
* return allocated instance of Messenger on success.
|
||||
* return 0 if there are problems.
|
||||
*/
|
||||
Messenger *initMessenger(void);
|
||||
Messenger *initMessenger(uint8_t ipv6enabled);
|
||||
|
||||
/* Run this before closing shop
|
||||
* Free all datastructures.
|
||||
|
|
|
@ -394,9 +394,13 @@ int tox_isconnected(void *tox)
|
|||
* return allocated instance of tox on success.
|
||||
* return 0 if there are problems.
|
||||
*/
|
||||
void *tox_new_ex(uint8_t ipv6enabled)
|
||||
{
|
||||
return initMessenger(ipv6enabled);
|
||||
}
|
||||
void *tox_new(void)
|
||||
{
|
||||
return initMessenger();
|
||||
return tox_new_ex(0);
|
||||
}
|
||||
|
||||
/* Run this before closing shop.
|
||||
|
|
|
@ -50,6 +50,8 @@ typedef struct {
|
|||
uint16_t padding;
|
||||
} tox_IP_Port;
|
||||
|
||||
#define TOX_IP_IS_IPV6 0
|
||||
|
||||
/* Errors for m_addfriend
|
||||
* FAERR - Friend Add Error
|
||||
*/
|
||||
|
@ -307,6 +309,7 @@ int tox_isconnected(Tox *tox);
|
|||
* return 0 if there are problems.
|
||||
*/
|
||||
Tox *tox_new(void);
|
||||
Tox *tox_new_ex(uint8_t ipv6enabled);
|
||||
|
||||
/* Run this before closing shop.
|
||||
* Free all datastructures. */
|
||||
|
|
Loading…
Reference in New Issue
Block a user