Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh: survive empty ip (fixes #1910) #1927

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ jobs:
sha256sum output/remote.aab > output/remote.aab.sha256
ls -alR output

# - name: publish AAB to playstore
# if: github.ref == 'refs/heads/master'
# uses: dogi/[email protected]
# with:
# serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
# packageName: io.treehouses.remote
# releaseFiles: output/remote.aab
# track: internal
# releaseName: "${{ env.VERSION }}"
# status: completed
- name: publish AAB to playstore
if: github.ref == 'refs/heads/master'
uses: dogi/[email protected]
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: io.treehouses.remote
releaseFiles: output/remote.aab
track: internal
releaseName: "${{ env.VERSION }}"
status: completed

# - name: mobile security framework
# run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import io.treehouses.remote.utils.SaveUtils
import io.treehouses.remote.utils.Utils.toast
import io.treehouses.remote.utils.logD


class SSHConfigFragment : BaseSSHConfig() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
bind = DialogSshBinding.inflate(inflater, container, false)
if (listener.getChatService().state == Constants.STATE_CONNECTED) {
listener.sendMessage(getString(R.string.TREEHOUSES_NETWORKMODE_INFO))
Expand All @@ -42,24 +41,24 @@ class SSHConfigFragment : BaseSSHConfig() {
addTextValidation()
Tutorials.sshTutorial(bind, requireActivity())
bind.connectSsh.setOnClickListener {
var uriString = bind.sshTextInput.text.toString()
val uriString = bind.sshTextInput.text.toString()
connect(uriString, false)
}
setUpAdapter()
bind.generateKeys.setOnClickListener { SSHKeyGenFragment().show(childFragmentManager, "GenerateKey") }
bind.smartConnect.setOnClickListener {
val shouldConnect = checkForSmartConnectKey()
var uriString = bind.sshTextInput.text.toString()
val uriString = bind.sshTextInput.text.toString()
if (shouldConnect) connect(uriString, true)
}
bind.showKeys.setOnClickListener { SSHAllKeyFragment().show(childFragmentManager, "AllKeys") }
}

private fun checkForSmartConnectKey(): Boolean {
if (!KeyUtils.getAllKeyNames(requireContext()).contains("SmartConnectKey")) {
if (listener?.getChatService()?.state == Constants.STATE_CONNECTED) {
if (listener.getChatService().state == Constants.STATE_CONNECTED) {
val key = KeyUtils.createSmartConnectKey(requireContext())
listener?.sendMessage(getString(R.string.TREEHOUSES_SSHKEY_ADD, getOpenSSH(key)))
listener.sendMessage(getString(R.string.TREEHOUSES_SSHKEY_ADD, getOpenSSH(key)))
} else {
context.toast("Bluetooth not connected. Could not send key to Pi.")
return false
Expand Down Expand Up @@ -115,14 +114,18 @@ class SSHConfigFragment : BaseSSHConfig() {
bind.sshTextInput.setText(hostAddress)
logD("GOT IP $ipAddress")
} else if (s.contains("ip") || s.startsWith("essid")) {
val ipString = s.split(", ")[1]
val ipAddress = ipString.substring(4)
val hostAddress = "pi@$ipAddress"
bind.sshTextInput.setText(hostAddress)
logD("GOT IP $ipAddress")
val splitResult = s.split(", ")
if (splitResult.size > 1) {
val ipString = splitResult[1]
if (ipString.startsWith("ip:")) {
val ipAddress = ipString.substring(4)
val hostAddress = "pi@$ipAddress"
bind.sshTextInput.setText(hostAddress)
logD("GOT IP $ipAddress")
}
}
}
}

override fun getMessage(msg: Message) {
when (msg.what) {
Constants.MESSAGE_READ -> {
Expand Down