@@ -139,6 +139,32 @@ impl Config {
139139 }
140140 }
141141
142+ /// Returns the addr of the tor control socket if it is set, or the default
143+ /// socket at localhost:9051 if not.
144+ pub fn get_tor_control_socket ( & self ) -> Result < InetSocketAddr , Error > {
145+ if let Some ( FarcasterdConfig {
146+ tor_control_socket : Some ( addr) ,
147+ ..
148+ } ) = & self . farcasterd
149+ {
150+ Ok ( InetSocketAddr :: from_str ( addr) ?)
151+ } else {
152+ Ok ( InetSocketAddr :: from_str ( "127.0.0.1:9051" ) ?)
153+ }
154+ }
155+
156+ pub fn create_hidden_service ( & self ) -> bool {
157+ if let Some ( FarcasterdConfig {
158+ create_hidden_service : Some ( create_hidden_service) ,
159+ ..
160+ } ) = & self . farcasterd
161+ {
162+ * create_hidden_service
163+ } else {
164+ false
165+ }
166+ }
167+
142168 /// Returns the swap config for the specified network and arbitrating/accordant blockchains
143169 pub fn get_swap_config (
144170 & self ,
@@ -230,6 +256,11 @@ pub struct FarcasterdConfig {
230256 pub bind_ip : Option < String > ,
231257 /// Whether checkpoints should be auto restored at start-up, or not
232258 pub auto_restore : Option < bool > ,
259+ /// Tor control socket for creating the hidden service
260+ pub tor_control_socket : Option < String > ,
261+ /// Whether to create a hidden service or not. If set, the node will only
262+ /// run in hidden service mode
263+ pub create_hidden_service : Option < bool > ,
233264}
234265
235266#[ derive( Deserialize , Serialize , Debug , Clone ) ]
@@ -432,6 +463,8 @@ impl Default for FarcasterdConfig {
432463 // write the default port and ip in the generated config
433464 bind_port : Some ( FARCASTER_BIND_PORT ) ,
434465 bind_ip : Some ( FARCASTER_BIND_IP . to_string ( ) ) ,
466+ tor_control_socket : None ,
467+ create_hidden_service : None ,
435468 }
436469 }
437470}
0 commit comments