summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--INSTALL.md8
-rw-r--r--cmake/Dependencies.cmake1
-rw-r--r--testing/BUILD.bazel10
-rw-r--r--testing/Makefile.inc21
-rw-r--r--testing/tox_shell.c161
6 files changed, 1 insertions, 205 deletions
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)
580 580
581add_executable(Messenger_test testing/Messenger_test.c) 581add_executable(Messenger_test testing/Messenger_test.c)
582target_link_modules(Messenger_test toxmessenger) 582target_link_modules(Messenger_test toxmessenger)
583
584if(UTIL_LIBRARIES)
585 add_executable(tox_shell testing/tox_shell.c)
586 target_link_modules(tox_shell toxcore ${UTIL_LIBRARIES})
587endif()
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
43 43
44#### Secondary 44#### Secondary
45 45
46There 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. 46There 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.
47
48| Name | Type | Dependencies | Platform | Description |
49|-------------|------------|------------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------|
50| tox_shell | Executable | libtoxcore, libutil | Unix-like | Proof of concept SSH-like server software using Tox. Testing program, not intended for actual use. |
51
52There 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.
53 47
54| Name | Type | Dependencies | Platform | Description | 48| Name | Type | Dependencies | Platform | Description |
55|---------------------|------------|----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 49|---------------------|------------|----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
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)
8 8
9find_package(Threads REQUIRED) 9find_package(Threads REQUIRED)
10 10
11find_library(UTIL_LIBRARIES util )
12find_library(RT_LIBRARIES rt ) 11find_library(RT_LIBRARIES rt )
13 12
14# For toxcore. 13# 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(
42 "@sndfile", 42 "@sndfile",
43 ], 43 ],
44) 44)
45
46cc_binary(
47 name = "tox_shell",
48 srcs = ["tox_shell.c"],
49 linkopts = ["-lutil"],
50 deps = [
51 ":misc_tools",
52 "//c-toxcore/toxcore",
53 ],
54)
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) \
32 $(WINSOCK2_LIBS) 32 $(WINSOCK2_LIBS)
33 33
34 34
35
36if !WIN32
37
38noinst_PROGRAMS += tox_shell
39
40tox_shell_SOURCES = ../testing/tox_shell.c
41
42tox_shell_CFLAGS = $(LIBSODIUM_CFLAGS) \
43 $(NACL_CFLAGS)
44
45tox_shell_LDADD = $(LIBSODIUM_LDFLAGS) \
46 $(NACL_LDFLAGS) \
47 libtoxcore.la \
48 $(LIBSODIUM_LIBS) \
49 $(NACL_OBJECTS) \
50 $(NACL_LIBS) \
51 -lutil
52
53
54endif
55
56EXTRA_DIST += $(top_srcdir)/testing/misc_tools.c 35EXTRA_DIST += $(top_srcdir)/testing/misc_tools.c
57 36
58endif 37endif
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 @@
1/* Tox Shell
2 *
3 * Proof of concept ssh like server software using tox.
4 *
5 * Command line arguments are the ip, port and public_key of a node (for bootstrapping).
6 *
7 * EX: ./test 127.0.0.1 33445 CDCFD319CE3460824B33BE58FD86B8941C9585181D8FBD7C79C5721D7C2E9F7C
8 */
9
10/*
11 * Copyright © 2016-2017 The TokTok team.
12 * Copyright © 2014 Tox project.
13 *
14 * This file is part of Tox, the free peer to peer instant messenger.
15 *
16 * Tox is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * Tox is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
28 */
29#define _XOPEN_SOURCE 600
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
35#include "../toxcore/tox.h"
36#include "misc_tools.c"
37
38#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
39#include <util.h>
40#elif defined(__FreeBSD__) || defined(__DragonFly__)
41#include <libutil.h>
42#else
43#include <pty.h>
44#endif
45#include <fcntl.h>
46
47static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata)
48{
49 if (status) {
50 printf("\nOther went online.\n");
51 } else {
52 printf("\nOther went offline.\n");
53 }
54}
55
56static void print_message(Tox *tox, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *string, size_t length,
57 void *userdata)
58{
59 int master = *((int *)userdata);
60 write(master, string, length);
61 write(master, "\n", 1);
62}
63
64int main(int argc, char *argv[])
65{
66 uint8_t ipv6enabled = 1; /* x */
67 int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled);
68
69 if (argvoffset < 0) {
70 exit(1);
71 }
72
73 /* with optional --ipvx, now it can be 1-4 arguments... */
74 if ((argc != argvoffset + 2) && (argc != argvoffset + 4)) {
75 printf("Usage: %s [--ipv4|--ipv6] ip port public_key (of the DHT bootstrap node)\n", argv[0]);
76 exit(0);
77 }
78
79 int *master = (int *)malloc(sizeof(int));
80 int ret = forkpty(master, nullptr, nullptr, nullptr);
81
82 if (ret == -1) {
83 printf("fork failed\n");
84 free(master);
85 return 1;
86 }
87
88 if (ret == 0) {
89 execl("/bin/sh", "sh", nullptr);
90 return 0;
91 }
92
93 int flags = fcntl(*master, F_GETFL, 0);
94 int r = fcntl(*master, F_SETFL, flags | O_NONBLOCK);
95
96 if (r < 0) {
97 printf("error setting flags\n");
98 }
99
100 Tox *tox = tox_new(0, 0);
101 tox_callback_friend_connection_status(tox, print_online);
102 tox_callback_friend_message(tox, print_message);
103
104
105 uint16_t port = atoi(argv[argvoffset + 2]);
106 unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]);
107 int res = tox_bootstrap(tox, argv[argvoffset + 1], port, binary_string, 0);
108 free(binary_string);
109
110 if (!res) {
111 printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
112 exit(1);
113 }
114
115 uint8_t address[TOX_ADDRESS_SIZE];
116 tox_self_get_address(tox, address);
117 uint32_t i;
118
119 for (i = 0; i < TOX_ADDRESS_SIZE; i++) {
120 printf("%02X", address[i]);
121 }
122
123 char temp_id[128];
124 printf("\nEnter the address of the other id you want to sync with (38 bytes HEX format):\n");
125
126 if (scanf("%s", temp_id) != 1) {
127 return 1;
128 }
129
130 uint8_t *bin_id = hex_string_to_bin(temp_id);
131 uint32_t num = tox_friend_add(tox, bin_id, (const uint8_t *)"Install Gentoo", sizeof("Install Gentoo"), 0);
132 free(bin_id);
133
134 if (num == UINT32_MAX) {
135 printf("\nSomething went wrong when adding friend.\n");
136 return 1;
137 }
138
139 uint8_t notconnected = 1;
140
141 while (1) {
142 if (tox_self_get_connection_status(tox) && notconnected) {
143 printf("\nDHT connected.\n");
144 notconnected = 0;
145 }
146
147 while (tox_friend_get_connection_status(tox, num, 0)) {
148 uint8_t buf[TOX_MAX_MESSAGE_LENGTH];
149 ret = read(*master, buf, sizeof(buf));
150
151 if (ret <= 0) {
152 break;
153 }
154
155 tox_friend_send_message(tox, num, TOX_MESSAGE_TYPE_NORMAL, buf, ret, 0);
156 }
157
158 tox_iterate(tox, master);
159 c_sleep(1);
160 }
161}