Today, I wrote what I am going to call a “protocol proxy,” a system that receives a request via one protocol (such as HTTP(S)), translates it into another, sends it, and sends back the response as the response for your request.
You might be wondering why anyone would need this. In Mini Micro, we only have HTTP(S) connections, and I want to create systems like live chat and a remote shell for my Mini Micro session so I can code anywhere in my house.
It works by sending specially crafted POST requests to my Python Flask server, the post request contains all of the necessary information to do the connection and sends it back as a response to our initial request.
An example request being something like:
http.post("http://127.0.0.1:5000", {"request_type": "socket", "dest":"192.168.1.157", "port":5050, "method": "send", "data": "Hello, world!"})
Unfortunately, I think we are limited to a system where we connect, send, disconnect then connect, receive.
The entire flow is like this:
Mini Micro makes its http.post request to 127.0.0.1:5000 with the correct info to send via a socket. ->
The server parses the request, performs it, target gets the request ->
Target does whatever, sends a response, web server returns the response as its response for the request we made ->
The response would be returned by http.post.
Few things I have to do before I am comfortable releasing it, it needs a cleanup under the hood, I want to write libraries that make the whole experience easy to use with your Mini Micro code, I want to support more protocols.
What would you do with this?
Top comments (0)