Community discussions

MikroTik App

Search found 2400 matches

  • 1
  • 2
  • 3
  • 4
  • 5
  • 8
by boen_robot
Sat Jul 06, 2019 4:21 pm
Forum: Scripting
Topic: userman with PHP [SOLVED]
Replies: 8
Views: 13606

Re: userman with PHP [SOLVED]

What you're doing is that for every iteration in your loop, you're making a brand new connection, login to the router once again. This is a huge waste of resources. Move the new RouterOS\Util and new RouterOS\Client outside of the loop, so that you keep using the same connection for all vouchers. Al...
by boen_robot
Wed Jul 03, 2019 9:21 am
Forum: Scripting
Topic: Mikrotik API call not working [SOLVED]
Replies: 37
Views: 54192

Re: Mikrotik API call not working [SOLVED]

Right now, PEAR2_Net_RouterOS supports the new login method only in the development version. That is, the currently unreleased 1.0.0b7. You can only get it via Composer by specifying "dev-develop" as your required version. Generating PHARs is a little bit difficult and time consuming right...
by boen_robot
Fri May 24, 2019 9:42 am
Forum: Scripting
Topic: how to api print range
Replies: 1
Views: 1353

Re: how to api print range

If there's a way to do it with scripting, there's a way to do it in the API. That said, I don't think there's a way to do it from scripting... RouterOS does let you scroll items interactively, and there's "no-paging" argument to make it not do that, but run down the screen immediatly. In t...
by boen_robot
Tue May 21, 2019 3:43 pm
Forum: Scripting
Topic: Time Format Api Call
Replies: 2
Views: 1659

Re: Time Format Api Call

You can still safely write "999d01:00:10". Just notice the lack of a space there. This is because the timeout is written as the scripting type "time", which supports this. You'll still get "42w5d1h10s" when you read it, but in terms of writing, it's fine. If you'd like ...
by boen_robot
Sun Apr 21, 2019 5:48 pm
Forum: General
Topic: ROS WebUI behind Apache reverse proxy
Replies: 3
Views: 2182

Re: ROS WebUI behind Apache reverse proxy

Have a look at Chrome's developer tools (F12), and more specifically the network tab. Compare what you see there with what you'll get if you open up the router directly. This will give you a hint as to what may be going on. I would guess that what's happening is that RouterOS is producting full link...
by boen_robot
Sat Apr 13, 2019 8:07 pm
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 4337

Re: Character Set

BTW, fun fact I learned just now first hand... MikroTik's mobile app supports and defaults to UTF-8, while allowing you to switch encodings. Assuming WebFig does also use UTF-8 (I haven't checked), this means Winbox and terminal are the only environments where UTF-8 is not supported. Terminal doesn'...
by boen_robot
Wed Apr 10, 2019 2:29 pm
Forum: Scripting
Topic: API call all in one
Replies: 1
Views: 1234

Re: API call all in one

You could use client's sendAsync() instead of the util methods. After making all sendAsync() calls, make a sequence of completeRequest() calls for each request, e.g. $client->sendAsync(new RouterOS\Request('/ip/hotspot/ip-binding/print', null, 'bindings')); $client->sendAsync(new RouterOS\Request('/...
by boen_robot
Sun Apr 07, 2019 11:31 pm
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 4337

Re: Character Set

Oh. Well, if Winbox doesn't allow you to type in both, then PHP is also working as expected. You have two options: 1. Write everything in Spanish. PEAR2_Net_RouterOS already uses iconv which should ignore (and therefore drop) all characters that Winbox would not allow you to type in. 2. Don't use ch...
by boen_robot
Sun Apr 07, 2019 5:32 pm
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 4337

Re: Character Set

What is your locale for non-Unicode applications (such as Winbox)? You can check by going to "Control Panel" > "Region" > "Administrative", under the "Current language for non-Unicode programs". Also if you click the "Change system locale", do you ha...
by boen_robot
Sun Apr 07, 2019 1:03 am
Forum: Scripting
Topic: Character Set
Replies: 6
Views: 4337

Re: Character Set

In addition to the Content-Type HTTP header and PEAR2_Net_RouterOS' charset settings, your actual PHP file (i.e. where the string is written) also needs to be UTF-8 encoded. To get a good handle on what the correct remote charset is, try to type something from Winbox that does contain the weird char...
by boen_robot
Tue Mar 26, 2019 3:21 pm
Forum: Scripting
Topic: PEAR2 RouterOS API new login method. [SOLVED]
Replies: 2
Views: 2145

Re: PEAR2 RouterOS API new login method. [SOLVED]

Does PEAR2 RouterOS already support the new login method? If you install with composer and using "dev-develop" as the version, yes. There is no PHAR release that includes this support yet. I haven't had time to prepare one. Also when the old login method will be removed from RouterOS? Fro...
by boen_robot
Mon Mar 25, 2019 12:18 am
Forum: Scripting
Topic: PHP Api add user and password to Hotspot
Replies: 9
Views: 8735

Re: PHP Api add user and password to Hotspot

Surround the add() with a try/catch, and in the catch, check if the error is the one you recognize and act accordingly. I.e. either remove and add the user (or you know, just set() them instead of remove(), then add()), or do what you do for all other errors (e.g. rethrow the exception). Or you coul...
by boen_robot
Mon Mar 25, 2019 12:12 am
Forum: Scripting
Topic: userman with PHP [SOLVED]
Replies: 8
Views: 13606

Re: userman with PHP [SOLVED]

"create-and-activate-profile" is a command, not a menu IIRC. It's not a normal CRUD command, so you'll have to make a request to give to Client, instead of using Util. Also, numbers should really contain the username (or otherwise the ID returned by finding the customer/username combo). e....
by boen_robot
Mon Mar 25, 2019 12:04 am
Forum: Scripting
Topic: Net_RouterOS interface monitor-traffic [SOLVED]
Replies: 1
Views: 1664

Re: Net_RouterOS interface monitor-traffic [SOLVED]

sendSync() waits for the command to finish executing. However, "/interface/monitor-traffic" is a continuous command - it never finishes executing until you manually stop it. You either have to pass the "once" argument to get just one sample in the $return, or use sendAsync() and ...
by boen_robot
Sun Mar 24, 2019 11:51 pm
Forum: Scripting
Topic: PEAR2 RouterOS - Up/Downgrade Mikrotik
Replies: 1
Views: 1223

Re: PEAR2 RouterOS - Up/Downgrade Mikrotik

AFAIK, a downgrade implicitly causes a reboot... Which means the API connection is closed. However, there's no indication to the client that the connection is being closed, which is why any command you would do after that would error. This API client in particular also sends a "/quit" comm...
by boen_robot
Tue Jan 22, 2019 8:20 pm
Forum: Scripting
Topic: php api script
Replies: 1
Views: 1315

Re: php api script

Using the API client from my signature: <?php require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; use PEAR2\Net\RouterOS; $util = new RouterOS\Util( $client = new RouterOS\Client('192.168.88.1', 'admin', 'password') ); $monitorTrafficResponses = $client->sendSync($util->setMenu('/interface') ->newReques...
by boen_robot
Thu Jan 10, 2019 3:28 pm
Forum: Scripting
Topic: Help on php api
Replies: 15
Views: 4672

Re: Help on php api

What about running the actual ping from the API? If the results are important for later in the script, you can pass the relevant parts of the result as parameters in Util::exec(), and act accordingly. You can run the actual ping with $pingResults = $client->sendSync( $util->setMenu('/tool')->newRequ...
by boen_robot
Thu Jan 10, 2019 12:03 pm
Forum: Scripting
Topic: API. Listening interfaces and bridges doesn't report deletions
Replies: 3
Views: 1445

Re: API. Listening interfaces and bridges doesn't report deletions

Yeah, I've also noticed that "/listen" is effectively an alias for "/print" with "follow-only" argument.

The .dead replies not being consistent across menus is probably a RouterOS bug.
by boen_robot
Thu Jan 10, 2019 11:42 am
Forum: Scripting
Topic: Help on php api
Replies: 15
Views: 4672

Re: Help on php api

You run it from the router how? Util::exec() uses "/system script run". If you're using f.e. scheduler, or /import a file, that's different. Also, Util::exec() prepends the current menu, while Script::prepare() doesn't (since it has no notion of a menu). If your script says "ping"...
by boen_robot
Mon Jan 07, 2019 4:17 pm
Forum: Scripting
Topic: API. Listening interfaces and bridges doesn't report deletions
Replies: 3
Views: 1445

Re: API. Listening interfaces and bridges doesn't report deletions

Try to use
/interface/print
=follow=
?dynamic=true
?#|
instead.

Print with "follow" behaves pretty much the same as "listen", as "print" is supposedly the only command that can accept queries.
by boen_robot
Mon Dec 24, 2018 4:21 pm
Forum: Scripting
Topic: API login
Replies: 1
Views: 1324

Re: API login

That's an odd timing to get that sort of an error... What API client are you using? What is the code that results in this error? Are you connecting directly to the router, or over a VPN or SSH tunnel? I can imagine several scenarios where this can happen, but none of them involve connecting directly...
by boen_robot
Mon Dec 24, 2018 4:03 pm
Forum: Scripting
Topic: PHP API =follow=1
Replies: 3
Views: 2624

Re: PHP API =follow=1

If you mean how do you make completeResponse() work... you just don't call loop().
by boen_robot
Tue Oct 09, 2018 9:40 am
Forum: General
Topic: Custom Hotspot Server - Cache Control and Expires Headers
Replies: 2
Views: 1863

Re: Custom Hotspot Server - Cache Control and Expires Headers

Any external server would require internet access, and hotspot prevents internet access. IMO, it's not worth the effort to cache hotspot page content, because users are supposed to get out of it as soon as possible and rarely see it. If you insist on caching it though, an external server is the way ...
by boen_robot
Tue Oct 09, 2018 9:37 am
Forum: Scripting
Topic: Android Ajax get not working
Replies: 1
Views: 1040

Re: Android Ajax get not working

Hard to tell... You should do some debugging. Both on success and on failure, dump the response (e.g. in an alert), see what it says, and continue investigating possible causes from there.
by boen_robot
Thu Oct 04, 2018 11:33 am
Forum: Scripting
Topic: C# API - disable serial port
Replies: 2
Views: 1395

Re: C# API - disable serial port

mikrotik.Send("/port/remote-access/set"); mikrotik.Send("=numbers=serial0"); mikrotik.Send("=disabled=true" , true); In general: 1. Target items with "=numbers=". 2. Specify properties to be modified with "=", name of property, "=", value....
by boen_robot
Tue Sep 18, 2018 4:58 pm
Forum: Scripting
Topic: port tracking in php PEAR2 Api
Replies: 2
Views: 1133

Re: port tracking in php PEAR2 Api

… And to do it on the app side, you can use preg_match while iterating over all items. You may narrow them down with other allowed criteria if you want (e.g. search for only tcp connections that come from a known interface) to optimize the performance somewhat. e.g. (without such criteria) foreach (...
by boen_robot
Thu Sep 06, 2018 2:52 pm
Forum: Scripting
Topic: Mikrotik synthesizer/piano programs
Replies: 23
Views: 20264

Re: Mikrotik synthesizer/piano programs

Requires VC2017 runtime I'd guess.
by boen_robot
Sun Aug 26, 2018 12:40 pm
Forum: Scripting
Topic: Get traffic usage via PEAR2 API
Replies: 2
Views: 2079

Re: Get traffic usage via PEAR2 API

Using a specialized tool that analyzes SNMP and/or Netflow to generate a graph would be most efficient for the router indeed. If you're OK with sacrificing some of that efficiency for the purposes of customizable implementation, the other way would be to detect a new PPPoE interface appearing (see y...
by boen_robot
Sat Aug 25, 2018 7:56 pm
Forum: Scripting
Topic: Retrieve list of PPP Active and compare with ppp secrets
Replies: 8
Views: 8036

Re: Retrieve list of PPP Active and compare with ppp secrets

If you have shell access to your web server, you can run a PHP from the command line. You can also add it as a startup script if you want it to also restart with a server restart. Or use cron if you want to run it at regular intervals rather than continuously. If you run it continuously, you can use...
by boen_robot
Mon Aug 13, 2018 9:08 pm
Forum: Scripting
Topic: Scripting and [] commands in PEAR2_Net_RouterOS [SOLVED]
Replies: 2
Views: 1758

Re: Scripting and [] commands in PEAR2_Net_RouterOS [SOLVED]

Easiest would be: $util = new RouterOS\Util($client); $util->setMenu('/ip firewall address-list')->disable(RouterOS\Query::where('address', '10.2.2.2')); Although there is a bug with Util and queries with multiple matches that's already fixed in the upcoming version... Until that version is released...
by boen_robot
Fri Aug 10, 2018 11:31 pm
Forum: Scripting
Topic: Class 'Phar' not found in /home/sharedhost/mysite/PEAR2_Net_RouterOS-1.0.0b6.phar on line 18
Replies: 2
Views: 1656

Re: Class 'Phar' not found in /home/sharedhost/mysite/PEAR2_Net_RouterOS-1.0.0b6.phar on line 18

For some reason your shared host doesn't have the Phar extension, which is required to open PHAR files. It may be using PHP 5.2 or earlier, where Phar was not enabled by default, or it may be disabled by the host for some reason. If the problem is 5.2, there's no workaround - find a different host w...
by boen_robot
Sat Aug 04, 2018 6:11 pm
Forum: Scripting
Topic: API /export problem
Replies: 16
Views: 9400

Re: API /export problem

Is there any progress with API and export? We have PHP side where we would like to send / export... and download via FTP afterwards, but very often we receive onyl file with interrupted lines. Or, Is there any process how to reach full export? Thank you You could use PHP to create a scheduler scrip...
by boen_robot
Sat Jul 14, 2018 6:04 pm
Forum: Scripting
Topic: New Mikrotik - Using API to log users instead of RADIUS server
Replies: 2
Views: 2828

Re: New Mikrotik - Using API to log users instead of RADIUS server

I assume you mean hotspot users. Yes, it's possible, but how easy it is depends on your topology. On successful authentication with your database, you'll need to create a temporary hotspot user with the API using the "/ip hotspot user add" command, then call the "/ip hotspot active lo...
by boen_robot
Mon Jul 09, 2018 5:31 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

With that setup, it should work, as long as
1) Both of the ethernet ports on the MikroTik are on the same bridge.
2) You have excluded your web server from hotspot via a "bypassed" IP binding that also sets it to a fixed IP.
by boen_robot
Fri Jul 06, 2018 10:29 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

It's generally not a good idea to have a web server running over Wi-Fi, precisely because of issues like this. The AP probably has "client isolation" enabled, meaning that Wi-Fi clients can't access either other. This is good for security, but bad if your goal IS for all Wi-Fi clients to s...
by boen_robot
Fri Jun 29, 2018 9:00 am
Forum: Scripting
Topic: Using set() with PEAR2
Replies: 1
Views: 1041

Re: Using set() with PEAR2

If the menu accepts names, you can just use it right there in place of the number, e.g. $util->set( 'myquota', array( 'limit-uptime' => $_GET['quota'] ) ); will look for an item named "myquota". If the item name contains a comma or matches the name of a function in PHP (and you don't want ...
by boen_robot
Sat Jun 23, 2018 2:29 pm
Forum: Scripting
Topic: Mikrotik API delete hosts
Replies: 5
Views: 3645

Re: Mikrotik API delete hosts

With the client from my signature:
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));

$util->setMenu('/ip hotspot host')->remove(RouterOS\Query::where('mac-address', '12:34:56:78:90:12'));
by boen_robot
Fri Jun 22, 2018 5:37 pm
Forum: Scripting
Topic: php API connection problem?
Replies: 17
Views: 12746

Re: php API connection problem?

Try the answers in the StackOverflow exchange linked above.
by boen_robot
Fri Jun 22, 2018 5:34 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

Maybe retry the whole installation from the beginning. Remove the whole vendor dir, as well as composer.json and composer.lock. Then run composer init enter whatever details you want, but make sure "minimum-stability" says "beta". When asked to define dependencies, search for &qu...
by boen_robot
Thu Jun 21, 2018 7:05 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

Strange... Did the two composer commands succeed with no errors?

Maybe try calling "composer update" to double check everything is installed, and regenerate the autoloader.
by boen_robot
Wed Jun 20, 2018 5:45 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

Run
composer config minimum-stability beta
and run
composer require pear2/net_routeros:@beta
again afterwards.
by boen_robot
Tue Jun 19, 2018 8:32 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

It will be quickest if you download the .phar file , and include it instead of trying to install PEAR or Pyrus. Or alternatively, install composer , call "composer require pear2/net_routeros:@beta", and include "vendor/autoload.php". The latest version of the API client is not av...
by boen_robot
Sun Jun 17, 2018 12:08 am
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

There are several possible reasons. To narrow it down, you'll need to see some error messages from PHP. Open up your php.ini, and find the lines "display_errors", "error_reporting", "error_log", and set them to display_errors = Off log_erros = On error_reporting = E_ALL...
by boen_robot
Fri Jun 15, 2018 9:17 am
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

The hotspot user credentials remain hosted on the router. The only thing you need to give to the script are credentials for a RouterOS user. From then on, the idea is similar to logging in from a terminal, and doing the commands on the router... Except that you're letting PHP do them automatically w...
by boen_robot
Tue Jun 05, 2018 10:19 am
Forum: Scripting
Topic: Help with PHP API
Replies: 3
Views: 6007

Re: Help with PHP API

key part from this error message is [_type:PEAR2\Net\RouterOS\Response:private] => !trap [attributes:protected] => Array ( [message] => input does not match any value of parent ) Apparently, you have no queue named "testparent", and thus the add() call in "/queue simple" fails. A...
by boen_robot
Sun Jun 03, 2018 2:04 pm
Forum: Scripting
Topic: Help with PHP API
Replies: 3
Views: 6007

Re: Help with PHP API

Using my PHP client: <?php require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; use PEAR2\Net\RouterOS; $util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password')); $util->setMenu('/ppp secret'); $util->remove('testuser'); $util->add( array( 'name' => 'testuser', 'passwo...
by boen_robot
Wed May 30, 2018 9:14 am
Forum: Scripting
Topic: "User hotspot change password itself"Mikrotik PHP API
Replies: 1
Views: 1715

Re: "User hotspot change password itself"Mikrotik PHP API

What do you mean "can't change password"? Before all that... Can you successfully open up the web page and see the correct username you're already logged in with? Does the form get submitted successfully, and yet setting the password fail?Are there any error messages at any point? What ver...
by boen_robot
Sat May 26, 2018 12:09 pm
Forum: Scripting
Topic: Print output for hotspot users
Replies: 3
Views: 6118

Re: Print output for hotspot users

You can use "print as-value" to save the output into a variable, that you can then loop over, and output in whatever fashion you want. f.e. :local users [/ip hotspot user print as-value]; :foreach user in=users do={ :put ($user->"username"); :put ($user->"password"); :p...
by boen_robot
Wed May 16, 2018 7:01 pm
Forum: Scripting
Topic: Multiple commands through API [SOLVED]
Replies: 2
Views: 2601

Re: Multiple commands through API [SOLVED]

Surrounding multiple commands on the command line with "{" and "}" and/or separating them with ";" isn't really combining them into one. The router still treats them as independent commands... I mean, you can't really combine commands into one call even on CLI, and thus...
by boen_robot
Wed May 16, 2018 6:53 pm
Forum: Scripting
Topic: running api as multi taksin C#?
Replies: 1
Views: 1147

Re: running api as multi taksin C#?

Search and read detailed tutorials on "threads". That's the thing you want - make each new connection its own thread. That will make your management device move back and forth between the different routers, which works out great, since you want it to manage a different router, while it wai...
by boen_robot
Fri May 11, 2018 8:25 pm
Forum: Scripting
Topic: Limit to API Call
Replies: 2
Views: 2030

Re: Limit to API Call

It's possible that the API client you're using isn't handling the network buffers well, so by the time it's finished processing what it has, the incoming packets have timed out, and it's not retrying. Or another possibility is that you have so many users in your client device's memory, that it can't...
by boen_robot
Tue May 08, 2018 9:38 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

The router model would've been sufficient (unless it was an x86 PC) :D

How much RAM you need depends on which OS you're going to install, and i don't know of a TILE compatible one you can use. In general, if you can spare at least 256MiB for the guest, that would most probably work.
by boen_robot
Mon May 07, 2018 3:13 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

(but under the hood, it would be turned into the first code) Thanks for your response, however, what do you mean by (but under the hood, it would be turned into the first code) I mean that if you analyze the source code for the RouterOS\Util::edit() method , you'll see that it ultimately does the s...
by boen_robot
Fri May 04, 2018 11:13 pm
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

The API protocol doesn't support "edit" commands. But to alter a property, you can use "set" as in the example code above. That API client in particular supports an edit() method that is really an alias for the above type of "set", e.g. the part $setRequest = new Router...
by boen_robot
Thu May 03, 2018 9:02 am
Forum: Scripting
Topic: Change of Password for hotspot users
Replies: 27
Views: 26868

Re: Change of Password for hotspot users

I got this code online and created a script named changepass.php by clicking on plus button in winbox system and then script. That's not how PHP or even the API in general works. RouterOS can't run PHP. You need to create the file on a separate device (or a KVM/MetaRouter), and have a web server an...
by boen_robot
Wed May 02, 2018 9:57 pm
Forum: Scripting
Topic: getting menu commands
Replies: 1
Views: 1058

Re: getting menu commands

Unfortunately, the API protocol doesn't support giving this type of meta data.

I've already made a feature request along with an example spec for what exactly they could implement, but as you can see, it's a very low priority for MikroTik.
by boen_robot
Tue May 01, 2018 11:41 am
Forum: General
Topic: openvpn and api
Replies: 1
Views: 902

Re: openvpn and api

Try to change the API port to port 80.

If you can connect that way, then the problem is the device that is connecting with the API. That device's firewall needs to allow outgoing connections to the API port. Port 80 is already allowed, since it's normally used for HTTP, but the API port isn't.
by boen_robot
Sat Apr 28, 2018 1:05 am
Forum: Scripting
Topic: API and RoMON
Replies: 1
Views: 1347

Re: API and RoMON

API is it's own TCP protocol, so I don't see this being possible without the api port taking in a special option during the login to forward the request over RoMON.
by boen_robot
Sat Apr 21, 2018 11:20 pm
Forum: Scripting
Topic: PEAR2_Net_RouterOS-1.0.0b6 and dummy fast-track rule
Replies: 1
Views: 1240

Re: PEAR2_Net_RouterOS-1.0.0b6 and dummy fast-track rule

Discussion happed at this GitHub issue.

(for future reference of other people reading the forum)
by boen_robot
Sat Apr 21, 2018 11:10 pm
Forum: Scripting
Topic: Interface Printout PHP API
Replies: 15
Views: 6386

Re: Interface Printout PHP API

<?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; $util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password')); $util->setMenu('/tool bandwidth-server')->set(null, array('enabled' => 'true')); For boolean fields, the API protocol uses the...
by boen_robot
Wed Apr 18, 2018 9:40 pm
Forum: Scripting
Topic: API external connection
Replies: 1
Views: 2136

Re: API external connection

You probably need to enable PHP to make outgoing connections in the web server's firewall. If you're on a web hosting plan, chances are you can already make outgoing connections to port 80 (HTTP), 443 (HTTPS) and 23 (FTP). Try to change the API port to this one, and connect with that instead. If it ...
by boen_robot
Mon Apr 09, 2018 10:23 pm
Forum: Scripting
Topic: RUNNING SCRIPT FROM PHP API
Replies: 1
Views: 1491

Re: RUNNING SCRIPT FROM PHP API

Don't use numbers. In the case of "actual" API calls, use "print" with a query that matches the item(s) you want affected, and get the ID from the ".id" property returned. If you've just added and ran a script in "/system script", then just use a nested "...
by boen_robot
Fri Apr 06, 2018 11:28 pm
Forum: Scripting
Topic: Api script add from file
Replies: 3
Views: 1664

Re: Api script add from file

You make two API calls - one to get the file contents from the router to the API client, another to put that content into the script. That's also how CLI does it, except that it's on a single line. Or you could add the script with the CLI contents in it, and run it, to let it modify itself. That's a...
by boen_robot
Tue Mar 27, 2018 3:04 pm
Forum: Scripting
Topic: sript to remove total bytes limit hotspot user
Replies: 4
Views: 2464

Re: sript to remove total bytes limit hotspot user

Or just
/ip hotspot user profile set [find] rate-limit=""
by boen_robot
Mon Mar 12, 2018 5:15 pm
Forum: Scripting
Topic: Built in function library
Replies: 132
Views: 133670

Re: Built in function library

Oh, oh... one more important idea... A function to show the type and value of a variable. When outputting strings or arrays, include lengths, and when outputting strings, surround them with quotes and escape quotes, slashes and unprintable characters inside (so that what's shown could potentially be...
by boen_robot
Thu Mar 08, 2018 5:22 pm
Forum: Scripting
Topic: Built in function library
Replies: 132
Views: 133670

Re: Built in function library

From most important to least importing in my opinion: String replacement. Both by a string needle, and a regex match. String splitting (into an array of strings). Both by a string needle, and a regex match. Joining strings in an array into a single string with a specified string between each array m...
by boen_robot
Tue Mar 06, 2018 4:31 pm
Forum: Scripting
Topic: PHP : hotspot user delete? [SOLVED]
Replies: 4
Views: 3214

Re: PHP : hotspot user delete? [SOLVED]

For the update, set() is the command you're looking for, and for the check, find(), which will be an empty string if the user is not found. Also, move the unconditional parts above the check, f.e. <?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar'; $util = new RouterOS\Util...
by boen_robot
Tue Mar 06, 2018 3:42 pm
Forum: Scripting
Topic: PHP : hotspot user delete? [SOLVED]
Replies: 4
Views: 3214

Re: PHP : hotspot user delete? [SOLVED]

As the name suggests, setMenu() is only about the menu, not about the command.

There are separate methods for each command. In this case:
$util->setMenu('/ip hotspot user')->remove(RouterOS\Query::where('name', '77777777'));
(also, side note, the latest version is 1.0.0b6)
by boen_robot
Tue Feb 27, 2018 12:13 am
Forum: Scripting
Topic: find where var~"hello" ... find where var!~"hello" [SOLVED]
Replies: 7
Views: 2416

Re: find where var~"hello" ... find where var!~"hello" [SOLVED]

[find where !(var~"hello")]
by boen_robot
Thu Feb 22, 2018 2:14 am
Forum: Scripting
Topic: bug report : find where builtin=no differs from builtin!=yes
Replies: 1
Views: 967

Re: bug report : find where builtin=no differs from builtin!=yes

Note that existence checks should work as expected: [admin@Box-04715E] /interface list> :put [ /interface list find where builtin ]; *2000000;*2000001;*2000002 [admin@Box-04715E] /interface list> :put [ /interface list find where !builtin ]; *2000010;*2000011;*2000012;*2000013;*2000014;*2000015
by boen_robot
Wed Feb 21, 2018 2:12 pm
Forum: Beginner Basics
Topic: how to access mikrotik from internet
Replies: 5
Views: 2805

Re: how to access mikrotik from internet

This is not a setting in MikroTik. It's at your modem.

As Lomez already said:
Hi,

If you have no Firewall rules on Mikrotik device, so you should just create some Forward rules on your Modem.
For example for web you must forward 172.x.x.x whatever port to 192.168.1.5:80.
by boen_robot
Wed Feb 21, 2018 12:33 pm
Forum: Scripting
Topic: disconnect from API in c#
Replies: 4
Views: 1634

Re: disconnect from API in c#

What does Read() do really? Read one sentence? Read until a !done sentence? Read until a timeout? Does it produce a single array/list that foreach is iterating over, or is it returning an iterator? Does it throw an exception? Debug this code with Visual Studio (place a breakpoint before the foreach)...
by boen_robot
Wed Feb 21, 2018 12:11 pm
Forum: General
Topic: GoDaddy's "Connection refused" - PHP API [SOLVED]
Replies: 4
Views: 3934

Re: GoDaddy's "Connection refused" - PHP API [SOLVED]

That's not what the reply says, and you're not asking the question that will get you results. Again: Ask them to "allow PHP to make outgoing connections to TCP port 8728". If you have that, you're set. OR configure the API to use TCP port 80 (and move Webfig to a different port, or disable...
by boen_robot
Tue Feb 20, 2018 9:21 pm
Forum: Scripting
Topic: script to write to file
Replies: 1
Views: 1719

Re: script to write to file

If the router is powerful enough, you could run a VM (using MetaRouter or KVM for x86), and run an API application from there. That's as local as you can get with that. If not that, you could collect all of your output in a single variable, and then output the variable to a file that you then send. ...
by boen_robot
Tue Feb 20, 2018 4:03 pm
Forum: Scripting
Topic: Multiple Scripts or Multiple Functions In a Script. [SOLVED]
Replies: 7
Views: 4618

Re: Multiple Scripts or Multiple Functions In a Script. [SOLVED]

That's a regular expression, sometimes called "regex" for short. RouterOS in particular uses POSIX Extended regular expressions. There are lots of tutorials on the internet for it - here's one . You can match a string against a regular expression by using "=~" instead of just &qu...
by boen_robot
Mon Feb 19, 2018 11:19 pm
Forum: Scripting
Topic: Multiple Scripts or Multiple Functions In a Script. [SOLVED]
Replies: 7
Views: 4618

Re: Multiple Scripts or Multiple Functions In a Script. [SOLVED]

Use the regex operator: /file remove [find name=~"^(filename1\\.rsc|filename2\\.rsc|folder/script\\.rsc)\$"] To remove "filename1.rsc" and "filename2.rsc" and "folder/script.rsc". Or you could "or" multiple conditions: /file remove [find name="f...
by boen_robot
Mon Feb 19, 2018 4:03 pm
Forum: Scripting
Topic: Multiple Scripts or Multiple Functions In a Script. [SOLVED]
Replies: 7
Views: 4618

Re: Multiple Scripts or Multiple Functions In a Script. [SOLVED]

IMHO, it's usually best to download everything as one file BUT then import it as multiple scripts/schedules. If something is used across multiple scripts/schedules, import it as a global variable that is a function, and use that function when needed. This is for scripts. However, by the way you're d...
by boen_robot
Sun Feb 18, 2018 5:10 pm
Forum: Scripting
Topic: Parsing problems with 'print terse' and 'print as-value'
Replies: 5
Views: 5763

Re: Parsing problems with 'print terse' and 'print as-value'

To be clear, my format above is not a 1:1 the API, due to the way the length is encoded/decoded, so you can't just give that portion to an API client with no alterations to the API client itself. After some experimentation, I see :put can output control characters as well with no escapes (which btw,...
by boen_robot
Fri Feb 16, 2018 12:26 pm
Forum: Scripting
Topic: if statement is not working [SOLVED]
Replies: 9
Views: 2930

Re: if statement is not working [SOLVED]

I've tried to run this simple code with script , but no luck

:if(1=1) do={:log info message="dddddddddd"}
You're missing a space after the "if". It's ":if (", not ":if(".
by boen_robot
Fri Feb 16, 2018 12:24 pm
Forum: Scripting
Topic: API set command
Replies: 6
Views: 3938

Re: API set command

Looking more closely at the source of mikumlib, the ID you get with its methods doesn't include the "*". However, that is required when actually giving the ID to RouterOS.

So make that
mk.Send("=numbers=*" + user.Id);
by boen_robot
Thu Feb 15, 2018 11:48 pm
Forum: Scripting
Topic: Parsing problems with 'print terse' and 'print as-value'
Replies: 5
Views: 5763

Re: Parsing problems with 'print terse' and 'print as-value'

If you use "print as-value", you then have an array of associative arrays, that you can then manually output into whatever string format you want. You do have to make a custom formatter, yes, but at least you can get an API-like level of reliability that way. Here's one possible API-ish ou...
by boen_robot
Thu Feb 15, 2018 10:30 pm
Forum: Scripting
Topic: API set command
Replies: 6
Views: 3938

Re: API set command

Each call to the Send() method represents one API word. And each sentence contains multiple words, plus a single empty one. So f.e. if (Login()) { mk.Send(url + "set"); mk.Send("=numbers=" + user.Id); mk.Send("=password=" + password); mk.Send(""); var output =...
by boen_robot
Thu Feb 15, 2018 9:08 pm
Forum: Scripting
Topic: API set command
Replies: 6
Views: 3938

Re: API set command

Can you show your actual code? When you say other commands... Do you mean remove/enable/disable? Or just "add"? Because with the exception of "add", other commands require the ID of the item(s) you want to target in the "numbers" argument, and you first need to get with...
by boen_robot
Sun Feb 11, 2018 5:48 pm
Forum: Scripting
Topic: Search mangle by command contain script...
Replies: 5
Views: 2087

Re: Search mangle by command contain script...

Just check it and got an error :/ "missing value for where (line 1 column 48)" Oops... Sorry... It's been a while since I've used the regex operator... It's /ip firewall mangle remove [find where comment=~"incoming from"] (the "~" is AFTER the "=", not before...
by boen_robot
Sat Feb 10, 2018 12:20 pm
Forum: Scripting
Topic: Search mangle by command contain script...
Replies: 5
Views: 2087

Re: Search mangle by command contain script...

There is, but you don't have to use foreach at all. You can just use "find" to match the correct items: /ip firewall mangle remove [find where comment~="incoming from"] The "find" gets you IDs of all items that contain "incoming from" in comment, and "rem...
by boen_robot
Fri Feb 09, 2018 12:51 pm
Forum: General
Topic: /queue simple > add [...] \ interface=? [SOLVED]
Replies: 3
Views: 1539

Re: /queue simple > add [...] \ interface=? [SOLVED]

The interface argument existed in RouterOS v5, and was removed in v6. It's functionality is part of the "target" argument since then. The manual hasn't been updated completely it seems. The exact analog in v6 would be to have parent queue that matches all traffic from ether2, and a child q...
by boen_robot
Thu Feb 08, 2018 8:22 pm
Forum: General
Topic: tls-host no document [SOLVED]
Replies: 18
Views: 10826

Re: tls-host no document [SOLVED]

I'm guessing that this matcher doesn't work on SYN and ACK packets, but instead it inspects the first content packets. The destination and source address are as determined without this matcher. And on a match, it terminates the original connection between router and server, and creates a new one to ...
by boen_robot
Wed Feb 07, 2018 5:49 pm
Forum: General
Topic: Slow login via ssh
Replies: 2
Views: 1626

Re: Slow login via ssh

SSH is encrypted, while API and Telnet aren't... That's probably the reason for the delay. You can make it faster by using an ECDSA key instead of an RSA one, and preferring ECDHE key exchange and ChaCha20 as your cipher... I don't know which one of these if any is supported by RouterOS though. I'm ...
by boen_robot
Wed Feb 07, 2018 1:14 pm
Forum: General
Topic: GoDaddy's "Connection refused" - PHP API [SOLVED]
Replies: 4
Views: 3934

Re: GoDaddy's "Connection refused" - PHP API [SOLVED]

You need to allow PHP to make outgoing connections in the OS' firewall. How exactly do you do that with GoDaddy, I don't know, as it depends on whether PHP is running as (F)CGI or an Apache module, and it also depends on whether SELinux is installed and enabled. I suggest you contact GoDaddy's suppo...
by boen_robot
Tue Feb 06, 2018 5:10 pm
Forum: Scripting
Topic: disconnect from API in c#
Replies: 4
Views: 1634

Re: disconnect from API in c#

Well, there is a "/quit" command, yes. And that would make RouterOS terminate the connection. To terminate it on the client side (ideally after calling "/quit" and waiting for the !fatal reply)... Depends on the exact client, but I'd hope that if it doesn't have a disconnect() me...
by boen_robot
Tue Feb 06, 2018 5:01 pm
Forum: General
Topic: Create external hotspot server with mikrotik?
Replies: 5
Views: 3265

Re: Create external hotspot server with mikrotik?

In addition to the RADIUS server, you'd setup a web server (Apache, Nginx) on the device where the RADIUS server sits. Or it could be a separate device, but the point is it's separate and in addition to RADIUS. The router redirects to the web page. The web page redirects back to the router with the ...
by boen_robot
Tue Feb 06, 2018 1:32 pm
Forum: General
Topic: Create external hotspot server with mikrotik?
Replies: 5
Views: 3265

Re: Create external hotspot server with mikrotik?

See this page in the manual for more details on RADIUS. Basically, in the "/radius" menu, you add a RADIUS server, tell MikroTik to use it for hotspot, and in the hotspot server profile, you check the "use RADIUS" option. That's about it on the MikroTik end... If a user doesn't e...
by boen_robot
Mon Feb 05, 2018 6:03 pm
Forum: General
Topic: tls-host no document [SOLVED]
Replies: 18
Views: 10826

Re: tls-host no document [SOLVED]

It is now added to the docs... And just as I said, it's based on the SNI value. Although an interesting caveat is that the TLS handshake the client sends needs to be within a single packet for the matcher to work. And since TLS is on a higher OSI level than TCP, sure, the idea is similar to L7 filte...
by boen_robot
Mon Feb 05, 2018 5:49 pm
Forum: Scripting
Topic: Using loop functions in rsc-files
Replies: 4
Views: 1603

Re: Using loop functions in rsc-files

From some quick tests, :global works as expected... The tricky part is to use it without a value in script in order to import a variable without setting it. If you call :global WITH a value, you are effectively setting its value to the one specified... The difference with ":set" being that...
by boen_robot
Mon Feb 05, 2018 1:57 pm
Forum: Scripting
Topic: Coding a RB Simulator
Replies: 6
Views: 2370

Re: Coding a RB Simulator

Run normal chr instead the simulator. What is normal chr? Cloud Hosted Router . A version of RouterOS for use in Virtual Machines, like VirtualBox, VMWare and the like. You get the real software running on a virtual hardware, and you can have as many of them running at once as the real hardware wil...
by boen_robot
Mon Feb 05, 2018 1:24 pm
Forum: Scripting
Topic: PHP Api by Vasil customization for web proxy
Replies: 6
Views: 2274

Re: PHP Api by Vasil customization for web proxy

When I say "inspect", I don't mean anything specific... I mean just lookup the information about the error that you want to show and/or act differently based on. The $e variable contains an Exception object containing all sorts of information about the error. Different types of errors cont...
by boen_robot
Sun Feb 04, 2018 12:21 pm
Forum: Scripting
Topic: change firewall filter order via script or API
Replies: 3
Views: 2898

Re: change firewall filter order via script or API

The way you can do that is to move the rules above the "unused-hs-chain" chain rule, disable hotspot, then immediately enable it again. This will recreate all dynamic rules, placing them above the "unused-hs-chain" chain rule. Or if you want to avoid the disable/enable steps, I g...
by boen_robot
Sun Feb 04, 2018 12:09 pm
Forum: Scripting
Topic: How to filter routes with API [SOLVED]
Replies: 2
Views: 2155

Re: How to filter routes with API [SOLVED]

In current RouterOS versions, you can't use the "in" operator... or the "~" operator, while we're at it. The only way you can do that currently is on the client side, which yes, means you'd first have to get all items matching other criteria, meaning more bandwidth wasted. OR The...
by boen_robot
Thu Feb 01, 2018 11:01 pm
Forum: General
Topic: tls-host no document [SOLVED]
Replies: 18
Views: 10826

Re: tls-host no document [SOLVED]

P.S. Also, why is this matcher added to NAT rules? There's no info about TLS hostname in TCP SYN packets :) There kind of is in recent TLS versions, supported by modern browsers and servers: SNI I'm assuming this is what this matcher checks. However, browsers or other applications that don't suppor...
by boen_robot
Thu Feb 01, 2018 6:28 pm
Forum: General
Topic: Create external hotspot server with mikrotik?
Replies: 5
Views: 3265

Re: Create external hotspot server with mikrotik?

To manage multiple routers from a single central authority, it's best you set up a RADIUS server, and have all of your hotspots connect to it. For the central web page... You can use rlogin.html (see this guide for details ) to setup a <meta> redirect to the external hotspot page.. Which should be i...
by boen_robot
Thu Feb 01, 2018 6:13 pm
Forum: General
Topic: Captive Portal Apple with Angular 5 - Rest Api
Replies: 6
Views: 2470

Re: Captive Portal Apple with Angular 5 - Rest Api

The whole point of the NAT is so that you only need a DNS record for the hotspot router 10.5.0.1. Remove your DNS record for 52.67.yy.xx and change your links to only point to either "webserver.mydomain.com" or "webserver.mydomain.com:8080". In fact, if you want things to also wo...
by boen_robot
Thu Feb 01, 2018 6:02 pm
Forum: Scripting
Topic: change firewall filter order via script or API
Replies: 3
Views: 2898

Re: change firewall filter order via script or API

Use the "move" command. "numbers" argument is the item(s) to move (in the other they must appear after the move), and the "destination" argument is item above which the targeted item(s) are to appear. If "destination" is omitted, the targeted items are moved t...
by boen_robot
Mon Jan 29, 2018 10:15 pm
Forum: General
Topic: Captive Portal Apple with Angular 5 - Rest Api
Replies: 6
Views: 2470

Re: Captive Portal Apple with Angular 5 - Rest Api

Like I said, I made both use the same IP, but different ports. You can add a dst-nat rule in the firewall to forward traffic to f.e. the router's TCP 8080 to the web server's TCP 80. More specifically: /ip firewall nat add action=dst-nat chain=dstnat dst-address-type=local protocol=tcp port=8080 to-...
by boen_robot
Mon Jan 29, 2018 1:42 pm
Forum: General
Topic: Captive Portal Apple with Angular 5 - Rest Api
Replies: 6
Views: 2470

Re: Captive Portal Apple with Angular 5 - Rest Api

Last time I was dealing with a similar issue, the cause was that iOS Safari for some bizarre reason needed both the web server and the hotspot portal to originate from the same IP, and differ only by port (instead of, like I wanted it, for the web server to be in a subdomain of the hotspot). I didn'...
by boen_robot
Mon Jan 29, 2018 11:54 am
Forum: Beginner Basics
Topic: IP firewall rules wihen default chain action is DROP [SOLVED]
Replies: 6
Views: 5386

Re: IP firewall rules wihen default chain action is DROP [SOLVED]

For that particular example, you're right, it doesn't make sense, since there aren't any accept rules later on. Perhaps that example was made such that it could be inserted into any rule set with no modifications. But a better rule set would indeed be to just accept the allowed and drop the rest, so...
by boen_robot
Mon Jan 29, 2018 1:24 am
Forum: Beginner Basics
Topic: IP firewall rules wihen default chain action is DROP [SOLVED]
Replies: 6
Views: 5386

Re: IP firewall rules wihen default chain action is DROP [SOLVED]

It's a matter of efficiency. If a firewall rule has an action that has an accept, drop or reject as an action, processing in that built in chain is finished. Otherwise, all rules are processed from top to bottom until such a rule is encountered and matched.
by boen_robot
Mon Jan 29, 2018 12:55 am
Forum: Scripting
Topic: API written in C
Replies: 2
Views: 1181

Re: API written in C

Post it to GitHub maybe? Also, one note based on a skim of the source: // ******************************************************************** // readBlock // ******************************************************************** // READ A BLOCK FROM THE SOCKET. // // Read a block of sentences from th...
by boen_robot
Sun Jan 28, 2018 4:17 pm
Forum: Beginner Basics
Topic: In what programming language was Winbox made? [SOLVED]
Replies: 8
Views: 3917

Re: In what programming language was Winbox made? [SOLVED]

I don't think Qt is the GUI toolkit though... Doesn't look exactly like it.
by boen_robot
Fri Jan 26, 2018 10:43 pm
Forum: Scripting
Topic: Quickly clone firewall rules via API written in C.
Replies: 4
Views: 1751

Re: Quickly clone firewall rules via API written in C.

Have you considered simply making a generic, cross platform, full featured (ideally focused to ease of use for the developer) API client with bindings for various other languages (e.g. for a PHP extension, a Node module, an unmanaged .NET assembly, etc.)? Current implementations aren't... that... so...
by boen_robot
Tue Jan 23, 2018 3:35 pm
Forum: Scripting
Topic: API set .id * not working - how to set all vi API
Replies: 7
Views: 2849

Re: API set .id * not working - how to set all vi API

You have to call the "find" command separately to get the (comma separated) list of all IDs. Write that list as the value of .id/numbers. isn't there a wildcard symbol or regex that I could use instead? At this time, no. There's no such feature in the protocol. Technically, it doesn't eve...
by boen_robot
Tue Jan 23, 2018 3:10 pm
Forum: Scripting
Topic: API set .id * not working - how to set all vi API
Replies: 7
Views: 2849

Re: API set .id * not working - how to set all vi API

You have to call the "find" command separately to get the (comma separated) list of all IDs. Write that list as the value of .id/numbers.
by boen_robot
Sat Jan 20, 2018 12:46 pm
Forum: Scripting
Topic: [Solved] read hotspot user password with php
Replies: 7
Views: 12923

Re: [Solved] read hotspot user password with php

This is an example of Util being overly helpful... my bad... Because the terminal can accept numbers, and yet the API can't, under the hood, when you attempt to get an item with a number, Util indexes all IDs into a numeric array, and then gets the ID out of it. That's the ID cache. It normally work...
by boen_robot
Fri Jan 19, 2018 3:14 pm
Forum: General
Topic: Mikrotik api
Replies: 1
Views: 853

Re: Mikrotik api

Usually, giving the argument "detail" will give you properties that are normally hidden without it. The raw protocol data to send is /ip/hotspot/user/print =detail= /ppp/secret/print =detail= But exactly how do you run it and extract results from it depends on the client you're using. With...
by boen_robot
Fri Jan 19, 2018 2:56 pm
Forum: Scripting
Topic: [Solved] read hotspot user password with php
Replies: 7
Views: 12923

Re: [Solved] read hotspot user password with php

By catching the exception and showing the error there: try { echo $util->setMenu('/ip hotspot user')->get('user1', 'password'); } catch (RouterOS\RouterErrorException $e) { echo '<script>alert("Your USER ID not found or is wrong."); window.location.href = "https://www.google.com"...
by boen_robot
Thu Jan 18, 2018 1:01 pm
Forum: Scripting
Topic: [Solved] read hotspot user password with php
Replies: 7
Views: 12923

Re: read hotspot user password with php

Using the API client from my signature: <?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; $util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password')); echo $util->setMenu('/ip hotspot user')->get('user1', 'password'); This will output the...
by boen_robot
Wed Jan 17, 2018 2:40 pm
Forum: Scripting
Topic: if statement... how? [SOLVED]
Replies: 9
Views: 4172

Re: if statement... how? [SOLVED]

:local x [/system identity get name]; :local y "MikroTik"; :local z [/system clock get dst-active]; :if ($x = $y && $z) do={ :put "Router identify is 'MikroTik' and we are currently in dailight savings time."; } else={ :put "Either router identity is not 'MikroTik',...
by boen_robot
Fri Jan 12, 2018 1:26 pm
Forum: Scripting
Topic: Reset Simple Queue Counters from API ? [SOLVED]
Replies: 2
Views: 2427

Re: Reset Simple Queue Counters from API ? [SOLVED]

You can use the queue name in place of the number. Same is true for any menu where unique names are required (e.g. interface). In menus that don't support this, you have to use a query to get the ID of the item(s) you want to target. e.g. <?php require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; use PEA...
by boen_robot
Fri Dec 22, 2017 8:35 pm
Forum: General
Topic: question about DNS allow remote requests
Replies: 7
Views: 7510

Re: question about DNS allow remote requests

You should use "/ip firewall filter" to drop DNS requests coming in from the WAN interface(s). With this setting on, and without filters, the router will respond to requests coming in from any interface, because RouterOS can't "know" if an interface is a WAN or LAN one. The filte...
by boen_robot
Fri Dec 22, 2017 7:28 pm
Forum: Scripting
Topic: Trying to run API in java - first time
Replies: 1
Views: 1239

Re: Trying to run API in java - first time

There are instructions on the page . You could use Maven (a package manager for Java - the concept is similar to C#'s Nuget). There's an Eclipse plugin for Maven if you'd like to go on that route. I haven't used Maven at all, so I can't be of assistance on that route. The other way is to download th...
by boen_robot
Mon Dec 18, 2017 11:48 pm
Forum: General
Topic: Get MAC address [SOLVED]
Replies: 4
Views: 2749

Re: Get MAC address [SOLVED]

The port can be specified at the 4th argument (defaults to API's default port 8728). As for the error... oops, my bad... missed an "n" in the variable name when doing the call (it's "snmp", not "smp"). I'll also fix it above for any copy&paste bypassing reader of th...
by boen_robot
Mon Dec 18, 2017 12:08 am
Forum: General
Topic: Get MAC address [SOLVED]
Replies: 4
Views: 2749

Re: Get MAC address [SOLVED]

The value is technically correct... It's just that It's shown as an ASCII string. "58" is the hex value of "X", and "0D" is the hex value for carriage return. If you're trying to automate, you should use the API instead of SSH. f.e. using the PHP client from my signatur...
by boen_robot
Thu Dec 14, 2017 8:09 pm
Forum: Scripting
Topic: Interface Printout PHP API
Replies: 15
Views: 6386

Re: Interface Printout PHP API

since I have your attention I have one more question: I connect the clients SXT via api-ssl, I want to change the pppoe account. The account changes, but the IP address changes as well, and the script starts to hang. After reaching the timeout, the page is displayed, can I not wait for the answer, ...
by boen_robot
Thu Dec 14, 2017 2:39 pm
Forum: Scripting
Topic: Interface Printout PHP API
Replies: 15
Views: 6386

Re: Interface Printout PHP API

Strange... I thought I specifically made it so that ADH is the default if no context is provided... Then again, I haven't thoroughly tested SSL due to problems with PHP, so this may also be a version specific thing... You can manually add a context with all desired options. For ADH (i.e. without a c...
by boen_robot
Mon Dec 11, 2017 6:47 pm
Forum: Scripting
Topic: Mikrotik API - Show hotspot customer information
Replies: 4
Views: 4068

Re: Mikrotik API - Show hotspot customer information

The very next example uses the hotspot cookie instead of $_SERVER['REMOTE_ADDR'], but as the entire section clarifies, you need to setup the router and server in a particular way to enable the server to read cookies set by the router. Once you have the user, you can use it to filter other hotspot me...
by boen_robot
Sun Dec 10, 2017 8:18 pm
Forum: Scripting
Topic: Mikrotik API - Show hotspot customer information
Replies: 4
Views: 4068

Re: Mikrotik API - Show hotspot customer information

Check out the forgotten password example for an example of this very thing.

That page checks the username of the user that opened the page as part of the process, but instead of changing the password for that user, you can just further query the router for information related to the user.
by boen_robot
Fri Nov 10, 2017 11:02 pm
Forum: General
Topic: Ignore specific logs( login - logout via API)
Replies: 1
Views: 1083

Re: Ignore specific logs( login - logout via API)

Not login/logout logs exactly, but you can filter by topic... Only exact topic lists though (as they appear on the command line). The API protocol doesn't yet support the "in" or "~" operators to let you match just a part of the topics. In the case of login/logout, you're looking...
by boen_robot
Mon Nov 06, 2017 9:54 pm
Forum: Scripting
Topic: Get pppoe in interface
Replies: 4
Views: 3059

Re: Get pppoe in interface

Sure: <?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; $client = new RouterOS\Client('192.168.88.1', 'admin', 'password'); $request = new RouterOS\Request('/interface pppoe-server monitor'); $request->setArgument('numbers', '<pppoe-user>')->setArgument('once'); ////Or if...
by boen_robot
Sat Nov 04, 2017 10:17 pm
Forum: Scripting
Topic: Update ROS and firmware via scripting / API
Replies: 3
Views: 2244

Re: Update ROS and firmware via scripting / API

You could make a scheduler script that would run after a few seconds from its creation time. Once it starts, it would remove itself and do the upgrade (in that order). Whether you make it with a terminal or API, it should work the same way, and allow you to disconnect as soon as the scheduler script...
by boen_robot
Wed Nov 01, 2017 5:03 pm
Forum: Beginner Basics
Topic: The better PHP API
Replies: 6
Views: 2513

Re: The better PHP API

The non-ssl version of the protocol (service name "api") sends and receives everything in plain text, except the password when you login, which is sent and checked in a CHAP-like authentication manner (making that part difficult to brute force). Using the SSL version (service name "ap...
by boen_robot
Fri Oct 13, 2017 1:10 pm
Forum: Beginner Basics
Topic: The better PHP API
Replies: 6
Views: 2513

Re: The better PHP API

Am I correct in understanding that using these kinds of API means that some functionality from the MikroTik cannot be exploited? Yes and no. If you can do something with the command line (Telnet, SSH, or the "New Terminal" window from Winbox and Webfig), you can almost always do it in an ...
by boen_robot
Wed Oct 11, 2017 7:02 pm
Forum: Beginner Basics
Topic: The better PHP API
Replies: 6
Views: 2513

Re: The better PHP API

Thanks for checking out my presentation. As the first slide says, the RouterOS API is really a custom Layer7 (i.e. "application layer") protocol. I.e. another protocol on the level of HTTP, SSH, SMTP and the like, except it's a proprietary one, defined by MikroTik. The protocol itself is v...
by boen_robot
Fri Oct 06, 2017 9:12 pm
Forum: Scripting
Topic: Get GPS values
Replies: 2
Views: 1878

Re: Get GPS values

You can use the "do" argument, e.g. /system gps monitor once do={ :put $longitude; :put $latitude; :put $speed; }; To find out all available variables inside the "do", write "$" and press the Tab key while inside the "do" block. Mikrotiks sport a gps device? Y...
by boen_robot
Wed Oct 04, 2017 2:41 pm
Forum: Scripting
Topic: How to return 'tx-bits-per-second' and 'rx-bits-per-second' with PEAR2_Net_RouterOS-1.0.0b6.phar [SOLVED]
Replies: 1
Views: 2064

Re: How to return 'tx-bits-per-second' and 'rx-bits-per-second' with PEAR2_Net_RouterOS-1.0.0b6.phar [SOLVED]

If you want to get just one probe per HTTP request, then you should define a queue for the hotspot user profile, and then get the "rate" property of the generated queue. if you want to monitor the rate continuously, then you should instead use "/tool torch", and use the hotspot s...
by boen_robot
Tue Oct 03, 2017 5:42 pm
Forum: General
Topic: White list web-pages
Replies: 1
Views: 886

Re: White list web-pages

You can't do that for HTTPS. By design, HTTPS is made to not allow that. For HTTP, you can setup a proxy , and define your access rules the way you want them. If you want to forbid an entire domain (for both HTTP and HTTPS), you can setup an address list with the domain name as the address, then set...
by boen_robot
Thu Sep 28, 2017 1:25 pm
Forum: Scripting
Topic: API - PHP [SOLVED]
Replies: 2
Views: 1733

Re: API - PHP [SOLVED]

Regular expressions are not supported by the API protocol yet.

Currently, the only way to do this sort of thing is on the PHP side, i.e. get all items, and check the properties with preg_match().
by boen_robot
Sat Sep 23, 2017 1:00 pm
Forum: Scripting
Topic: getting sms rx/tx
Replies: 3
Views: 1403

Re: getting sms rx/tx

You could collect the reads in an array that's defined outside, and then send the SMS after all reads are done. e.g. #Setup interfaces :local reads ({"WAN-1"={};"WAN-2"={}}); #Gather reads for each interface :foreach name,read in=$reads do={ /interface monitor-traffic interface=$...
by boen_robot
Thu Sep 21, 2017 7:12 pm
Forum: Scripting
Topic: Interface Printout PHP API
Replies: 15
Views: 6386

Re: Interface Printout PHP API

Commands in the request constructor must have argument names. Unnamed arguments are not supported by the API protocol. The "/interface ethernet monitor" in particular has the interface name in an unnamed argument called "numbers" (as many other commands btw). You can find that ou...
by boen_robot
Wed Sep 20, 2017 7:02 pm
Forum: Scripting
Topic: Manipulate Hotspot Vars
Replies: 2
Views: 998

Re: Manipulate Hotspot Vars

Why not call the server name "My Hotspot" to begin with? It is allowed you know. Other than that, you can output the variable into a JavaScript string, and then do the replacement and display within JavaScript. e.g. <h1><script type="text/javascript">document.write('$(server-name...
by boen_robot
Tue Sep 19, 2017 7:07 pm
Forum: Scripting
Topic: Statistics
Replies: 1
Views: 962

Re: Statistics

Whatever things you can access from CLI, you can access from API. So if you can over CLI, then the answer is "yes, you can use the API for that. That's what it's meant for". "Sites being accessed" is kind of tricky, unless maybe you're talking just reading the router's DNS cache,...
by boen_robot
Wed Sep 13, 2017 5:03 pm
Forum: Scripting
Topic: PEAR2\Net\RouterOS export
Replies: 3
Views: 1777

Re: PEAR2\Net\RouterOS export

Sadly, no. Not with current versions at least.

You can remove the file, as in the example above, but you do have to make the HDD write.
by boen_robot
Wed Sep 13, 2017 4:43 pm
Forum: Scripting
Topic: PEAR2\Net\RouterOS export
Replies: 3
Views: 1777

Re: PEAR2\Net\RouterOS export

At least in current versions, /export doesn't return anything over the API, so you can't just output it. You can use the "file" argument to export to a file, and then read the file though. e.g. $exportFileName = 'EXPORT.rsc'; $util = new RouterOS\Util($client = new RouterOS\Client('192.168...
by boen_robot
Fri Sep 08, 2017 6:45 pm
Forum: Scripting
Topic: looking for an API equivalent
Replies: 3
Views: 1187

Re: looking for an API equivalent

In menus like "/ip pool" where unique names are required, you should be able to use the name directly, but you do need to give it to "numbers", e.g. /ip/pool/remove =numbers=test_pool2 And the same can actually be done from CLI too, except that giving the name "numbers"...
by boen_robot
Thu Sep 07, 2017 3:56 pm
Forum: Scripting
Topic: PHP Api PEAR2_Net_RouterOS, local ip
Replies: 5
Views: 2416

Re: PHP Api PEAR2_Net_RouterOS, local ip

i always view ip from providers router and not from mikrotik. Is VPN the only solution? Yes. A VPN of any sort is the only solution for this. Sorry. Are there any commands in routerOS to view my local ip? The problem is that from the router's point of view, you can have multiple WAN interfaces (e.g...
by boen_robot
Thu Sep 07, 2017 3:29 pm
Forum: General
Topic: Mikrotik API Error
Replies: 1
Views: 1146

Re: Mikrotik API Error

Some more info would be needed. When does the error happen? What is the error message? What are the versions of RouterOS and Splynx?
by boen_robot
Thu Sep 07, 2017 3:09 pm
Forum: Scripting
Topic: PHP Api PEAR2_Net_RouterOS, local ip
Replies: 5
Views: 2416

Re: PHP Api PEAR2_Net_RouterOS, local ip

See this issue in GitHub for a sample code that does just that. Note that the web server needs to be able to reach the router without a double NAT in play, i.e. the router's WAN IP must be the public IP, or alternatively, you need to setup a VPN between the web server and router, and connect through...
by boen_robot
Wed Sep 06, 2017 4:22 pm
Forum: General
Topic: IPv6 support
Replies: 5
Views: 2082

Re: IPv6 support

IPv6 is a software feature, not a hardware feature.

RouterOS does support it, so any router running RouterOS will have it too.
by boen_robot
Tue Sep 05, 2017 3:59 pm
Forum: General
Topic: IP SERVICE SET.... - API PHP [SOLVED]
Replies: 3
Views: 2388

Re: IP SERVICE SET.... - API PHP [SOLVED]

It's "=numbers=ssh", not just "=ssh". Same for all "set" commands in all menus.
by boen_robot
Mon Sep 04, 2017 10:16 pm
Forum: Scripting
Topic: Can't run script - no such item
Replies: 3
Views: 5172

Re: Can't run script - no such item

The "/system script run" command runs scripts from the "/system script" menu.

To run scripts in files, you need to use the "/import" command, with the file name, e.g.
/import test.rsc
by boen_robot
Mon Sep 04, 2017 12:35 pm
Forum: Scripting
Topic: Transactions [Feature Request]
Replies: 10
Views: 2584

Re: Transactions [Feature Request]

I'm fairly certain the script would continue to run to its end. Really? My experience is that RouterOS scripts quit at the first error encountered, being parsing error or runtime error. Right... That's what I said in the next sentence. But the question was whether if you disconnect yourself (f.e. w...
by boen_robot
Mon Sep 04, 2017 11:20 am
Forum: Scripting
Topic: Transactions [Feature Request]
Replies: 10
Views: 2584

Re: Transactions [Feature Request]

If I run /import and loose connection, will the import command complete or would I be better of uploading a .auto.rsc file? I can always test this out and find out. I'm fairly certain the script would continue to run to its end. Unless the command you've issued is a reboot, shutdown, upgrade or res...
by boen_robot
Sun Sep 03, 2017 1:48 pm
Forum: Scripting
Topic: Transactions [Feature Request]
Replies: 10
Views: 2584

Re: Transactions [Feature Request]

When provisioning NEW routers, you can use the "/system reset-configuration" command. More specifically, you can upload a script that includes the total configuration with things being in the right order (e.g. called "setup.rsc"), and then apply it with /system reset-configuratio...
by boen_robot
Sat Sep 02, 2017 4:28 pm
Forum: Scripting
Topic: Current speed via API [SOLVED]
Replies: 2
Views: 1904

Re: Current speed via API [SOLVED]

One way is to use "/tool torch" over the hotspot subnet. And keep listening on "/ip hotspot active" to verify that the user is logged in (as otherwise, you'd also be monitoring users that are not logged in).

I'm not familiar with any hotspot specific way.
by boen_robot
Sat Sep 02, 2017 4:25 pm
Forum: Scripting
Topic: ROS Version
Replies: 2
Views: 1500

Re: ROS Version

Well, there are release candidates on the download page... You could get the ISO of one, install it on a VM, and check.
by boen_robot
Fri Sep 01, 2017 4:53 pm
Forum: Scripting
Topic: PHP Api by Vasil customization for web proxy
Replies: 6
Views: 2274

Re: PHP Api by Vasil customization for web proxy

1) As last mod I want php to lookup into a txt file containing all customers names and ip addresses and put them into array; See file() and explode() . 2) Why do you suggest one router at time if addresses are into the array? Mostly because that's how PHP works. It doesn't have "threads" ...
by boen_robot
Tue Aug 29, 2017 6:43 pm
Forum: Scripting
Topic: Testing API length encoding on long words
Replies: 3
Views: 1263

Re: Testing API length encoding on long words

Well, you can enable some logging topics in "/system logging", but that's not really going to tell you much, so... pretty much "no".
by boen_robot
Tue Aug 29, 2017 6:21 pm
Forum: General
Topic: how to get GMT Offset in command? [SOLVED]
Replies: 10
Views: 4130

Re: how to get GMT Offset in command? [SOLVED]

From a quick test, I'm seeing that the gmt-offset itself is returned as unsigned (or more accurately, as a "num" value). Technically, RouterOS does not have a signed integer type. The "num" type values are 64 bit unsigned integers. "time" values however can be negative....
by boen_robot
Tue Aug 29, 2017 3:50 pm
Forum: Scripting
Topic: api does not return rate-limit of a hotspot profile
Replies: 3
Views: 1363

Re: api does not return rate-limit of a hotspot profile

I have another question: Wait, wait... What happened with the first one though? Did you upgrade? Or did "detail" help with whatever your current (I assume older) version is? Both? how can i return errors when use util In the latest version of the API client, if there are errors from Util ...
by boen_robot
Tue Aug 29, 2017 3:38 pm
Forum: Scripting
Topic: Testing API length encoding on long words
Replies: 3
Views: 1263

Re: Testing API length encoding on long words

maybe /file/set =numbers=text.txt =contents=[insert more than 2MB data here] for the encoder? In all honesty, I haven't been able to reach 4 byte length words "for real" with my API client either... I only know it's not my length encoder/decoder, as I have made my encoder and decoder be ab...
by boen_robot
Tue Aug 29, 2017 3:19 pm
Forum: Scripting
Topic: PHP Api by Vasil customization for web proxy
Replies: 6
Views: 2274

Re: PHP Api by Vasil customization for web proxy

Thanks :D . The particular rules you have are in menus where the rules could potentially be duplicated, and they could also be influenced by their position. It would be best if you use f.e. a comment to identify them, and if a rule with that comment exists, create a new rule above it, and remove the...
by boen_robot
Mon Aug 28, 2017 2:15 pm
Forum: Scripting
Topic: api does not return rate-limit of a hotspot profile
Replies: 3
Views: 1363

Re: api does not return rate-limit of a hotspot profile

What RouterOS version is this? I have 6.40, and if there's a rate-limit set, it is included, as expected. Maybe also add "detail" to the arguments, i.e. $profilelist = $this->util->setMenu('/ip/hotspot/user/profile')->getAll(array('detail'),RouterOS\Query::where('name', 'default')->not());...
by boen_robot
Fri Aug 25, 2017 11:38 pm
Forum: Virtualization
Topic: CHR suggestions for new functionality
Replies: 157
Views: 57404

Re: CHR suggestions for new functionality

RouterOS in a Docker container- I'm not sure that is at all possible. My understanding is that Docker containers are meant to run a single application, not the whole OS. Containers are self-contained in that they contain an application plus all the required libraries, but not the OS kernel. RouterO...
by boen_robot
Fri Aug 25, 2017 8:46 pm
Forum: Virtualization
Topic: CHR suggestions for new functionality
Replies: 157
Views: 57404

Re: CHR suggestions for new functionality

(1) A new CHR variant could be added that would be a Docker container. For many people, this would probably be the easiest way to run a CHR variant, given the low overhead and easy setup of Docker containers. This would avoid the requirement to deploy and maintain a more robust (also higher overhea...
by boen_robot
Thu Aug 24, 2017 12:50 am
Forum: Scripting
Topic: Modifying /ip/firewall/filter with api/script
Replies: 12
Views: 6864

Re: Modifying /ip/firewall/filter with api/script

Is there a better way? Should I open a different thread? Probably yes (to both questions). But in short and in general: You can group rules into a custom chain, and jump to certain chains depending on criteria. That way, you limit evaluation only to rules in the custom chain, within which the prior...
by boen_robot
Wed Aug 23, 2017 11:15 pm
Forum: Scripting
Topic: get current frequency via API
Replies: 3
Views: 1447

Re: get current frequency via API

Huh... suits me right for using tab instead of "?" when checking CLI. In CLI, when using tab, "once" appears only after you specify the interface name, but not before.
by boen_robot
Wed Aug 23, 2017 10:05 pm
Forum: Scripting
Topic: get current frequency via API
Replies: 3
Views: 1447

Re: get current frequency via API

You can use the "monitor" command, and extract the frequency out of the returned "channel" property. Unlike some other similar commands, this one doesn't have a "once" argument though, so you'll need to manually cut it off once it begins (unless you do want to monitor t...
by boen_robot
Tue Aug 22, 2017 10:30 pm
Forum: Beginner Basics
Topic: mikrotik software ?
Replies: 2
Views: 1202

Re: mikrotik software ?

MikroTik doesn't just have software, it also has hardware. The different hardware routers have different architectures. The software page has the latest software version for each architecture. That's what the MIPSBE, SMIPS, TILE, etc. are - hardware architectures. The one architecture you can use on...
by boen_robot
Fri Aug 18, 2017 10:06 pm
Forum: Scripting
Topic: Modifying /ip/firewall/filter with api/script
Replies: 12
Views: 6864

Re: Modifying /ip/firewall/filter with api/script

Since I know from another topic you're using my API client, I can tell you that you can use the Util methods. They implement numbers under the hood. More specifically, you can use Util::find() with a number to get the item at that index, or give a number to Util::move() to implicitly find() the item...
by boen_robot
Fri Aug 18, 2017 6:01 pm
Forum: General
Topic: REST API v7 Make Our Day ! +1 it Please
Replies: 17
Views: 12103

Re: REST API v7 Make Our Day ! +1 it Please

@NodeMax I think the complexity with the API you're perceiving is due to the fact that the manual page is not intended for users of the API protocol... It's intended for implementers of the API protocol. I mean, if implementation details are how you're judging ease of protocols, then the HTTP protoc...
by boen_robot
Fri Aug 18, 2017 2:55 pm
Forum: Scripting
Topic: Modifying /ip/firewall/filter with api/script
Replies: 12
Views: 6864

Re: Modifying /ip/firewall/filter with api/script

The "add" command has an argument called "place-before". It takes an ID of an item, before which the new one will be placed. If you want to move an existing item, you need to use the "move" command. It takes two arguments - "numbers", which is items that will ...
by boen_robot
Wed Aug 16, 2017 8:16 pm
Forum: Scripting
Topic: Adding User to Userman via PHP
Replies: 38
Views: 31214

Re: Adding User to Userman via PHP

Is there a specific reason you want to use sendAsync() instead of sendSync()? Like a bunch of other API calls you want to make at once maybe? Although you could use sendAsync() for finite commands, that method is best suited for infinite commands (where you have to explicitly cancel them to stop the...
by boen_robot
Mon Aug 14, 2017 2:43 pm
Forum: General
Topic: Run [find] via API not run
Replies: 1
Views: 1596

Re: Run [find] via API not run

You need to first run "find" to get all IDs (in the "ret" property of the reply), and then pass this list of IDs in the "numbers" argument of "remove"... That's actually what happens in CLI too, but the CLI hides it, whereas the API requires you to be explicit...
by boen_robot
Thu Aug 10, 2017 7:35 pm
Forum: Scripting
Topic: API to increase Hotspot http-cookie-lifetime
Replies: 2
Views: 1318

Re: API to increase Hotspot http-cookie-lifetime

I'm pretty sure "set hsprof1" is not a menu.

I'm guessing that's the name of the profile, so:
$util->setMenu('/ip hotspot profile');

$util->edit('hsprof1', 'http-cookie-lifetime', $_POST['logincookie']);
by boen_robot
Mon Aug 07, 2017 7:10 pm
Forum: Scripting
Topic: Adding User to Userman via PHP
Replies: 38
Views: 31214

Re: Adding User to Userman via PHP

User Manager has a separate command for that called "create-and-active-profile" that identifies the user, the customer they belong to, and the profile to assign and activate. All of those must exist beforehand of course. Util can't call that command on its own, but it can make a request fo...
by boen_robot
Mon Aug 07, 2017 2:48 pm
Forum: Scripting
Topic: Editing Interface Entry,
Replies: 3
Views: 1074

Re: Editing Interface Entry,

There's a separate command called "make-static". e.g.
client.talk(['/ip/dhcp-server/lease/make-static, '=numbers=*1A1'])
by boen_robot
Mon Aug 07, 2017 1:37 am
Forum: Scripting
Topic: Editing Interface Entry,
Replies: 3
Views: 1074

Re: Editing Interface Entry,

In terms of protocol flow:
/interface/set
=numbers=*01
=comment=room404
(replace *01 with the actual ID you get from the print)
by boen_robot
Sat Aug 05, 2017 6:55 pm
Forum: Scripting
Topic: Adding User to Userman via PHP
Replies: 38
Views: 31214

Re: Adding User to Userman via PHP

Well, the error message says "input does not match any value of profile", so... Perhaps there's no user profile named "profile1"?
by boen_robot
Sat Jul 29, 2017 7:03 pm
Forum: Scripting
Topic: Saving Mikrotik Simple Queue Statistic PHP API
Replies: 2
Views: 2984

Re: Saving Mikrotik Simple Queue Statistic PHP API

If the properties you want to save are already there, you can extract them with the getProperty() method, or __invoke(), i.e. echo $queueEntry('name'); //same as echo $queueEntry->getProperty('name');  Also, you can let the router give you only those properties, to minimize the input and be able to ...
by boen_robot
Sat Jul 29, 2017 6:51 pm
Forum: Scripting
Topic: Adding User to Userman via PHP
Replies: 38
Views: 31214

Re: Adding User to Userman via PHP

The API protocol matches the RouterOS CLI in terms of capabilities. And you can't generate vouchers from CLI, so therefore you can't make vouchers from CLI either. You'd need to replicate the individual steps as part of your PHP application, and use the API where applicable. i.e. use PHP to generate...
by boen_robot
Tue Jul 25, 2017 11:44 pm
Forum: Scripting
Topic: Adding User to Userman via PHP
Replies: 38
Views: 31214

Re: Adding User to Userman via PHP

The question is how would you do it "manually"? For enabling an existing, but disabled, hotspot user: $util->changeMenu('/ip hotspot user')->enable('user1'); (replacing "user1" with the name of the user you want to enable) And again... How would you generate a voucher "manua...
by boen_robot
Sun Jul 23, 2017 11:41 pm
Forum: Beginner Basics
Topic: RB1100AH with local webserver
Replies: 9
Views: 3608

Re: RB1100AH with local webserver

Ah. Well it seems docmarius is right and I misunderstood. You have a separate device, and you want... to connect it to one of the router's Ethernet ports(?!?). Physically speaking, of course you can. Logically speaking - as docmarius said, if you're trying to make a local web server visible from the...
by boen_robot
Sun Jul 23, 2017 3:34 am
Forum: Scripting
Topic: How do I run a custom binary?
Replies: 19
Views: 8080

Re: How do I run a custom binary?

Besides there is already a backdoor in RouterOS. If you manage to create /nova/etc/devel-login file then a developer console will be available. Seems like you already knew the answer to your own question then. There's no legit/"by design" way to run any binaries on RouterOS, only these ty...
by boen_robot
Sat Jul 22, 2017 8:21 pm
Forum: Beginner Basics
Topic: RB1100AH with local webserver
Replies: 9
Views: 3608

Re: RB1100AH with local webserver

You'll need to get a MetaRouter image of a separate OS, and run your web server there.

See this manual page for details (and a link to a precompiled compatible OpenWRT image).
by boen_robot
Mon Jul 17, 2017 10:49 am
Forum: Scripting
Topic: Command result
Replies: 4
Views: 1817

Re: Command result

Use :pick to take only the first ID out of the list:
:put [get [:pick [find comment=ISP1] 0] gateway]
by boen_robot
Sat Jul 15, 2017 8:59 pm
Forum: Scripting
Topic: C# API read SMS
Replies: 3
Views: 1534

Re: C# API read SMS

The list returned by "find" has them in order. The first ID corresponds to message 1, the second to message 2, etc.

Same for all menus.
by boen_robot
Sat Jul 15, 2017 2:31 pm
Forum: Scripting
Topic: C# API read SMS
Replies: 3
Views: 1534

Re: C# API read SMS

Like all menus, you can use the print command's "from" argument. However, instead of a number, it needs an ID. And you can get all IDs (and just the IDs that is) by calling "find". The reply will contain a "ret" property that has all IDs, separated by... I think it was ...
by boen_robot
Sun Jul 09, 2017 6:56 pm
Forum: General
Topic: get active user hotspot by php api hlep me
Replies: 5
Views: 4589

Re: get active user hotspot by php api hlep me

Oh, right... "user", not "name". I keep forgetting which menu has which property name... And yeah, I used single quotes when I should've used double (which would've created a few new lines in the output), sorry. The "/ip hotspot user" menu is for all users (and that's w...
by boen_robot
Sun Jul 09, 2017 3:50 am
Forum: General
Topic: get active user hotspot by php api hlep me
Replies: 5
Views: 4589

Re: get active user hotspot by php api hlep me

Either the Request must be sent using Client, or you could use Util's methods. You have everything ready, just haven't actually asked the router. Using Util f.e. use PEAR2\Net\RouterOS; require_once 'system/autoload/PEAR2/Autoload.php';  $util = new RouterOS\Util($client = new RouterOS\Client('8.8.8...
by boen_robot
Wed Jul 05, 2017 11:39 pm
Forum: Scripting
Topic: Set "connect-to" for pptp/sstp/l2tp/ovpn client via API
Replies: 3
Views: 1680

Re: Set "connect-to" for pptp/sstp/l2tp/ovpn client via API

Try
/interface/pptp-client/set
=numbers=pptp-out1
=connect-to=host2.domain.com
(the "numbers" argument is where you match the items to be modified; "interface" is instead the new value for whatever interface "numbers" matches)
by boen_robot
Thu Jun 29, 2017 4:07 pm
Forum: Scripting
Topic: Run API call on remote Routerboard via another Routerboard
Replies: 2
Views: 1284

Re: Run API call on remote Routerboard via another Routerboard

An API call to switch to another router's API - no. However, you can set up your VPN server so that the device the API application is on is a special VPN client that can connect to any other device in the VPN network. That is, instead of connecting to the central router via API, you connect directly...
by boen_robot
Wed Jun 28, 2017 1:42 pm
Forum: Scripting
Topic: Api Search From Usermanager using C#
Replies: 2
Views: 1478

Re: Api Search From Usermanager using C#

This feature is not yet supported by the API protocol in any way.

For now, you need to fetch all items over the wire, and filter them on the client side.
by boen_robot
Tue Jun 27, 2017 8:23 pm
Forum: Scripting
Topic: hot to get CCQ in C#?
Replies: 2
Views: 1014

Re: hot to get CCQ in C#?

Add the "stats" argument to your "print" command call.
by boen_robot
Tue Jun 27, 2017 8:20 pm
Forum: Scripting
Topic: C# bandwidth test won't stop
Replies: 11
Views: 1990

Re: C# bandwidth test won't stop

It stops after 2 seconds, during which it could collect much more than 2 sections - yours apparently reached at least 33. Each section just groups all data retrieved in one swoop. e.g. the router may collect f.e. 10 measurements, before giving them all over the API, and meanwhile, another 15 are rea...
by boen_robot
Sun Jun 25, 2017 1:21 am
Forum: Scripting
Topic: Get uptime in easy-to-parse form
Replies: 4
Views: 3509

Re: Get uptime in easy-to-parse form

Weeks is the biggest component of time values. Anything above that (months, years) varies based on the date, and to keep the data type simple, scripting doesn't go as far as keeping track of a date. It's just a float formatted in descending order from weeks down to seconds, with seconds having the f...
by boen_robot
Thu Jun 22, 2017 6:59 pm
Forum: Scripting
Topic: how to disable\enable interfce C#?
Replies: 3
Views: 1190

Re: how to disable\enable interfce C#?

"numbers", not "number".
by boen_robot
Fri Jun 09, 2017 8:57 pm
Forum: Scripting
Topic: i need help for php api
Replies: 4
Views: 1264

Re: i need help for php api

Using the client from my signature: <?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; $util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password')); $user = 'user1'; $customer = 'customer1'; $newProfile = 'profile2'; $util->setMenu('/tool u...
by boen_robot
Sun Jun 04, 2017 12:48 pm
Forum: General
Topic: How does my ISP control my Mikrotik?
Replies: 3
Views: 1195

Re: How does my ISP control my Mikrotik?

Most likely, they have a VPN set up. If you have any type of Winbox/Webfig access, you should be able to see it in the list of interfaces. It would be the one that isn't Ethernet or Wireless, but something else like OVPN or L2TP. If they have a custom config panel for you, they could be hiding that,...
by boen_robot
Sat Jun 03, 2017 12:10 pm
Forum: Scripting
Topic: [PEAR2_Net_RouterOS] Updating Hotspot Users
Replies: 8
Views: 2905

Re: [PEAR2_Net_RouterOS] Updating Hotspot Users

Goddamn it... this Ubuntu version keeps being all messed up... I can't duplicate it on other OS-es, but yes, I can duplicate it on Ubuntu 16.04 (good thing I kept the VM used for diagnosing the "Failed to parse address" error...). The cause has something to do with how this particularly pa...
by boen_robot
Fri Jun 02, 2017 12:59 pm
Forum: Scripting
Topic: how can I connect hotspot using API?
Replies: 13
Views: 5823

Re: how can I connect hotspot using API?

I mean, one obvious solution is to just move the 1st button's logic into the second button's logic, above the API related code. If you want to only make an attempt to connect to the hotspot when that is necessary, then one way is to surround the line mikrotik = new MK(IP); in a try...catch block. Th...
by boen_robot
Thu Jun 01, 2017 3:45 pm
Forum: Scripting
Topic: how can I connect hotspot using API?
Replies: 13
Views: 5823

Re: how can I connect hotspot using API?

The line mikrotik = new MK(IP); (and everything related to the API) must be executed only after the request has been successfully completed, not before. It seems like you've omitted the part that shows inside what method that line is in, but it clearly isn't inside the click... If it's inside the fo...
by boen_robot
Wed May 31, 2017 9:25 pm
Forum: Scripting
Topic: how can I connect hotspot using API?
Replies: 13
Views: 5823

Re: how can I connect hotspot using API?

You don't need to "save" anything. You only need to "check" it, and act accordingly. Do some requests to the router with a valid and invalid password. See if ResponseUri is different for example... I haven't tried programmatically checking hotspot success to tell you if that's wh...
by boen_robot
Tue May 30, 2017 3:45 pm
Forum: Scripting
Topic: how can I connect hotspot using API?
Replies: 13
Views: 5823

Re: how can I connect hotspot using API?

You don't need the part // Use "ResponseUri" property to get the actual Uri from where the response was attained. if (ourUri.Equals(myWebResponse.ResponseUri))    Console.WriteLine("\nRequest Url : {0} was not redirected",url);    else    Console.WriteLine("\nRequest Url : {...
by boen_robot
Tue May 30, 2017 2:23 pm
Forum: Scripting
Topic: how can I connect hotspot using API?
Replies: 13
Views: 5823

Re: how can I connect hotspot using API?

You need to either have a fixed MAC address or a fixed IP address. The command is simply /ip hotspot ip-binding add type=bypassed mac-address="01:23:45:67:89:AB" address=192.168.88.254 to-address=192.168.88.254 and you can omit either the "mac-address" or the "address" ...
by boen_robot
Tue May 30, 2017 1:44 pm
Forum: Scripting
Topic: Getting realtime traffic speeds from interface
Replies: 3
Views: 2354

Re: Getting realtime traffic speeds from interface

Wait, is this with the API or SSH? I ask because your syntax is a mix of the two... If you're having code that processes this (rather than you simply reading this), consider using the API instead of SSH. The API will (or at least it should) give you all rates in fully readable "bps" values...
by boen_robot
Tue May 30, 2017 1:39 pm
Forum: Scripting
Topic: how can I connect hotspot using API?
Replies: 13
Views: 5823

Re: how can I connect hotspot using API?

You mean you want to login to the hotspot? If it's solely for the purposes of your server being able to connect to the router and do something else with the API, the best way is to simply create a "bypassed" binding for the server in "/ip hotspot ip-binding". That way, you don't ...
by boen_robot
Sun May 28, 2017 1:03 pm
Forum: Scripting
Topic: PHP parameters using CLI
Replies: 1
Views: 994

Re: PHP parameters using CLI

It should work, yes. That's what Util::exec() is for. Although for the particular scenario you want, I would recommend you just use add() instead. And if you want to integrate some local variables from user input, there's the new Script::prepare() in the new version (the previous one had it under Ut...
by boen_robot
Sat May 27, 2017 5:30 pm
Forum: General
Topic: Hotspot Radius and Login customization
Replies: 2
Views: 1982

Re: Hotspot Radius and Login customization

Maybe send it to another PHP file on the same place as the custom login.php?

Assuming the radius database is FreeRADIUS, you can just modify it through MySQL after validating the supplied code, and then redirect to login.php, where (now that they are validated) the user would login as normal.
by boen_robot
Fri May 26, 2017 5:13 pm
Forum: Beginner Basics
Topic: Add openvpn user using API or terminal
Replies: 3
Views: 2054

Re: Add openvpn user using API or terminal

Hmm... I can't think of a "trivial" way to do it, but there are a few non-trivial ones you can try. The most optimal way would be to keep a known reference with the latest IP, and use that when making the command. First, run from a terminal :global OVPNIP 172.28.1.47 to set up a global Rou...
by boen_robot
Wed May 24, 2017 8:05 pm
Forum: Scripting
Topic: Really no solution?
Replies: 2
Views: 923

Re: Really no solution?

The thing is classic ASP is just not a popular language anymore, and besides, you're trying to access webfig, which is a wrong approach to begin with. Consider using the RouterOS API protocol. There are clients in various languages , including NodeJS (if we're talking server side JavaScript...), at ...
by boen_robot
Tue May 23, 2017 11:35 pm
Forum: Beginner Basics
Topic: Add openvpn user using API or terminal
Replies: 3
Views: 2054

Re: Add openvpn user using API or terminal

Using the API client from my signature: <?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b6.phar'; $util = new RouterOS\Util($client = new RouterOS\Client('44.144.126.80', 'admin', 'mypassword')); $util->setMenu('/ppp secret')->add(array( 'name' => 'kris-homeoffice', 'password' =>...
by boen_robot
Tue May 23, 2017 1:29 pm
Forum: Scripting
Topic: PHP API Parse Date from address-list timeout
Replies: 4
Views: 1709

Re: PHP API Parse Date from address-list timeout

Huh... after a few minutes playing around with seemingly ridiculous cases, I found RouterOS actually accepts each time fragment type to occur multiple times, in any order, and sums them up... e.g. 1s2w3h4s5:6ms7m (equals 2w08:07:05.006) Script::parseValue() doesn't support that yet. It supports only...
by boen_robot
Tue May 23, 2017 11:27 am
Forum: Scripting
Topic: PHP API Parse Date from address-list timeout
Replies: 4
Views: 1709

Re: PHP API Parse Date from address-list timeout

Wow, thats quick @boen_robot . Well, not really... The feature has been there for a few months, if not a year. It's just that the version having it wasn't released. And I did it now not just because of your post, but also because of other recent issues that others have been having and were already ...
by boen_robot
Mon May 22, 2017 10:22 pm
Forum: Scripting
Topic: How to run script from Client to RouterOS
Replies: 1
Views: 1189

Re: How to run script from Client to RouterOS

One way would be to modify the main() function to use hard coded input instead of reading from stdin. The actual part is communicating with RouterOS is the ApiRos class, not main(). Although I would instead recommend you get and learn to use an "actual" library. There are a few other Pytho...
by boen_robot
Mon May 22, 2017 7:22 pm
Forum: Scripting
Topic: PHP API Parse Date from address-list timeout
Replies: 4
Views: 1709

Re: PHP API Parse Date from address-list timeout

The latest version, 1.0.0b6 (which I released just now...) can now parse this. I mean, even 1.0.0b5 includes said function, but the letter notation was not recognized with it. The method in question: $duration = RouterOS\Script::parseValue('1d1h1m1s');//Returns a DateInterval object $startDate = new...
by boen_robot
Mon May 15, 2017 10:23 am
Forum: Scripting
Topic: ~ ( Pear2 RouterOS )
Replies: 2
Views: 919

Re: ~ ( Pear2 RouterOS )

Sadly, the protocol does not support this yet.

The only thing you can do is fetch all items, and filter them on the client side with preg_match().

See also this GitHub issue for the end of a link trail of everything that's been mentioned about the topic.
by boen_robot
Wed Apr 19, 2017 10:38 am
Forum: Scripting
Topic: Pear2 Routeros Persistent Connection
Replies: 2
Views: 927

Re: Pear2 Routeros Persistent Connection

The latest version of PEAR2_Cache_SHM (not bundled with the current PEAR2_Net_RouterOS; will be in the next release) also supports APCu. If instead of a PHAR file you use Composer, you can get that version right now, and enable APCu. FastCache supports a lot of other caching back ends, which may sou...
by boen_robot
Sun Apr 16, 2017 12:03 am
Forum: Scripting
Topic: variable doubt
Replies: 3
Views: 1021

Re: variable doubt

I'm pretty sure the quotes turn it into a string. There IS variable interpolation in strings, but no arithmetic operations. So if you're trying to generate a number, you need to use brackets to mark an expression instead, i.e. :for a from 1 to 10 do={/ip firewall nat add chain=dstnat protocol=tcp ds...
by boen_robot
Sun Apr 09, 2017 7:01 pm
Forum: Scripting
Topic: Snooper
Replies: 6
Views: 5103

Re: Snooper

In more recent versions of RouterOS, you can use the "/interface wireless snooper flat-snoop" command, even with the API.

The data returned is slightly different, but still has most everything you'd want.
by boen_robot
Thu Apr 06, 2017 1:14 pm
Forum: Scripting
Topic: how to know if routeros/usermanager is running or not
Replies: 8
Views: 1847

Re: how to know if routeros/usermanager is running or not

No. The code above tests if the RADIUS server is running and accepting connections. The test you're linking to instead tests how the server would respond to a particular query. If you want to test how the RADIUS server would respond to a query, you need to use a RADIUS client, like this PECL package...
by boen_robot
Thu Apr 06, 2017 12:49 pm
Forum: Scripting
Topic: how to know if routeros/usermanager is running or not
Replies: 8
Views: 1847

Re: how to know if routeros/usermanager is running or not

It's the 5th constructor argument, in seconds. F.e. new RouterOS\Client( "xxx.xxx.xxx.xxx", "username", "password", null, false, 10); will set the timeout to 10 seconds. Alternatively, you can set the php.ini directive default_socket_timeout. In the absence of a timeout...
by boen_robot
Thu Apr 06, 2017 12:10 pm
Forum: Scripting
Topic: how to know if routeros/usermanager is running or not
Replies: 8
Views: 1847

Re: how to know if routeros/usermanager is running or not

Checking RouterOS itself is as simple as making a connection attempt. To check if User Manager is accepting connections, once you make a connection with the API, you can do $isRadiusRunning = 'true' === $util->setMenu('/radius incoming')->get(null, 'accept'); if ($isRadiusRunning) { //RADIUS server ...
by boen_robot
Wed Apr 05, 2017 2:00 pm
Forum: Scripting
Topic: PHP Api add user and password to Hotspot
Replies: 9
Views: 8735

Re: PHP Api add user and password to Hotspot

It seems the forum started using non breaking spaces even in code blocks for some reason, and that's what ended up breaking the whole thing. I tried to replace the original code above with one that I just checked has normal spaces, but the one that ends up in the forum is still faulty :? . The way t...
by boen_robot
Wed Apr 05, 2017 1:42 am
Forum: Scripting
Topic: PHP Api add user and password to Hotspot
Replies: 9
Views: 8735

Re: PHP Api add user and password to Hotspot

@chenashop

Is your PHP version at least 5.3.0? Check with "php --version" if you're not sure, and if it is earlier, upgrade it.
by boen_robot
Tue Apr 04, 2017 11:27 am
Forum: Scripting
Topic: Help on php api
Replies: 15
Views: 4672

Re: Help on php api

$util->setMenu('/ppp secret')->set($name, array('password' => $password, 'service' => $service)); 
would be the equivalent of the command line
/ppp secret set numbers="user1" password="password1" service="pppoe"
by boen_robot
Fri Mar 31, 2017 9:50 am
Forum: Scripting
Topic: Java API: filtering in {set,remove} commands
Replies: 2
Views: 1492

Re: Java API: filtering in {set,remove} commands

In some menus (typically, wherever there is "name"), you can use the name instead of the ID, meaning you don't need the "print" in those cases. For VLANs in particular though, that doesn't seem to be the case. So sorry, you can't do that. It's a protocol limitation. It has alread...
by boen_robot
Tue Mar 28, 2017 11:26 am
Forum: Scripting
Topic: API Output fields
Replies: 1
Views: 994

Re: API Output fields

You can filter properties by using an argument called ".proplist" (including the dot), which is a comma separated list of properties to include. For example /ip/hotspot/active/print =.proplist=user,login-by may return for example !re =user=user1 =login-by=cookie !re =user=user2 =login-by=m...
by boen_robot
Tue Mar 28, 2017 12:21 am
Forum: Scripting
Topic: ambiguous value of type
Replies: 2
Views: 2899

Re: ambiguous value of type

This is about the "connection-type" property. An empty string is not a valid value for it. If you don't want to specify it, don't have the property at all. I agree the error message is misleading, though I can see what's going on under the hood... When you specify an invalid/incomplete val...
by boen_robot
Mon Mar 27, 2017 7:21 pm
Forum: General
Topic: Deleteable
Replies: 4
Views: 1576

Re: Politic sharing I condemn the promotion of a mikrotic instructor !!!

I must say... You're providing very little context here. First off, this is the man's personal Facebook page from what I can see. So what, just because he's an instructor, he's not allowed to have an opinion on politics? If you're saying he's discussing politics during teaching sessions, I would be ...
by boen_robot
Mon Mar 27, 2017 1:33 pm
Forum: Scripting
Topic: how to get interface status on API?
Replies: 8
Views: 5028

Re: how to get interface status on API?

On CLI, it would be
/interface ppp-client print detail
or in API flow:
/interface/ppp-client/print
=detail=
by boen_robot
Mon Mar 27, 2017 12:51 pm
Forum: Scripting
Topic: how to get interface status on API?
Replies: 8
Views: 5028

Re: how to get interface status on API?

Have the "=detail=" argument also?

I'm sure the type specific menu has "running", as doing "print where [tab]" on the command line shows that property as one you can filter by.
by boen_robot
Sun Mar 26, 2017 9:02 pm
Forum: Scripting
Topic: how to get interface status on API?
Replies: 8
Views: 5028

Re: how to get interface status on API?

Hmm... I guess those are only available from the type specific menus, or in your case, I'm guessing that would be "/interface/ppp-client/print".
by boen_robot
Sat Mar 25, 2017 8:54 pm
Forum: Scripting
Topic: REGEX
Replies: 3
Views: 4333

Re: REGEX

Ah. Sorry. I was left with the impression that "HT" is not matched, and you wanted to include it in the match. Well then... If you don't want to match "H" only, then what you're missing is a "." in front of the second "*", i.e. the regex should be ".*HT.*...
by boen_robot
Sat Mar 25, 2017 8:46 pm
Forum: Scripting
Topic: REGEX
Replies: 3
Views: 4333

Re: REGEX

The regex should match capital "HT" only, and from a quick test on my router, that does seem to be the case: [admin@MikroTik] > :global NAME "HT" [admin@MikroTik] > :put ($"NAME"~".*HT*") true The regex, as written, should match H HT xH xHT xHTT xHx Hx (where ...
by boen_robot
Fri Mar 24, 2017 6:11 pm
Forum: Scripting
Topic: how can i get rx/tx-rate of an active user (hotspot)?
Replies: 6
Views: 4812

Re: how can i get rx/tx-rate of an active user (hotspot)?

I'm not aware exactly how those values get into that menu, so I can't say what would be a perfect analog, but a close enough analog would be if you have your hotspot user profile create a queue in "/queue simple", and then check the queue with "/queue simple print stats".
by boen_robot
Fri Mar 24, 2017 6:08 pm
Forum: Scripting
Topic: how to get interface status on API?
Replies: 8
Views: 5028

Re: how to get interface status on API?

"/interface/print" and check the "disabled" property. It is the string "true" if the interface is disabled, or the string "false" if it is enabled. There is also a separate property called "running", which is also either the strings "true" ...
by boen_robot
Mon Mar 20, 2017 4:17 pm
Forum: Scripting
Topic: how can i get rx/tx-rate of an active user (hotspot)?
Replies: 6
Views: 4812

Re: how can i get rx/tx-rate of an active user (hotspot)?

You can get the rates from "/ip hotspot host". Those rates include any device going through the hotspot interface, including devices that are not yet logged in. You'll want to get the user and their IP from "/ip hotspot active" and associate the IP/MAC combos there with what &quo...
by boen_robot
Wed Mar 15, 2017 3:46 pm
Forum: Scripting
Topic: Getting tx-bits-per-second and rx-bits-per-second
Replies: 3
Views: 2815

Re: Getting tx-bits-per-second and rx-bits-per-second

Unnamed arguments are not supported. You need to explicitly specify the name. Otherwise, you're calling a command called "Hotspot-Bridge", which does not exist. In the case of monitor-traffic, the argument is called "interface", so: $requests = new RouterOS\Request('/interface mo...
by boen_robot
Tue Mar 14, 2017 10:18 pm
Forum: Scripting
Topic: why I can't call the MK class from my main ?
Replies: 10
Views: 2504

Re: why I can't call the MK class from my main ?

In general, it's best to call a single command that continuously returns data. Said commands can be configured to only return on intervals or in the case of "print" with a "follow" argument, they would only return when there's new stuff to be seen. With that in place, your app ca...
by boen_robot
Tue Mar 14, 2017 6:50 pm
Forum: Scripting
Topic: why I can't call the MK class from my main ?
Replies: 10
Views: 2504

Re: why I can't call the MK class from my main ?

The line MK mikrotik = new MK(IP); is still creating a new local variable (within the method), meaning that you're not using the property. To reference the class property, omit the type specifier, i.e. mikrotik = new MK(IP); Although then again... The app should compile since the property is there, ...
by boen_robot
Tue Mar 14, 2017 6:13 pm
Forum: Scripting
Topic: why I can't call the MK class from my main ?
Replies: 10
Views: 2504

Re: why I can't call the MK class from my main ?

See my last example code. You need to define the variable as a Form1 property (as the code shows). That way, it would be accessible to all methods of the class. The way I've made it there, if the text in textBox3 changes before you've clicked button1, the app will crash, but it should compile either...
by boen_robot
Tue Mar 14, 2017 5:52 pm
Forum: Scripting
Topic: why I can't call the MK class from my main ?
Replies: 10
Views: 2504

Re: why I can't call the MK class from my main ?

I mean that instead of using that particular C# client, using this API client would be much better in the long run. With it, you can easily form arbitrary requests, and retrieve all individual pieces of information related to the reply. Granted your current problem would also happen there, because h...
by boen_robot
Tue Mar 14, 2017 10:02 am
Forum: Scripting
Topic: why I can't call the MK class from my main ?
Replies: 10
Views: 2504

Re: why I can't call the MK class from my main ?

The line MK mikrotik = new MK(IP); is where the connection and the variable holding it are created. The connection lasts as long as the object lasts. Because that line is within the button click event, what this means is that your connection starts and ends within the button click. The "mikroti...
by boen_robot
Tue Mar 14, 2017 9:43 am
Forum: Scripting
Topic: how can I switch from console to WindowsFormsApplication?
Replies: 2
Views: 927

Re: how can I switch from console to WindowsFormsApplication?

Sure. Just create your UI, and place the code that interacts with the router within the appropriate event for the appropriate UI control. E.g. have a button and a text box, do the action when the button is clicked, and within that same event, place the output in the text box. You can of course put d...
by boen_robot
Sat Mar 11, 2017 9:42 pm
Forum: Scripting
Topic: Help on php api
Replies: 15
Views: 4672

Re: Help on php api

The max-limit value in a queue contains the limit in the form of "upload/download". IIRC, you get the number as bits per second, so doubling an existing limit should be as simple as separating by the "/", doing the multiplication on the two parts, and setting the two new values i...
by boen_robot
Wed Feb 22, 2017 10:39 pm
Forum: Scripting
Topic: API Hotspot Login with multiple RADIUS
Replies: 5
Views: 3375

Re: API Hotspot Login with multiple RADIUS

For future reference's sake... Which one of the two?
by boen_robot
Wed Feb 22, 2017 10:25 pm
Forum: Scripting
Topic: API Hotspot Login with multiple RADIUS
Replies: 5
Views: 3375

Re: API Hotspot Login with multiple RADIUS

I've never even attempted to use the "login" command with a RADIUS server in the mix, but I see that there is a separate argument called "domain". Maybe try to specify the domain there? So either $usr = "USERCP58VUZ"; $domain = "mydomain"; $pwd = "58adb62...
by boen_robot
Thu Feb 09, 2017 8:41 pm
Forum: Scripting
Topic: Torch sections
Replies: 1
Views: 892

Re: Torch sections

Each distinct value of section represents a new "list" of sniffed packets gathered between the previous section and this one. In terms of "times" between each list, that's determined by the "freeze-frame-interval" argument, though yes, I think it defaults to 1 second. I...
by boen_robot
Sun Feb 05, 2017 4:26 am
Forum: Scripting
Topic: How To definition of special character
Replies: 1
Views: 1775

Re: How To definition of special character

Using a backslash (the character "\") followed by a hex of the ASCII value is the way for an arbitrary character. Your particular example string (the value of CharSpe that is): :global CharSpe "\21\40\23\24\25\5E\26\2A\28\29\5F\2B\7C\5C\3D\2D\2F\2E\2C\3C\3E\3F\3B\27\3A\22\5B\5D\7B\7D&...
by boen_robot
Fri Feb 03, 2017 3:29 pm
Forum: Scripting
Topic: Need to poll simple value from router with Perl - solved
Replies: 4
Views: 1559

Re: Need to poll simple value from router with Perl

You can use "/ip/arp/print" with a query ("?mac-address=$t_mac"), and get the "address" property from the result. The beauty of the API (compared to SSH) is precisely that the individual properties can be read with relative ease and reliability (as opposed to SSH, where...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 8