Skip to content

Commit

Permalink
Merge of #33
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Aug 17, 2018
1 parent e4d99cb commit b877f2d
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 10 deletions.
37 changes: 37 additions & 0 deletions Makefile
Expand Up @@ -105,3 +105,40 @@ install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz
$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/
$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/
$(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/

# Docker builder section
DOCKER_IMAGE_NAME=ntop/supernode
DOCKER_IMAGE_VERSION=$N2N_VERSION
N2N_COMMIT_HASH=21055550f3392235a1b41d71257e9dc9ead0dfa0

default: steps

steps:
if [ "$(TARGET_ARCHITECTURE)" = "arm32v7" ] || [ "$(TARGET_ARCHITECTURE)" = "" ]; then DOCKER_IMAGE_FILENAME="Dockerfile.arm32v7" DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-arm32v7 make build; fi
if [ "$(TARGET_ARCHITECTURE)" = "x86_64" ] || [ "$(TARGET_ARCHITECTURE)" = "" ]; then DOCKER_IMAGE_FILENAME="Dockerfile.x86_64" DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-x86_64 make build; fi

build:
$(eval OS := $(shell uname -s))
$(eval ARCHITECTURE := $(shell export DOCKER_IMAGE_TAGNAME="$(DOCKER_IMAGE_TAGNAME)"; echo $$DOCKER_IMAGE_TAGNAME | grep -oe -.*))

docker build --target builder --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) -t $(DOCKER_IMAGE_TAGNAME) -f image-platforms/$(DOCKER_IMAGE_FILENAME) .

docker container create --name builder $(DOCKER_IMAGE_TAGNAME)
if [ ! -d "./build" ]; then mkdir ./build; fi
docker container cp builder:/usr/src/n2n/supernode ./build/supernode-$(OS)$(ARCHITECTURE)
docker container cp builder:/usr/src/n2n/edge ./build/edge-$(OS)$(ARCHITECTURE)
docker container rm -f builder

docker build --build-arg COMMIT_HASH=$(N2N_COMMIT_HASH) -t $(DOCKER_IMAGE_TAGNAME) -f image-platforms/$(DOCKER_IMAGE_FILENAME) .
docker tag $(DOCKER_IMAGE_TAGNAME) $(DOCKER_IMAGE_NAME):latest$(ARCHITECTURE)

push:
if [ ! "$(TARGET_ARCHITECTURE)" = "" ]; then \
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)-$(TARGET_ARCHITECTURE); \
docker push $(DOCKER_IMAGE_NAME):latest-$(TARGET_ARCHITECTURE); \
else \
echo "Please pass TARGET_ARCHITECTURE, see README.md."; \
fi

.PHONY: steps build push
# End Docker builder section
54 changes: 47 additions & 7 deletions README.md
@@ -1,32 +1,34 @@
# N2N

Edge node
---------

You need to start an edge node on each host you want to connect with the *same*
community.

Enable the edge process
```

```sh
$ sudo ./edge -d n2n0 -c mynetwork -k encryptme -u 99 -g 99 -m 3C:A0:12:34:56:78 -a 1.2.3.4 -l a.b.c.d:xyw
```

or
```

```sh
$ N2N_KEY=encryptme sudo ./edge -d n2n0 -c mynetwork -u 99 -g 99 -m 3C:A0:12:34:56:78 -a 1.2.3.4 -l a.b.c.d:xyw
```

By defaul the edge will run in background but you can use the `-f` option to keep it in foreground.

Note that `-d`, `-u`, `-g` and `-f` options are not available for Windows.


Supernode
--------

You need to start the supernode once (no need to be root unless you want to use a privileged port)

1. `./supernode -l 1234 -v`



Dropping Root Privileges and SUID-Root Executables (UNIX)
--------------------------------------------------

Expand Down Expand Up @@ -106,6 +108,44 @@ AES (-O3) 12532
TF (-O3) 14046
NULL (-O3) 10659

-----------------
# N2N Builder (Supernode Docker Image based on Debian)

## Running the supernode image

```sh
$ docker run --rm -d -p 5645:5645/udp -p 7654:7654/udp supermock/supernode:[TAGNAME]
```

## Docker registry

- [DockerHub](https://hub.docker.com/r/supermock/supernode/)
- [DockerStore](https://store.docker.com/community/images/supermock/supernode/)

(C) 2007-18 - ntop.org and contributors
## Documentation

### 1. Build image and binaries

Use `make` command to build the images. Before starting the arm32v7 platform build, you need to run this registry, so you can perform a cross-build. Just follow the documentation: https://github.com/multiarch/qemu-user-static/blob/master/README.md

```sh
$ TARGET_ARCHITECTURE=[arm32v7, x86_64, (nothing to build all architectures)] make
```

### 2. Push it

Use `make push` command to push the image, TARGET_ARCHITECTURE is necessary.

```sh
$ TARGET_ARCHITECTURE=[arm32v7, x86_64] make push
```

### 3. Test it

Once the image is built, it's ready to run:

```sh
$ docker run --rm -d -p 5645:5645/udp -p 7654:7654/udp supermock/supernode:[TAGNAME]
```

-----------------
(C) 2007-2018 - ntop.org and contributors
6 changes: 3 additions & 3 deletions sn.c
Expand Up @@ -639,14 +639,14 @@ static int run_loop( n2n_sn_t * sss );

/* *************************************************** */

static int setOption(int optkey, char *optarg, n2n_sn_t *sss) {
static int setOption(int optkey, char *optargument, n2n_sn_t *sss) {

//traceEvent(TRACE_NORMAL, "Option %c = %s", optkey, optarg ? optarg : "");
//traceEvent(TRACE_NORMAL, "Option %c = %s", optkey, optargument ? optargument : "");

switch(optkey) {
case 'l': /* local-port */
{
sss->lport = atoi(optarg);
sss->lport = atoi(optargument);
break;
}

Expand Down

0 comments on commit b877f2d

Please sign in to comment.