- if(listen_sockets)
- logger(LOG_NOTICE, "Ready");
- else {
- logger(LOG_ERR, "Unable to create any listening socket!");
+ /* Done */
+
+ mesh->self->nexthop = mesh->self;
+
+ node_add(mesh, mesh->self);
+
+ if(!config_scan_all(mesh, "current", "hosts", load_node, NULL)) {
+ logger(mesh, MESHLINK_WARNING, "Could not scan all host config files");
+ }
+
+ /* Open sockets */
+
+ mesh->listen_sockets = 0;
+
+ if(!add_listen_address(mesh, NULL, NULL)) {
+ if(strcmp(mesh->myport, "0")) {
+ logger(mesh, MESHLINK_INFO, "Could not bind to port %s, asking OS to choose one for us", mesh->myport);
+ free(mesh->myport);
+ mesh->myport = strdup("0");
+
+ if(!mesh->myport) {
+ return false;
+ }
+
+ if(!add_listen_address(mesh, NULL, NULL)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ if(!mesh->listen_sockets) {
+ logger(mesh, MESHLINK_ERROR, "Unable to create any listening socket!");