@@ -58,19 +58,35 @@ public NetworkDiscovery() {
5858
5959 @ Override
6060 public List <BoardPort > discovery () {
61- List <BoardPort > ports = clonePortsList ();
62- Iterator <BoardPort > iterator = ports .iterator ();
63- while (iterator .hasNext ()) {
61+ List <BoardPort > boardPorts = clonePortsList ();
62+ Iterator <BoardPort > boardPortIterator = boardPorts .iterator ();
63+ while (boardPortIterator .hasNext ()) {
6464 try {
65- BoardPort board = iterator .next ();
66- if (!NetUtils .isReachable (InetAddress .getByName (board .getAddress ()), Integer .parseInt (board .getPrefs ().get ("port" )))) {
67- iterator .remove ();
65+ BoardPort board = boardPortIterator .next ();
66+
67+ InetAddress inetAddress = InetAddress .getByName (board .getAddress ());
68+ int broadcastedPort = Integer .valueOf (board .getPrefs ().get ("port" ));
69+
70+ List <Integer > ports = new LinkedList <Integer >();
71+ ports .add (broadcastedPort );
72+
73+ //dirty code: allows non up to date yuns to be discovered. Newer yuns will broadcast port 22
74+ if (broadcastedPort == 80 ) {
75+ ports .add (0 , 22 );
76+ }
77+
78+ boolean reachable = false ;
79+ for (Integer port : ports ) {
80+ reachable = reachable || NetUtils .isReachable (inetAddress , port );
81+ }
82+ if (!reachable ) {
83+ boardPortIterator .remove ();
6884 }
6985 } catch (UnknownHostException e ) {
70- iterator .remove ();
86+ boardPortIterator .remove ();
7187 }
7288 }
73- return ports ;
89+ return boardPorts ;
7490 }
7591
7692 private List <BoardPort > clonePortsList () {
0 commit comments