Advertisement
Guest User

location vparam

a guest
Mar 16th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. log("location v-param");
  2. let ip = null;
  3. let igd = declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.ExternalIPAddress", {value: 1});
  4. let result = "UNKNOWN";
  5.  
  6. if (igd.size) {
  7.     for (let p of igd) {
  8.         if (p.value[0] && p.value[0] !== '0.0.0.0') {
  9.             ip = p.value[0];
  10.             break;
  11.         }
  12.     }
  13. }
  14. if (ip !== null) {
  15.     let firstTwo = ip.match(/(\\d+\\.\\d+)/)[0];
  16.     let map = {
  17.         '172.16': 'Tok',
  18.         '172.17': 'Haines',
  19.         '172.18': 'Wrangell',
  20.         '172.19': 'Petersburg',
  21.         '172.21': 'Craig',
  22.         '172.22': 'Metlakatla',
  23.         '172.27': 'Wasilla'
  24.     };
  25.     declare("VirtualParameters.Location", null, {value: map[firstTwo]});
  26.     if (map[firstTwo]) {
  27.         result = map[firstTwo];
  28.     }
  29. }
  30. log("Location: " + result);
  31. return {writable: false, value: [result, "xsd:string"]};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement