Sync only when a RJ-45/USB-C connected on Android

Hi! I use a connector RJ-45/USB-C to connect my android device. It’is possible to add a new feature to sync only when the device are LAN connected, the same way we could choise to sync only when the device are connected on WIFI?

Thank you

I think this may be tricky because the Wi-Fi setting in the app is about the phone being connected to Wi-Fi or not (i.e. it’s not about the kind of connection used to connect remote devices inside Syncthing). Unless you mean that sync should only happen when the phone is connected to the Internet through LAN? It sounds like you mean that you use the “USB tethering” option in Android settings to share the phone’s connection which isn’t the same thing.

Nevertheless, the Android app is currently in maintenance mode (see https://github.com/syncthing/syncthing-android#status-maintenance-mode—co-maintainers-welcome), so for any new features to be added, someone will need to volunteer and do the work themselves.

Hi, thank you for your response, I’m using this thing (see picture). I’m in the configuration : sync should only happen when the phone is connected to the Internet through LAN. I’don’t have programming skill to do the work, so I’hope someone find this feature usefull enough to do the job :slight_smile: 5101xVANHsS._AC_SX300_SY300_QL70_ML2

Because the phone needs an IP address for the USB Ethernet adapter (either via DHCP or static configuration), that’s a way to limit which link is used for syncing.

In the Syncthing app (either the official or forked release), adjust the “Sync Protocol Listen Addresses” setting.

The default value is default. If your phone’s IP address via the USB Ethernet adapter is 192.168.1.2, then tcp://192.168.1.2:22000 would tell Syncthing to bind only to the network interface using that particular IP address instead of to all available network interfaces.

(See Listen Addresses section of Syncthing’s documentation for more details.)

1 Like

Alternatively, I think you can also use https://docs.syncthing.net/advanced/device-allowednetworks.html.

Please keep in mind though that this isn’t the same as tweaking the conditions available in the Android app settings. In other words, the app will still continue to run even outside of the LAN, however Syncthing itself won’t allow connections from non-LAN devices.

Restricting the Listen Address setting might not be enough though. Syncthing on the Android device tries to discover and connect to the other devices, through whatever available network link. You’d have to set the “Allowed Networks” configuration for the devices as well, see here: allowedNetworks — Syncthing documentation

Maybe you’d be better off with a generic Android automation solution though. Apps like ITTT (If-This-Then-That) should provide such functionality and can control the Syncthing app via its “start” and “stop” intents. See Remote Control by Broadcast Intents · Catfriend1/syncthing-android Wiki · GitHub