Config for UDP connection request port (#221)
This commit is contained in:
1 parent
84e79bda9e
commit
6338f9f07c
3 files changed
+20
-7
No files matched your search
@@ -46,7 +46,13 @@ udpConReq = (address, un, key, callback) ->
|
|||||||
|
|
||||||
message = Buffer.from("GET #{uri} HTTP/1.1\r\nHost: #{address}\r\n\r\n")
|
message = Buffer.from("GET #{uri} HTTP/1.1\r\nHost: #{address}\r\n\r\n")
|
||||||
|
|
||||||
client = dgram.createSocket('udp4')
|
client = dgram.createSocket({type: 'udp4', reuseAddr: true})
|
||||||
|
UDP_CONNECTION_REQUEST_PORT = config.get('UDP_CONNECTION_REQUEST_PORT')
|
||||||
|
if UDP_CONNECTION_REQUEST_PORT
|
||||||
|
# When a device is NAT'ed, the UDP Connection Request must originate from the same address and port used by the STUN server, in order to traverse the firewall.
|
||||||
|
# This does require that the Genieacs NBI and STUN server are allowed to bind to the same address and port.
|
||||||
|
# The STUN server needs to open its UDP port with the SO_REUSEADDR option, allowing the NBI to also bind to the same port.
|
||||||
|
client.bind({port: UDP_CONNECTION_REQUEST_PORT, exclusive: true})
|
||||||
|
|
||||||
count = 3
|
count = 3
|
||||||
client.send(message, 0, message.length, port, host, f = (err) ->
|
client.send(message, 0, message.length, port, host, f = (err) ->
|
||||||
|
|||||||
+11
-6
@@ -68,6 +68,8 @@ function restartWorker(worker, code, signal) {
|
|||||||
function start(service) {
|
function start(service) {
|
||||||
logger.init(service, VERSION);
|
logger.init(service, VERSION);
|
||||||
const config = require("./config");
|
const config = require("./config");
|
||||||
|
const SERVICE_ADDRESS = config.get(`${service.toUpperCase()}_INTERFACE`)
|
||||||
|
const SERVICE_PORT = config.get(`${service.toUpperCase()}_PORT`)
|
||||||
|
|
||||||
logger.info({
|
logger.info({
|
||||||
message: `GenieACS (genieacs-${service}) starting`,
|
message: `GenieACS (genieacs-${service}) starting`,
|
||||||
@@ -78,12 +80,15 @@ function start(service) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
cluster.on("listening", function(worker, address) {
|
cluster.on("listening", function(worker, address) {
|
||||||
logger.info({
|
if ((address.addressType === 4 || address.addressType === 6) &&
|
||||||
message: "Worker listening",
|
address.address === SERVICE_ADDRESS && address.port === SERVICE_PORT) {
|
||||||
pid: worker.process.pid,
|
logger.info({
|
||||||
address: address.address,
|
message: "Worker listening",
|
||||||
port: address.port
|
pid: worker.process.pid,
|
||||||
});
|
address: address.address,
|
||||||
|
port: address.port
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cluster.on("exit", restartWorker);
|
cluster.on("exit", restartWorker);
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ options = {
|
|||||||
FS_LOG_FILE : {type: 'path', default : ''},
|
FS_LOG_FILE : {type: 'path', default : ''},
|
||||||
FS_ACCESS_LOG_FILE : {type : 'path', default : ''},
|
FS_ACCESS_LOG_FILE : {type : 'path', default : ''},
|
||||||
|
|
||||||
|
UDP_CONNECTION_REQUEST_PORT : {type : 'int', default : 0},
|
||||||
|
|
||||||
DOWNLOAD_TIMEOUT: {type : 'int', default : 3600},
|
DOWNLOAD_TIMEOUT: {type : 'int', default : 3600},
|
||||||
EXT_TIMEOUT: {type: 'int', default: 3000},
|
EXT_TIMEOUT: {type: 'int', default: 3000},
|
||||||
MAX_CACHE_TTL : {type : 'int', default : 86400},
|
MAX_CACHE_TTL : {type : 'int', default : 86400},
|
||||||
|
|||||||
Reference in new issue
Block a user