removed all contents
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
Testing
|
||||
======
|
||||
|
||||
|
||||
|
||||
|
||||
### Unit Tests
|
||||
|
||||
To build the API unit tests:
|
||||
- `make tests`
|
||||
|
||||
All necessary binaries and scripts will be built and copied into `build/tests`.
|
||||
|
||||
Running `build/tests/test.sh` will execute the automatic API unit tests.
|
||||
|
||||
***
|
||||
|
||||
|
||||
|
||||
|
||||
### Docker Unit Tests
|
||||
|
||||
**Running all docker tests**
|
||||
|
||||
- Build the docker images: `make docker_images`
|
||||
|
||||
- Run the docker tests from the docker containers: `make docker_test`
|
||||
|
||||
- Check the results of the completed tests: `make docker_test_check`
|
||||
|
||||
Each unit test will temporarily copy all required ZeroTier binaries into its local directory, then build the `sdk_dockerfile` and `monitor_dockerfile`. Once built, each container will be run and perform tests and monitoring specified in `sdk_entrypoint.sh` and `monitor_entrypoint.sh`
|
||||
|
||||
Results will be written to the `tests/docker/_results/` directory which is a common shared volume between all containers involved in the test and will be a combination of raw and formatted dumps to files whose names reflect the test performed. In the event of failure, `FAIL.` will be prepended to the result file's name (e.g. `FAIL.my_application_1.0.2.x86_64`), likewise in the event of success, `OK.` will be prepended.
|
||||
|
||||
To run unit tests:
|
||||
|
||||
1) Disable SELinux. This is so the containers can use a shared volume to exchange MD5 sums and address information.
|
||||
|
||||
2) Set up your own network at [https://my.zerotier.com/](https://my.zerotier.com/). For our example we'll just use the Earth network (8056c2e21c000001). Use its network id as follows:
|
||||
|
||||
3) Generate two pairs of identity keys. Each public/private pair will be used by the *sdk* and *monitor* containers:
|
||||
|
||||
mkdir -p /tmp/sdk_first
|
||||
cp -f ./sdk/liblwip.so /tmp/sdk_first
|
||||
./zerotier-sdk-service -d -p8100 /tmp/sdk_first
|
||||
while [ ! -f /tmp/sdk_first/identity.secret ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
./zerotier-cli -D/tmp/sdk_first join 8056c2e21c000001
|
||||
kill `cat /tmp/sdk_first/zerotier-one.pid`
|
||||
|
||||
mkdir -p /tmp/sdk_second
|
||||
cp -f ./sdk/liblwip.so /tmp/sdk_second
|
||||
./zerotier-sdk-service -d -p8101 /tmp/sdk_second
|
||||
while [ ! -f /tmp/sdk_second/identity.secret ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
./zerotier-cli -D/tmp/sdk_second join 8056c2e21c000001
|
||||
kill `cat /tmp/sdk_second/zerotier-one.pid`
|
||||
|
||||
4) Copy the identity files to *tests/docker*. Names will be altered during copy step so the dockerfiles know which identities to use for each image/container:
|
||||
|
||||
cp /tmp/sdk_first/identity.public ./sdk/tests/docker/sdk_identity.public
|
||||
cp /tmp/sdk_first/identity.secret ./sdk/tests/docker/sdk_identity.secret
|
||||
|
||||
cp /tmp/sdk_second/identity.public ./sdk/tests/docker/monitor_identity.public
|
||||
cp /tmp/sdk_second/identity.secret ./sdk/tests/docker/monitor_identity.secret
|
||||
|
||||
|
||||
5) Place a blank network config file in the `tests/docker` directory (e.g. "8056c2e21c000001.conf")
|
||||
- This will be used to inform test-specific scripts what network to use for testing
|
||||
|
||||
After you've created your network and placed its blank config file in `tests/docker` run the following to perform unit tests for httpd:
|
||||
|
||||
./build.sh httpd
|
||||
./test.sh httpd
|
||||
|
||||
It's useful to note that the keyword *httpd* in this example is merely a substring for a test name, this means that if we replaced it with *x86_64*, *fc23*, or *nginx*, it would run all unit tests for *x86_64*, *Fedora 23*, or *nginx* respectively.
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "\n\n\n\nStarting client(s)"
|
||||
|
||||
# test.sh [udp|tcp|all] [nwid]
|
||||
TEST_EXECUTABLE_PATH="build/tests"
|
||||
protocol=$1
|
||||
NWID=$2
|
||||
HOME_DIR=$(pwd)/$TEST_EXECUTABLE_PATH
|
||||
ZT_HOME_PATH=$(pwd)/$TEST_EXECUTABLE_PATH/zerotier
|
||||
|
||||
BUILD_PATH=$(pwd)/build
|
||||
localAddr="127.0.0.1"
|
||||
|
||||
export ZT_NC_NETWORK=$ZT_HOME_PATH/nc_$NWID
|
||||
export DYLD_LIBRARY_PATH=.$HOME_DIR/libztintercept.so
|
||||
|
||||
echo "network = " $NWID
|
||||
echo "protocol = " $protocol
|
||||
echo "ZT_NC_NETWORK = " $ZT_NC_NETWORK
|
||||
echo "ZT_NC_NETWORK = " $ZT_NC_NETWORK
|
||||
|
||||
echo "ZT_HOME_PATH = " $ZT_HOME_PATH
|
||||
echo "DYLD_LIBRARY_PATH = " $DYLD_LIBRARY_PATH
|
||||
|
||||
# Start ZeroTier service
|
||||
echo "Starting ZeroTier background service..."
|
||||
mkdir -p $ZT_HOME_PATH/networks.d
|
||||
touch $ZT_HOME_PATH/networks.d/$NWID.conf
|
||||
$BUILD_PATH/zerotier-sdk-service -U -p$RANDOM $ZT_HOME_PATH &
|
||||
zt_service_pid=$!
|
||||
|
||||
if [ $protocol="tcp" ]; then
|
||||
echo "Starting TCP test..."
|
||||
random_tcp_server_port=$RANDOM
|
||||
./$TEST_EXECUTABLE_PATH/Darwin.tcp_server.out $random_tcp_server_port &
|
||||
tcp_server_pid=$!
|
||||
echo "TCP SERVER AT = " $localAddr ":" $random_tcp_server_port
|
||||
sleep 3
|
||||
./$TEST_EXECUTABLE_PATH/Darwin.tcp_client.out $localAddr $random_tcp_server_port &
|
||||
tcp_client_pid=$!
|
||||
fi
|
||||
|
||||
echo "Waiting for test to conclude..."
|
||||
sleep 5
|
||||
kill -9 $zt_service_PID $tcp_server_pid $tcp_client_pid
|
||||
@@ -1,60 +0,0 @@
|
||||
// TCP Client test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int atoi(const char *str);
|
||||
int close(int filedes);
|
||||
|
||||
#define MSG_SZ 128
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
if(argc < 3) {
|
||||
printf("usage: client <addr> <port>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sock, port = atoi(argv[2]);
|
||||
struct sockaddr_in server;
|
||||
char message[MSG_SZ] , server_reply[MSG_SZ];
|
||||
|
||||
sock = socket(AF_INET , SOCK_STREAM , 0);
|
||||
if (sock == -1) {
|
||||
printf("could not create socket");
|
||||
}
|
||||
server.sin_addr.s_addr = inet_addr(argv[1]);
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons( port );
|
||||
|
||||
printf("connecting...\n");
|
||||
if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0) {
|
||||
perror("connect failed. Error");
|
||||
return 1;
|
||||
}
|
||||
printf("\n\n\nconnected\n");
|
||||
|
||||
char *msg = "welcome to the machine!";
|
||||
|
||||
// TX
|
||||
if(send(sock, msg, strlen(msg), 0) < 0) {
|
||||
printf("send failed");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("TX: %s\n", msg);
|
||||
printf("len = %ld\n", strlen(msg));
|
||||
|
||||
int bytes_read = read(sock, server_reply, MSG_SZ);
|
||||
if(bytes_read < 0)
|
||||
printf("\tRX: Nothing\n");
|
||||
else
|
||||
printf("\tRX = (%d bytes): %s\n", bytes_read, server_reply);
|
||||
}
|
||||
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// TCP Server test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int atoi(const char *str);
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
if(argc < 2) {
|
||||
printf("usage: tcp_server <port>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sock, client_sock, c, read_size, port = atoi(argv[1]);
|
||||
char client_message[2000];
|
||||
|
||||
char str[100];
|
||||
int comm_fd;
|
||||
|
||||
struct sockaddr_in servaddr;
|
||||
struct sockaddr_in client;
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
bzero( &servaddr, sizeof(servaddr));
|
||||
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htons(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
|
||||
|
||||
printf("listening\n");
|
||||
listen(sock , 3);
|
||||
printf("waiting to accept\n");
|
||||
c = sizeof(struct sockaddr_in);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
client_sock = accept(sock, (struct sockaddr *)&client, (socklen_t*)&c);
|
||||
if (client_sock < 0) {
|
||||
perror("accept failed");
|
||||
return 0;
|
||||
}
|
||||
printf("\n\n\nconnection accepted\n reading...\n");
|
||||
|
||||
// RX
|
||||
|
||||
int msglen = 1024;
|
||||
unsigned long count = 0;
|
||||
|
||||
int bytes_read = read(client_sock, client_message, msglen);
|
||||
printf("[%lu] RX = (%d): ", count, bytes_read);
|
||||
for(int i=0; i<bytes_read; i++) {
|
||||
printf("%c", client_message[i]);
|
||||
}
|
||||
|
||||
// TX
|
||||
int bytes_written = write(client_sock, "Server here!", 12);
|
||||
printf("\t\nTX = %d\n", bytes_written);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// TCP Client test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MSGSZ 1024
|
||||
|
||||
int atoi(const char *str);
|
||||
int close(int filedes);
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
if(argc < 3) {
|
||||
printf("usage: client <addr> <port>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sock, port = atoi(argv[2]);
|
||||
struct sockaddr_in server;
|
||||
char message[MSGSZ] , server_reply[MSGSZ];
|
||||
|
||||
sock = socket(AF_INET , SOCK_STREAM , 0);
|
||||
if (sock == -1) {
|
||||
printf("could not create socket");
|
||||
}
|
||||
server.sin_addr.s_addr = inet_addr(argv[1]);
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons( port );
|
||||
|
||||
printf("connecting...\n");
|
||||
if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0) {
|
||||
perror("connect failed. Error");
|
||||
return 1;
|
||||
}
|
||||
printf("connected\n");
|
||||
|
||||
memset(message, 1, MSGSZ);
|
||||
|
||||
while(1)
|
||||
{
|
||||
//sleep(1);
|
||||
// TX
|
||||
if(send(sock, message, MSGSZ, 0) < 0) {
|
||||
printf("send failed");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("TX: %s\n", message);
|
||||
printf("len = %ld\n", strlen(message));
|
||||
|
||||
int bytes_read = read(sock, server_reply, MSGSZ);
|
||||
if(bytes_read < 0)
|
||||
printf("\tRX: Nothing\n");
|
||||
else
|
||||
printf("\tRX = (%d bytes): %s\n", bytes_read, server_reply);
|
||||
}
|
||||
}
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
// TCP Server test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#define MSGSZ 1024
|
||||
|
||||
int atoi(const char *str);
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
if(argc < 2) {
|
||||
printf("usage: tcp_server <port>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sock, client_sock, c, read_size, port = atoi(argv[1]);
|
||||
char message[MSGSZ];
|
||||
|
||||
char str[MSGSZ];
|
||||
int comm_fd;
|
||||
|
||||
struct sockaddr_in servaddr;
|
||||
struct sockaddr_in client;
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
bzero( &servaddr, sizeof(servaddr));
|
||||
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htons(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
|
||||
|
||||
printf("listening\n");
|
||||
listen(sock , 3);
|
||||
printf("waiting to accept\n");
|
||||
c = sizeof(struct sockaddr_in);
|
||||
|
||||
client_sock = accept(sock, (struct sockaddr *)&client, (socklen_t*)&c);
|
||||
if (client_sock < 0) {
|
||||
perror("accept failed");
|
||||
return 0;
|
||||
}
|
||||
printf("connection accepted\n reading...\n");
|
||||
|
||||
// RX
|
||||
|
||||
unsigned long count = 0;
|
||||
while(1)
|
||||
{
|
||||
count++;
|
||||
int bytes_read = read(client_sock, message, MSGSZ);
|
||||
printf("[%lu] RX = (%d): ", count, bytes_read);
|
||||
//for(int i=0; i<bytes_read; i++) {
|
||||
// printf("%c", message[i]);
|
||||
//}
|
||||
|
||||
// TX
|
||||
int bytes_written = write(client_sock, message, MSGSZ);
|
||||
printf("\t\nTX = %d\n", bytes_written);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "\n\n\n\nStarting server(s)"
|
||||
|
||||
# test.sh [udp|tcp|all] [nwid]
|
||||
TEST_EXECUTABLE_PATH="build/tests"
|
||||
LIB_PATH="./build/libztintercept.so"
|
||||
|
||||
PLATFORM="Linux"
|
||||
protocol=$1
|
||||
NWID=$2
|
||||
ZT_HOME_PATH=$3
|
||||
HOME_DIR=$(pwd)/$TEST_EXECUTABLE_PATH
|
||||
|
||||
BUILD_PATH=$(pwd)/build
|
||||
TEST_PATH=$(pwd)/build/tests
|
||||
localAddr="127.0.0.1"
|
||||
|
||||
export ZT_NC_NETWORK=$ZT_HOME_PATH/nc_$NWID
|
||||
export LD_PRELOAD=$LIB_PATH
|
||||
|
||||
echo "network = " $NWID
|
||||
echo "protocol = " $protocol
|
||||
echo "ZT_NC_NETWORK = " $ZT_NC_NETWORK
|
||||
echo "ZT_NC_NETWORK = " $ZT_NC_NETWORK
|
||||
echo "ZT_HOME_PATH = " $ZT_HOME_PATH
|
||||
echo "DYLD_LIBRARY_PATH = " $DYLD_LIBRARY_PATH
|
||||
|
||||
# Start ZeroTier service
|
||||
echo "Starting ZeroTier background service..."
|
||||
mkdir -p $ZT_HOME_PATH/networks.d
|
||||
touch $ZT_HOME_PATH/networks.d/$NWID.conf
|
||||
$BUILD_PATH/zerotier-sdk-service -U -p$RANDOM $ZT_HOME_PATH &
|
||||
zt_service_pid=$!
|
||||
|
||||
if [ $protocol="tcp" ]; then
|
||||
echo "Starting TCP test..."
|
||||
random_tcp_server_port=$RANDOM
|
||||
echo $random_tcp_server_port > $TEST_EXECUTABLE_PATH/tcp_server.port
|
||||
./$TEST_EXECUTABLE_PATH/$PLATFORM.tcp_server.out $random_tcp_server_port &
|
||||
tcp_server_pid=$!
|
||||
|
||||
# echo "TCP SERVER AT = " $localAddr ":" $random_tcp_server_port
|
||||
# sleep 3
|
||||
# ./$TEST_EXECUTABLE_PATH/$PLATFORM.tcp_client.out $localAddr $random_tcp_server_port &
|
||||
# tcp_client_pid=$!
|
||||
fi
|
||||
|
||||
echo "Waiting for test to conclude..."
|
||||
echo $random_tcp_server_port
|
||||
# ,$random_udp_server_port
|
||||
sleep 10
|
||||
echo "Cleaning up"
|
||||
kill -9 $zt_service_PID $tcp_server_pid $tcp_client_pid
|
||||
@@ -1,62 +0,0 @@
|
||||
// TCP Client test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int atoi(const char *str);
|
||||
int close(int filedes);
|
||||
|
||||
#define MSG_SZ 128
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
if(argc < 3) {
|
||||
printf("usage: client <addr> <port>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sock, port = atoi(argv[2]);
|
||||
struct sockaddr_in server;
|
||||
char message[MSG_SZ] , server_reply[MSG_SZ];
|
||||
|
||||
sock = socket(AF_INET , SOCK_STREAM , 0);
|
||||
if (sock == -1) {
|
||||
printf("could not create socket");
|
||||
}
|
||||
server.sin_addr.s_addr = inet_addr(argv[1]);
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons( port );
|
||||
|
||||
printf("connecting...\n");
|
||||
if (connect(sock , (struct sockaddr *)&server , sizeof(server)) < 0) {
|
||||
perror("connect failed. Error");
|
||||
return 1;
|
||||
}
|
||||
printf("connected\n");
|
||||
|
||||
char *msg = "welcome to the machine!";
|
||||
|
||||
while(1)
|
||||
{
|
||||
// TX
|
||||
if(send(sock, msg, strlen(msg), 0) < 0) {
|
||||
printf("send failed");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("TX: %s\n", msg);
|
||||
printf("len = %ld\n", strlen(msg));
|
||||
|
||||
int bytes_read = read(sock, server_reply, MSG_SZ);
|
||||
if(bytes_read < 0)
|
||||
printf("\tRX: Nothing\n");
|
||||
else
|
||||
printf("\tRX = (%d bytes): %s\n", bytes_read, server_reply);
|
||||
}
|
||||
}
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
void error(char *msg) {
|
||||
perror(msg);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int sockfd, portno, n;
|
||||
struct sockaddr_in6 serv_addr;
|
||||
struct hostent *server;
|
||||
char buffer[256] = "This is a string from client!";
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s \n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
portno = atoi(argv[2]);
|
||||
|
||||
printf("\nIPv6 TCP Client Started...\n");
|
||||
|
||||
//Sockets Layer Call: socket()
|
||||
sockfd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
if (sockfd < 0)
|
||||
error("ERROR opening socket");
|
||||
|
||||
//Sockets Layer Call: gethostbyname2()
|
||||
server = gethostbyname2(argv[1],AF_INET6);
|
||||
if (server == NULL) {
|
||||
fprintf(stderr, "ERROR, no such host\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
memset((char *) &serv_addr, 0, sizeof(serv_addr));
|
||||
serv_addr.sin6_flowinfo = 0;
|
||||
serv_addr.sin6_family = AF_INET6;
|
||||
memmove((char *) &serv_addr.sin6_addr.s6_addr, (char *) server->h_addr, server->h_length);
|
||||
serv_addr.sin6_port = htons(portno);
|
||||
|
||||
//Sockets Layer Call: connect()
|
||||
if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
|
||||
error("ERROR connecting");
|
||||
|
||||
|
||||
//Sockets Layer Call: send()
|
||||
n = send(sockfd,buffer, strlen(buffer)+1, 0);
|
||||
if (n < 0)
|
||||
error("ERROR writing to socket");
|
||||
|
||||
printf("sent %d bytes\n", n);
|
||||
memset(buffer, 0, 256);
|
||||
|
||||
//Sockets Layer Call: recv()
|
||||
printf("reading...\n");
|
||||
n = recv(sockfd, buffer, 255, 0);
|
||||
if (n < 0)
|
||||
error("ERROR reading from socket");
|
||||
printf("Message from server: %s\n", buffer);
|
||||
|
||||
//Sockets Layer Call: close()
|
||||
close(sockfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// TCP Server test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int atoi(const char *str);
|
||||
|
||||
int main(int argc , char *argv[])
|
||||
{
|
||||
if(argc < 2) {
|
||||
printf("usage: tcp_server <port>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int comm_fd, sock, client_sock, c, read_size, port = atoi(argv[1]);
|
||||
char client_message[2000];
|
||||
|
||||
struct sockaddr_in servaddr;
|
||||
struct sockaddr_in client;
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
bzero( &servaddr, sizeof(servaddr));
|
||||
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr = htons(INADDR_ANY);
|
||||
servaddr.sin_port = htons(port);
|
||||
bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
|
||||
|
||||
printf("listening\n");
|
||||
listen(sock , 3);
|
||||
printf("waiting to accept\n");
|
||||
c = sizeof(struct sockaddr_in);
|
||||
|
||||
client_sock = accept(sock, (struct sockaddr *)&client, (socklen_t*)&c);
|
||||
if (client_sock < 0) {
|
||||
perror("accept failed");
|
||||
return 0;
|
||||
}
|
||||
printf("connection accepted\n reading...\n");
|
||||
|
||||
// RX
|
||||
|
||||
int msglen = 1024;
|
||||
unsigned long count = 0;
|
||||
while(1)
|
||||
{
|
||||
count++;
|
||||
int bytes_read = read(client_sock, client_message, msglen);
|
||||
printf("[%lu] RX = (%d): ", count, bytes_read);
|
||||
for(int i=0; i<bytes_read; i++) {
|
||||
printf("%c", client_message[i]);
|
||||
}
|
||||
|
||||
// TX
|
||||
int bytes_written = write(client_sock, "Server here!", 12);
|
||||
printf("\t\nTX = %d\n", bytes_written);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
void error(char *msg) {
|
||||
perror(msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int sockfd, newsockfd, portno;
|
||||
socklen_t clilen;
|
||||
char buffer[256];
|
||||
struct sockaddr_in6 serv_addr, cli_addr;
|
||||
int n;
|
||||
char client_addr_ipv6[100];
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s \n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("\nIPv6 TCP Server Started...\n");
|
||||
|
||||
//Sockets Layer Call: socket()
|
||||
sockfd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
if (sockfd < 0)
|
||||
error("ERROR opening socket");
|
||||
|
||||
bzero((char *) &serv_addr, sizeof(serv_addr));
|
||||
portno = atoi(argv[1]);
|
||||
serv_addr.sin6_flowinfo = 0;
|
||||
serv_addr.sin6_family = AF_INET6;
|
||||
serv_addr.sin6_addr = in6addr_any;
|
||||
serv_addr.sin6_port = htons(portno);
|
||||
|
||||
|
||||
//Sockets Layer Call: bind()
|
||||
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
|
||||
error("ERROR on binding");
|
||||
|
||||
//Sockets Layer Call: listen()
|
||||
listen(sockfd, 5);
|
||||
clilen = sizeof(cli_addr);
|
||||
|
||||
//Sockets Layer Call: accept()
|
||||
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
|
||||
if (newsockfd < 0)
|
||||
error("ERROR on accept");
|
||||
|
||||
//Sockets Layer Call: inet_ntop()
|
||||
inet_ntop(AF_INET6, &(cli_addr.sin6_addr),client_addr_ipv6, 100);
|
||||
printf("Incoming connection from client having IPv6 address: %s\n",client_addr_ipv6);
|
||||
|
||||
memset(buffer,0, 256);
|
||||
|
||||
//Sockets Layer Call: recv()
|
||||
n = recv(newsockfd, buffer, 255, 0);
|
||||
if (n < 0)
|
||||
error("ERROR reading from socket");
|
||||
|
||||
printf("Message from client: %s\n", buffer);
|
||||
|
||||
//Sockets Layer Call: send()
|
||||
printf("sending...\n");
|
||||
n = send(newsockfd, "Server got your message", 23+1, 0);
|
||||
if (n < 0)
|
||||
error("ERROR writing to socket");
|
||||
|
||||
//Sockets Layer Call: close()
|
||||
close(sockfd);
|
||||
close(newsockfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Performing unit tests..."
|
||||
|
||||
chmod 755 build/tests/servers.sh
|
||||
chmod 755 build/tests/clients.sh
|
||||
|
||||
./servers.sh $1 $2 $3 &
|
||||
sleep 3
|
||||
./clients.sh $1 $2 $3 &
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* udpclient.c - A simple UDP client
|
||||
* usage: udpclient <host> <port>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
/*
|
||||
* error - wrapper for perror
|
||||
*/
|
||||
void error(char *msg) {
|
||||
perror(msg);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int sock, portno, n;
|
||||
int serverlen;
|
||||
struct sockaddr_in serveraddr;
|
||||
struct hostent *server;
|
||||
char *hostname;
|
||||
char buf[BUFSIZE];
|
||||
|
||||
/* check command line arguments */
|
||||
if (argc != 3) {
|
||||
fprintf(stderr,"usage: %s <hostname> <port>\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
hostname = argv[1];
|
||||
portno = atoi(argv[2]);
|
||||
|
||||
/* socket: create the socket */
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0)
|
||||
error("ERROR opening socket");
|
||||
|
||||
/* gethostbyname: get the server's DNS entry */
|
||||
server = gethostbyname(hostname);
|
||||
if (server == NULL) {
|
||||
fprintf(stderr,"ERROR, no such host as %s\n", hostname);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* build the server's Internet address */
|
||||
bzero((char *) &serveraddr, sizeof(serveraddr));
|
||||
serveraddr.sin_family = AF_INET;
|
||||
bcopy((char *)server->h_addr,
|
||||
(char *)&serveraddr.sin_addr.s_addr, server->h_length);
|
||||
serveraddr.sin_port = htons(portno);
|
||||
|
||||
/* get a message from the user */
|
||||
char *msg = "A message to the server!\0";
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
long count = 0;
|
||||
while(1)
|
||||
{
|
||||
count++;
|
||||
printf("\n\n\nTX(%lu)...\n", count);
|
||||
sleep(1);
|
||||
//usleep(10000);
|
||||
//bzero(buf, BUFSIZE);
|
||||
//printf("\nPlease enter msg: ");
|
||||
//fgets(buf, BUFSIZE, stdin);
|
||||
|
||||
/* send the message to the server */
|
||||
serverlen = sizeof(serveraddr);
|
||||
n = sendto(sock, msg, strlen(msg), 0, (struct sockaddr *)&serveraddr, serverlen);
|
||||
//if (n < 0)
|
||||
// error("ERROR in sendto");
|
||||
|
||||
/* print the server's reply */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
n = recvfrom(sock, buf, BUFSIZE, 0, (struct sockaddr *)&serveraddr, (socklen_t *)&serverlen);
|
||||
//if (n < 0)
|
||||
// printf("ERROR in recvfrom: %d", n);
|
||||
printf("Echo from server: %s", buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAXBUF 65536
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int status;
|
||||
struct addrinfo sainfo, *psinfo;
|
||||
struct hostent *server;
|
||||
char buffer[MAXBUF];
|
||||
|
||||
int sock, portno, n;
|
||||
struct sockaddr_in6 serv_addr;
|
||||
|
||||
if(argc < 2)
|
||||
printf("Specify a port number\n"), exit(1);
|
||||
|
||||
sock = socket(PF_INET6, SOCK_DGRAM,0);
|
||||
|
||||
portno = atoi(argv[2]);
|
||||
server = gethostbyname2(argv[1],AF_INET6);
|
||||
memset((char *) &serv_addr, 0, sizeof(serv_addr));
|
||||
serv_addr.sin6_flowinfo = 0;
|
||||
serv_addr.sin6_family = AF_INET6;
|
||||
memmove((char *) &serv_addr.sin6_addr.s6_addr, (char *) server->h_addr, server->h_length);
|
||||
serv_addr.sin6_port = htons(portno);
|
||||
|
||||
sprintf(buffer,"Ciao");
|
||||
|
||||
status = sendto(sock, buffer, strlen(buffer), 0, (const struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||
printf("buffer : %s \t%d\n", buffer, status);
|
||||
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
// UDP Server test program
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#define MAXBUF 1024*1024
|
||||
|
||||
void echo(int sock) {
|
||||
char bufin[MAXBUF];
|
||||
struct sockaddr_in remote;
|
||||
int n;
|
||||
socklen_t len = sizeof(remote);
|
||||
long count = 0;
|
||||
|
||||
while (1) {
|
||||
sleep(1);
|
||||
//usleep(50);
|
||||
count++;
|
||||
// read a datagram from the socket (put result in bufin)
|
||||
n=recvfrom(sock,bufin,MAXBUF,0,(struct sockaddr *)&remote,&len);
|
||||
// print out the address of the sender
|
||||
printf("DGRAM from %s:%d\n", inet_ntoa(remote.sin_addr), ntohs(remote.sin_port));
|
||||
|
||||
if (n<0) {
|
||||
perror("Error receiving data");
|
||||
} else {
|
||||
printf("GOT %d BYTES (count = %ld)\n", n, count);
|
||||
// Got something, just send it back
|
||||
// sendto(sock,bufin,n,0,(struct sockaddr *)&remote,len);
|
||||
printf("RX = %s\n", bufin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if(argc < 2) {
|
||||
printf("usage: udp_server <port>\n");
|
||||
return 0;
|
||||
}
|
||||
int sock, port = atoi(argv[1]);
|
||||
socklen_t len;
|
||||
struct sockaddr_in skaddr;
|
||||
struct sockaddr_in skaddr2;
|
||||
|
||||
// Create socket
|
||||
if ((sock = socket( PF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
printf("error creating socket\n");
|
||||
return 0;
|
||||
}
|
||||
// Create address
|
||||
skaddr.sin_family = AF_INET;
|
||||
skaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
skaddr.sin_port = htons(port);
|
||||
// Bind to address
|
||||
if (bind(sock, (struct sockaddr *) &skaddr, sizeof(skaddr))<0) {
|
||||
printf("error binding\n");
|
||||
return 0;
|
||||
}
|
||||
// find out what port we were assigned
|
||||
len = sizeof( skaddr2 );
|
||||
//if (getsockname(sock, (struct sockaddr *) &skaddr2, &len)<0) {
|
||||
// printf("error getsockname\n");
|
||||
// return 0;
|
||||
//}
|
||||
// Display address:port to verify it was sent over RPC correctly
|
||||
/*
|
||||
port = ntohs(skaddr2.sin_port);
|
||||
int ip = skaddr2.sin_addr.s_addr;
|
||||
unsigned char d[4];
|
||||
d[0] = ip & 0xFF;
|
||||
d[1] = (ip >> 8) & 0xFF;
|
||||
d[2] = (ip >> 16) & 0xFF;
|
||||
d[3] = (ip >> 24) & 0xFF;
|
||||
printf("bound to address: %d.%d.%d.%d : %d\n", d[0],d[1],d[2],d[3], port);
|
||||
*/
|
||||
// RX
|
||||
echo(sock);
|
||||
return(0);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAXBUF 65536
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int sock;
|
||||
int n;
|
||||
struct sockaddr_in6 sin6;
|
||||
socklen_t sin6len;
|
||||
char buffer[MAXBUF];
|
||||
|
||||
sock = socket(PF_INET6, SOCK_DGRAM,0);
|
||||
sin6len = sizeof(struct sockaddr_in6);
|
||||
memset(&sin6, 0, sin6len);
|
||||
|
||||
sin6.sin6_port = htons(atoi(argv[1]));
|
||||
sin6.sin6_family = AF_INET6;
|
||||
sin6.sin6_addr = in6addr_any;
|
||||
|
||||
n = bind(sock, (struct sockaddr *)&sin6, sin6len);
|
||||
if(-1 == n)
|
||||
perror("bind"), exit(1);
|
||||
|
||||
//n = getsockname(sock, (struct sockaddr *)&sin6, &sin6len);
|
||||
//printf("%d\n", ntohs(sin6.sin6_port));
|
||||
|
||||
while (1) {
|
||||
sleep(1);
|
||||
n = recvfrom(sock, buffer, MAXBUF, 0, (struct sockaddr *)&sin6, &sin6len);
|
||||
printf("n = %d, buffer : %s\n", n, buffer);
|
||||
}
|
||||
|
||||
shutdown(sock, 2);
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
killall zerotier-sdk-service
|
||||
|
||||
killall Darwin.tcp_server.out
|
||||
killall Darwin.tcp_client.out
|
||||
killall Darwin.udp_server.out
|
||||
killall Darwin.udp_client.out
|
||||
|
||||
killall Linux.tcp_server.out
|
||||
killall Linux.tcp_client.out
|
||||
killall Linux.udp_server.out
|
||||
killall Linux.udp_client.out
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete all containers
|
||||
docker rm $(docker ps -a -q)
|
||||
# Delete all images
|
||||
docker rmi $(docker images -q)
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Runs test image and monitor image as daemons
|
||||
test_name=${PWD##*/}
|
||||
echo 'Starting containers for: ' "$test_name"
|
||||
touch "$test_name".name
|
||||
test_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name":latest)
|
||||
monitor_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name"_monitor:latest)
|
||||
|
||||
echo "waiting $sdk_test_wait_time for test to complete."
|
||||
sleep $sdk_test_wait_time
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $test_container
|
||||
docker rm $monitor_container
|
||||
|
||||
rm -f *.name
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Merely BUILDS test images
|
||||
|
||||
# Remove previous test results
|
||||
rm _results/*.txt
|
||||
|
||||
# How long we shall wait for each test to conclude
|
||||
export sdk_test_wait_time=60s
|
||||
export image_build_script=_build_single_image.sh
|
||||
|
||||
# Iterate over all depth=2 (relatively-speaking) directories and perform each test
|
||||
find . -mindepth 2 -maxdepth 2 -type d | while read testdir; do
|
||||
|
||||
if [[ $testdir != *$1* ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "\n\n\n*** Building: '$testdir'..."
|
||||
rm _results/*.tmp
|
||||
|
||||
# Stage scripts
|
||||
cp $image_build_script $testdir/$image_build_script
|
||||
cd $testdir
|
||||
|
||||
# Build test docker images
|
||||
./$image_build_script
|
||||
rm $image_build_script
|
||||
|
||||
cd ../../
|
||||
done
|
||||
@@ -1,30 +0,0 @@
|
||||
# Builds a test docker image
|
||||
|
||||
test_name=${PWD##*/}
|
||||
echo 'Building dockerfiles for test: ' "$test_name"
|
||||
touch "$test_name".name
|
||||
|
||||
# Docker won't allow the inclusion of files outside of the build directory
|
||||
cp ../../*.conf .
|
||||
cp ../../zerotier-one zerotier-one
|
||||
cp ../../zerotier-cli zerotier-cli
|
||||
cp ../../zerotier-cli zerotier-sdk-service
|
||||
cp ../../zerotier-intercept zerotier-intercept
|
||||
cp ../../libztintercept.so libztintercept.so
|
||||
cp ../../liblwip.so liblwip.so
|
||||
cp ../../sdk_identity.public sdk_identity.public
|
||||
cp ../../sdk_identity.secret sdk_identity.secret
|
||||
cp ../../monitor_identity.public monitor_identity.public
|
||||
cp ../../monitor_identity.secret monitor_identity.secret
|
||||
|
||||
docker build --tag="$test_name" -f sdk_dockerfile .
|
||||
docker build --tag="$test_name"_monitor -f monitor_dockerfile .
|
||||
|
||||
rm -f zerotier-cli
|
||||
rm -f zerotier-sdk-service
|
||||
rm -f zerotier-intercept
|
||||
rm -f *.so
|
||||
rm -f *.public
|
||||
rm -f *.secret
|
||||
rm -f *.conf
|
||||
rm -f *.name
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Runs test image and monitor image as daemons
|
||||
test_name=${PWD##*/}
|
||||
echo 'Starting containers for: ' "$test_name"
|
||||
touch "$test_name".name
|
||||
test_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name":latest)
|
||||
monitor_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name"_monitor:latest)
|
||||
|
||||
echo "waiting $sdk_test_wait_time for test to complete."
|
||||
sleep $sdk_test_wait_time
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $test_container
|
||||
docker rm $monitor_container
|
||||
|
||||
rm -f *.name
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install darkhttpd-1.11
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '--- Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of="$bigfile_name" bs="$bigfile_size" count=1
|
||||
md5sum < "$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
darkhttpd /
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install httpd-2.4.16-1.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '--- Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of=/var/www/html/"$bigfile_name" bs="$bigfile_size" count=1
|
||||
md5sum < /var/www/html/"$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
rm -rf /run/httpd/* /tmp/httpd*
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
/usr/sbin/httpd -X
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM ubuntu:14.04
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
RUN \
|
||||
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install apache2
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '--- Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of=/var/www/html/"$bigfile_name" bs="$bigfile_size" count=1
|
||||
md5sum < /var/www/html/"$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
rm -rf /run/httpd/* /tmp/httpd*
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
/usr/sbin/httpd -X
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Runs test image and monitor image as daemons
|
||||
test_name=${PWD##*/}
|
||||
echo 'Starting containers for: ' "$test_name"
|
||||
touch "$test_name".name
|
||||
test_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name":latest)
|
||||
monitor_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name"_monitor:latest)
|
||||
|
||||
echo "waiting $sdk_test_wait_time for test to complete."
|
||||
sleep $sdk_test_wait_time
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $test_container
|
||||
docker rm $monitor_container
|
||||
|
||||
rm -f *.name
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install httpd-2.4.18-1.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of=/var/www/html/"$bigfile_name" bs="$bigfile_size" count=1
|
||||
#md5sum /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
|
||||
md5sum < /var/www/html/"$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
rm -rf /run/httpd/* /tmp/httpd*
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
/usr/sbin/httpd -X
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
@@ -1,69 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="http://bootswatch.com/cosmo/bootstrap.min.css">
|
||||
<title>ZeroTier SDK Preview</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<br><br>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-1 col-xs-offset-1"><img src="ZeroTierIcon.png" style="width: 100%; height: 100%;"></div>
|
||||
<div class="col-xs-9">
|
||||
<h1>ZeroTier SDK Preview</h1>
|
||||
(a.k.a. super bleeding edge pre-alphe pre-release demo)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<hr>
|
||||
<br>
|
||||
|
||||
<div class="container-fluid"><div class="row"><div class="col-xs-10 col-xs-offset-1 lead">
|
||||
|
||||
<p><b>This page is being served from a Docker container with its own private TCP/IP microservice.</b></p>
|
||||
|
||||
<p>
|
||||
It's connected to a virtual network, but if you "docker exec" into it and look around you won't find any special devices. No special privileges or configuration changes on the Docker host were needed. Everything is completely "stock" and completely self-contained.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There's nothing special about the web server. It's just Apache. There's nothing special about the Linux image. It's based on a regular Fedora Docker base image. Other than Apache, the only thing this image contains is the ZeroTier network containers microservice and dynamic library.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When Apache is run, our launcher script configures it to load a special dynamic library. This library intercepts calls to the Linux C networking API, redirecting network I/O to our private network stack microservice instead of the standard Linux kernel network path. This microservice takes care of the rest, automatically encapsulating traffic and sending it over the virtual network instead of the physical.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It's a bit like how networking would work on a microkernel: modular, composable, portable, and independent.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
SDK allows a Docker (or LXC, CoreOS/rkt, runc, OpenVZ, SmartOS/Triton, <a target="_blank" href="https://github.com/p8952/bocker">bocker</a>, or even just bare metal Linux) system to connect to virtual networks without requiring <u>any</u> special permissions or special configuration on the host node. Processes inside the container don't even need to run with root permissions. It's 100% user-space, making it ideal for multi-tenant deployments or any other situation where modifying the configuration of the host node is impossible or just inconvenient.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Once properly tuned and optimized, SDK also has the potential to be much faster than tun/tap or pcap based network overlays. It imposes only a single context switch from application/service to virtual network microservice as opposed to at least four for tun/tap and pcap-based solutions, since the latter require two trips through the kernel network stack. We believe it may be possible to approach or even equal the performance of VXLAN/IPSec or other fully kernel-mode configurations, but with the ease and total independence of a fully container-based solution.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
We created this container image to show you a preview of one of the projects we've been working on at ZeroTier. We still have a good deal of packaging, testing, and performance optimization work to do before SDK will be ready for a real public beta release. Follow the <a href="https://www.zerotier.com/blog">blog</a> or <a href="https://twitter.com/zerotier">@zerotier</a> for updates and announcements.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
P.S. If you want to use ZeroTier in Docker today, you can do it with the same ZeroTier One endpoint service you're using to access this network. The only catch is that you have to launch your containers with "--device=/dev/net/tun --cap-add=NET_ADMIN". SDK eliminates the need for these special options.
|
||||
</p>
|
||||
|
||||
</div></div></div>
|
||||
|
||||
<hr>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,25 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /
|
||||
RUN mkdir -p ext/bin/lwip
|
||||
RUN cp liblwip.so ext/bin/lwip/liblwip.so
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,86 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=25 # wait for test container to come online
|
||||
app_timeout_time=15 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
echo '*** Waiting for initial identity generation...'
|
||||
while [ ! -s /var/lib/zerotier-one/identity.secret ]; do
|
||||
sleep 0.2
|
||||
done
|
||||
echo '*** Waiting for network config...'
|
||||
virtip4=""
|
||||
while [ ! -s /var/lib/zerotier-one/networks.d/"$nwconf" ]; do
|
||||
sleep 0.2
|
||||
done
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" >> "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ $rx_md5sum != $tx_md5sum ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install httpd-2.4.17-3.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
#include Apache
|
||||
ADD htdocs/index.html /
|
||||
ADD htdocs/ZeroTierIcon.png /
|
||||
RUN mv index.html /var/www/html/index.html
|
||||
RUN mv ZeroTierIcon.png /var/www/html/ZeroTierIcon.png
|
||||
|
||||
# Install syscall intercept library
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /
|
||||
RUN mkdir -p ext/bin/lwip
|
||||
RUN cp liblwip.so ext/bin/lwip/liblwip.so
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
echo '*** Waiting for initial identity generation...'
|
||||
while [ ! -s /var/lib/zerotier-one/identity.secret ]; do
|
||||
sleep 0.2
|
||||
done
|
||||
echo '*** Waiting for network config...'
|
||||
virtip4=""
|
||||
while [ ! -s /var/lib/zerotier-one/networks.d/"$nwconf" ]; do
|
||||
sleep 0.2
|
||||
done
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of=/var/www/html/"$bigfile_name" bs="$bigfile_size" count=1
|
||||
#md5sum /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
|
||||
md5sum < /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
rm -rf /run/httpd/* /tmp/httpd*
|
||||
zerotier-intercept /usr/sbin/httpd -X
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
#listen [::]:80 default_server;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM ubuntu:14.04
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
|
||||
# Install
|
||||
RUN \
|
||||
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install nginx
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
ADD nginx.conf_ /
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls {*.conf,}) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
cp -f nginx.conf_ /etc/nginx/nginx.conf
|
||||
nginx_html_path=/usr/share/nginx/html/
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of="$nginx_html_path$bigfile_name" bs="$bigfile_size" count=1
|
||||
#md5sum /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
|
||||
md5sum < "$nginx_html_path$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
nginx
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Runs test image and monitor image as daemons
|
||||
test_name=${PWD##*/}
|
||||
echo 'Starting containers for: ' "$test_name"
|
||||
touch "$test_name".name
|
||||
test_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name":latest)
|
||||
monitor_container=$(docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$test_name"_monitor:latest)
|
||||
|
||||
echo "waiting $sdk_test_wait_time for test to complete."
|
||||
sleep $sdk_test_wait_time
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $test_container
|
||||
docker rm $monitor_container
|
||||
|
||||
rm -f *.name
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
#listen [::]:80 default_server;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install nginx-1:1.8.0-13.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
ADD nginx.conf_ /
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls {*.conf,}) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
cp -f nginx.conf_ /etc/nginx/nginx.conf
|
||||
nginx_html_path=/usr/share/nginx/html/
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of="$nginx_html_path$bigfile_name" bs="$bigfile_size" count=1
|
||||
#md5sum /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
|
||||
md5sum < "$nginx_html_path$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
nginx
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
#listen [::]:80 default_server;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install nginx-1:1.8.0-14.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
ADD nginx.conf_ /
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls {*.conf,}) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
cp -f nginx.conf_ /etc/nginx/nginx.conf
|
||||
nginx_html_path=/usr/share/nginx/html/
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of="$nginx_html_path$bigfile_name" bs="$bigfile_size" count=1
|
||||
#md5sum /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
|
||||
md5sum < "$nginx_html_path$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
nginx
|
||||
@@ -1,7 +0,0 @@
|
||||
var http = require('http');
|
||||
var server = http.createServer(function (request, response) {
|
||||
response.writeHead(200, {"Content-Type": "text/plain"});
|
||||
response.end("welcome to the machine!\n");
|
||||
});
|
||||
server.listen(8080);
|
||||
console.log("Server running!");
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=25 # wait for test container to come online
|
||||
app_timeout_time=15 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
response_string=$(curl --connect-timeout "$app_timeout_time" -v http://"$ncvirtip":8080/)
|
||||
|
||||
if [[ $response_string == *"welcome to the machine!"* ]]
|
||||
then
|
||||
echo 'NODEJS RESPONSE OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: nodejs-server responded!\n' >> "$file_path$ok$test_name.txt"
|
||||
else
|
||||
echo 'NODEJS RESPONSE FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: nodejs server did NOT respond!\n' >> "$file_path$fail$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install nodejs
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 8080/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
#
|
||||
ADD httpserver.js /
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
node httpserver.js
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install python
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '--- Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of="$bigfile_name" bs="$bigfile_size" count=1
|
||||
md5sum < "$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
python -m SimpleHTTPServer 80
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=35 # wait for test container to come online
|
||||
app_timeout_time=25 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Curling from intercepted server at' $ncvirtip
|
||||
rm -rf "$file_path"*."$file_base"
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Perform test
|
||||
# curl --connect-timeout "$app_timeout_time" -v -o "$file_path$file_base" http://"$ncvirtip"/index.html
|
||||
# Large transfer test
|
||||
curl --connect-timeout "$app_timeout_time" -v -o "$bigfile_name" http://"$ncvirtip"/"$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
rx_md5sum=$(<$rx_md5sumfile)
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
echo '*** Comparing md5: ' "$rx_md5sum" ' and ' "$tx_md5sum"
|
||||
|
||||
if [ "$rx_md5sum" != "$tx_md5sum" ];
|
||||
then
|
||||
echo 'MD5 FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: md5 sum did not match!\n' >> "$file_path$fail$test_name.txt"
|
||||
else
|
||||
echo 'MD5 OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: md5 sum ok!\n' >> "$file_path$ok$test_name.txt"
|
||||
cat "$rx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
cat "$tx_md5sumfile" >> "$file_path$ok$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp 80/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
ADD zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '--- Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of="$bigfile_name" bs="$bigfile_size" count=1
|
||||
md5sum < "$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
python3 -m http.server 80
|
||||
@@ -1,3 +0,0 @@
|
||||
local msg = "welcome to the machine!"
|
||||
redis.call("SET", "msg", msg)
|
||||
return redis.call("GET", "msg")
|
||||
@@ -1,28 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD hello.lua /
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=25 # wait for test container to come online
|
||||
app_timeout_time=15 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Running lua script against redis host at' $ncvirtip
|
||||
redis-cli -h $ncvirtip EVAL "$(cat hello.lua)" 0 > redis_response.txt
|
||||
response_string=$(<redis_response.txt)
|
||||
|
||||
if [[ $response_string == *"welcome to the machine!"* ]]
|
||||
then
|
||||
echo 'REDIS RESPONSE OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: redis-server responded!\n' >> "$file_path$ok$test_name.txt"
|
||||
else
|
||||
echo 'REDIS RESPONSE FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: redis server did NOT respond!\n' >> "$file_path$fail$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
EXPOSE 9993/udp 6379/udp
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
Add zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
/usr/bin/redis-server --port 6379
|
||||
@@ -1,24 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=25 # wait for test container to come online
|
||||
app_timeout_time=15 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile # large, random test transfer file
|
||||
rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the Network Container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Copying file to intercepted server at' $ncvirtip
|
||||
touch "$bigfile_name"
|
||||
|
||||
# Check md5
|
||||
md5sum < "$bigfile_name" > "$rx_md5sumfile"
|
||||
tx_md5sum=$(<$tx_md5sumfile)
|
||||
|
||||
# ...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install openssh-server
|
||||
RUN yum clean all
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,52 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
bigfile_name=bigfile
|
||||
bigfile_size=10M # size of file we want to use for the test
|
||||
tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
|
||||
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
./zerotier-one -d -U -p9993
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
export ZT_NC_NWID=$dev
|
||||
|
||||
# --- Test section ---
|
||||
# Generate large random file for transfer test, share md5sum for monitor container to check
|
||||
echo '*** Generating ' "$bigfile_size" ' file'
|
||||
dd if=/dev/urandom of=/var/www/html/"$bigfile_name" bs="$bigfile_size" count=1
|
||||
md5sum < /var/www/html/"$bigfile_name" > "$tx_md5sumfile"
|
||||
echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
|
||||
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
# wait for rsa public key from monitor
|
||||
#while [ ! -s "$file_path$rsa_public_key_file" ]; do
|
||||
# sleep 0.2
|
||||
#done
|
||||
|
||||
zerotier-intercept /usr/sbin/sshd
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Runs test images
|
||||
|
||||
echo "*** Running unit tests..."
|
||||
|
||||
# Remove previous test results
|
||||
rm _results/*.txt
|
||||
|
||||
# How long we shall wait for each test to conclude
|
||||
export sdk_test_wait_time=60s
|
||||
|
||||
# Test structure, in later releases more complex multi-party scripts will be included
|
||||
export test_script=_two_party_test.sh
|
||||
|
||||
# Iterate over all depth=2 (relatively-speaking) directories and perform each test
|
||||
find . -mindepth 2 -maxdepth 2 -type d | while read testdir; do
|
||||
|
||||
if [[ $testdir != *$1* ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "*** Testing: '$testdir'..."
|
||||
rm _results/*.tmp
|
||||
|
||||
# Stage scripts
|
||||
cp $test_script $testdir/$test_script
|
||||
cd $testdir
|
||||
|
||||
# Run test
|
||||
./$test_script
|
||||
rm $test_script
|
||||
|
||||
cd ../../
|
||||
done
|
||||
|
||||
echo "*** Done"
|
||||
@@ -1,10 +0,0 @@
|
||||
var http = require('http');
|
||||
|
||||
var server = http.createServer(function (request, response) {
|
||||
response.writeHead(200, {"Content-Type": "text/plain"});
|
||||
response.end("Welcome to the machine!\n");
|
||||
});
|
||||
|
||||
server.listen(8777);
|
||||
|
||||
console.log("Server running at http://127.0.0.1:8777/");
|
||||
@@ -1,4 +0,0 @@
|
||||
Unit Test Results
|
||||
====
|
||||
|
||||
This directory contains the temporary and resultant output files for the docker-based unit tests. Upon the conclusion of the suite of unit tests a check will be run, and all files in this directory will be deleted. See `start.sh` for more information.
|
||||
@@ -1,13 +0,0 @@
|
||||
# Calls target in makefile to build docker images and execute unit tests
|
||||
|
||||
# lwIP
|
||||
make clean; make -f make-linux.mk unit_test SDK_DEBUG=1 SDK_LWIP=1 SDK_IPV4=1
|
||||
./tests/unit/docker/start.sh
|
||||
make clean; make -f make-linux.mk unit_test SDK_DEBUG=1 SDK_LWIP=1 SDK_IPV6=1
|
||||
./tests/unit/docker/start.sh
|
||||
|
||||
# picoTCP
|
||||
make clean; make -f make-linux.mk unit_test SDK_DEBUG=1 SDK_PICOTCP=1 SDK_IPV4=1
|
||||
./tests/unit/docker/start.sh
|
||||
make clean; make -f make-linux.mk unit_test SDK_DEBUG=1 SDK_PICOTCP=1 SDK_IPV6=1
|
||||
./tests/unit/docker/start.sh
|
||||
@@ -1,94 +0,0 @@
|
||||
Docker + ZeroTier SDK
|
||||
====
|
||||
|
||||
Welcome!
|
||||
|
||||
Imagine a flat, encrypted, no-configuration LAN for all of your Docker containers.
|
||||
|
||||
This short tutorial will show you how to enable ZeroTier functionality for your Docker software container with little to no configuration. In this example we aim to build a Docker container with ZeroTier’s Network Container service bundled right in so that it’s effortless to hook any number of your services in the container up to your virtual network. Alternatively, you can check out a docker project directory [here](docker_demo).
|
||||
|
||||
|
||||
**Step 1: Build ZeroTier shared library**
|
||||
|
||||
`make linux_shared_lib`
|
||||
- For debug output from the SDK, use `make linux_shared_lib SDK_DEBUG=1`, or `make linux_shared_lib ZT_DEBUG=1` to see debug output from the ZeroTier service.
|
||||
|
||||
**Step 2: Build your Docker image**
|
||||
|
||||
`docker build --tag=redis_test .`
|
||||
|
||||
The example dockerfile below incorperates a few important elements:
|
||||
|
||||
1) The ZeroTier service binaries
|
||||
2) Whatever ZeroTier identity keys you plan on using (if you don't already have keys you wish to use, fret not! A new identity will be generated automatically).
|
||||
3) The service we've chosen to use. In this case, redis.
|
||||
```
|
||||
FROM fedora:23
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||
RUN yum clean all
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
EXPOSE 9993/udp 6379/udp
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libztintercept
|
||||
ADD zerotier-cli /
|
||||
Add zerotier-sdk-service /
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
```
|
||||
|
||||
**Step 3: Start container**
|
||||
|
||||
`docker run -d -it redis_test /bin/bash`
|
||||
|
||||
**Step 4: From container, set up environment variables**
|
||||
|
||||
Set our application pre-load with `export LD_PRELOAD=./libztintercept.so`. This dynamically loads our intercept library into your application which allows us to re-direct its network calls to our virtual network.
|
||||
|
||||
Tell the ZeroTier Network Containers service which network to connect to with `export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_XXXXXXXXXXXXXXXX`.
|
||||
|
||||
**Step 5: Run your new ZeroTier-enabled service**
|
||||
|
||||
At this point, simply run your application as you normally would. It will be automatically intercepted and linked to the ZeroTier service (and hence your virtual networks!)
|
||||
|
||||
`/usr/bin/redis-server --port 6379`
|
||||
|
||||
***
|
||||
**Additional info**
|
||||
If you'd like to know the IP address your service can be reached at on this particular virtual network, use the following:
|
||||
`zerotier-cli -D/var/lib/zerotier-one/nc_XXXXXXXXXXXXXXXX listnetworks`
|
||||
|
||||
## Installing in a Docker container (or any other container engine)
|
||||
|
||||
If it's not immediately obvious, installation into a Docker container is easy. Just install `zerotier-sdk-service`, `libztintercept.so`, and `liblwip.so` into the container at an appropriate locations. We suggest putting it all in `/var/lib/zerotier-one` since this is the default ZeroTier home and will eliminate the need to supply a path to any of ZeroTier's services or utilities. Then, in your Docker container entry point script launch the service with *-d* to run it in the background, set the appropriate environment variables as described above, and launch your container's main application.
|
||||
|
||||
The only bit of complexity is configuring which virtual network to join. ZeroTier's service automatically joins networks that have `.conf` files in `ZTHOME/networks.d` even if the `.conf` file is empty. So one way of doing this very easily is to add the following commands to your Dockerfile or container entry point script:
|
||||
|
||||
mkdir -p /var/lib/zerotier-one/networks.d
|
||||
touch /var/lib/zerotier-one/networks.d/8056c2e21c000001.conf
|
||||
|
||||
Replace 8056c2e21c000001 with the network ID of the network you want your container to automatically join. It's also a good idea in your container's entry point script to add a small loop to wait until the container's instance of ZeroTier generates an identity and comes online. This could be something like:
|
||||
|
||||
/var/lib/zerotier-one/zerotier-sdk-service -d
|
||||
while [ ! -f /var/lib/zerotier-one/identity.secret ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
# zerotier-sdk-service is now running and has generated an identity
|
||||
|
||||
(Be sure you don't bundle the identity into the container, otherwise every container will try to be the same device and they will "fight" over the device's address.)
|
||||
|
||||
Now each new instance of your container will automatically join the specified network on startup. Authorizing the container on a private network still requires a manual authorization step either via the ZeroTier Central web UI or the API. We're working on some ideas to automate this via bearer token auth or similar since doing this manually or with scripts for large deployments is tedious.
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete all containers
|
||||
docker rm $(docker ps -a -q)
|
||||
# Delete all images
|
||||
docker rmi $(docker images -q)
|
||||
@@ -1,7 +0,0 @@
|
||||
Simple Docker Demo
|
||||
====
|
||||
|
||||
- Type `make docker_demo` to build an image with the SDK pre-installed and a test image to serve as a monitor
|
||||
- From this local directory, start both containers with `./start.sh`
|
||||
|
||||
Results of the test can be found in `_results`
|
||||
@@ -1,3 +0,0 @@
|
||||
local msg = "welcome to the machine!"
|
||||
redis.call("SET", "msg", msg)
|
||||
return redis.call("GET", "msg")
|
||||
@@ -1,28 +0,0 @@
|
||||
# ZT SDK Test Monitor
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||
|
||||
EXPOSE 9993/udp
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
ADD hello.lua /
|
||||
|
||||
ADD zerotier-one /
|
||||
ADD zerotier-cli /
|
||||
|
||||
# Start ZeroTier-One
|
||||
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||
RUN chmod -v +x /monitor_entrypoint.sh
|
||||
CMD ["./monitor_entrypoint.sh"]
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
sdk_wait_time=60 # wait for test container to come online
|
||||
app_timeout_time=15 # app-specific timeout
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
fail=FAIL. # appended to result file in event of failure
|
||||
ok=OK. # appended to result file in event of success
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test Monitor'
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
done
|
||||
echo '*** Starting Test...'
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the container to come online...'
|
||||
sleep "$sdk_wait_time"s
|
||||
ncvirtip=$(<$address_file)
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Running lua script against redis host at' $ncvirtip
|
||||
redis-cli -h $ncvirtip EVAL "$(cat hello.lua)" 0 > redis_response.txt
|
||||
response_string=$(<redis_response.txt)
|
||||
|
||||
|
||||
if [[ $response_string == *"welcome to the machine!"* ]]
|
||||
then
|
||||
echo 'REDIS RESPONSE OK'
|
||||
touch "$file_path$ok$test_name.txt"
|
||||
printf 'Test: redis-server responded!\n' >> "$file_path$ok$test_name.txt"
|
||||
else
|
||||
echo 'REDIS RESPONSE FAIL'
|
||||
touch "$file_path$fail$test_name.txt"
|
||||
printf 'Test: redis server did NOT respond!\n' >> "$file_path$fail$test_name.txt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# ZT SDK Test
|
||||
FROM fedora:23
|
||||
MAINTAINER https://www.zerotier.com/
|
||||
|
||||
# Install apps
|
||||
RUN yum -y update
|
||||
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||
RUN yum clean all
|
||||
|
||||
# Add ZT files
|
||||
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||
ADD *.conf /
|
||||
ADD *.name /
|
||||
|
||||
EXPOSE 9993/udp 6379/udp
|
||||
|
||||
# Install LWIP library used by service
|
||||
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||
|
||||
# Install syscall intercept library
|
||||
ADD libztintercept.so /
|
||||
RUN cp libztintercept.so lib/libztintercept.so
|
||||
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||
|
||||
ADD zerotier-cli /
|
||||
Add zerotier-sdk-service /
|
||||
|
||||
# Install test scripts
|
||||
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||
RUN chmod -v +x /sdk_entrypoint.sh
|
||||
|
||||
# Start ZeroTier-One
|
||||
CMD ["./sdk_entrypoint.sh"]
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||
|
||||
# --- Test Parameters ---
|
||||
test_namefile=$(ls *.name)
|
||||
test_name="${test_namefile%.*}" # test network id
|
||||
nwconf=$(ls *.conf) # blank test network config file
|
||||
nwid="${nwconf%.*}" # test network id
|
||||
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||
file_base="$test_name".txt # test result output file
|
||||
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||
|
||||
# --- Network Config ---
|
||||
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||
chown -R daemon /var/lib/zerotier-one
|
||||
chgrp -R daemon /var/lib/zerotier-one
|
||||
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||
virtip4=""
|
||||
while [ -z "$virtip4" ]; do
|
||||
sleep 0.2
|
||||
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||
done
|
||||
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||
echo '*** Writing address to ' "$address_file"
|
||||
echo $virtip4 > "$address_file"
|
||||
|
||||
# --- Test section ---
|
||||
echo '*** Starting application...'
|
||||
sleep 0.5
|
||||
|
||||
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||
export LD_PRELOAD=./libztintercept.so
|
||||
/usr/bin/redis-server --port 6379
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Before running this script, run: make unit_tests [COMPILE_FLAGS] to build the necessary docker images
|
||||
|
||||
# Runs test sdk and monitor containers based on the images built by the makefile
|
||||
test_name="docker_demo"
|
||||
echo 'Starting containers for: ' "$test_name"
|
||||
touch "$test_name".name
|
||||
test_container=$(docker run -d -it -v $PWD/tests/results:/opt/results --privileged --device=/dev/net/tun "$test_name":latest)
|
||||
monitor_container=$(docker run -d -it -v $PWD/tests/results:/opt/results --privileged --device=/dev/net/tun "$test_name"_monitor:latest)
|
||||
|
||||
sleep 90
|
||||
|
||||
# By this stage, enough time should have passed for all of the unit tests to conclude
|
||||
RESULTS_DIR=tests/results
|
||||
|
||||
./check.sh $RESULTS_DIR/OK.docker_demo.txt
|
||||
echo $(cat $RESULTS_DIR/OK.docker_demo.txt)
|
||||
|
||||
rm -rf *.tmp
|
||||
rm -rf *.txt
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user