master
emdee 2 months ago
parent 8a6e08470e
commit 553a192910

@ -20,8 +20,8 @@
cmake_minimum_required(VERSION 2.8.12)
project(tox-weechat C)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/var/local/src/c-toxcore/toxcore -I/var/local/src/c-toxcore/toxac -I/var/local/src/c-toxcore/toxencryptsave")
set(LD_FLAGS "${LD_FLAGS} -I/var/local/src/c-toxcore/_build")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/src/c-toxcore/toxcore -I/var/local/src/c-toxcore/toxav -I/usr/local/src/c-toxcore/toxencryptsave")
set(LD_FLAGS "${LD_FLAGS} -I/usr/local/src/c-toxcore/_build")
add_library(tox MODULE
src/twc.c

@ -1,6 +1,7 @@
# Tox-WeeChat
Tox-WeeChat is a [Tox][1] protocol plugin for [WeeChat][2]. It is functional,
but lacks certain features that might be expected of a full-fledged Tox client.
Originally from the abandonned https://github.com/haavard/tox-weechat
Tox-WeeChat is compliant with all "Required" points in the [Tox Client
Standard][3].

@ -0,0 +1,11 @@
#!/bin/sh
mkdir _build || exit 1
cd _build
# -DTox_INCLUDE_DIRS="/usr/local/src/c-toxcore/toxencryptsave /usr/local/src/c-toxcore/toxav /usr/local/src/c-toxcore/toxcore"
cmake -DPLUGIN_PATH=~/.cache/weechat/plugins -DCMAKE_PREFIX_PATH=/usr/local \
-DTox_INCLUDE_DIRS="/usr/local/src/c-toxcore" \
-DTox_LIBRARIES=/usr/local/src/c-toxcore/_build \
.. >> cmake.log 2>&1 || exit 2$?
make >> make.log 2>&1 || exit 3$?

@ -0,0 +1,108 @@
/* bootstrap nodes generated by /o/var/local/src/tox-weechat/misc/getnodes.py
* last generated 2022-11-11T08:54:10.303144 */
static struct t_twc_bootstrap_node const twc_bootstrap_nodes[] = {
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 33445},
/* Maintainer: Cody, location: US */
{"BEF0CFB37AF874BD17B9A8F9FE64C75521DB95A37D33C5BDB00E9CF58659C04F",
"198.199.98.108", 33445},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 53},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 33445},
/* Maintainer: tux1973, location: DE */
{"B84E865125B4EC4C368CD047C72BCE447644A2DC31EF75BD2CDA345BFD310107",
"195.201.7.101", 33445},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 33445},
/* Maintainer: miaoski, location: TW */
{"5716530A10D362867C8E87EE1CD5362A233BAFBBA4CF47FA73B7CAD368BD5E6E",
"122.116.39.151", 33445},
/* Maintainer: Cüber, location: US */
{"28DB44A3CEEE69146469855DFFE5F54DA567F5D65E03EFB1D38BBAEFF2553255",
"198.98.49.206", 33445},
};
static struct t_twc_bootstrap_node const twc_bootstrap_relays[] = {
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 33445},
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"144.217.167.73", 3389},
/* Maintainer: Cody, location: US */
{"BEF0CFB37AF874BD17B9A8F9FE64C75521DB95A37D33C5BDB00E9CF58659C04F",
"198.199.98.108", 33445},
/* Maintainer: Cody, location: US */
{"BEF0CFB37AF874BD17B9A8F9FE64C75521DB95A37D33C5BDB00E9CF58659C04F",
"198.199.98.108", 3389},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 3389},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 443},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 33445},
/* Maintainer: GDR!, location: US */
{"3091C6BEB2A993F1C6300C16549FABA67098FF3D62C6D253828B531470B53D68",
"205.185.115.131", 53},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 3389},
/* Maintainer: kotelnik, location: DE */
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 33445},
/* Maintainer: tux1973, location: DE */
{"B84E865125B4EC4C368CD047C72BCE447644A2DC31EF75BD2CDA345BFD310107",
"195.201.7.101", 3389},
/* Maintainer: tux1973, location: DE */
{"B84E865125B4EC4C368CD047C72BCE447644A2DC31EF75BD2CDA345BFD310107",
"195.201.7.101", 33445},
/* Maintainer: Tha_14, location: MD */
{"836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409",
"114.35.245.150", 443},
/* Maintainer: Tha_14, location: MD */
{"836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409",
"114.35.245.150", 3389},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 3389},
/* Maintainer: Nikat, location: RU */
{"1911341A83E02503AB1FD6561BD64AF3A9D6C3F12B5FBB656976B2E678644A67",
"188.225.9.167", 33445},
/* Maintainer: miaoski, location: TW */
{"5716530A10D362867C8E87EE1CD5362A233BAFBBA4CF47FA73B7CAD368BD5E6E",
"122.116.39.151", 3389},
/* Maintainer: miaoski, location: TW */
{"5716530A10D362867C8E87EE1CD5362A233BAFBBA4CF47FA73B7CAD368BD5E6E",
"122.116.39.151", 33445},
/* Maintainer: Cüber, location: LV */
{"534A589BA7427C631773D13083570F529238211893640C99D1507300F055FE73",
"195.123.208.139", 3389},
/* Maintainer: Cüber, location: LV */
{"534A589BA7427C631773D13083570F529238211893640C99D1507300F055FE73",
"195.123.208.139", 33445},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 443},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 33445},
/* Maintainer: ToxTom, location: CA */
{"F76A11284547163889DDC89A7738CF271797BF5E5E220643E97AD3C7E7903D55",
"139.162.110.188", 3389},
/* Maintainer: Cüber, location: US */
{"28DB44A3CEEE69146469855DFFE5F54DA567F5D65E03EFB1D38BBAEFF2553255",
"198.98.49.206", 33445},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 3389},
/* Maintainer: Toxdaemon, location: RU */
{"DA98A4C0CD7473A133E115FEA2EBDAEEA2EF4F79FD69325FC070DA4DE4BA3238",
"5.19.249.240", 38296},
};

@ -1396,9 +1396,10 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
free(stripped_name);
if (error != TOX_ERR_FILE_SEND_OK)
{
weechat_printf(profile->buffer, "%ssending \"%s\" has been failed: %s",
weechat_printf(profile->buffer, "%ssending \"%s\" has been failed: %d",
weechat_prefix("error"), filename,
twc_tox_err_file_send(error));
/* twc_tox_err_file_send */
error);
return WEECHAT_RC_ERROR;
}
if (!(profile->tfer->buffer))
@ -1427,7 +1428,7 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
void
twc_commands_init()
{
weechat_hook_command("bootstrap", "manage bootstrap nodes",
weechat_hook_command("bootstrap", "manage bootstrap nodes (see also /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"connect <address> <port> <Tox ID>"
" || relay <address> <port> <Tox ID>",
"address: internet address of node to bootstrap with\n"
@ -1437,7 +1438,7 @@ twc_commands_init()
" || relay",
twc_cmd_bootstrap, NULL, NULL);
weechat_hook_command("friend", "manage friends",
weechat_hook_command("friend", "manage friends (see also /bootstrap, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"list"
" || add [-force] <address> [<message>]"
" || remove <number>|<name>|<Tox ID>"
@ -1457,7 +1458,7 @@ twc_commands_init()
" || decline",
twc_cmd_friend, NULL, NULL);
weechat_hook_command("conf", "manage conf chats",
weechat_hook_command("conf", "manage conf chats (see also /bootstrap, /friend, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"create"
" || invites"
" || join <number>"
@ -1472,62 +1473,62 @@ twc_commands_init()
twc_cmd_conf, NULL, NULL);
weechat_hook_command(
"invite", "invite someone to a conf chat", "<number>|<name>|<Tox ID>",
"invite", "invite someone to a conf chat (see also /bootstrap, /friend, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "<number>|<name>|<Tox ID>",
"number, name, Tox ID: friend to message\n",
"%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_invite, NULL, NULL);
weechat_hook_command("me", "send an action to the current chat",
weechat_hook_command("me", "send an action to the current chat (see also /bootstrap, /friend, /conf, /invite, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"<message>", "message: message to send", NULL,
twc_cmd_me, NULL, NULL);
weechat_hook_command("msg", "send a message to a Tox friend",
weechat_hook_command("msg", "send a message to a Tox friend (see also /bootstrap, /friend, /conf, /invite, /me, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"<number>|<name>|<Tox ID> [<message>]",
"number, name, Tox ID: friend to message\n"
"message: message to send",
"%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_msg,
NULL, NULL);
weechat_hook_command("query", "send a message to a Tox friend",
weechat_hook_command("query", "send a message to a Tox friend (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)",
"<number>|<name>|<Tox ID> [<message>]",
"number, name, Tox ID: friend to message\n"
"message: message to send",
"%(tox_friend_name)|%(tox_friend_tox_id)", twc_cmd_msg,
NULL, NULL);
weechat_hook_command("myid", "get your Tox ID to give to friends", "", "",
weechat_hook_command("myid", "get your Tox ID to give to friends (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "", "",
NULL, twc_cmd_myid, NULL, NULL);
weechat_hook_command("name", "change your Tox name", "<name>",
weechat_hook_command("name", "change your Tox name (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "<name>",
"name: your new name", NULL, twc_cmd_name, NULL, NULL);
weechat_hook_command("names", "list names in a conf chat", "", "", NULL,
weechat_hook_command("names", "list names in a conf chat (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", "", "", NULL,
twc_cmd_names, NULL, NULL);
weechat_hook_command("nospam", "change nospam value", "[<hex value>]",
weechat_hook_command("nospam", "change nospam value (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /part, /status, /statusmsg, /topic, /tox, /send)", "[<hex value>]",
"hex value: new nospam value; when omitted, a random "
"new value is used\n\n"
"Warning: changing your nospam value will alter your "
"Tox ID!",
NULL, twc_cmd_nospam, NULL, NULL);
weechat_hook_command("part", "leave a conf chat", "", "", NULL,
weechat_hook_command("part", "leave a conf chat (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /status, /statusmsg, /topic, /tox, /send)", "", "", NULL,
twc_cmd_part, NULL, NULL);
weechat_hook_command_run("/save", twc_cmd_save, NULL, NULL);
weechat_hook_command_run("/save (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox, /send)", twc_cmd_save, NULL, NULL);
weechat_hook_command("status", "change your Tox status", "online|busy|away",
weechat_hook_command("status", "change your Tox status (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /statusmsg, /topic, /tox, /send)", "online|busy|away",
"", NULL, twc_cmd_status, NULL, NULL);
weechat_hook_command("statusmsg", "change your Tox status message",
weechat_hook_command("statusmsg", "change your Tox status message (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /topic, /tox, /send)",
"[<message>]", "message: your new status message",
NULL, twc_cmd_statusmsg, NULL, NULL);
weechat_hook_command("topic", "set a conf chat topic", "<topic>",
weechat_hook_command("topic", "set a conf chat topic (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /tox, /send)", "<topic>",
"topic: new conf chat topic", NULL, twc_cmd_topic,
NULL, NULL);
weechat_hook_command(
"tox", "manage Tox profiles",
"tox", "manage Tox profiles (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /send)",
"list"
" || create <name>"
" || delete <name> -yes|-keepdata"
@ -1550,7 +1551,7 @@ twc_commands_init()
" || reload %(tox_loaded_profiles)|%*",
twc_cmd_tox, NULL, NULL);
weechat_hook_command(
"send", "send a file to a friend",
"send", "send a file to a friend (see also /bootstrap, /friend, /conf, /invite, /me, /msg, /myid, /name, /names, /nospam, /part, /status, /statusmsg, /topic, /tox)",
"<file>"
" || <number>|<name>|<Tox ID> <file>",
"file: path to the file\n"

@ -53,6 +53,8 @@ char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] = {
"passphrase",
"logging",
"downloading_path",
"local_discovery_enabled",
"dht_announcements_enabled",
};
/**
@ -283,11 +285,11 @@ twc_config_init_option(struct t_twc_profile *profile,
break;
case TWC_PROFILE_OPTION_PROXY_TYPE:
type = "integer";
description = "proxy type; requires profile reload to take effect";
string_values = "none|socks5|http";
description = "proxy type (none=0|http=1||socks5=2); requires profile reload to take effect";
/* string_values = "none|socks5|http"; */
min = 0;
max = 0;
default_value = "none";
max = 2;
default_value = 0; /* "none"; */
break;
case TWC_PROFILE_OPTION_SAVEFILE:
type = "string";
@ -300,6 +302,11 @@ twc_config_init_option(struct t_twc_profile *profile,
description = "use UDP when communicating with the Tox network";
default_value = "on";
break;
case TWC_PROFILE_OPTION_LAN_DISCOVERY:
type = "boolean";
description = "look for nodes on the local lan";
default_value = "off";
break;
case TWC_PROFILE_OPTION_DOWNLOADING_PATH:
type = "string";
description =
@ -307,6 +314,16 @@ twc_config_init_option(struct t_twc_profile *profile,
"WeeChat home folder and \"%p\" by profile name";
default_value = "%h/tfer/%p/";
break;
case TWC_PROFILE_OPTION_DHT_ANNOUNCEMENTS_ENABLED:
type = "boolean";
description = "dht announcements enabled";
default_value = "on";
break;
case TWC_PROFILE_OPTION_HOLE_PUNCHING_ENABLED:
type = "boolean";
description = "hole_punching_enabled";
default_value = "off";
break;
default:
return NULL;
}

@ -28,8 +28,8 @@ extern struct t_config_option *twc_config_short_id_size;
enum t_twc_proxy
{
TWC_PROXY_NONE = 0,
TWC_PROXY_SOCKS5,
TWC_PROXY_HTTP
TWC_PROXY_HTTP,
TWC_PROXY_SOCKS5
};
void

@ -198,12 +198,12 @@ twc_profile_set_options(struct Tox_Options *options,
case TWC_PROXY_NONE:
options->proxy_type = TOX_PROXY_TYPE_NONE;
break;
case TWC_PROXY_SOCKS5:
options->proxy_type = TOX_PROXY_TYPE_SOCKS5;
break;
case TWC_PROXY_HTTP:
options->proxy_type = TOX_PROXY_TYPE_HTTP;
break;
case TWC_PROXY_SOCKS5:
options->proxy_type = TOX_PROXY_TYPE_SOCKS5;
break;
}
options->proxy_port =
@ -212,6 +212,12 @@ twc_profile_set_options(struct Tox_Options *options,
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_UDP);
options->ipv6_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_IPV6);
options->local_discovery_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_LAN_DISCOVERY);
options->dht_announcements_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_DHT_ANNOUNCEMENTS_ENABLED);
options->hole_punching_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_HOLE_PUNCHING_ENABLED);
#ifndef NDEBUG
options->log_callback = twc_tox_log_callback;
@ -248,7 +254,7 @@ twc_tox_new_print_error(struct t_twc_profile *profile,
break;
case TOX_ERR_NEW_PROXY_BAD_PORT:
weechat_printf(profile->buffer,
"%scould not load Tox (invalid proxy port: \"%"
"%scould not load Tox (invalid proxy port: \"%d"
PRIu16 "\")",
weechat_prefix("error"), options->proxy_port);
break;
@ -318,7 +324,7 @@ twc_profile_load(struct t_twc_profile *profile)
/* print a proxy message */
if (options.proxy_type != TOX_PROXY_TYPE_NONE)
{
weechat_printf(profile->buffer, "%susing %s proxy %s:%" PRIu16,
weechat_printf(profile->buffer, "%susing %s proxy %s:%d" PRIu16,
weechat_prefix("network"),
options.proxy_type == TOX_PROXY_TYPE_HTTP
? "HTTP"
@ -331,8 +337,7 @@ twc_profile_load(struct t_twc_profile *profile)
"but UDP is not disabled. Your IP address may not "
"be hidden.",
weechat_prefix("error"), weechat_color("lightred"),
weechat_color("reset"), options.proxy_host,
options.proxy_port);
weechat_color("reset"));
}
/* try loading data file */
@ -709,11 +714,11 @@ twc_profile_free(struct t_twc_profile *profile)
twc_group_chat_invite_free_list(profile->group_chat_invites);
twc_tfer_free(profile->tfer);
twc_message_queue_free_profile(profile);
free(profile->name);
free(profile);
/* remove from list */
twc_list_remove_with_data(twc_profiles, profile);
free(profile->name);
free(profile);
}
/**

@ -42,6 +42,7 @@ enum t_twc_profile_option
TWC_PROFILE_OPTION_PASSPHRASE,
TWC_PROFILE_OPTION_LOGGING,
TWC_PROFILE_OPTION_DOWNLOADING_PATH,
TWC_PROFILE_OPTION_LAN_DISCOVERY,
TWC_PROFILE_NUM_OPTIONS,
};

Loading…
Cancel
Save