Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically connect to replicated peers #339

Merged
merged 1 commit into from
Mar 28, 2020

Conversation

christianbundy
Copy link
Member

Problem: By default we only connect to people that we're directly
following, which often don't have public IP addresses.

Solution: Automatically connect to all available peers within our
replication hops (default 2) to make peering more reliable.

Problem: By default we only connect to people that we're directly
following, which often don't have public IP addresses.

Solution: Automatically connect to all available peers within our
replication hops (default 2) to make peering more reliable.
@christianbundy christianbundy added the enhancement New feature or request label Mar 23, 2020
@christianbundy christianbundy requested a review from jedahan March 23, 2020 21:25
@christianbundy christianbundy added the networking Connections between computers label Mar 27, 2020
@sbillig
Copy link
Collaborator

sbillig commented Mar 27, 2020

@christianbundy

How does this behave for you? For me, ssb.conn.stagedPeers() seems to give the same three peers over and over again (none of which happen to be within hop range for me).

  oasis hops: Infinity addr: net:157.230.172.152:8008~shs:bcH4cFvuDtFDfFf3RS6V33iXok+zRL9k+3PYNxn4+7I= +2s
  oasis hops: Infinity addr: net:pub.delatech.net:8008~shs:Kut5+dork5zDlmn7S3Ye+Gxik+49ZUhzBPkC8kD/enA= +0ms
  oasis hops: Infinity addr: net:diefreien.club:8008~shs:tRzW0j6g7sDc94GNnD5/BZQmUCrMn1BZQ/dl+7V/KhI= +0ms
  oasis hops: Infinity addr: net:157.230.172.152:8008~shs:bcH4cFvuDtFDfFf3RS6V33iXok+zRL9k+3PYNxn4+7I= +1ms
  oasis hops: Infinity addr: net:pub.delatech.net:8008~shs:Kut5+dork5zDlmn7S3Ye+Gxik+49ZUhzBPkC8kD/enA= +0ms
  oasis hops: Infinity addr: net:diefreien.club:8008~shs:tRzW0j6g7sDc94GNnD5/BZQmUCrMn1BZQ/dl+7V/KhI= +0ms
  oasis hops: Infinity addr: net:157.230.172.152:8008~shs:bcH4cFvuDtFDfFf3RS6V33iXok+zRL9k+3PYNxn4+7I= +0ms
  oasis hops: Infinity addr: net:pub.delatech.net:8008~shs:Kut5+dork5zDlmn7S3Ye+Gxik+49ZUhzBPkC8kD/enA= +0ms
  oasis hops: Infinity addr: net:diefreien.club:8008~shs:tRzW0j6g7sDc94GNnD5/BZQmUCrMn1BZQ/dl+7V/KhI= +0ms

lodash.get(ssbConfig, "friends.hops", 0)
);

const add = address => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like ssb-conn's (ssb-conn-hub's) connect function already handles this (connect() returns false if there's already a connection open or in progress), so inProgress and add probably aren't necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I noticed that the same person was showing up multiple times in my peer list, but maybe one was just { state: 'connecting' }.

@christianbundy
Copy link
Member Author

How does this behave for you?

Here's what I'm seeing:

  oasis Connecting to staged peer at 2/4 hops: net:hub.devcontrol.org:8008~shs:nSCVHJ5OSajcynWgo3Xh0bChZN3e4oV1ooIuFWdxrmg= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:post.tableflip.io:8008~shs:YXquIbh1OqCCdMuqCO4tSJuYR7RL811CTuu59n7G0pk= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:138.197.22.54:8008~shs:s2HQ9ncELBUOJ8A/JCKuZV9elfn3FwrTYt4bK4fvD0o= +0ms
  oasis Connecting to staged peer at 4/4 hops: net:174.21.238.192:8008~shs:Ql06HdDq12i6dN0jA7LQ9G5GPOLI+Nzx9hsnEjavPq8= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:hub.lnbrg.io:8008~shs:V3lOSCJHKqiWFL2ui03oIDlHliJJUYw+ehpLU/2ipOM= +1ms
  oasis Connecting to staged peer at 2/4 hops: net:cryptoscope.co:8008~shs:G20wv2IZkB7BA/LKe7WMuByop3++J0u9+Y32OoEVOj8= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:denverpubby.com:8008~shs:tFvOJUqVUcIbeUVK4/V6oNY/BywboRt2TKE3Uf5d11E= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:pub.dao.cool:8008~shs:xyv7La5FUMV0LZos48g9o9uuuOVIKmbKe7nGTHGhd/s= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:ssb.badran.net.nz:8008~shs:q544H88nAvNX1WPg9830AxCUnTdNzzkEpwuwJc/mAYI= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:ssb.badran.net.nz:8008~shs:+hGSCBZrKuzB/y4KzsIoGrw03fNlVj8kyYLIB2oFtAw= +1ms
  oasis Connecting to staged peer at 2/4 hops: net:88.198.115.222:8008~shs:ffstBCHpmUTQvgkjVupR/GdulHsSsS4coh1sxEL4pWA= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:ssb.cryptoscope.co:8008~shs:G20wv2IZkB7BA/LKe7WMuByop3++J0u9+Y32OoEVOj8= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:evbogue.com:8008~shs:J2VKbbf69rK38vXIRLOCwaZdEm+0vzv/LMeaxmJks3k= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:207.154.204.200:8008~shs:GF8UXwmSBvu/qcVrj18SUYPXzya694n7u30RUFajPws= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:woodbine.ansuz.xyz:8008~shs:ppdSxn1pSozJIqtDE4pYgwaQGmswCT9y15VJJcXRntI= +1ms
  oasis Connecting to staged peer at 4/4 hops: net:robeson.io:8008~shs:+XyZeJU/V2g+YqCsyV5/+fm8/Y1UcdoedzddjcDHmfY= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:54.144.208.18:8008~shs:/oBboQ7B5kWuDhjsNfIpQJccKO1irnS679riDR3rdTw= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:54.144.208.18:8008~shs:s+5UQAg/7rc+B5FUsmCD6xOdr9Ovy2V+EEIZXxZKvVs= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:pub.locksmithdon.net:8008~shs:5Iy0jt/wxI84VmdFeTdDedXjI1zyAU6BXQvb4DUyZIE= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:82.196.3.140:8008~shs:eLgXe759ZIW1QokHm/aXQhvqDPcyiM0EUzEBk4uu4fU= +1ms
  oasis Connecting to staged peer at 3/4 hops: net:pub.locksmithdon.net:8008~shs:gQA/OqZbakO+6Srr8Wqy512O+M1Qdd1T77gLEzIrxxo= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:pub.locksmithdon.net:8008~shs:CFaZuctqiVxiHentlafdtBDhMf2IDGF+b831SxwGoIA= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:pub.doge.haus:8008~shs:7nTbqZVRYRo7FokY8BBYGpXvvveRPb4u+G1vunRmNn4= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:ssb-pub.solvingmaz.es:8008~shs:oqkBi0czedWJNPmc36jcJZ40tKNL3zT91K1P9rviipA= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:ssb.sethvincent.com:8008~shs:OlbyVmOV0r4ha0pCEMzY537ShmW3PatQr0nblCNmhaY= +1ms
  oasis Connecting to staged peer at 2/4 hops: net:localhost:8080~shs:G20wv2IZkB7BA/LKe7WMuByop3++J0u9+Y32OoEVOj8= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:94.237.35.82:80~shs:0YTV22Eg35HneBaqZtbebkG5bTyRZxxKvjnsYtI2adY= +0ms
  oasis Connecting to staged peer at 3/4 hops: net:pub.corcoran.io:8008~shs:TiMeM1e5oOzwtQQ1NtXtLa34jfOM2RZNKkuUBJUr/Jg= +0ms
  oasis Connecting to staged peer at 4/4 hops: net:telnet.tokyo:8008~shs:8nXNyEsnUcB0JNS84+O8vAs5r/TVKHxkLDGGSi/1OKY= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:46.101.124.81:8008~shs:GF8UXwmSBvu/qcVrj18SUYPXzya694n7u30RUFajPws= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:198.211.122.115:8008~shs:7snGJQdhw12HrUTzeaWMfxuBO8c2U75sG7sNkeEfYOw= +1ms
  oasis Connecting to staged peer at 3/4 hops: net:room.sudoroom.org:8008~shs:qtoz1F39isKO79Hv1WUPWUCAxzAwdJl/YaUe83eKZxo= +0ms
  oasis Connecting to staged peer at 2/4 hops: net:pub.locksmithdon.net:8008~shs:H/LX/ilXqn42MEikWw3O3jm7oTbF15UqK7zNC6fKfxE= +0ms

I think the right way to do this would be to make the hops configurable in SSB-CONN, but I'm not sure if that's an option (see ssbc/ssb-conn#16).

@sbillig
Copy link
Collaborator

sbillig commented Mar 28, 2020

I read ssb-conn's readme; staging contains peers with autoconnect=false, and these three peers were the only ones with autoconnect=false in my conn.json, for whatever reason. After moving conn.json (and gossip.json for good measure), everything in conn.json is autoconnect=false, so this makes more sense now.

Bluetooth peers are also in staging, so a possible side effect is that we'd hypothetically aggressively connect to bt peers, but that seems fine (?).

@sbillig sbillig merged commit 4aa2841 into fraction:master Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request networking Connections between computers
Development

Successfully merging this pull request may close these issues.

Connection hops (vs replication) Should maybe connect to pubs automatically
2 participants