@@ -28,6 +28,10 @@ pub struct Cli {
2828 #[ clap( long, env = "DITTO_CLIENT_NAME" ) ]
2929 client_name : Option < String > ,
3030
31+ /// Enable peer-to-peer transports (LAN, Bluetooth). Set to false to force all communication through Big Peer.
32+ #[ clap( long, env = "DITTO_P2P_ENABLED" , default_value = "true" ) ]
33+ p2p_enabled : bool ,
34+
3135 /// Path to write logs on disk
3236 #[ clap( long, default_value = "/tmp/ditto-quickstart.log" ) ]
3337 log : PathBuf ,
@@ -61,6 +65,7 @@ async fn main() -> Result<()> {
6165 cli. token ,
6266 cli. custom_auth_url ,
6367 cli. websocket_url . clone ( ) ,
68+ cli. p2p_enabled ,
6469 )
6570 . await ?;
6671 let _tui_task = TuiTask :: try_spawn (
@@ -105,6 +110,7 @@ async fn try_init_ditto(
105110 token : String ,
106111 custom_auth_url : String ,
107112 websocket_url : String ,
113+ p2p_enabled : bool ,
108114) -> Result < Ditto > {
109115 // We use a temporary directory to store Ditto's local database.
110116 // This means that data will not be persistent between runs of the
@@ -127,11 +133,16 @@ async fn try_init_ditto(
127133 . build ( ) ?;
128134
129135 ditto. update_transport_config ( |config| {
130- // Explicitly disable all peer-to-peer transports - only use Big Peer
131- config. peer_to_peer . bluetooth_le . enabled = false ;
132- config. peer_to_peer . lan . enabled = false ;
136+ if p2p_enabled {
137+ // Enable all peer-to-peer transports (original behavior)
138+ config. enable_all_peer_to_peer ( ) ;
139+ } else {
140+ // Explicitly disable all peer-to-peer transports - only use Big Peer
141+ config. peer_to_peer . bluetooth_le . enabled = false ;
142+ config. peer_to_peer . lan . enabled = false ;
143+ }
133144
134- // Keep only the WebSocket connection to Big Peer
145+ // Set WebSocket URL for Big Peer connection
135146 config. connect . websocket_urls . insert ( websocket_url) ;
136147 } ) ;
137148
0 commit comments