antirez/redis — pull request #2095 by mattsta (2014-10-23 18:40:13+00:00)
Title: Add slave IP details during a sync

If you have multiple replicas sync at the same time, you can't tell which replica is causing which action.

See the "Before" box below — two cluster replicas are attached and sync'ing at once, but you can't tell which is which.

Before:
```haskell
17204:M 23 Oct 13:31:11.256 # IP address for this node updated to ::1
17204:M 23 Oct 13:31:15.958 # Cluster state changed: ok
17204:M 23 Oct 13:31:18.421 * Slave asks for synchronization
17204:M 23 Oct 13:31:18.421 * Full resync requested by slave.
17204:M 23 Oct 13:31:18.421 * Starting BGSAVE for SYNC
17204:M 23 Oct 13:31:18.421 * Background saving started by pid 17333
17333:C 23 Oct 13:31:18.422 * DB saved on disk
17204:M 23 Oct 13:31:18.439 * Slave asks for synchronization
17204:M 23 Oct 13:31:18.439 * Full resync requested by slave.
17204:M 23 Oct 13:31:18.439 * Waiting for end of BGSAVE for SYNC
17204:M 23 Oct 13:31:18.475 * Background saving terminated with success
17204:M 23 Oct 13:31:18.475 * Synchronization with slave succeeded
17204:M 23 Oct 13:31:18.475 * Synchronization with slave succeeded
```

After:
```haskell
22172:M 23 Oct 14:18:27.602 # IP address for this node updated to [::1]
22172:M 23 Oct 14:18:27.645 # Cluster state changed: ok
22172:M 23 Oct 14:18:30.619 * Slave asks for synchronization from [::1]:59696
22172:M 23 Oct 14:18:30.619 * Full resync requested by slave from [::1]:59696
22172:M 23 Oct 14:18:30.619 * Starting BGSAVE for SYNC
22172:M 23 Oct 14:18:30.619 * Background saving started by pid 22238
22238:C 23 Oct 14:18:30.620 * DB saved on disk
22172:M 23 Oct 14:18:30.637 * Slave asks for synchronization from [::1]:59698
22172:M 23 Oct 14:18:30.637 * Full resync requested by slave from [::1]:59698
22172:M 23 Oct 14:18:30.637 * Waiting for end of BGSAVE for SYNC
22172:M 23 Oct 14:18:30.675 * Background saving terminated with success
22172:M 23 Oct 14:18:30.675 * Synchronization with slave succeeded from [::1]:59696
22172:M 23 Oct 14:18:30.675 * Synchronization with slave succeeded from [::1]:59698
```

I thought this would be a quick one or two line change, but I ended up refactoring all the IP formatting code. Some of the "format an IP properly" code was getting copy/pasted around (since it's just one or two lines), but we can make a nicer interface for it.

Now we have achieved the goal of eradicating any copy/paste use of `strchr(ip, ':')` outside of formatting functions and config parsing.