now it skips the fe80 bogus ipv6 addr

sigsegv_dump
Greg Alexander 9 years ago
parent 63d63e4f84
commit 698ce0c52c

14
NOTES

@ -157,6 +157,20 @@ So that is my remedy -- static executables for the moment. I tested them
and it is only a little bit bigger -- 904kB of binaries instead of 668kB.
January 18, 2015.
Markus Ethen suggested it display the current IP address so you know
where to ssh to, in case it isn't convenient to use static dhcp or to
remember the address. That seems to be easier said than done. You can
use WifiManager, but that won't give your IP address unless you're on
wifi. That is probably "good enough", but it is certainly not ideal.
There is also java.net.NetworkInterface, which seems to return a random
ipv6 address.
Ah-hah! It is fe80::macaddr, which is a bogus "local-connection only"
ipv6 address, like 192.168, but automatically-generated without dhcp.
So if I skip that, it finds the proper ipv4 address!
XXX - display the phone's IP address
XXX - if you remove it from the recent apps list, does it stop the service??
XXX - support password-based logins?

@ -10,6 +10,7 @@
android:typeface="monospace"
android:singleLine="true"
android:background="#ff112266"
android:scrollHorizontally="true"
android:text="IP: XXX" />
<EditText android:id="@+id/log"
android:layout_width="fill_parent"

@ -171,8 +171,14 @@ public class SimpleSSHD extends Activity
for (NetworkInterface intf : interfaces) {
List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
for (InetAddress addr : addrs) {
if (!addr.isLoopbackAddress()) {
return addr.getHostAddress();
String ip = addr.getHostAddress();
if (!addr.isLoopbackAddress() &&
!ip.startsWith("fe80")) {
int i = ip.indexOf('%');
if (i != -1) {
ip = ip.substring(0,i);
}
return ip;
}
}
}

Loading…
Cancel
Save