Community discussions

MUM Europe 2020
 
JoZu
just joined
Topic Author
Posts: 5
Joined: Fri Nov 12, 2010 5:14 pm

How to use some API from LAN?

Sun Apr 22, 2012 10:38 pm

Is there any way to use some API to send and receive commands from LAN? To run directly from the pages of the router mikrotik own.
Javascript?
Send commands via HTML?
JSP Pages?
Java?

Thanks so much.
http://www.wifibar.es
Soluciones Wifi
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How to use some API from LAN?

Mon Apr 23, 2012 8:30 pm

There is an API protocol with clients in lots of server side scripting and desktop languages.

Is that the kind of thing you're after? The "from LAN" in your post sounds a little vague, especially considering the sentence after it... if this is supposed to mean "from outside the router", then yes, that's what the API is for - allowing you to send commands and/or receive information between a client (a web server or a desktop app) and RouterOS.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
JoZu
just joined
Topic Author
Posts: 5
Joined: Fri Nov 12, 2010 5:14 pm

Re: How to use some API from LAN?

Mon Apr 23, 2012 9:24 pm

In this case I mean a javascript api built into the router itself through a file. (perhaps mikrotik.js? jsp page? ssh command via html page?)
That javascript could be used for through a web page (inside the router) to control the hotspot.
It could make hotspot management pages without relying on any external server, accessed through the wifi itself.
Do not know if I explained very well, thank you and sorry my english.
http://www.wifibar.es
Soluciones Wifi
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How to use some API from LAN?

Tue Apr 24, 2012 12:01 pm

JavaScript runs on a browser (the HTTP client), not the router (the HTTP server), so there's no way MikroTik could do that, and if they did do something similar (e.g. send aribitrary commands to a special URL on the router's HTTP server), it would be very insecure, as you're essentially allowing the client to do whatever they want.

If the HTTP server supported a server scripting engine (JSP, PHP, a proprtietary language), you would've been able to do that, but there's no such support, and AFAIK, no plans to add such (beyond the pseudo server language for outputting hotspot variables that is).

You could always make the router redirect or dst-nat to a separate web server that controls it via the API protocol. The end user wouldn't know (or care about) the difference.
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)

Who is online

Users browsing this forum: No registered users and 10 guests