浏览代码

bin/darkirc: DEP-0007: add network profiles to net setting section of darkirc toml configs, use the maximum outbound_connect_timeout from all the network profiles for dag sync timeout

oars 1 年之前
父节点
当前提交
757f1d0542

+ 14 - 13
bin/darkirc/config/darkirc-clearnet.toml

@@ -20,23 +20,24 @@ datastore = "~/.local/share/darkfi/darkirc"
 ## Path to a configured hostlist for saving known peers
 hostlist = "~/.local/share/darkfi/darkirc/p2p_hostlist.tsv"
 
-## Whitelisted transports for outbound connections
-allowed_transports = ["tcp+tls"]
-
-## Addresses we want to advertise to peers
-external_addrs = ["tcp+tls://MY_IP_V4:26661", "tcp+tls://MY_IP_V6:26661", "tcp+tls://my.resolveable.address:26661"]
-
-## Seed nodes to connect to 
-seeds = ["tcp+tls://lilith1.dark.fi:5262"]
-
-## P2P accept addresses
-inbound = ["tcp+tls://0.0.0.0:26661", "tcp+tls://[::]:26661"]
-
 ## Outbound connection slots
 outbound_connections = 8
 
 ## Inbound connection slots
 inbound_connections = 64
 
+## Whitelisted transports for outbound connections
+active_profiles = ["tcp+tls"]
+
 ## Transports to be mixed
-mixed_transports = []
+mixed_profiles = []
+
+[net.profiles."tcp+tls"]
+## Seed nodes to connect to
+seeds = ["tcp+tls://lilith1.dark.fi:25551"]
+
+## Addresses we want to advertise to peers
+external_addrs = ["tcp+tls://MY_IP_V4:26661", "tcp+tls://MY_IP_V6:26661", "tcp+tls://my.resolveable.address:26661"]
+
+## P2P accept addresses
+inbound = ["tcp+tls://0.0.0.0:26661", "tcp+tls://[::]:26661"]

+ 18 - 20
bin/darkirc/config/darkirc-i2p.toml

@@ -21,34 +21,32 @@ datastore = "~/.local/share/darkfi/darkirc"
 hostlist = "~/.local/share/darkfi/darkirc/p2p_hostlist.tsv"
 
 ## connection settings
-outbound_connect_timeout = 60
-channel_handshake_timeout = 55
-channel_heartbeat_interval = 90
 outbound_peer_discovery_cooloff_time = 60
 
+## Outbound connection slots
+outbound_connections = 8
+
+## Inbound connection slots
+inbound_connections = 64
+
 ## Whitelisted transports for outbound connections
-allowed_transports = ["i2p", "i2p+tls"]
+active_profiles = ["i2p"]
 
-## Addresses we want to advertise to peers
-external_addrs = ["i2p://youraddress.b32.i2p:25551"]
+## Transports to be mixed
+mixed_profiles = []
 
-## Seed nodes to connect to 
+## I2p Socks5 proxy
+i2p_socks5_proxy = "socks5://127.0.0.1:4447"
+
+[net.profiles."i2p"]
+## Seed nodes to connect to
 seeds = [
     ##TODO: replace with an official seed address
     "i2p://6l2rdfriixo2nh5pr5bt555lyz56qox2ikzia4kuzm4okje7gtmq.b32.i2p:5262"
 ]
 
-## P2P accept addresses
-inbound = ["tcp://127.0.0.1:25551"]
-
-## Outbound connection slots
-outbound_connections = 8
-
-## Inbound connection slots
-inbound_connections = 64
-
-## Enable transport mixing
-transport_mixing = false
+## Addresses we want to advertise to peers
+external_addrs = ["i2p://youraddress.b32.i2p:25551"]
 
-## I2p Socks5 proxy
-i2p_socks5_proxy = "socks5://127.0.0.1:4447"
+## P2P accept addresses
+inbound = ["tcp://127.0.0.1:25551"]

+ 39 - 16
bin/darkirc/config/darkirc-mixed.toml

@@ -21,32 +21,55 @@ datastore = "~/.local/share/darkfi/darkirc"
 hostlist = "~/.local/share/darkfi/darkirc/p2p_hostlist.tsv"
 
 ## connection settings
-outbound_connect_timeout = 60
-channel_handshake_timeout = 55
-channel_heartbeat_interval = 90
 outbound_peer_discovery_cooloff_time = 60
 
+## Outbound connection slots
+outbound_connections = 8
+
+## Inbound connection slots
+inbound_connections = 64
+
 ## Whitelisted transports for outbound connections
-allowed_transports = ["tcp+tls", "tor", "tor+tls"]
+active_profiles = ["tcp+tls", "tor", "i2p"]
+
+## Transports to be mixed
+mixed_profiles = []
+
+[net.profiles."tcp+tls"]
+## Seed nodes to connect to
+seeds = ["tcp+tls://lilith0.dark.fi:25551", "tcp+tls://lilith1.dark.fi:25551"]
+
+## P2P accept addresses
+inbound = ["tcp+tls://0.0.0.0:26661", "tcp+tls://[::]:26661"]
 
 ## Addresses we want to advertise to peers
-external_addrs = ["tcp+tls://MY_IP_V4:26661", "tcp+tls://MY_IP_V6:26661", "tcp+tls://my.resolveable.address:26661", "tor://youraddress.onion:25551"]
+external_addrs = ["tcp+tls://MY_IP_V4:26661", "tcp+tls://MY_IP_V6:26661", "tcp+tls://my.resolveable.address:26661"]
 
-## Seed nodes to connect to 
+[net.profiles."tor"]
+## Seed nodes to connect to
 seeds = [
-    "tcp+tls://lilith1.dark.fi:5262",
-    "tor://czzulj66rr5kq3uhidzn7fh4qvt3vaxaoldukuxnl5vipayuj7obo7id.onion:5263",
-    "tor://vgbfkcu5hcnlnwd2lz26nfoa6g6quciyxwbftm6ivvrx74yvv5jnaoid.onion:5273",
+    "tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:25552",
+    "tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:25552",
 ]
 
 ## P2P accept addresses
-inbound = ["tcp://127.0.0.1:25551", "tcp+tls://0.0.0.0:26661", "tcp+tls://[::]:26661"]
+inbound = ["tcp://127.0.0.1:26662"]
 
-## Outbound connection slots
-outbound_connections = 8
+## Addresses we want to advertise to peers
+external_addrs = ["tor://youraddress.onion:26662"]
 
-## Inbound connection slots
-inbound_connections = 64
+[net.profiles."i2p"]
+## Seed nodes to connect to
+seeds = [
+    ##TODO: replace with an official seed address
+    "i2p://6l2rdfriixo2nh5pr5bt555lyz56qox2ikzia4kuzm4okje7gtmq.b32.i2p:5262"
+]
 
-## Transports to be mixed
-mixed_transports = ["tcp", "tcp+tls"]
+## Manual peers to connect to
+#peers = []
+
+## P2P accept addresses
+inbound = ["tcp://127.0.0.1:26663"]
+
+## Addresses we want to advertise to peers
+external_addrs = ["i2p://youraddress.b32.i2p:26663"]

+ 17 - 19
bin/darkirc/config/darkirc-tor.toml

@@ -21,31 +21,29 @@ datastore = "~/.local/share/darkfi/darkirc"
 hostlist = "~/.local/share/darkfi/darkirc/p2p_hostlist.tsv"
 
 ## connection settings
-outbound_connect_timeout = 60
-channel_handshake_timeout = 55
-channel_heartbeat_interval = 90
 outbound_peer_discovery_cooloff_time = 60
 
-## Whitelisted transports for outbound connections
-allowed_transports = ["tor", "tor+tls"]
-
-## Addresses we want to advertise to peers
-external_addrs = ["tor://youraddress.onion:25551"]
-
-## Seed nodes to connect to 
-seeds = [
-    "tor://czzulj66rr5kq3uhidzn7fh4qvt3vaxaoldukuxnl5vipayuj7obo7id.onion:5263",
-    "tor://vgbfkcu5hcnlnwd2lz26nfoa6g6quciyxwbftm6ivvrx74yvv5jnaoid.onion:5273",
-]
-
-## P2P accept addresses
-inbound = ["tcp://127.0.0.1:25551"]
-
 ## Outbound connection slots
 outbound_connections = 8
 
 ## Inbound connection slots
 inbound_connections = 64
 
+## Whitelisted transports for outbound connections
+active_profiles = ["tor"]
+
 ## Transports to be mixed
-mixed_transports = []
+mixed_profiles = []
+
+[net.profiles."tor"]
+## Seed nodes to connect to
+seeds = [
+    "tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:25552",
+    "tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:25552",
+]
+
+## Addresses we want to advertise to peers
+external_addrs = ["tor://youraddress.onion:26661"]
+
+## P2P accept addresses
+inbound = ["tcp://127.0.0.1:26661"]

+ 13 - 16
bin/darkirc/config/inbound.toml

@@ -1,5 +1,5 @@
 ## IRC listen URL
-irc_listen = "127.0.0.1:11067"
+irc_listen = "tcp://127.0.0.1:11067"
 
 ## Sets Datastore Path
 datastore = "~/.config/darkfi/darkirc-inbound"
@@ -17,24 +17,21 @@ rpc_disabled_methods = ["p2p.get_info"]
 # Magic Bytes to distinguish the p2p network
 magic_bytes = [251, 229, 199, 181]
 
-## P2P accept addresses
-inbound = ["127.0.0.1:11002"]
-
 ## Connection slots
 #outbound_connections=5
 
-## P2P external addresses
-external_addr = ["127.0.0.1:11004"]
+# Whitelisted transports for outbound connections
+active_profiles = ["tcp"]
 
-## Peers to connect to
-#peers=["127.0.0.1:11003"]
+[net.profiles."tcp"]
+## Seed nodes to connect to
+seeds = ["tcp://127.0.0.1:11001"]
 
-## Seed nodes to connect to 
-seeds = ["127.0.0.1:11001"]
+## P2P accept addresses
+inbound = ["tcp://127.0.0.1:11002"]
+
+## P2P external addresses
+external_addr = ["tcp://127.0.0.1:11004"]
 
-## these are the default configuration for the p2p network
-#manual_attempt_limit=0
-#seed_query_timeout_seconds=8
-#connect_timeout_seconds=10
-#channel_handshake_seconds=4
-#channel_heartbeat_seconds=10
+## Peers to connect to
+#peers=["tcp://127.0.0.1:11003"]

+ 13 - 16
bin/darkirc/config/outbound.toml

@@ -1,5 +1,5 @@
 ## IRC listen URL
-irc_listen = "127.0.0.1:11066"
+irc_listen = "tcp://127.0.0.1:11066"
 
 ## Sets Datastore Path
 datastore = "~/.config/darkfi/darkirc-outbound"
@@ -17,24 +17,21 @@ rpc_disabled_methods = ["p2p.get_info"]
 # Magic Bytes to distinguish the p2p network
 magic_bytes = [251, 229, 199, 181]
 
-## P2P accept addresses
-# inbound=["127.0.0.1:11002"]
-
 ## Connection slots
 outbound_connections = 5
 
-## P2P external addresses
-#external_addr=["127.0.0.1:11002"]
+# Whitelisted transports for outbound connections
+active_profiles = ["tcp"]
 
-## Peers to connect to
-#peers=["127.0.0.1:11003"]
+[net.profiles."tcp"]
+## Seed nodes to connect to
+seeds = ["tcp://127.0.0.1:11001"]
 
-## Seed nodes to connect to 
-seeds = ["127.0.0.1:11001"]
+## P2P accept addresses
+# inbound=["tcp://127.0.0.1:11002"]
+
+## P2P external addresses
+#external_addr=["tcp://127.0.0.1:11002"]
 
-## these are the default configuration for the p2p network
-#manual_attempt_limit=0
-#seed_query_timeout_seconds=8
-#connect_timeout_seconds=10
-#channel_handshake_seconds=4
-#channel_heartbeat_seconds=10
+## Peers to connect to
+#peers=["tcp://127.0.0.1:11003"]

+ 13 - 16
bin/darkirc/config/seed.toml

@@ -1,5 +1,5 @@
 ## IRC listen URL
-irc_listen = "127.0.0.1:11065"
+irc_listen = "tcp://127.0.0.1:11065"
 
 ## Sets Datastore Path
 datastore = "~/.config/darkfi/darkirc-seed"
@@ -17,24 +17,21 @@ rpc_disabled_methods = ["p2p.get_info"]
 # Magic Bytes to distinguish the p2p network
 magic_bytes = [251, 229, 199, 181]
 
-## P2P accept addresses
-inbound = ["127.0.0.1:11001"]
-
 ## Connection slots
 # outbound_connections=5
 
-## P2P external addresses
-# external_addr=["127.0.0.1:11001"]
+# Whitelisted transports for outbound connections
+active_profiles = ["tcp"]
 
-## Peers to connect to
-# peers=["127.0.0.1:11001"]
+[net.profiles."tcp"]
+## P2P accept addresses
+inbound = ["tcp://127.0.0.1:11001"]
+
+## Seed nodes to connect to
+# seeds=["tcp://127.0.0.1:11002"]
 
-## Seed nodes to connect to 
-# seeds=["127.0.0.1:11002"]
+## P2P external addresses
+# external_addr=["tcp://127.0.0.1:11001"]
 
-## these are the default configuration for the p2p network
-#manual_attempt_limit=0
-#seed_query_timeout_seconds=8
-#connect_timeout_seconds=10
-#channel_handshake_seconds=4
-#channel_heartbeat_seconds=10
+## Peers to connect to
+# peers=["tcp://127.0.0.1:11001"]

+ 95 - 27
bin/darkirc/darkirc_config.toml

@@ -61,10 +61,6 @@ p2p_datastore = "~/.local/share/darkfi/darkirc"
 # Path to a configured hostlist for saving known peers
 hostlist = "~/.local/share/darkfi/darkirc/p2p_hostlist.tsv"
 
-## P2P accept addresses
-#inbound = ["tcp+tls://0.0.0.0:26661", "tcp+tls://[::]:26661"]
-#inbound = ["tor://127.0.0.1:26661"]
-
 ## Outbound connection slots
 # outbound_connections = 8
 
@@ -77,44 +73,116 @@ hostlist = "~/.local/share/darkfi/darkirc/p2p_hostlist.tsv"
 ## White connection percent
 # white_connect_percent = 70
 
+# Nodes to avoid interacting with for the duration of the program, in the
+# format ["host", ["scheme", "scheme"], [port, port]].
+# If scheme is left empty it will default to "tcp+tls".
+# If ports are left empty all ports from this peer will be blocked.
+#blacklist = [["example.com", ["tcp"], [8551, 23331]]]
+
+# Whitelisted transports for outbound connections
+active_profiles = ["tor"]
+#active_profiles = ["tcp+tls"]
+#active_profiles = ["tor", "tor+tls"]
+
+# Transports you want to be mixed (e.g. Tor would be allowed to connect to `tcp://`
+# if tcp is added to mixed_profiles and tor is added to active_profiles)
+#mixed_profiles = []
+
+# Tor Socks5 proxy
+#tor_socks5_proxy = "socks5://127.0.0.1:9050"
+
+# Nym Socks5 proxy
+#nym_socks5_proxy = "socks5://127.0.0.1:1080"
+
+# I2p Socks5 proxy
+#i2p_socks5_proxy = "socks5://127.0.0.1:4447"
+
+[net.profiles."tcp+tls"]
+## Seed nodes to connect to
+seeds = ["tcp+tls://lilith0.dark.fi:25551", "tcp+tls://lilith1.dark.fi:25551"]
+
+## Manual peers to connect to
+#peers = []
+
+## P2P accept addresses
+#inbound = ["tcp+tls://0.0.0.0:26661", "tcp+tls://[::]:26661"]
+
 ## Addresses we want to advertise to peers (optional)
 ## These should be reachable externally
 #external_addrs = ["tcp+tls://my.resolveable.address:26661"]
 
-## Seed nodes to connect to 
+[net.profiles."tor"]
+## Seed nodes to connect to
 seeds = [
-    "tcp+tls://lilith0.dark.fi:25551",
-    "tcp+tls://lilith1.dark.fi:25551",
-    #"tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:25552",
-    #"tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:25552",
+    "tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:25552",
+    "tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:25552",
 ]
 
 ## Manual peers to connect to
 #peers = []
 
-# Whitelisted transports for outbound connections
-allowed_transports = ["tcp+tls"]
-#allowed_transports = ["tor"]
-#allowed_transports = ["tor", "tor+tls"]
+## P2P accept addresses
+#inbound = ["tor://127.0.0.1:26661"]
 
-# Transports you want to be mixed (e.g. Tor would be allowed to connect to `tcp://`
-# if tcp is added to mixed_transports and tor is added to allowed_transports)
-mixed_transports = []
+[net.profiles."i2p"]
+## Seed nodes to connect to
+seeds = [
+    ##TODO: replace with an official seed address
+    "i2p://6l2rdfriixo2nh5pr5bt555lyz56qox2ikzia4kuzm4okje7gtmq.b32.i2p:5262"
+]
 
-# Tor Socks5 proxy
-#tor_socks5_proxy = "socks5://127.0.0.1:9050"
+## Manual peers to connect to
+#peers = []
 
-# Nym Socks5 proxy
-#nym_socks5_proxy = "socks5://127.0.0.1:1080"
+## P2P accept addresses
+#inbound = ["tcp://127.0.0.1:25551"]
 
-# I2p Socks5 proxy
-#i2p_socks5_proxy = "socks5://127.0.0.1:4447"
+## Addresses we want to advertise to peers (optional)
+## These should be reachable externally
+#external_addrs = ["i2p://youraddress.b32.i2p:25551"]
 
-# Nodes to avoid interacting with for the duration of the program, in the
-# format ["host", ["scheme", "scheme"], [port, port]].
-# If scheme is left empty it will default to "tcp+tls". 
-# If ports are left empty all ports from this peer will be blocked.
-#blacklist = [["example.com", ["tcp"], [8551, 23331]]]
+[net.profiles."socks5"]
+## Seed nodes to connect to
+seeds = [
+    "socks5://127.0.0.1:9050/g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:25552",
+    "socks5://127.0.0.1:9050/yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:25552",
+]
+
+## Manual peers to connect to
+#peers = []
+
+[net.profiles."socks5+tls"]
+## Seed nodes to connect to
+seeds = [
+    #"socks5+tls://127.0.0.1:9050/lilith0.dark.fi:25551",
+    #"socks5+tls://127.0.0.1:1080/lilith1.dark.fi:25551"
+]
+
+## Manual peers to connect to
+#peers = []
+
+[net.profiles."tor+tls"]
+## Seed nodes to connect to
+seeds = [
+    "tor+tls://lilith0.dark.fi:25551",
+    "tor+tls://lilith1.dark.fi:25551"
+]
+
+## Manual peers to connect to
+#peers = []
+
+[net.profiles."tcp"]
+## Seed nodes to connect to
+#seeds = ["tcp://127.0.0.1:25551"]
+
+## Manual peers to connect to
+#peers = []
+
+## P2P accept addresses
+#inbound = ["tcp://127.0.0.1:26661"]
+
+## Addresses we want to advertise to peers
+#external_addrs = ["tcp://127.0.0.1:26661"]
 
 ## ====================
 ## IRC channel settings

+ 1 - 1
bin/darkirc/src/main.rs

@@ -548,7 +548,7 @@ async fn monitor_network(subscription: &Subscription<Error>) -> Result<()> {
 
 /// Async task to endlessly try to sync DAG, returns Ok if done.
 async fn sync_task(p2p: &P2pPtr, event_graph: &EventGraphPtr, skip_dag_sync: bool) -> Result<()> {
-    let comms_timeout = p2p.settings().read().await.outbound_connect_timeout;
+    let comms_timeout = p2p.settings().read_arc().await.outbound_connect_timeout_max();
 
     loop {
         if p2p.is_connected() {