diff --git a/README.md b/README.md
index 99e84dd..41a6648 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-
+
# Swarmlab Venus
-### **Welcome to Swarmlab.io**
+### **Welcome to VEnus Network Unification Service**
## Swarmlab-venus Network Virtualization
### on-demand network environments
@@ -13,27 +13,53 @@
# on-demand sandbox environments
-
-
* Virtual Labroom
* Virtual Classroom
* Proof-of-Concept (POC)
### Table of contents
+1. [Features](#introduction)
2. [System requirements ](#systemrequirements)
3. [Prerequisites](#prerequisites)
4. [Installation](#installation)
-
+5. [More info](#moreinfo)
+###
+## Swarmlab Venus is Swarmlabs hybrids syblin, diagnosed with the VPN disease.
+
+Swarmlab venus provides the user with the unique abillity to create **virtual networks** and use them to project for a Virtual Classroom, an app of your own making or proof of concept. An all of that using only a browser of their choice.
+
+## Why?
+
+Ever imagined having a network environment to tryout stuff with your coworkers/costudents for work or just for fun?
+
+Ever created a service that you would like to test on a real-world network?
+
+Ever designed an Labroom/application you would like to distribute to your students/coworkers/potential clients?
+
+Swarmlab venus comes to bridge the gap between you, your network/computer, the coder/developer of a service and the end user while at the same time meeting the needs for a real-world testing environment.
+
+With venus you can now as part of the cloud work independantly but also stay connected.
+
+The venus service allows us to utilize the power of Swarmlab itself but also combine it with the practiacally unlimited computing of our own machines.
+
+## Another Swarmlab app. Why?
+
+How does Swarmlab Venus differ from Swarmlab Hybrid?
+Well swarmlab-hybrid forces server-client/containerized applications while venus allows for peer-to-peer connection! You can create and connect directly to a network with your coworkers, whithout needing a server.
+
+Ofcourse you can use venus independantly or alongside swarmlab and all of its powerful features.
+
+To sum up, you can now design, develop and test apps using swarlab-hybrid but you can also connect directly to other interested parties for testing or work purposes.
## System requirements
-**Before** you create and configure a hybrid deployment using the swarmlab-agent client, your Local Machines need to meet certain requirements.
+**Before** you create and configure a venus deployment using the swarmlab-agent client, your Local Machines need to meet certain requirements.
> If you don't meet those requirements, you won't be able to complete the steps within the swarmlab-agent client and you won't be able to configure a network deployment between your Local Enviroment and Swarmlab Online Enviroment.
@@ -50,7 +76,7 @@
- Minimum: 2
- Recommended 4+
- Disk Space
- - 10 GB for internal requirements.
+ - 5 GB for internal requirements.
- The amount of additional disk space soloemnly depends on you intended use.
:warning: Since Docker uses hypervisor the host NEEDS TO HAVE VIRTUALIZATION ENABLED!
@@ -62,43 +88,18 @@
* node version >15
-
-[Install Node](http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/nodejs/install-nodejs.adoc.html)
-
-or run
-
-
```sh
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs
```
-
-
-* wireguard
-
-[Install Wireguard](http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/wg/install-wg.adoc.html)
-
-or run
-
-
- ```sh
- sudo apt install wireguard jq
-
- ```
-
-
* docker
-[install docker](http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/docker/install-docker.adoc.html)
-
-or run
-
```sh
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y docker-ce
- sudo usermod -aG docker $USER # Please replace $USER with the user you want to run docker on
+ sudo usermod -aG docker [USERNAME] # Please replace [USERNAME] with the user you want to run docker on
```
:information_source: for kali specifically please visit the following link to install docker.
@@ -113,13 +114,26 @@ https://linuxhint.com/install_docker_kali_linux/
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
```
-
* pm2
```sh
sudo npm install -g pm2
```
+* wireguard
+ ```sh
+ sudo apt install wireguard jq
+
+ ```
+
+### **MORE Installation info here**
+
+
+[install docker](http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/docker/install-docker.adoc.html)
+
+[Install Wireguard](http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/wg/install-wg.adoc.html)
+
+[Install Node](http://docs.swarmlab.io/SwarmLab-HowTos/labs/Howtos/nodejs/install-nodejs.adoc.html)
diff --git a/llo/connect-new.js b/llo/connect-new.js
index bb7a9ea..39bd729 100644
--- a/llo/connect-new.js
+++ b/llo/connect-new.js
@@ -56,6 +56,33 @@ var static_options = {
app.use('/', express.static('client', static_options))
+function myexec(res) {
+ var mypath = process.cwd()
+ var RES = new Object();
+
+ try {
+ var showexec = `${res}`
+ console.error('execi 1 ' + JSON.stringify(res));
+ const stdout = execSync(res, {
+ env: {
+ NODE_ENV: "production",
+ },
+ });
+ var datajson = stdout.toString()
+ //var datajson = JSON.parse(string);
+ RES.error = false
+ RES.error_msg = "ok"
+ RES.data = datajson;
+ console.error('exec ' + JSON.stringify(RES.data));
+ return RES
+ } catch (error) {
+ var datajson = error.toString()
+ return datajson
+ }
+
+}
+
+
/*
* **********************************************************
@@ -64,23 +91,41 @@ app.use('/', express.static('client', static_options))
*/
-function wg_save_clientconf(res) {
+async function wg_save_clientconf(res) {
/*
res.publickey
res.endpoint
res.serverip
+ res.bootstrapstackid
res.netmask
res.privatekey
res.allowedips
res.interfaceip
res.endpointfpath
*/
+
+
+const apptest = require('express')();
+const servertest = apptest.listen(0, () => {
+ var newport = servertest.address().port
+ servertest.close();
+ fs.mkdir(`./hybrid/connect/${res.bootstrapstackid}`, { recursive: true }, (err) => {
+ if (err){
+ var RES = new Object();
+ RES.error = true
+ RES.error_msg = "error"
+ RES.validator_msg = 'write error'
+ RES.error_statuscode = "500"
+ RES.data = err
+ return RES
+ }else{
+
var endpointfpath = `${res.serverip}:${res.endpoint}`
var peerconfig =`
[Interface]
PrivateKey = ${res.privatekey}
- ListenPort = 51820
+ ListenPort = ${newport}
[Peer]
PublicKey = ${res.publickey}
@@ -89,14 +134,28 @@ var peerconfig =`
#AllowedIPs = 10.1.0.0/24, 0.0.0.0/0, ::/0
PersistentKeepalive = 30
`
-
- try {
- fs.writeFileSync('./hybrid/connect/wg0.conf', peerconfig);
- return 'ok'
- } catch (error) {
- var datajson = error.toString()
- return datajson
- }
+ try {
+ fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/wg0.conf`, peerconfig);
+ var RES1 = new Object();
+ RES1.error = false
+ RES1.error_msg = "ok"
+ RES1.validator_msg = 'ok'
+ RES1.error_statuscode = "200"
+ RES1.data = 'created'
+ return RES1
+ } catch (error) {
+ var datajson = error.toString()
+ var RES1 = new Object();
+ RES1.error = true
+ RES1.error_msg = "error"
+ RES1.validator_msg = 'write error'
+ RES1.error_statuscode = "500"
+ RES1.data = datajson
+ return RES1
+ }
+ }
+ });
+ })
}
/*
@@ -105,7 +164,7 @@ var peerconfig =`
* **********************************************************
*/
-function wg_save_ifup_linux(res) {
+async function wg_save_ifup_linux(res) {
var mypath = process.cwd()
var DEV_NAME = res.dev_name
var INTERFACE_IP = res.INTERFACE_IP
@@ -115,6 +174,7 @@ function wg_save_ifup_linux(res) {
res.publickey
res.endpoint
res.serverip
+ res.bootstrapstackid
res.netmask
res.privatekey
res.allowedips
@@ -137,13 +197,13 @@ function wg_save_ifup_linux(res) {
ip route show table 200 | grep -w ${INTERFACE_IProute}
ip rule add table main suppress_prefixlength 0
`
- fs.writeFileSync('./hybrid/connect/ifup_linux', myExec);
+ fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/ifup_linux`, myExec);
const myExec1 = `
ip link set ${DEV_NAME} down
ip link del ${DEV_NAME}
`
- fs.writeFileSync('./hybrid/connect/ifdown_linux', myExec1);
+ fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/ifdown_linux`, myExec1);
return 'ok'
} catch (error) {
@@ -158,7 +218,7 @@ function wg_save_ifup_linux(res) {
* **********************************************************
*/
-function wg_save_connect_linux(res) {
+async function wg_save_connect_linux(res) {
var mypath = process.cwd()
var DEV_NAME = res.dev_name
var INTERFACE_IP = res.INTERFACE_IP
@@ -168,6 +228,7 @@ function wg_save_connect_linux(res) {
res.publickey
res.endpoint
res.serverip
+ res.bootstrapstackid
res.netmask
res.privatekey
res.allowedips
@@ -176,38 +237,38 @@ function wg_save_connect_linux(res) {
*/
try {
const myExec = `
- docker exec -it swarmlabwg /bin/bash -c "ip link set swarmlab0 down; ip link del swarmlab0"
+ docker exec -it swarmlabwg-${res.bootstrapstackid} /bin/bash -c "ip link set ${DEV_NAME} down; ip link del ${DEV_NAME}"
sleep 1
-docker stop swarmlabwg; docker container rm swarmlabwg
+docker stop swarmlabwg-${res.bootstrapstackid}; docker container rm swarmlabwg-${res.bootstrapstackid}
sleep 1
docker pull hub.swarmlab.io:5480/venusclient:latest
sleep 1
docker run -d \
--net=host \
- --name=swarmlabwg \
+ --name=swarmlabwg-${res.bootstrapstackid} \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Europe/Athens \
- -p 51820:51820/udp \
- -v ${mypath}/hybrid/connect:/settingsclient \
+ -v ${mypath}/hybrid/connect/${res.bootstrapstackid}:/settingsclient \
-v /lib/modules:/lib/modules \
--restart unless-stopped \
hub.swarmlab.io:5480/venus-alpine:latest
`
+ //-p 51820:51820/udp \
//docker exec -it swarmlabwg /bin/bash -c "pm2-runtime start /app/swarmlab-venus/client_ecosystem.config.js"
//hub.swarmlab.io:5480/venusclient:latest
- fs.writeFileSync('./hybrid/connect/swarmlabwg', myExec);
- fs.writeFileSync('./hybrid/connect/swarmlabstatus', 'wgstatusclient=off');
+ fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabwg`, myExec);
+ fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabstatus`, 'wgstatusclient=off');
const myExec1 = `
- docker exec -it swarmlabwg /bin/bash -c "ip link set swarmlab0 down; ip link del swarmlab0"
+ docker exec -it swarmlabwg-${res.bootstrapstackid} /bin/bash -c "ip link set ${DEV_NAME} down; ip link del ${DEV_NAME}"
sleep 1
- docker stop swarmlabwg; docker container rm swarmlabwg
+ docker stop swarmlabwg-${res.bootstrapstackid}; docker container rm swarmlabwg-${res.bootstrapstackid}
sleep 1
`
- fs.writeFileSync('./hybrid/connect/swarmlabwgdown', myExec1);
+ fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabwgdown`, myExec1);
return 'ok'
@@ -223,12 +284,14 @@ app.post('/hybrid_join_start', (req, res, next) => {
RES.publickey = req.body["publickey"]
RES.endpoint = req.body["endpointport"]
RES.serverip = req.body["serverip"]
+ RES.bootstrapstackid = req.body["bootstrapstackid"]
RES.netmask = req.body["netmask"]
RES.privatekey = req.body["privatekey"]
RES.allowedips = req.body["allowedips"]
RES.interfaceip = req.body["peer_ip"]
RES.endpointfpath = `${RES.serverip}:${RES.endpoint}`
- RES.dev_name = 'swarmlab0'
+ RES.dev_name = `swlab${RES.bootstrapstackid.slice(0, 10)}`
+console.log(RES.dev_name)
RES.INTERFACE_IP = `${RES.interfaceip}/${RES.netmask}`
RES.INTERFACE_IProute = `${RES.interfaceip}`
@@ -236,9 +299,11 @@ app.post('/hybrid_join_start', (req, res, next) => {
// *****************************************
// *** save wg config file wg0.conf
// *****************************************
- RES.serverconf = wg_save_clientconf(RES)
- RES.serverrun = wg_save_ifup_linux(RES)
- RES.serverconnect = wg_save_connect_linux(RES)
+ (async() => {
+ RES.serverconf = await wg_save_clientconf(RES)
+ RES.serverrun = await wg_save_ifup_linux(RES)
+ RES.serverconnect = await wg_save_connect_linux(RES)
+ })()
// *****************************************
// *** save wg ifup linux
// *****************************************
@@ -263,13 +328,14 @@ app.post('/hybrid_join_connect', (req, res, next) => {
var RES = new Object();
RES.action = req.body["action"]
+ RES.bootstrapstackid = req.body["bootstrapstackid"]
try {
if(RES.action == "connect"){
- fs.writeFileSync('./hybrid/connect/swarmlabstatus', 'wgstatusclient=on');
+ fs.writeFileSync(`./hybrid/connect/${RES.bootstrapstackid}/swarmlabstatus`, 'wgstatusclient=on');
- var showexecrm = `/bin/sh ./hybrid/connect/swarmlabwg`
+ var showexecrm = `/bin/sh ./hybrid/connect/${RES.bootstrapstackid}/swarmlabwg`
execSync(showexecrm);
var showexec = `docker ps --format '{"ID":"{{ .ID }}", "Image": "{{ .Image }}", "Names":"{{ .Names }}", "Ports":"{{.Ports}}", "Networks":"{{.Networks}}", "Status":"{{.Status}}","RunningFor":"{{.RunningFor}}","CreatedAt":"{{.CreatedAt}}"}' | jq . -s `
@@ -284,7 +350,7 @@ app.post('/hybrid_join_connect', (req, res, next) => {
var datajson = JSON.parse(string);
var results = []
- var filter = "swarmlabwg"
+ var filter = `swarmlabwg-${RES.bootstrapstackid}`
var grep = new RegExp(filter);
var datalenth = datajson.length
for (var i=0 ; i < datalenth ; i++)
@@ -313,9 +379,9 @@ app.post('/hybrid_join_connect', (req, res, next) => {
}
});
}else if( RES.action == "disconnect" ){
- fs.writeFileSync('./hybrid/connect/swarmlabstatus', 'wgstatusclient=off');
+ fs.writeFileSync(`./hybrid/connect/${RES.bootstrapstackid}/swarmlabstatus`, 'wgstatusclient=off');
- var showexecrm1 = `/bin/sh ./hybrid/connect/swarmlabwgdown`
+ var showexecrm1 = `/bin/sh ./hybrid/connect/${RES.bootstrapstackid}/swarmlabwgdown`
execSync(showexecrm1);
var showexec = `docker ps --format '{"ID":"{{ .ID }}", "Image": "{{ .Image }}", "Names":"{{ .Names }}", "Ports":"{{.Ports}}", "Networks":"{{.Networks}}", "Status":"{{.Status}}","RunningFor":"{{.RunningFor}}","CreatedAt":"{{.CreatedAt}}"}' | jq . -s `
@@ -330,7 +396,7 @@ app.post('/hybrid_join_connect', (req, res, next) => {
var datajson = JSON.parse(string);
var results = []
- var filter = "swarmlabwg"
+ var filter = `swarmlabwg-${RES.bootstrapstackid}`
var grep = new RegExp(filter);
var datalenth = datajson.length
for (var i=0 ; i < datalenth ; i++)
@@ -387,6 +453,7 @@ app.get('/getserviceshybridstatus', (req, res, next) => {
if (stdout) {
var string = stdout.toString()
var datajson = JSON.parse(string);
+ /*
var search = RES.bootstrapstackname
var extenderror = new RegExp(search);
var found = 'no';
@@ -397,6 +464,7 @@ app.get('/getserviceshybridstatus', (req, res, next) => {
found = 'yes';
}
}
+ */
RES.error = false
RES.error_msg = "ok"
RES.test = datajson;