Native messaging or http - sockets

I want to be able to execute local shell commands in a web application.
Chrome Native messaging api seems to be good for that, but as it needs also a service in background, I do not see a real difference with a little http server.
Is there a real structural difference between them? As I see there is somewhere a socket used as an interface.
Is there any other solutions for that?

Chrome Native messaging does not work by calling a running daemon. Instead, it spawns a new process each time sendMessage or connect is called.
While you can keep the process you opened with connect running, if you want to do one-shot commands the sendMessage approach is good.
Do note that you will still need a Chrome App or Extension installed to be able to do it, as well as a (separately installed) Native Host module.

Related

Use same terminal session across the devices when using vscode-remote ssh

I'm using three of the devices to develop. Desktop(Home), MacBook(Work), Laptop(Remote).
I'm developing a web project that needs to build and API server. So I'm running build steps and API server using watch parameter.
However, If I do work at remote or home, I can't start API server because that port already bound by other process that executed by work MacBook terminal. I tried to kill that process, but It restored automatically by watch parameter.
So now I want to use the same terminal session across the multiple devices. I thought maybe I can do this using tmux, but I don't know is there a better solution for this.
Is there available something to do this in vscode-server? Or just I need to use tmux or other solution?

Why does VSCode keep connecting to Apple?

I have a web debugger running on my machine, and I noticed that VSCode is running a lot of web calls to captive.apple.com/hotspot-detect.html followed by a call to ipv4.icanhazip.com:443 every second. The body of the Apple call is <HTML><HEAD><TITLE>Success</TITLE></HEAD><BODY>Success</BODY></HTML>
What is VS Code up to in the background?
This had to do with the underlying online/offline detection library we were using in the Atlassian for VS Code extension. We have since removed the dependency and now only connect to Atlassian servers. We've also backed off the aggressiveness of the checks.

Controlling Google Chrome via Perl script

I was looking for a way to check for changes in a specific URL provided by the user. I wrote a script that I ran at home that can do that successfully using WWW::Mechanize. The thing is, I need to run it in another computer network that has a group policy that blocks all $mech->get($url) requests (it's not firewall problems, I let Perl through), so I thought I'll try and work around this problem by letting Perl control the web browser.
The computers in the network run Google Chrome and IE8 only and I can't install Firefox due to another policy (thought of using WWW::Mechanize::Firefox). I don't want to invoke IE8 in the script because most of the URLs that will be provided will be of websites that don't work well with it, so that leaves me with Chrome only.
Searching for a module that can do that, I only found AnyEvent::Chromi:
which exposes all of the Chrome Extensions API via a websocket connection.
This doesn't work (the policy probably blocks that websocket as well).
Is there another way to work around this problem/control Chrome from within a Perl script?
Is there another way to work around this problem/control Chrome from
within a Perl script?
WWW::Mechanize::Chrome
Like WWW::Mechanize, this module automates web browsing with a Perl object. Fetching and rendering of web pages is delegated to the Chrome (or Chromium) browser by starting an instance of the browser and controlling it with Chrome DevTools.
You can also do this from scratch without using any CPAN modules.
I tested this on Linux (Ubuntu 16.04, Google Chrome version 53) using Unix Domain (UD)
sockets. Unfortunately, it seems Windows does not have UD sockets, but
it should be possible to do same from Windows using named pipes.
First, make sure google-chrome is running in the background. We will
need to create a Chrome App
that will communicate
with a native host through the native messaging
API. The
native host can be any script that reads messages from its STDIN and
returns replies through its STDOUT. I tested both a Python
script and a Perl script.
Now, in order for a standalone Perl script to communicate with the
Chrome browser, it will send request through a UD socket (created by
the native host) to the native host; the native host will then
forward the request to google-chrome through its standard output
pipe. Then the Chrome App (written in JavaScript)
will receive the request. The Chrome App will use the Chrome
JavaScript APIs to get the requested data and return it to the native
host. Finally, the native host forwards the result through the socket to
the Perl script.
As you can see, there are some details required for setting this up, but I can
confirm that it works on my Linux platform. Please let me know if you need more
details.
Since you mentioned IE8, I'm assuming that you're dealing with a Windows system. And since you mentioned that you had considered WWW:Mechanix::Firefox, it sounds like you are not being restricted to just core modules.
Based on that, the only way that I can think of to automate the Chrome broswer would be to use Win32::GuiTest to control the Chrome browser. If you can figure out how to manually drive your testing using only keyboard input (i.e. no mouse), that would make things easier than trying to figure out the mouse emulation to get the cursor to the correct position for various tasks.
I'm not sure if that's necessarily a route that you will like to use or not. It's just the only way that I can think of to accomplish what you want to do with the restrictions that you have to deal with.

Can I use sockets on Appengine without a special lib?

I'm confused by the GAE documentations. It says App Engine supports sockets without requiring you to import any special App Engine libraries or add any special App Engine code. but it seems misleading as just above it says App Engine supports outbound sockets through the appengine/socket package.
I would like to connect to an IMAP server using the standard net package. Is that possible or I'm stuck with the GAE sockets API?
https://cloud.google.com/appengine/docs/go/sockets/
It is not possible to open an outbound socket without going through the appengine/socket api. This is because it works through RPC and an appengine.Context is needed to do that. You can still use the IMAP library you linked, though, as it provides a function to create a client with a given net.Conn. You can get a net.Conn from appengine/socket and pass it to NewClient to do your business. The reason it works on python and java is because they both use thread local memory to manage request state implicitly, whereas the go runtime does not.
Nothing stops you from connecting to an Imap server, since you will initiate an outbound connection. For java, the standard java mail packages work out of the box.
Only for paid apps though, i.e. you need to have billing enabled.

Deliver application's GUI via browser

I need to show to a user an interface of some application running on a server using a browser. It should be like RDP-client for a single application on a server.
Are there any solutions or services that can implement following functionality? Maybe Citrix?
Thanks in advance!
This looks like what you're looking for:
http://freerdp.net/
About FreeRDP-WebConnect
FreeRDP-WebConnect is an open source gateway for accessing RDP
sessions using any HTML5 compliant browser. In particular it relies on
the Canvas and the WebSockets feature. FreeRDP-WebConnect is a
subproject of the FreeRDP project.
On the server side, a standalone daemon - written in C++ - provides a
Web page via HTTPS (or HTTP, if configured) and uses FreeRDP libs to
connect as a client to any RDP session. The server side WebSockets
implementation handles current RFC6455 only, so browsers that
implement the older drafts do not work. With RFC6455 being raised to
the "Proposed Standard" level, this should change now really soon.
I would create an account on the server for the user, and only give it access to the one application it needs access to.
You can use Cameyo. To start, create yourself a free account, and click on "Add App". If your installer supports unattended installation, you simply need to submit it. Otherwise, you can build a Cameyo package locally and send it in. It will then be playable as HTML5.
You don't indicate what server you are running on.
As an alternative to FreeRDP-Webconnect cited above, also open source and also using FreeRDP as rdp client through an HTTP gateway, there is Myrtille.
FreeRDP-WebConnect embeds a standalone daemon written in C++ to provide a web page via HTTP(S), and so will also work on Linux servers, while Myrtille have a IIS/.NET (C#) implementation and an MSI installer, thus is more intended for Windows Servers.