andrewhodel / ispapp-routeros-client

MIT License
0 stars 0 forks source link

fix v7 cmds #1

Closed andrewhodel closed 2 years ago

andrewhodel commented 2 years ago

no response

andrewhodel commented 2 years ago
/system/script/run base64EncodeFunctions 
expected command name (line 11 column 753)
andrewhodel commented 2 years ago

Same problem that was an already created issue with Mikrotik, array declaration syntax.

https://github.com/andrewhodel/ispapp-routeros-client/blob/master/ispapp.rsc#L1470

andrewhodel commented 2 years ago
{:local a [:toarray ""]; :set ($a->"asdf") 67; :put $a;}
andrewhodel commented 2 years ago

character codes

var import_type = true;

var p = document.createElement('pre');
document.body.appendChild(p);
var c = 32;
var skips = [34, 92];
var escapes = [36]
while (c <= 126) {
    var s = '';
  var ch = String.fromCharCode(c);
  if (skips.includes(c)) {
    // skip it
    c++;
    continue;
  } else if (escapes.includes(c)) {
    ch = "\\" + ch;
  }
  if (import_type) {
    // print for pasting to routeros import script
    s = s + '\\n:set (\\$charToDec->\\"' + ch + '\\") ' + c + ';\\r\\\n';
  } else {
    // print for testing in shell
    s = s + ':set ($charToDec->"' + ch + '") ' + c + ';\n';
  }
    p.innerHTML += s;
  c++;
}

// base64 characters
var b64index = [];
c = 65;
while (c <= 90) {
    b64index.push(String.fromCharCode(c));
  c++
}
c = 97;
while (c <= 122) {
    b64index.push(String.fromCharCode(c));
  c++;
}
c = 48;
while (c <= 57) {
    b64index.push(String.fromCharCode(c));
  c++;
}
c = 62;
b64index.push("+");
b64index.push("/");
c = 0
while (c < b64index.length) {
    var s = '';
  var ch = b64index[c];
  if (import_type) {
    // print for pasting to routeros import script
    s = s + '\\n:set (\\$base64Chars->' + c + ') \\"' + ch + '\\";\\r\\\n';
  } else {
    // print for testing in shell
    s = s = s + ':set ($base64Chars->' + c + ') "' + ch + '";\n';
  }
  p.innerHTML += s;
  c++;
}
andrewhodel commented 2 years ago

Rewrite cmd execution, more junk from Emrah designed to create problems while people die.