From 52f6e4e7c59ab3fddac779278dd90796569a857f Mon Sep 17 00:00:00 2001 From: iphydf Date: Fri, 2 Feb 2018 17:25:29 +0000 Subject: [PATCH] Move tox_shell program to the toxins repository. https://github.com/TokTok/toxins/tree/master/tox_shell --- CMakeLists.txt | 5 -- INSTALL.md | 8 +- cmake/Dependencies.cmake | 1 - testing/BUILD.bazel | 10 --- testing/Makefile.inc | 21 ----- testing/tox_shell.c | 161 --------------------------------------- 6 files changed, 1 insertion(+), 205 deletions(-) delete mode 100644 testing/tox_shell.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a029e14..542f151d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -580,8 +580,3 @@ target_link_modules(DHT_test toxdht) add_executable(Messenger_test testing/Messenger_test.c) target_link_modules(Messenger_test toxmessenger) - -if(UTIL_LIBRARIES) - add_executable(tox_shell testing/tox_shell.c) - target_link_modules(tox_shell toxcore ${UTIL_LIBRARIES}) -endif() diff --git a/INSTALL.md b/INSTALL.md index efd5d383..067a4b9c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -43,13 +43,7 @@ This repository, although called `toxcore`, in fact contains several libraries b #### Secondary -There are some testing programs that you might find interesting. Note that they are not intended for the real-world use and are not coded to the high security standards, so use them on your own risk. - -| Name | Type | Dependencies | Platform | Description | -|-------------|------------|------------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------| -| tox_shell | Executable | libtoxcore, libutil | Unix-like | Proof of concept SSH-like server software using Tox. Testing program, not intended for actual use. | - -There are also some programs that are not plugged into the CMake build system which you might find interesting. You would need to build those programs yourself. These programs reside in [`other/fun`](other/fun) directory. +There are some programs that are not plugged into the CMake build system which you might find interesting. You would need to build those programs yourself. These programs reside in [`other/fun`](other/fun) directory. | Name | Type | Dependencies | Platform | Description | |---------------------|------------|----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index d2a52ae7..be21bbf8 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -8,7 +8,6 @@ include(ModulePackage) find_package(Threads REQUIRED) -find_library(UTIL_LIBRARIES util ) find_library(RT_LIBRARIES rt ) # For toxcore. diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 1413acc9..ca354998 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -42,13 +42,3 @@ cc_binary( "@sndfile", ], ) - -cc_binary( - name = "tox_shell", - srcs = ["tox_shell.c"], - linkopts = ["-lutil"], - deps = [ - ":misc_tools", - "//c-toxcore/toxcore", - ], -) diff --git a/testing/Makefile.inc b/testing/Makefile.inc index 7d5b41e7..f4ed568c 100644 --- a/testing/Makefile.inc +++ b/testing/Makefile.inc @@ -32,27 +32,6 @@ Messenger_test_LDADD = $(LIBSODIUM_LDFLAGS) \ $(WINSOCK2_LIBS) - -if !WIN32 - -noinst_PROGRAMS += tox_shell - -tox_shell_SOURCES = ../testing/tox_shell.c - -tox_shell_CFLAGS = $(LIBSODIUM_CFLAGS) \ - $(NACL_CFLAGS) - -tox_shell_LDADD = $(LIBSODIUM_LDFLAGS) \ - $(NACL_LDFLAGS) \ - libtoxcore.la \ - $(LIBSODIUM_LIBS) \ - $(NACL_OBJECTS) \ - $(NACL_LIBS) \ - -lutil - - -endif - EXTRA_DIST += $(top_srcdir)/testing/misc_tools.c endif diff --git a/testing/tox_shell.c b/testing/tox_shell.c deleted file mode 100644 index d0f38e24..00000000 --- a/testing/tox_shell.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Tox Shell - * - * Proof of concept ssh like server software using tox. - * - * Command line arguments are the ip, port and public_key of a node (for bootstrapping). - * - * EX: ./test 127.0.0.1 33445 CDCFD319CE3460824B33BE58FD86B8941C9585181D8FBD7C79C5721D7C2E9F7C - */ - -/* - * Copyright © 2016-2017 The TokTok team. - * Copyright © 2014 Tox project. - * - * This file is part of Tox, the free peer to peer instant messenger. - * - * Tox 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 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. If not, see . - */ -#define _XOPEN_SOURCE 600 - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "../toxcore/tox.h" -#include "misc_tools.c" - -#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) -#include -#elif defined(__FreeBSD__) || defined(__DragonFly__) -#include -#else -#include -#endif -#include - -static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata) -{ - if (status) { - printf("\nOther went online.\n"); - } else { - printf("\nOther went offline.\n"); - } -} - -static void print_message(Tox *tox, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *string, size_t length, - void *userdata) -{ - int master = *((int *)userdata); - write(master, string, length); - write(master, "\n", 1); -} - -int main(int argc, char *argv[]) -{ - uint8_t ipv6enabled = 1; /* x */ - int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); - - if (argvoffset < 0) { - exit(1); - } - - /* with optional --ipvx, now it can be 1-4 arguments... */ - if ((argc != argvoffset + 2) && (argc != argvoffset + 4)) { - printf("Usage: %s [--ipv4|--ipv6] ip port public_key (of the DHT bootstrap node)\n", argv[0]); - exit(0); - } - - int *master = (int *)malloc(sizeof(int)); - int ret = forkpty(master, nullptr, nullptr, nullptr); - - if (ret == -1) { - printf("fork failed\n"); - free(master); - return 1; - } - - if (ret == 0) { - execl("/bin/sh", "sh", nullptr); - return 0; - } - - int flags = fcntl(*master, F_GETFL, 0); - int r = fcntl(*master, F_SETFL, flags | O_NONBLOCK); - - if (r < 0) { - printf("error setting flags\n"); - } - - Tox *tox = tox_new(0, 0); - tox_callback_friend_connection_status(tox, print_online); - tox_callback_friend_message(tox, print_message); - - - uint16_t port = atoi(argv[argvoffset + 2]); - unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); - int res = tox_bootstrap(tox, argv[argvoffset + 1], port, binary_string, 0); - free(binary_string); - - if (!res) { - printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); - exit(1); - } - - uint8_t address[TOX_ADDRESS_SIZE]; - tox_self_get_address(tox, address); - uint32_t i; - - for (i = 0; i < TOX_ADDRESS_SIZE; i++) { - printf("%02X", address[i]); - } - - char temp_id[128]; - printf("\nEnter the address of the other id you want to sync with (38 bytes HEX format):\n"); - - if (scanf("%s", temp_id) != 1) { - return 1; - } - - uint8_t *bin_id = hex_string_to_bin(temp_id); - uint32_t num = tox_friend_add(tox, bin_id, (const uint8_t *)"Install Gentoo", sizeof("Install Gentoo"), 0); - free(bin_id); - - if (num == UINT32_MAX) { - printf("\nSomething went wrong when adding friend.\n"); - return 1; - } - - uint8_t notconnected = 1; - - while (1) { - if (tox_self_get_connection_status(tox) && notconnected) { - printf("\nDHT connected.\n"); - notconnected = 0; - } - - while (tox_friend_get_connection_status(tox, num, 0)) { - uint8_t buf[TOX_MAX_MESSAGE_LENGTH]; - ret = read(*master, buf, sizeof(buf)); - - if (ret <= 0) { - break; - } - - tox_friend_send_message(tox, num, TOX_MESSAGE_TYPE_NORMAL, buf, ret, 0); - } - - tox_iterate(tox, master); - c_sleep(1); - } -}