Skarafaz / mercury

Simple Android app that sends pre-configured commands to remote servers via SSH.
GNU General Public License v2.0
115 stars 20 forks source link

Add support for icons in command list, use common SSH connection, add support for mDNS service resolve #14

Closed stephanritscher closed 7 years ago

stephanritscher commented 7 years ago

Command icons are specified using optional "icon" property in json file. If "icon" property is not specified, the old layout without icon is used. Icon files should be placed in Mercury-SSH folder.

Currently icon size is fixed (96x96 pixels). Personally I like symbolic icons from Adwaita theme with inverted colors.

From the second command executed for a server, the execution will be faster because the SSH session is reused (only a new exec channel is opened). From the second command on, no password has to be entered (if at all). The SSH session is only kept alive as long as the server fragment is shown (disconnect in onPause). A new property "wait" is introduced. If true, the exec channel will be kept open until the command finishes. The displayed toast will depend on the exit code of the command.

Example configuration snippet:

  "commands" : [
           {
                   "name" : "Reboot system",
                   "icon" : "system-shutdown-symbolic.png",
                   "cmd" : "systemctl reboot",
                   "confirm" : true,
                   "wait" : true
           }
  ]

Adds server properties "mdnsname" and "mdnstype". "mdnsname" may be specified instead of or additionally to "host"(/"port"). "mdnstype" defaults to "_ssh._tcp". If mDNS resolve is successful, host and port of the mDNS service are used. If unsuccessful or no "mdnsname" is specified, use "host"(/"port") property for connection (specified as IP address or classic DNS name).

Example:

{
        "name" : "My laptop",
        "host" : "192.168.0.10",
        "port" : 22,
        "mdnsname" : "server",
        "mdnstype" : "_ssh._tcp",
        "user" : "guest",
        "commands" : [
                ...
        ]
}

This feature is especially useful if you use dynamic adresses (e.g. assigned by DHCP) and DNS resolution fails (DDNS update by DHCP is not configured).

Remark: By default, the mDNS domain .local is used. Specifying "server.local" as "mdnsname" didn't work for me. Use the following for debugging:

avahi-browse -vrt _ssh._tcp

Skarafaz commented 7 years ago

Hi! Thanks for your contribution! I'll check the changes asap

stephanritscher commented 7 years ago

You're welcome. Thanks for your app! I'm looking forward to your feedback.

Skarafaz commented 7 years ago

I think you missed some commits on strings.xml

stephanritscher commented 7 years ago

I think now the branch is complete. I also had another feature waiting which is now committed.

Skarafaz commented 7 years ago

@stephanritscher I really appreciated your contribution but, after a careful analysis, I decided to not merge this pull request. This app is based on the "keep it simple" principle, so I do not want to implement features that I do not consider essential. Anyway some ideas/enhancements you proposed are good, so they could be implemented in future releases.

stephanritscher commented 7 years ago

@Skarafaz Thanks for taking your time and considering my changes. Feel free to use also parts of my code for the features you choose to implement. My motivation for adding thus many features was and still is using the app as a remote control (e.g. for a photo session using my laptop at home or at a friends place - thus zeroconf) which launches programs, simulates (parts of) a keyboard (also for a Wayland desktop environment), makes and displays snapshots (from screen or webcam). I've seen some other apps which came close(r) to my needs, but were not open source which is why I chose your project as base. @all For my current needs the "fork" is quite feature complete, so I won't be working on it in the near future, I guess.