balta2ar / brotab

Control your browser's tabs from the command line
MIT License
389 stars 27 forks source link

Get tabs from remote firefox? #18

Closed philipsd6 closed 4 years ago

philipsd6 commented 4 years ago

I'm running Firefox in a Linux VM and on the parent Windows host, and I would like to access the tabs from the Windows host in my VM. Is there any way to link the parent Firefox to the VM so I can access both sets of tabs from the VM? Can it be set up to work over port forwarding?

balta2ar commented 4 years ago

@philipsd6 when brotab client starts and looks up for the available mediators, it queries 10 local TCP ports starting from 4625. Thus if you set up your VM port forwarding so that host port 4625 is mapped to VM's port 4626 (just an example; leave 4625 for the VM's browser), brotab client should discover the host's Firefox automatically.

philipsd6 commented 4 years ago

Do I need to execute bt install on the host? I forwarded the port and restarted both the host and guest Firefox and bt clients still shows only the VM Firefox.

balta2ar commented 4 years ago

Yes, bt install updates the manifest paths required for the browser to run the extension

On Fri, Jan 31, 2020, 13:14 Philip Douglass notifications@github.com wrote:

Do I need to execute bt install on the host? I forwarded the port and restarted both the host and guest Firefox and bt clients still shows only the VM Firefox.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/balta2ar/brotab/issues/18?email_source=notifications&email_token=AACTFRGMCVZ7GN5DXAJVZ5DRAQIY7A5CNFSM4KOAQZOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKOO6BY#issuecomment-580710151, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTFRGWY7LTYB4XUM7BK7TRAQIY7ANCNFSM4KOAQZOA .

philipsd6 commented 4 years ago

Ok, well I had to install Python3 on the host, as I don't usually use Python there. I then created a virtualenv and installed brotab, then executed bt install which worked (after I created C:\tmp... per #14)

Then I restarted Firefox on the host, after which I cannot get bt list to return any results. It's blank. So it seems like installing brotab on Windows isn't very well supported... :/

When I set up port forwarding as you suggested (host 4625 -> VM port 4626) bt clients on the VM still only shows the VM's firefox, but now running bt list on the host returns:

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
balta2ar commented 4 years ago

Oh right, Windows.. you may have wait until #14 is fixed

philipsd6 commented 4 years ago

Well, I just manually created C:\tmp and the error in #14 doesn't occur.

balta2ar commented 4 years ago

Windows support is indeed "best effort" for this tool. Sorry if that doesn't meet your expectations.

But let's get to the bottom of this anyway. Could you show me the recent relevant log records from tmp/brotab.log, tmp/brotab_mediator.log after executing bt list on Windows? We should make it work on the host first.

philipsd6 commented 4 years ago

Sure... I've got brotab==1.1.0 installed in a Python 3.8 venv, and did this:

(brotab) C:\Users\philipsd6>pip install brotab
(brotab) C:\Users\philipsd6>bt install
Installing mediator manifest C:\Users\philipsd6/.mozilla/native-messaging-hosts/brotab_mediator.json
Installing mediator manifest C:\Users\philipsd6/.config/chromium/NativeMessagingHosts/brotab_mediator.json
Installing mediator manifest C:\Users\philipsd6/.config/google-chrome/NativeMessagingHosts/brotab_mediator.json
Link to Firefox extension: https://addons.mozilla.org/en-US/firefox/addon/brotab/
Link to Chrome (Chromium) extension: https://chrome.google.com/webstore/detail/brotab/mhpeahbikehnfkfnmopaigggliclhmnc/
(brotab) C:\Users\philipsd6>bt list

no output... and only brotab.log in C:\tmp, containing this:

2020-02-01 16:01:00,319 INFO       Logger has been created
2020-02-01 16:01:00,325 INFO       Installing mediators
2020-02-01 16:01:00,413 INFO       Installing template mediator/firefox_mediator.json into C:\Users\philipsd6/.mozilla/native-messaging-hosts/brotab_mediator.json
2020-02-01 16:01:00,415 INFO       Installing template mediator/chromium_mediator.json into C:\Users\philipsd6/.config/chromium/NativeMessagingHosts/brotab_mediator.json
2020-02-01 16:01:00,416 INFO       Installing template mediator/chromium_mediator.json into C:\Users\philipsd6/.config/google-chrome/NativeMessagingHosts/brotab_mediator.json
2020-02-01 16:05:51,563 INFO       Logger has been created
2020-02-01 16:05:51,569 INFO       Listing tabs
2020-02-01 16:05:52,573 INFO       Created clients: []
balta2ar commented 4 years ago

I think the problem is that Windows requires some special care when installing native messaging apps. See Registry section: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging

In order to let Firefox know about the location of the manifest on your machine, try executing the following commands in command-line prompt:

REG ADD "HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts\BroTab" /ve /t REG_SZ /d "C:\Users\philipsd6\.mozilla\native-messaging-hosts\brotab_mediator.json" /f 

REG ADD "HKEY_LOCAL_MACHINE\Software\Mozilla\NativeMessagingHosts\BroTab" /ve /t REG_SZ /d "C:\Users\philipsd6\.mozilla\native-messaging-hosts\brotab_mediator.json" /f 

If that works, I should think about adding this step into installation process for Windows users.