Commit 0b9b60b118bb18ca6d9b41ad54e138c59e76ed20
1 parent
97a8eb629f
Exists in
master
penanganan ipv6 hybrid remoteAddress
Showing 1 changed file with 8 additions and 7 deletions Side-by-side Diff
xmlrpc-server.js
... | ... | @@ -79,8 +79,9 @@ function createDiyHttpXmlRpcServer() { |
79 | 79 | } |
80 | 80 | |
81 | 81 | var httpServer = https.createServer(serverOptions, function(req, res) { |
82 | + var remoteAddress = req.connection.remoteAddress.replace(/^::ffff:/, ''); | |
82 | 83 | |
83 | - logger.verbose("Incoming connection from " + req.connection.remoteAddress); | |
84 | + logger.verbose("Incoming connection from " + remoteAddress); | |
84 | 85 | |
85 | 86 | var body = ""; |
86 | 87 | |
... | ... | @@ -93,7 +94,7 @@ function createDiyHttpXmlRpcServer() { |
93 | 94 | xml2jsParser(body, function(err, message) { |
94 | 95 | |
95 | 96 | if (err) { |
96 | - logger.warn('Got XMLRPC invalid XML request body from ' + req.connection.remoteAddress, {body: body, err: err}); | |
97 | + logger.warn('Got XMLRPC invalid XML request body from ' + remoteAddress, {body: body, err: err}); | |
97 | 98 | res.end('Invalid XMLRPC request'); |
98 | 99 | return; |
99 | 100 | } |
... | ... | @@ -106,17 +107,17 @@ function createDiyHttpXmlRpcServer() { |
106 | 107 | _params = message.methodCall.params[0].param[0].value[0].struct[0].member; |
107 | 108 | } |
108 | 109 | catch(errSelectMethod) { |
109 | - logger.warn('Failed to get method and params on request from ' + req.connection.remoteAddress); | |
110 | + logger.warn('Failed to get method and params on request from ' + remoteAddress); | |
110 | 111 | res.end('Invalid XMLRPC message') |
111 | 112 | return; |
112 | 113 | } |
113 | 114 | |
114 | - params = getXmlRpcParam(_params); | |
115 | - logger.info('Got XMLRPC request from ' + req.connection.remoteAddress, {method: method, params: params}); | |
115 | + var params = getXmlRpcParam(_params); | |
116 | + logger.info('Got XMLRPC request from ' + remoteAddress, {method: method, params: params}); | |
116 | 117 | |
117 | 118 | if (method == 'topUpRequest') { |
118 | 119 | |
119 | - sendTopUpRequestToMaster(params, req.connection.remoteAddress, function(forwardError) { | |
120 | + sendTopUpRequestToMaster(params, remoteAddress, function(forwardError) { | |
120 | 121 | if (forwardError) { |
121 | 122 | immediateReply(params, res, '40', forwardError.toString()); |
122 | 123 | } else { |
... | ... | @@ -127,7 +128,7 @@ function createDiyHttpXmlRpcServer() { |
127 | 128 | } |
128 | 129 | else if (method == 'topUpInquiry') { |
129 | 130 | |
130 | - sendTopUpInquryToMaster(params, req.connection.remoteAddress, res); | |
131 | + sendTopUpInquryToMaster(params, remoteAddress, res); | |
131 | 132 | |
132 | 133 | } |
133 | 134 | else { |