Config for UDP connection request port (#221)

This commit is contained in:
Spencer Lambert authored and Zaid Abdulla committed 2017-03-31 11:14:44 -07:00
1 parent 84e79bda9e
commit 6338f9f07c
3 files changed
+20 -7

No files matched your search

+7 -1
View File
@@ -46,7 +46,13 @@ udpConReq = (address, un, key, callback) ->
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
client.send(message, 0, message.length, port, host, f = (err) ->
+11 -6
View File
@@ -68,6 +68,8 @@ function restartWorker(worker, code, signal) {
function start(service) {
logger.init(service, VERSION);
const config = require("./config");
const SERVICE_ADDRESS = config.get(`${service.toUpperCase()}_INTERFACE`)
const SERVICE_PORT = config.get(`${service.toUpperCase()}_PORT`)
logger.info({
message: `GenieACS (genieacs-${service}) starting`,
@@ -78,12 +80,15 @@ function start(service) {
});
cluster.on("listening", function(worker, address) {
logger.info({
message: "Worker listening",
pid: worker.process.pid,
address: address.address,
port: address.port
});
if ((address.addressType === 4 || address.addressType === 6) &&
address.address === SERVICE_ADDRESS && address.port === SERVICE_PORT) {
logger.info({
message: "Worker listening",
pid: worker.process.pid,
address: address.address,
port: address.port
});
}
});
cluster.on("exit", restartWorker);
+2
View File
@@ -49,6 +49,8 @@ options = {
FS_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},
EXT_TIMEOUT: {type: 'int', default: 3000},
MAX_CACHE_TTL : {type : 'int', default : 86400},