$ git clone https://socialnetwork.ion.nu/socialnetwork.git
commit c38d23c7c0c5b14162a12893aab3df75b96205eb
Author: Alicia <...>
Date:   Tue Jan 17 20:37:39 2017 +0000

    Added peer_exportpeers() to save the list of peers we're connected to (for future bootstrapping)

diff --git a/peer.c b/peer.c
index d19eb54..f356207 100644
--- a/peer.c
+++ b/peer.c
@@ -503,3 +503,23 @@ struct peer* peer_findbyid(const unsigned char id[20])
   }
   return 0;
 }
+
+void peer_exportpeers(const char* path)
+{
+  int f=open(path, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+  unsigned int i;
+  for(i=0; i<peercount; ++i)
+  {
+    if(!peers[i]->handshake){continue;} // Skip bad peers
+    switch(peers[i]->addr.sa_family)
+    {
+    case AF_INET:
+      {
+      struct sockaddr_in* addr=(struct sockaddr_in*)&peers[i]->addr;
+      unsigned char* ip=(unsigned char*)&addr->sin_addr.s_addr;
+      dprintf(f, "%hhu.%hhu.%hhu.%hhu:%hu\n", ip[0], ip[1], ip[2], ip[3], ntohs(addr->sin_port));
+      }
+    }
+  }
+  close(f);
+}
diff --git a/peer.h b/peer.h
index 9caabca..e366797 100644
--- a/peer.h
+++ b/peer.h
@@ -50,3 +50,4 @@ extern void peer_sendcmd(struct peer* peer, const char* cmd, void* data, uint32_
 extern void peer_disconnect(struct peer* peer, char cleanly);
 extern void peer_findpeer(const unsigned char id[20]); // Find and ask a peer to connect to us
 extern struct peer* peer_findbyid(const unsigned char id[20]);
+extern void peer_exportpeers(const char* path);
diff --git a/socialtest.c b/socialtest.c
index 7beeb75..1170818 100644
--- a/socialtest.c
+++ b/socialtest.c
@@ -122,6 +122,11 @@ int main(int argc, char** argv)
         buf[len]=0;
         social_updatefield(name, buf);
       }
+      else if(!strncmp(buf, "exportpeers ", 12))
+      {
+        peer_exportpeers(&buf[12]);
+      }
+      else{printf("Unknown command '%s'\n", buf);}
     }
     if(pfd[1].revents) // UDP
     {