-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathservicevar-clientIP.js
More file actions
27 lines (21 loc) · 854 Bytes
/
servicevar-clientIP.js
File metadata and controls
27 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// DataPower service-metadata example: Client IP and port.
// This demonstrates GatewayScript (ECMA) service variable information.
// Author: Steve Edwards, Escala Ltd.
// Date : 2014-09-30.
// Note : this code is for demonstration purposes only, not production - level.
var sm = require ('service-metadata');
var client_service_address_JSON = {};
// Read the client-service-address as a string using the URL notation
// result is of form:
var client_service_address = sm.getVar ('var://service/client-service-address');
var client_ip = client_service_address.split(":")[0];
var client_port = client_service_address.split(":")[1];
client_service_address_JSON.ip = client_ip;
client_service_address_JSON.port = client_port;
session.output.write(client_service_address_JSON);
/* Sample output:
{
"ip": "192.168.1.112",
"port": "49318"
}
*/