Skip to content

Commit 5fd5f3d

Browse files
Okuro3499dogi
andauthored
ssh: survive empty ip (fixes #1910) (#1927)
Co-authored-by: dogi <[email protected]>
1 parent e3f7ea1 commit 5fd5f3d

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

.github/workflows/android-release.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ jobs:
7272
sha256sum output/remote.aab > output/remote.aab.sha256
7373
ls -alR output
7474
75-
# - name: publish AAB to playstore
76-
# if: github.ref == 'refs/heads/master'
77-
# uses: dogi/[email protected]
78-
# with:
79-
# serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
80-
# packageName: io.treehouses.remote
81-
# releaseFiles: output/remote.aab
82-
# track: internal
83-
# releaseName: "${{ env.VERSION }}"
84-
# status: completed
75+
- name: publish AAB to playstore
76+
if: github.ref == 'refs/heads/master'
77+
uses: dogi/[email protected]
78+
with:
79+
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
80+
packageName: io.treehouses.remote
81+
releaseFiles: output/remote.aab
82+
track: internal
83+
releaseName: "${{ env.VERSION }}"
84+
status: completed
8585

8686
# - name: mobile security framework
8787
# run: |

app/src/main/kotlin/io/treehouses/remote/fragments/SSHConfigFragment.kt

+15-12
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import io.treehouses.remote.utils.SaveUtils
2424
import io.treehouses.remote.utils.Utils.toast
2525
import io.treehouses.remote.utils.logD
2626

27-
2827
class SSHConfigFragment : BaseSSHConfig() {
2928

30-
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
29+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
3130
bind = DialogSshBinding.inflate(inflater, container, false)
3231
if (listener.getChatService().state == Constants.STATE_CONNECTED) {
3332
listener.sendMessage(getString(R.string.TREEHOUSES_NETWORKMODE_INFO))
@@ -42,24 +41,24 @@ class SSHConfigFragment : BaseSSHConfig() {
4241
addTextValidation()
4342
Tutorials.sshTutorial(bind, requireActivity())
4443
bind.connectSsh.setOnClickListener {
45-
var uriString = bind.sshTextInput.text.toString()
44+
val uriString = bind.sshTextInput.text.toString()
4645
connect(uriString, false)
4746
}
4847
setUpAdapter()
4948
bind.generateKeys.setOnClickListener { SSHKeyGenFragment().show(childFragmentManager, "GenerateKey") }
5049
bind.smartConnect.setOnClickListener {
5150
val shouldConnect = checkForSmartConnectKey()
52-
var uriString = bind.sshTextInput.text.toString()
51+
val uriString = bind.sshTextInput.text.toString()
5352
if (shouldConnect) connect(uriString, true)
5453
}
5554
bind.showKeys.setOnClickListener { SSHAllKeyFragment().show(childFragmentManager, "AllKeys") }
5655
}
5756

5857
private fun checkForSmartConnectKey(): Boolean {
5958
if (!KeyUtils.getAllKeyNames(requireContext()).contains("SmartConnectKey")) {
60-
if (listener?.getChatService()?.state == Constants.STATE_CONNECTED) {
59+
if (listener.getChatService().state == Constants.STATE_CONNECTED) {
6160
val key = KeyUtils.createSmartConnectKey(requireContext())
62-
listener?.sendMessage(getString(R.string.TREEHOUSES_SSHKEY_ADD, getOpenSSH(key)))
61+
listener.sendMessage(getString(R.string.TREEHOUSES_SSHKEY_ADD, getOpenSSH(key)))
6362
} else {
6463
context.toast("Bluetooth not connected. Could not send key to Pi.")
6564
return false
@@ -115,14 +114,18 @@ class SSHConfigFragment : BaseSSHConfig() {
115114
bind.sshTextInput.setText(hostAddress)
116115
logD("GOT IP $ipAddress")
117116
} else if (s.contains("ip") || s.startsWith("essid")) {
118-
val ipString = s.split(", ")[1]
119-
val ipAddress = ipString.substring(4)
120-
val hostAddress = "pi@$ipAddress"
121-
bind.sshTextInput.setText(hostAddress)
122-
logD("GOT IP $ipAddress")
117+
val splitResult = s.split(", ")
118+
if (splitResult.size > 1) {
119+
val ipString = splitResult[1]
120+
if (ipString.startsWith("ip:")) {
121+
val ipAddress = ipString.substring(4)
122+
val hostAddress = "pi@$ipAddress"
123+
bind.sshTextInput.setText(hostAddress)
124+
logD("GOT IP $ipAddress")
125+
}
126+
}
123127
}
124128
}
125-
126129
override fun getMessage(msg: Message) {
127130
when (msg.what) {
128131
Constants.MESSAGE_READ -> {

0 commit comments

Comments
 (0)