From a6babca5ec5d699f9211255a64d9605a9de19757 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Sun, 16 Jun 2013 23:39:31 +0200 Subject: [PATCH] Add IPv6 support --- bin/nodecoin | 26 ++++++++++++++++++++++---- config.js | 4 +++- readme.md | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/bin/nodecoin b/bin/nodecoin index 1b7a6771d..8c83ecff7 100755 --- a/bin/nodecoin +++ b/bin/nodecoin @@ -7,12 +7,30 @@ var config = require('../config'), program .version('0.0.1') .option('-p, --port <port>', 'Port to listen for requests', parseInt) + .option('--ipv4 <address>', 'IPV4 interface to listen for requests') + .option('--ipv6 <address>', 'IPV6 interface to listen for requests') .parse(process.argv); -config.server.port = program.port || config.server.port; +config.server.port = program.port || config.server.port; +config.server.ipv4address = program.ipv4 || config.server.ipv4address; +config.server.ipv6address = program.ipv6 || config.server.ipv6address; var app = nodecoin.express.app(config); -http.createServer(app).listen(app.get('port'), function(){ - console.log('NodeCoin server listening on port ' + app.get('port')); -}); \ No newline at end of file +if(!config.server.ipv4address){ + http.createServer(app).listen(app.get('port'), function(){ + console.log('NodeCoin server listening on port ' + app.get('port')); + }); +} + +if(config.server.ipv4address){ + http.createServer(app).listen(app.get('port'), config.server.ipv4address, function(){ + console.log('NodeCoin server listening on ' + config.server.ipv4address + ' port ' + app.get('port')); + }); +} + +if(config.server.ipv6address){ + http.createServer(app).listen(app.get('port'), config.server.ipv6address, function(){ + console.log('NodeCoin server listening on ' + config.server.ipv6address + ' port ' + app.get('port')); + }); +} \ No newline at end of file diff --git a/config.js b/config.js index f9e10d003..5f33f0f16 100644 --- a/config.js +++ b/config.js @@ -1,3 +1,5 @@ exports.server = { - port : 8081 + port: 8081, + ipv4address: '', + ipv6address: '' }; diff --git a/readme.md b/readme.md index df18395e2..cac633c79 100644 --- a/readme.md +++ b/readme.md @@ -30,10 +30,30 @@ By default, nodecoin runs on port 8081. You may change it using the --port param $ nodecoin --port 80 -Note that your system may require root access to launch on port 80. +Note that your system may require root access to launch on port 80. It is also possible to specify the IPv4 interface: + + $ nodecoin -p 8888 --ipv4 127.0.0.1 + + NodeCoin server listening on 127.0.0.1 port 8888 + +Or IPv6 interface: + + $ nodecoin -p 8888 --ipv6 ::1 + + NodeCoin server listening on ::1 port 8888 + +Or both: + + $ nodecoin -p 8888 --ipv4 127.0.0.1 --ipv6 ::1 + + NodeCoin server listening on 127.0.0.1 port 8888 + NodeCoin server listening on ::1 port 8888 + +Note too that listening to multiple interfaces doesn't imply mutiple program instances: only *one* is running on multiple interfaces. + For more more details on the nodecoin command, run: - nodecoin -h + nodecoin --help Which displays: @@ -44,6 +64,8 @@ Which displays: -h, --help output usage information -V, --version output the version number -p, --port <port> Port to listen for requests + --ipv4 <address> IPV4 interface to listen for requests + --ipv6 <address> IPV6 interface to listen for requests ## Disclaimer @@ -54,6 +76,13 @@ Consequently, NodeCoin proposes its own protocol which differs with OpenUDC. How For the moment NodeCoin is developed only by its author. If you wish to participate/debate on it, you may join OpenUDC XMPP chatroom (open-udc@muc.jappix.com) on [OpenUDC blog](http://www.openudc.org/) (chat is available on the bottom-right corner of the blog) and contact *cgeek*. +# References + +* Official OpenUDC project website: <http://www.openudc.org> +* Official OpenUDC repository: <https://github.com/Open-UDC/open-udc> +* Other project trying to implement OpenUDC in python: <https://github.com/canercandan/django-openudc> +* Theoretical reference: [Relativity Theory of Money v2.718, Stephane Laborde - Nov. 2012](http://wiki.creationmonetaire.info/index.php?title=Main_Page) + # License Copyright (c) 2013 The nodecoin team. -- GitLab