Skip to content

Commit

Permalink
alpha version of iotronic node and partial version of iotronic python
Browse files Browse the repository at this point in the history
  • Loading branch information
alotronto committed Jan 29, 2015
1 parent 271658e commit 8082d91
Show file tree
Hide file tree
Showing 633 changed files with 380 additions and 84,675 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"publish": true,
"subscribe": true,
"call": true,
"register": true
"register": true,
"debug":true
}
]
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
s4t-server-node/node_modules
s4t-server-node/lib/node_modules
16 changes: 0 additions & 16 deletions s4t-server-node/.crossbar/node.pid

This file was deleted.

13 changes: 5 additions & 8 deletions ..._modules/node-reverse-wstunnel/lib/wst.js → s4t-server-node/bin/server
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

/*
The MIT License (MIT)
Expand All @@ -22,13 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

(function() {
module.exports = {
server: require("./wst_server"),
client: require("./wst_client"),
server_reverse : require("./wst_server_reverse"),
client_reverse : require("./wst_client_reverse"),
};
var s4t = require("../lib/s4t_WS");

}).call(this);
var server = new s4t.server

server.start(6655);
5 changes: 2 additions & 3 deletions ...modules/node-reverse-wstunnel/bin/wstt.js → s4t-server-node/index.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

/*
The MIT License (MIT)
Expand All @@ -23,4 +21,5 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
require("./wst")

module.exports = require('./lib/s4t_WS');
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Andrea Rocco Lotronto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -22,18 +18,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

(function() {
var https, old_https_request;

https = require("https");

old_https_request = https.request;

https.request = function() {
var options;
options = arguments[0];
options.rejectUnauthorized = false;
return old_https_request.apply(void 0, Array.apply(null, arguments));
};

}).call(this);
var networkInterfaces = require('os').networkInterfaces();

module.exports = function (interface, version) {
var ip ;
for (var ifName in networkInterfaces){
if(ifName == interface){
var ifDetails = networkInterfaces[ifName];
for (var i = 0; ifDetails[i].family == version; i++){
ip = ifDetails[i].address;
}
}
}

return ip;
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Andrea Rocco Lotronto
Expand All @@ -18,4 +19,9 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
*/

module.exports = {
server: require("./s4t_wamp_server")
};
143 changes: 143 additions & 0 deletions s4t-server-node/lib/s4t_wamp_server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Andrea Rocco Lotronto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

var autobahn = require('autobahn');
var express = require('express');


s4t_wamp_server = function(){


}

s4t_wamp_server.prototype.start = function(restPort){


var boards = {};
var getIP = require('./getIP.js');
var IPLocal = getIP('eth0', 'IPv4');

var url_wamp_router = "ws://ip:port/ws"; //example of url wamp router

var connection = new autobahn.Connection({
url: url_wamp_router,
realm: "s4t"
});

var topic_command = 'board.command'
var topic_connection = 'board.connection'

connection.onopen = function (session, details) {


var rest = express();

rest.get('/', function (req, res){
res.send('API: <br> http://'+IPLocal+':'+restPort+'/list for board list');
});

rest.get('/command/', function (req, res){

//DEBUG Message
console.log('POST::::'+req.originalUrl);
var board = req.query.board
var command = req.query.command

if(boards[board] != undefined){
//DEBUG Message
//
console.log("ID exsist");
//random port for reverse service
var port = randomIntInc(6000,7000);
session.publish(topic_command, [board, command, port]);
if(command == 'ssh'){
res.send("ssh -p "+port+" root@"+IPLocal);
}
if(command == 'ideino'){
res.send("http://"+IPLocal+":"+port);
}

}
else
res.send("Error: malformed REST ");

});

rest.get('/list/', function (req, res){

var board_list='';

for (var i in boards){
board_list += boards[i];
command_list = "ssh"
}

res.send('List of the board: '+board_list+'<br>'+'use URL: '+IPLocal+":"+'6655'+"/commad/?board=board_name&command=ssh|ideino");
});

rest.listen(restPort);
console.log("Server REST started on: http://"+IPLocal+":"+restPort);

console.log("Connected to router WAMP");
// Publish, Subscribe, Call and Register

var onBoardConnected = function (args){
//registrare le schede che si connettono
if(args[1]=='connection'){
boards[args[0]] = args[0];
//DEBUGGG Message
console.log("Board connected:"+args[0]+" board state:"+args[1]);
//DEBUGGG Message
console.log("List of board::"+boards.length);
for (var i in boards){
console.log('Key: '+i+' value: '+boards[i]);
}

}
if(args[1]=='disconnect'){
delete boards[args[0]];
//DEBUGGG
console.log("Board disconnected:"+args[0]+" board state:"+args[1]);
//DEBUGGG
console.log("List of the board::"+boards.length);
for (var i in boards){
console.log('Key: '+i+' value: '+boards[i]);
}
}
}

session.subscribe(topic_connection, onBoardConnected);
console.log("Subsscribe to topic: "+topic_connection);
};

connection.onclose = function (reason, details) {
// handle connection lost
}

connection.open();

}

//function for pseudo random number
function randomIntInc (low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
}

module.exports = s4t_wamp_server;
5 changes: 0 additions & 5 deletions s4t-server-node/node_modules/autobahn/.npmignore

This file was deleted.

25 changes: 0 additions & 25 deletions s4t-server-node/node_modules/autobahn/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions s4t-server-node/node_modules/autobahn/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions s4t-server-node/node_modules/autobahn/index.js

This file was deleted.

39 changes: 0 additions & 39 deletions s4t-server-node/node_modules/autobahn/lib/auth/cra.js

This file was deleted.

Loading

0 comments on commit 8082d91

Please sign in to comment.