Remove ToxDNS-related code.
ToxDNS is deprecated.
This commit is contained in:
parent
f6ac605f92
commit
01ff90ad65
@ -13,7 +13,6 @@ future.
|
||||
- [x] Proxy support
|
||||
- [x] Multiple profiles
|
||||
- [x] Encrypted save files
|
||||
- [ ] Tox DNS
|
||||
- [ ] File transfer
|
||||
- [ ] WeeChat `/upgrade`
|
||||
- [ ] Audio/video
|
||||
|
@ -10,9 +10,6 @@ find_library(Tox_AV_LIBRARY toxav)
|
||||
find_path(Tox_ENCRYPTSAVE_INCLUDE_DIR tox/toxencryptsave.h)
|
||||
find_library(Tox_ENCRYPTSAVE_LIBRARY toxencryptsave)
|
||||
|
||||
find_path(Tox_DNS_INCLUDE_DIR tox/toxdns.h)
|
||||
find_library(Tox_DNS_LIBRARY toxdns)
|
||||
|
||||
if(Tox_CORE_INCLUDE_DIR AND Tox_CORE_LIBRARY)
|
||||
set(Tox_CORE_FOUND TRUE)
|
||||
list(APPEND Tox_INCLUDE_DIRS ${Tox_CORE_INCLUDE_DIR})
|
||||
@ -31,11 +28,8 @@ if(Tox_ENCRYPTSAVE_INCLUDE_DIR AND Tox_ENCRYPTSAVE_LIBRARY)
|
||||
list(APPEND Tox_LIBRARIES ${Tox_ENCRYPTSAVE_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(Tox_DNS_INCLUDE_DIR AND Tox_DNS_LIBRARY)
|
||||
set(Tox_DNS_FOUND TRUE)
|
||||
list(APPEND Tox_INCLUDE_DIRS ${Tox_DNS_INCLUDE_DIR})
|
||||
list(APPEND Tox_LIBRARIES ${Tox_DNS_LIBRARY})
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Tox FOUND_VAR Tox_FOUND REQUIRED_VARS Tox_INCLUDE_DIRS Tox_LIBRARIES HANDLE_COMPONENTS)
|
||||
find_package_handle_standard_args(Tox
|
||||
FOUND_VAR Tox_FOUND
|
||||
REQUIRED_VARS Tox_INCLUDE_DIRS Tox_LIBRARIES
|
||||
HANDLE_COMPONENTS)
|
||||
|
140
src/twc-dns.c
140
src/twc-dns.c
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Håvard Pettersson <mail@haavard.me>
|
||||
*
|
||||
* This file is part of Tox-WeeChat.
|
||||
*
|
||||
* Tox-WeeChat is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tox-WeeChat is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <weechat/weechat-plugin.h>
|
||||
#include <tox/tox.h>
|
||||
|
||||
#include "twc.h"
|
||||
#include "twc-utils.h"
|
||||
|
||||
#include "twc-dns.h"
|
||||
|
||||
/**
|
||||
* Struct for holding information about a Tox DNS query callback.
|
||||
*/
|
||||
struct t_twc_dns_callback_info
|
||||
{
|
||||
void (*callback)(void *data,
|
||||
enum t_twc_dns_rc rc,
|
||||
const uint8_t *tox_id);
|
||||
void *data;
|
||||
|
||||
struct t_hook *hook;
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback when the DNS resolver child process has written to our file
|
||||
* descriptor. Process the data a bit and pass it on to the original callback.
|
||||
*/
|
||||
int
|
||||
twc_dns_fd_callback(void *data, int fd)
|
||||
{
|
||||
struct t_twc_dns_callback_info *callback_info = data;
|
||||
|
||||
char buffer[TOX_ADDRESS_SIZE * 2 + 1];
|
||||
ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
|
||||
buffer[size] = '\0';
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
if (size == TOX_ADDRESS_SIZE * 2)
|
||||
{
|
||||
uint8_t tox_id[TOX_ADDRESS_SIZE];
|
||||
twc_hex2bin(buffer, TOX_ADDRESS_SIZE, tox_id);
|
||||
|
||||
callback_info->callback(callback_info->data,
|
||||
TWC_DNS_RC_OK, tox_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
int rc = atoi(buffer);
|
||||
callback_info->callback(callback_info->data,
|
||||
rc, NULL);
|
||||
}
|
||||
|
||||
weechat_unhook(callback_info->hook);
|
||||
free(callback_info);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a Tox DNS lookup and write either a Tox ID (as a hexadecimal string)
|
||||
* or an error code (as a decimal string) to out_fd.
|
||||
*/
|
||||
void
|
||||
twc_perform_dns_lookup(const char *dns_id, int out_fd)
|
||||
{
|
||||
dprintf(out_fd, "%d", TWC_DNS_RC_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a Tox DNS lookup. If return code (rc) parameter in callback is
|
||||
* TWC_DNS_RC_OK, tox_id contains the resolved Tox ID. For any other value,
|
||||
* something caused the Tox ID not to be found.
|
||||
*
|
||||
* If twc_dns_query returns TWC_DNS_RC_ERROR, the callback will never be
|
||||
* called.
|
||||
*/
|
||||
enum t_twc_dns_rc
|
||||
twc_dns_query(const char *dns_id,
|
||||
void (*callback)(void *data,
|
||||
enum t_twc_dns_rc rc,
|
||||
const uint8_t *tox_id),
|
||||
void *callback_data)
|
||||
{
|
||||
if (!callback) return TWC_DNS_RC_OK;
|
||||
|
||||
int fifo[2];
|
||||
if (pipe(fifo) < 0)
|
||||
return TWC_DNS_RC_ERROR;
|
||||
|
||||
pid_t pid;
|
||||
if ((pid = fork()) == -1)
|
||||
{
|
||||
return TWC_DNS_RC_ERROR;
|
||||
}
|
||||
else if (pid == 0)
|
||||
{
|
||||
twc_perform_dns_lookup(dns_id, fifo[1]);
|
||||
_exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct t_twc_dns_callback_info *callback_info
|
||||
= malloc(sizeof(struct t_twc_dns_callback_info));
|
||||
if (!callback_info)
|
||||
return TWC_DNS_RC_ERROR;
|
||||
|
||||
callback_info->callback = callback;
|
||||
callback_info->data = callback_data;
|
||||
callback_info->hook = weechat_hook_fd(fifo[0], 1, 0, 0,
|
||||
twc_dns_fd_callback,
|
||||
callback_info);
|
||||
}
|
||||
|
||||
return TWC_DNS_RC_OK;
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Håvard Pettersson <mail@haavard.me>
|
||||
*
|
||||
* This file is part of Tox-WeeChat.
|
||||
*
|
||||
* Tox-WeeChat is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tox-WeeChat is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOX_WEECHAT_DNS_H
|
||||
#define TOX_WEECHAT_DNS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum t_twc_dns_rc
|
||||
{
|
||||
TWC_DNS_RC_OK = 0,
|
||||
TWC_DNS_RC_ERROR = -1,
|
||||
};
|
||||
|
||||
enum t_twc_dns_rc
|
||||
twc_dns_query(const char *dns_id,
|
||||
void (*callback)(void *data,
|
||||
enum t_twc_dns_rc rc,
|
||||
const uint8_t *tox_id),
|
||||
void *callback_data);
|
||||
|
||||
#endif // TOX_WEECHAT_DNS_H
|
||||
|
Loading…
Reference in New Issue
Block a user