mirror of
https://github.com/amark/gun.git
synced 2025-11-23 22:15:55 +00:00
set multicast advertised port in examples/http.js
This commit is contained in:
parent
ad079ad49b
commit
058bd3cae9
@ -16,6 +16,7 @@
|
||||
config.server = require('http').createServer(Gun.serve(__dirname));
|
||||
}
|
||||
|
||||
var gun = Gun({web: config.server.listen(config.port) });
|
||||
require('../lib/multicast');
|
||||
var gun = Gun({web: config.server.listen(config.port), multicast: { port: 8765 } });
|
||||
console.log('Relay peer started on port ' + config.port + ' with /gun');
|
||||
}());
|
||||
@ -10,7 +10,9 @@ Gun.on('create', function(root){
|
||||
opt.multicast = opt.multicast || {};
|
||||
|
||||
var MULTICAST_ADDR = "233.255.255.255";
|
||||
var MULTICAST_INTERVAL = 1000;
|
||||
var PORT = 20000;
|
||||
var DEFAULT_GUN_PORT = 8765;
|
||||
var ENC = 'utf8';
|
||||
|
||||
var dgram = require("dgram");
|
||||
@ -24,7 +26,8 @@ Gun.on('create', function(root){
|
||||
socket.on("listening", function() {
|
||||
socket.addMembership(MULTICAST_ADDR);
|
||||
if (opt.multicast && opt.multicast.port) { // if port is specified, advertise our node
|
||||
setInterval(sendMessage, 1000);
|
||||
console.log(`Advertising this node (port ${opt.multicast.port}) on multicast (${MULTICAST_ADDR})`);
|
||||
setInterval(sendMessage, MULTICAST_INTERVAL);
|
||||
}
|
||||
address = socket.address();
|
||||
});
|
||||
@ -33,7 +36,7 @@ Gun.on('create', function(root){
|
||||
var msgObj = {
|
||||
gun: {
|
||||
version: Gun.version,
|
||||
port: opt.multicast.port || 8765
|
||||
port: opt.multicast.port || DEFAULT_GUN_PORT
|
||||
}
|
||||
};
|
||||
var message = Buffer.from(JSON.stringify(msgObj), ENC);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user