{"action":"created","issue":{"url":"https://api.github.com/repos/neuravion/mesh-chat/issues/14","repository_url":"https://api.github.com/repos/neuravion/mesh-chat","labels_url":"https://api.github.com/repos/neuravion/mesh-chat/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/neuravion/mesh-chat/issues/14/comments","events_url":"https://api.github.com/repos/neuravion/mesh-chat/issues/14/events","html_url":"https://github.com/neuravion/mesh-chat/issues/14","id":146470422,"number":14,"title":"Idea for a relay server out on the internet?","user":{"login":"NullVoxPopuli","id":199018,"avatar_url":"https://avatars.githubusercontent.com/u/199018?v=3","gravatar_id":"","url":"https://api.github.com/users/NullVoxPopuli","html_url":"https://github.com/NullVoxPopuli","followers_url":"https://api.github.com/users/NullVoxPopuli/followers","following_url":"https://api.github.com/users/NullVoxPopuli/following{/other_user}","gists_url":"https://api.github.com/users/NullVoxPopuli/gists{/gist_id}","starred_url":"https://api.github.com/users/NullVoxPopuli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NullVoxPopuli/subscriptions","organizations_url":"https://api.github.com/users/NullVoxPopuli/orgs","repos_url":"https://api.github.com/users/NullVoxPopuli/repos","events_url":"https://api.github.com/users/NullVoxPopuli/events{/privacy}","received_events_url":"https://api.github.com/users/NullVoxPopuli/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/neuravion/mesh-chat/labels/Relaying","name":"Relaying","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-07T00:05:36Z","updated_at":"2016-04-18T18:12:10Z","closed_at":null,"body":"This is separate from the mesh-relaying problem we have to solve, but more about the problem of getting around firewall restrictions in two-way p2p communication. \r\n\r\nAs a side note, however, the mesh-relaying will eventually need to be built in to this idea of a 'relay server', so we may want to think of an easy-to-deploy mesh-network.\r\n\r\nBut, back to the\r\n## Relay Server\r\n\r\nThis would be a server that doesn't partake in the full mesh-chat protocol, but just routes messages to a designated client/user. And does implement the mesh-routing strategies.\r\n\r\nNot all users would need to be connected to the relay server. Only one user per subnet needs to be connected to the relay server if they want to communicate with other subnets  / over the internet.\r\n\r\n### How the relay server would work\r\n\r\nIn order to avoid the firewall / subnet firewall problem, each user that connects to the relay server will do so over [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API).\r\n - ref [Rails' Action Cable](http://jargon.io/joeyschoblaska/rails-5-chess-with-action-cable-websockets)\r\n\r\nThe users will need to keep track of which users are not on their subnet, and then send those messages to the relay server.  \r\n\r\nThe relay server will know who is connected to it (by uid), and will be able to broadcast received messages to those users.\r\n - The server will also need to keep track of who is behind a particular user (the person connected to the relay server) -- otherwise everyone would need to be connected to the relay server, and that's not scale-able.\r\n\r\n### For a Proof of Concept,\r\n\r\n - Have all network participants open a WebSocket connection to the server. \r\n - User A sends a message to User B, but User B has changed his IP address since the last time you spoke.\r\n - User A discovers User B is not at the old IP address, and then sends the message to the relay server (and makes a note of this decision for future messages, in case User B is not on the same subnet as User A)\r\n - The Relay server receives the message from User A, and broadcasts it to User B\r\n - When User B receives the message from the relay server, User B can check the IP address to see if it's from the same subnet, and update the ip address if it is. Otherwise User A and User B will only communicate over the relay server.\r\n"},"comment":{"url":"https://api.github.com/repos/neuravion/mesh-chat/issues/comments/211507840","html_url":"https://github.com/neuravion/mesh-chat/issues/14#issuecomment-211507840","issue_url":"https://api.github.com/repos/neuravion/mesh-chat/issues/14","id":211507840,"user":{"login":"NullVoxPopuli","id":199018,"avatar_url":"https://avatars.githubusercontent.com/u/199018?v=3","gravatar_id":"","url":"https://api.github.com/users/NullVoxPopuli","html_url":"https://github.com/NullVoxPopuli","followers_url":"https://api.github.com/users/NullVoxPopuli/followers","following_url":"https://api.github.com/users/NullVoxPopuli/following{/other_user}","gists_url":"https://api.github.com/users/NullVoxPopuli/gists{/gist_id}","starred_url":"https://api.github.com/users/NullVoxPopuli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NullVoxPopuli/subscriptions","organizations_url":"https://api.github.com/users/NullVoxPopuli/orgs","repos_url":"https://api.github.com/users/NullVoxPopuli/repos","events_url":"https://api.github.com/users/NullVoxPopuli/events{/privacy}","received_events_url":"https://api.github.com/users/NullVoxPopuli/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T18:12:10Z","updated_at":"2016-04-18T18:12:10Z","body":"Note:\r\n this allows for people on multiple mesh networks to use the relay without there being a security risk of cross-communication between networks.\r\n\r\nA work meshnet could be used at the same time as a reddit meshnet, as long as the relay server(s) can handle the load. \r\n\r\nTODO (for much later): load balancing / multiple relays"}}