Search code examples
databasesqliteprotocolsdistributed-computing

Synchronize sqlite files without a public IP


I'm trying to come up with a way to sync a sqlite database between two computers.

If this were on a machine with a public IP this would not be difficult but I'm trying to find a way to make this work for ANY two devices, and most computers don't have a static IP.

What are some of the ways I can tackle this problem?


Solution

  • Assuming you just need to find the peers IP address...

    1. Broadcast a Udp packet onto Lan, if machines are same lan segment. You can also try using admin scoped multicast, but mileage will vary according to the network setup and gear in use.

    2. If trying to find two machines across the internet (assuming you can solve the NAT address translation issue), you need to bounce off a node that will hold info for you. Eg write a packet to dweet.io or sparkfun or other website that will hold store and forward data. You can also read twitter feeds etc, basically you need a known reference point to both talk too. Look into how malware create command and control networks for some ideas. Or search for rendezvous servers and protocols.

    3. If the address range is small, probe all possible addresses. But be careful as you might trigger anti virus or ISP action

    4. If wanting more browser based, look at webrtc, not quite what you are after but some of the techniques for discovery might be interesting.

    5. If you have access, you can play with your DNS records. Essentially this is a variation of (2).

    There are more options too, but that get more special purpose or become a bit too stelthy for general use. Also see how mesh networks are formed.