- if(read(cl->meta_socket, &((char*)(&tmp))[1], sizeof(tmp)-1) <= 0)
- {
- syslog(LOG_ERR, "%d: Receive failed: %m", __LINE__);
- return -1;
- }
-
- cl->protocol_version = tmp.protocol;
- cl->port = tmp.portnr;
- cl->vpn_ip = tmp.vpn_ip;
- cl->vpn_mask = tmp.vpn_mask;
-
- if(cl->protocol_version < PROT_CURRENT)
- {
- syslog(LOG_ERR, "Peer uses protocol version %d which is too old.",
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got BASIC_INFO from %s"), cl->hostname);
+
+ if(sscanf(cl->buffer, "%*d %d %lx/%lx:%hx %d", &cl->protocol_version, &cl->vpn_ip, &cl->vpn_mask, &cl->port, &cl->flags) != 5)
+ {
+ syslog(LOG_ERR, _("Got bad BASIC_INFO from %s"),
+ cl->hostname);
+ if(cl->status.outgoing)
+ {
+ /* If we get here, it means that our uplink uses the wrong protocol.
+ If we don't do anything, we will reconnect every 5 seconds. Pretty dumb.
+ So we disable the outgoing flag, so that we won't reconnect anymore.
+ This still allows other tinc daemons to connect to us.
+ */
+ syslog(LOG_ERR, _("Warning: disabling uplink!"));
+ cl->status.outgoing = 0;
+ }
+ return -1;
+ }
+
+ if(cl->protocol_version != PROT_CURRENT)
+ {
+ syslog(LOG_ERR, _("Peer uses incompatible protocol version %d"),