Major setp forward in PeerNetQt's functionality. Have demonstrated successful Direct, Proxy and Relay Comms now. Still lots to do, but getting there!

* Added DhtState to NetStateBox.
 * Added LocalTesting flag, this lets the UdpStunner report a local address.
 * Completed the TOU 3 Stack routing.
 * Tweaked the UdpStunners so Proxy runs fast, and Dht is slow.
 * Push suitable DHT peers to both Stunners.
 * Added the UnreachablePeerCallback (hardwired to RELAY for now).
 * Added External Address checks for Proxy Connections.
 * Added slow tick() for NetState and Relay Checks.
 * Filled in the install/remove Relay Connection stuff.
 * Fixed several bugs for the display of Failed Peers. (Non-Friends).



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-peernet@4292 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-06-18 18:22:53 +00:00
parent 713f512406
commit 227880b216
8 changed files with 1071 additions and 631 deletions

View File

@ -1,500 +1,500 @@
212.139.213.150 14338
84.109.61.19 57401
212.50.84.124 49302
212.139.213.150 14302
212.139.213.150 14339
46.42.61.188 55357
212.139.213.150 14261
76.181.245.226 49127
212.139.213.150 14349
2.82.88.7 38377
212.139.213.150 14357
94.220.248.138 7000
217.42.159.134 28318
212.139.213.150 14348
78.102.94.60 11943
212.139.213.150 14255
109.111.157.144 55981
62.107.121.127 58811
92.162.121.190 56782
98.208.71.103 51760
212.139.213.150 14345
78.105.204.201 6881
208.96.101.152 26516
207.81.138.15 47037
24.64.255.14 42832
116.14.230.62 36209
212.139.213.150 14359
12.157.91.3 40518
89.142.20.136 14398
212.139.213.150 14346
212.139.213.150 14365
194.105.212.4 62621
212.139.213.150 14396
212.139.213.150 14354
178.59.155.252 64247
212.139.213.150 14356
93.80.198.28 19808
118.173.167.181 55555
86.135.254.39 30775
122.111.160.207 40935
67.188.133.52 41610
178.206.54.90 16839
190.172.93.70 11570
83.149.45.126 52149
212.139.213.150 14397
212.139.213.150 14400
2.93.235.181 33261
212.139.213.150 14404
212.139.213.150 14362
220.255.182.78 33156
212.139.213.150 14358
87.252.189.32 28450
31.163.78.187 18829
220.208.137.27 14073
85.141.153.202 60486
212.139.213.150 14387
67.174.105.123 10869
212.139.213.150 14405
212.139.213.150 14392
212.139.213.150 14347
212.139.213.150 14391
14.195.184.182 56775
91.207.211.238 55912
212.139.213.150 14394
110.168.76.6 48740
212.139.213.150 14379
89.243.192.56 15702
212.139.213.150 14389
188.168.212.228 18042
217.118.81.25 16657
79.126.254.95 57424
212.139.213.150 14406
178.209.78.84 15055
212.139.213.150 14403
98.224.171.170 47056
212.139.213.150 14375
94.79.45.182 38981
212.139.213.150 14401
212.139.213.150 14012
212.139.213.150 14378
212.139.213.150 14366
85.246.89.125 34298
217.208.136.18 48425
212.139.213.150 14381
212.139.213.150 14384
118.100.49.125 16562
92.24.85.204 15051
212.139.213.150 14024
212.139.213.150 14371
212.139.213.150 14043
77.30.14.68 24199
46.48.252.227 63522
212.139.213.150 14395
94.66.172.218 22031
91.148.85.131 24393
217.36.223.67 17347
212.139.213.150 14330
212.139.213.150 14016
212.139.213.150 14355
178.33.1.86 40881
80.212.246.174 36015
24.7.248.177 10557
87.97.224.239 8670
87.227.2.46 45058
119.42.68.216 21041
123.81.98.6 11935
212.139.213.150 14328
94.0.13.248 44097
212.139.213.150 14019
212.139.213.150 14051
178.214.165.121 45773
212.139.213.150 14021
193.91.80.87 61509
217.122.249.84 57437
178.122.33.126 53591
85.89.102.43 13937
212.139.213.150 14049
31.163.28.116 35691
94.212.156.76 60058
212.139.213.150 14045
81.13.46.86 16204
217.77.223.10 59670
151.41.137.113 59773
212.139.213.150 14022
212.139.213.150 14061
212.139.213.150 14031
212.139.213.150 14050
178.151.134.214 24650
194.190.96.113 16790
112.148.7.57 48056
79.55.225.231 16050
212.139.213.150 14053
212.139.213.150 14206
212.139.213.150 14048
212.139.213.150 14036
212.139.213.150 14011
79.1.168.85 31292
212.139.213.150 14069
212.139.213.150 14326
212.139.213.150 14070
212.139.213.150 14056
97.100.60.84 3759
109.184.21.108 59479
212.139.213.150 14033
109.187.76.172 29988
85.222.176.161 24716
213.178.39.131 32699
212.139.213.150 14068
85.74.141.93 15562
217.79.4.48 60540
212.139.213.150 14092
212.139.213.150 14094
46.191.182.198 60569
212.139.213.150 14331
212.139.213.150 14329
120.56.221.154 59781
212.139.213.150 14084
79.176.96.63 32915
212.139.213.150 14028
212.139.213.150 14037
213.98.122.61 57515
83.162.23.140 47358
212.139.213.150 14047
78.99.61.140 15043
212.139.213.150 14038
212.139.213.150 14333
212.139.213.150 14035
216.36.169.134 60540
212.139.213.150 14334
212.139.213.150 14283
212.139.213.150 14060
79.132.23.203 60229
213.114.186.7 26957
212.139.213.150 14278
92.102.207.212 40821
78.84.115.34 56208
86.58.106.144 44915
86.58.106.144 44786
86.58.106.144 44846
86.58.106.144 44928
86.58.106.144 44899
86.58.106.144 44739
86.58.106.144 44872
95.182.163.175 30987
96.21.63.46 49584
67.215.242.138 6881
90.196.80.182 53404
212.139.213.150 14044
95.154.213.131 28058
88.118.78.172 44179
79.114.40.79 35512
112.207.122.61 45489
212.115.244.50 61640
212.139.217.146 11889
212.139.217.146 11876
46.214.208.159 43422
78.148.195.46 27559
78.150.212.173 22224
212.139.217.146 11904
95.226.48.189 16113
189.155.11.83 10066
78.26.164.208 11542
212.139.217.146 11877
82.141.191.250 6149
1.22.249.95 30134
62.122.68.244 65215
83.23.181.22 22074
94.240.133.253 35691
24.177.55.18 27659
83.175.179.86 22947
178.95.25.34 10629
94.27.214.209 12614
124.6.181.104 39740
78.230.90.8 10861
93.78.219.90 38299
74.212.167.146 30158
212.139.217.146 11873
92.158.151.122 58496
212.139.217.146 11898
79.132.119.62 26032
94.64.155.139 29680
46.159.236.190 28486
85.230.170.213 11218
76.224.231.127 18769
217.208.165.110 55002
212.139.217.146 11802
178.40.130.200 28853
212.139.217.146 11910
116.71.30.241 10027
96.252.103.20 25371
75.65.212.238 51320
71.83.40.179 57064
143.90.181.3 62198
212.139.217.146 11921
223.204.29.104 11438
188.120.211.16 39092
212.139.217.146 11843
82.225.83.25 19693
178.123.123.138 19174
190.98.112.243 29779
60.240.253.89 45682
46.11.87.172 39287
81.206.55.20 51154
89.208.242.38 28222
109.227.209.138 14557
140.116.25.246 29850
61.24.86.59 17
68.121.60.202 24860
81.247.116.196 58638
194.44.174.33 11653
95.176.175.236 9256
109.165.50.223 25319
79.31.174.131 30212
212.139.217.146 11927
212.139.217.146 11939
187.38.54.27 10208
89.161.26.23 35383
178.176.9.238 41471
178.44.193.163 30516
117.192.139.164 24561
75.117.67.42 61050
212.139.217.146 11940
186.206.234.157 12136
212.139.217.146 11944
89.132.118.81 11762
75.117.67.42 61058
176.14.103.184 13973
212.139.217.146 11951
212.139.217.146 11836
58.215.242.74 1103
212.139.217.146 11890
212.139.217.146 11952
202.106.53.78 59461
178.212.78.195 49695
201.9.243.131 35311
67.204.7.51 16247
186.212.57.40 39646
212.139.217.146 11934
115.242.184.10 24818
212.139.217.146 11916
84.133.198.167 10495
90.230.133.68 55332
92.99.94.98 56574
212.139.217.146 11980
212.139.217.146 11943
96.228.172.112 50103
117.194.97.246 25110
124.122.224.48 12646
109.86.128.78 3517
41.237.228.52 11398
212.139.217.146 11971
212.139.217.146 11989
77.69.207.172 11699
188.186.22.224 21250
81.153.128.80 35986
94.196.219.239 25797
31.16.86.30 26003
213.226.169.17 53769
178.206.54.57 32119
212.139.217.146 11918
189.240.140.204 40919
212.139.217.146 11953
188.241.32.103 17499
168.20.228.179 28471
124.8.223.142 16880
85.95.200.144 55358
212.139.217.146 11966
212.139.217.146 11961
111.92.122.154 54370
95.144.135.206 52489
183.82.231.121 59703
212.139.217.146 11977
93.89.58.101 10333
151.49.65.45 52969
212.139.217.146 11661
117.196.217.86 12437
222.183.70.162 51541
94.251.30.95 52072
212.139.217.146 11837
83.28.72.14 30792
212.139.217.146 11797
79.102.55.113 34118
109.152.184.81 18670
213.151.5.17 39860
212.139.217.146 11993
212.139.217.146 11804
95.29.119.143 53849
151.75.95.168 61765
2.6.187.140 11874
75.73.93.28 59127
193.169.44.203 19795
178.76.220.14 26921
85.242.185.197 53876
83.239.216.12 33654
70.26.106.140 37651
121.212.12.50 35466
212.139.217.146 11990
90.231.204.152 47621
212.139.217.146 11973
212.139.217.146 12018
71.45.107.99 34140
77.47.167.188 16413
108.66.43.123 61779
212.139.217.146 11859
46.72.153.147 54896
190.253.207.163 10575
182.53.61.50 10038
212.139.217.146 11820
211.27.43.35 29717
96.43.239.132 59068
212.139.217.146 12033
212.139.217.146 12027
178.222.105.154 10000
180.191.53.46 23885
92.55.30.19 64833
212.139.217.146 11848
212.139.217.146 11866
109.199.236.32 17531
194.28.222.2 21245
46.241.27.55 32327
212.139.217.146 12030
212.139.217.146 12031
93.138.185.237 42636
188.208.36.109 54741
117.65.134.100 11818
174.60.89.157 45259
212.139.217.146 11874
212.139.217.146 11647
212.139.217.146 11825
74.216.21.206 17552
95.73.127.245 10005
212.139.217.146 11754
212.139.217.146 12024
212.139.217.146 11730
93.26.3.164 23713
14.45.166.191 26876
212.139.217.146 12002
212.139.217.146 12009
212.139.217.146 11850
121.54.32.131 13443
212.139.217.146 12035
178.175.80.169 16218
173.63.28.251 43747
212.139.217.146 11717
212.139.217.146 11650
212.139.217.146 12028
212.139.217.146 11926
212.139.217.146 12013
69.138.161.130 23976
212.139.217.146 11719
212.139.217.146 11683
114.24.6.239 22812
212.139.217.146 11721
212.139.217.146 11766
212.139.217.146 12023
90.206.110.191 36080
212.139.217.146 11862
46.238.202.1 64568
212.139.217.146 11648
201.79.12.167 50102
113.190.37.156 48704
94.112.75.163 46513
212.139.217.146 11736
212.139.217.146 11759
212.139.217.146 12021
203.99.173.51 57929
212.139.217.146 12020
98.99.202.70 58002
187.113.232.117 51790
109.182.68.166 62260
212.139.217.146 11758
88.135.161.101 1024
212.139.217.146 11746
212.139.217.146 12015
212.139.217.146 11641
113.165.18.254 10033
109.77.23.106 33037
205.206.74.3 55582
2.89.126.67 10098
94.231.48.5 62087
212.139.217.146 11800
212.139.217.146 11815
212.139.217.146 11640
212.139.217.146 11642
46.2.70.183 1101
86.100.247.99 14846
120.63.14.216 13490
178.150.56.145 63828
212.139.217.146 11871
212.139.217.146 11868
79.107.217.18 64451
212.139.217.146 12006
212.139.217.146 12012
212.35.18.211 28330
75.88.44.198 60971
212.139.217.146 12011
212.139.217.146 12032
221.209.62.74 43147
84.196.243.19 48922
93.44.99.79 64276
212.139.217.146 11658
124.148.198.132 14663
212.139.217.146 11744
95.26.215.96 35054
46.185.19.224 21714
93.87.180.81 20975
92.243.167.188 57734
212.139.217.146 11667
212.139.217.146 11665
92.86.240.28 13975
173.54.41.248 57329
178.123.216.78 57152
95.139.138.109 13882
188.19.254.203 50266
212.139.217.146 11655
212.139.217.146 11669
78.230.16.44 23957
75.151.72.182 56265
180.230.234.60 18674
187.40.59.86 61240
89.74.236.69 12237
195.189.107.132 30143
154.20.253.148 29820
212.139.217.146 11663
212.139.217.146 11651
178.95.214.19 46959
187.78.75.55 38578
97.96.15.133 37800
91.146.166.137 13093
89.106.233.207 9889
189.104.42.109 43197
188.230.192.187 52543
46.107.242.158 6881
89.106.110.176 63180
212.232.14.183 54616
46.73.70.221 24156
88.80.61.120 61873
66.168.253.127 51203
206.45.38.102 30150
76.121.200.90 46445
184.11.73.89 26747
188.19.11.175 44094
66.49.170.198 39799
212.139.213.150 14008
86.52.68.6 6880
79.110.118.210 62077
78.126.14.172 44034
98.24.219.225 16384
99.241.83.62 1723
174.112.230.21 41498
76.25.35.43 54187
108.9.136.14 29195
84.120.136.105 32850
173.192.155.239 15033
174.1.100.129 32814
118.175.28.79 56497
74.105.185.250 57439
58.153.142.222 34531
94.100.109.8 60103
88.170.61.126 7465
212.139.213.150 14054
78.31.155.30 13424
188.27.120.60 51380
86.124.219.249 33957
109.185.173.240 1041
193.200.95.79 38960
62.192.233.232 7895
95.87.226.29 45208
173.53.63.32 51876
66.61.66.63 19564
98.154.134.83 15560
115.64.229.150 22892
124.148.249.237 25706
203.212.211.20 61746
76.18.64.115 2326
212.139.213.150 14030
109.67.106.204 53269
81.180.19.127 47100
77.236.190.95 8339
125.26.235.87 10025
86.58.106.144 44726
86.58.106.144 44730
86.58.106.144 44675
92.147.4.113 13452
88.198.183.157 32257
82.232.0.124 9156
81.13.186.186 27652
24.1.118.110 27704
81.183.174.132 15988
46.12.53.197 61028
134.106.236.73 32092
118.2.32.188 7247
119.46.206.23 16880
212.139.213.150 14168
85.240.120.122 22213
79.191.15.44 12153
46.147.165.230 27441
212.139.213.150 14343
212.139.213.150 14098
212.139.213.150 14307
76.199.226.43 44373
196.207.251.217 57228
212.139.213.150 14091
46.24.194.42 30918
212.139.213.150 14102
193.107.110.133 53080
212.139.213.150 14116
88.203.42.205 28902
203.247.210.4 25407
212.139.213.150 14170
92.100.38.252 1025
212.139.213.150 14172
188.126.17.78 17598
212.139.213.150 14175
213.110.197.112 62937
212.139.213.150 14176
212.139.213.150 14177
213.240.225.105 18889
95.71.32.208 43381
95.54.13.104 53376
69.153.8.205 44000
78.1.130.191 36853
212.139.213.150 14178
24.222.89.165 40665
78.62.155.129 22210
212.139.213.150 14179
212.139.213.150 14181
99.149.72.110 13147
79.136.206.236 61941
212.139.213.150 14183
119.231.250.87 26614
220.253.237.237 33760
109.127.185.46 10003
72.209.17.211 23892
78.60.131.27 44353
86.58.106.144 44821
86.58.106.144 44656
95.178.163.118 10040
86.58.106.144 44887
86.58.106.144 45040
86.58.106.144 45053
67.162.186.239 28803
71.197.114.158 39551
222.161.71.29 58402
92.127.147.15 54505
180.26.130.61 58275
178.203.129.209 47916
212.139.213.150 14186
68.58.61.213 19226
59.93.163.82 20608
212.139.213.150 14184
60.230.224.116 34375
178.34.212.38 62631
212.139.213.150 14147
212.93.100.154 8958
98.95.139.75 50189
212.139.213.150 14155
95.53.47.62 17324
96.226.36.197 47981
212.139.213.150 14173
212.139.213.150 14187
92.124.13.163 37942
115.133.246.245 12471
124.148.226.36 1024
195.68.196.178 27752
178.233.42.2 52326
212.139.213.150 14191
178.65.193.3 6881
68.198.34.93 7300
212.139.213.150 14189
212.139.213.150 14148
78.106.199.57 21226
212.139.213.150 14188
109.191.218.155 56898
212.139.213.150 14192
121.184.203.110 14373
212.139.213.150 14194
188.19.28.246 35691
85.97.253.234 61205
67.174.242.60 60402
195.135.243.253 29687
88.119.156.119 25578
88.247.150.82 51293
151.25.110.128 61120
212.5.136.203 4896
110.32.77.202 55129
212.139.213.150 14195
212.139.213.150 14204
212.139.213.150 14207
212.139.213.150 14081
81.229.152.229 53358
212.139.213.150 14220
178.73.200.28 45416
89.204.181.36 49398
78.60.208.218 50393
94.236.156.185 62054
178.206.115.35 56645
178.93.226.62 1047
212.139.213.150 14064
212.139.213.150 14217
212.139.213.150 14224
178.217.161.252 56744
94.21.156.254 63365
212.139.213.150 14209
94.21.156.254 64756
68.60.83.40 20047
125.26.7.60 19258
90.28.192.174 64433
86.94.222.93 60010
95.168.51.151 60745
46.42.26.194 34245
186.212.96.8 64673
212.139.213.150 14225
94.21.156.254 48191
189.31.48.238 29662
212.139.213.150 14212
188.222.3.162 51817
212.139.213.150 14219
119.231.171.236 15479
95.90.231.148 35420
212.139.213.150 14213
212.139.213.150 14221
217.25.96.84 12156
109.54.50.47 19771
79.106.109.8 53252
212.139.213.150 14230
84.120.136.105 32850
115.43.156.110 34775
77.215.187.40 51413
24.64.255.14 42832
109.70.52.238 44500
220.208.137.27 14073
84.122.175.250 17226
212.139.217.146 11639
79.168.197.23 26861
87.239.161.29 37863
79.114.192.207 28146
77.239.71.136 11997
81.236.195.180 18203
78.247.178.58 31218
82.117.224.17 40005
72.23.223.10 35313
212.139.217.146 11662
95.32.130.5 41696
95.79.67.118 16945
88.198.183.157 32257
134.106.236.63 7584
77.236.180.53 22337
114.17.132.233 19663
88.178.72.2 7812
212.139.213.150 14157
2.36.207.224 23351
2.5.39.160 59279
94.143.40.43 42460
80.103.114.22 58936
92.152.32.108 49954
67.213.245.183 24529
77.81.15.235 49907
173.177.162.164 43977
212.200.140.210 18552
91.217.91.11 39192
212.139.213.150 14201
109.111.8.2 23889
212.139.213.150 14164
78.178.59.11 18804
94.243.117.194 35691
79.199.21.188 13532
80.229.150.160 15068
62.33.80.14 60114
87.242.30.46 44863
46.42.61.215 52760
91.200.156.202 42058
95.106.13.231 53770
46.72.26.78 45757
78.138.241.104 25758
212.139.213.150 14232
83.22.139.33 35845
212.139.213.150 14239
83.81.210.203 36686
222.254.60.54 29855
194.0.206.2 3879
71.213.139.7 30352
78.139.116.51 48392
82.224.136.52 7812
212.139.213.150 14248
204.8.8.7 37709
124.122.234.209 22676
212.139.213.150 14247
212.139.213.150 14159
201.75.66.171 62533
212.139.213.150 14233
220.243.14.191 11935
188.163.84.131 59039
110.66.16.169 58522
58.16.22.215 11935
212.139.213.150 14130
78.153.26.159 59422
95.26.114.196 59506
46.104.235.97 29088
212.139.213.150 14256
212.139.213.150 14236
188.25.174.37 46259
79.115.163.187 44688
75.151.225.185 2736
91.221.218.208 32825
85.113.152.153 55555
212.139.213.150 14243
78.127.90.146 9394
178.177.35.38 64559
80.61.140.215 60103
92.25.255.254 25274
188.54.119.110 21783
94.176.146.130 19542
123.195.112.218 19900
109.195.7.196 35691
212.92.245.254 26036
212.139.213.150 14259
93.80.230.191 28305
88.196.161.66 8718
81.86.154.253 10817
75.147.215.162 47340
223.205.96.55 10100
212.139.213.150 14162
212.139.213.150 14253
24.10.149.251 35727
123.150.95.97 11935
212.139.213.150 14113
84.51.218.196 35691
89.84.8.228 10995
121.216.65.122 24800
208.38.121.36 33149
195.240.219.110 15912
212.139.213.150 14267
14.198.69.137 6882
212.139.213.150 14268
212.139.213.150 14161
62.228.40.213 58083
212.139.213.150 14059
212.139.213.150 14240
88.168.14.141 46232
178.134.10.69 14560
93.103.120.220 11277
67.183.213.107 34680
212.139.213.150 14287
178.210.25.69 48175
212.139.213.150 14292
212.139.213.150 14284
212.139.213.150 14260
212.139.213.150 14288
212.139.213.150 14270
212.139.213.150 14205
212.139.213.150 14277
46.10.52.218 33673
212.139.213.150 14190
212.139.213.150 14208
212.139.213.150 14223
212.139.213.150 14231
212.139.213.150 14082
212.139.213.150 14280
212.139.213.150 14295
117.198.213.128 51456
212.139.213.150 14086
212.139.213.150 14085
212.139.213.150 14227
212.139.213.150 14226
212.139.213.150 14197
212.139.213.150 14202
212.139.213.150 14276
82.44.220.175 17627
31.163.140.17 13686
91.217.91.11 39192
79.142.169.27 11404
134.106.236.73 32092
81.13.186.186 27652
99.22.212.223 51413
85.198.170.202 19072
82.232.0.124 9156
82.244.203.153 21428
88.187.80.252 49180
95.90.231.148 35420
72.207.215.101 36844
67.188.133.52 41610
67.190.19.67 61407
188.123.252.97 23741
212.80.57.57 32646
89.252.42.111 62101
85.220.111.51 45435
99.241.83.62 1723
89.174.79.62 25812
78.29.117.80 49431
41.35.118.144 10942
119.46.206.23 16880
119.152.72.72 36324
78.21.229.179 60005
90.220.122.198 13134
74.89.237.152 60454
212.139.217.146 11686
2.123.218.171 23949
201.9.223.200 30617
87.120.82.153 9088
195.114.136.71 51981
212.139.217.146 11698
111.250.38.229 18254
151.49.85.221 38449
93.126.72.23 39391
94.62.225.94 11454
95.179.113.191 28329
95.80.59.11 65098
188.62.25.223 56591
213.199.197.114 25115
78.84.243.30 33282
212.139.217.146 11660
49.203.19.202 38852
212.139.217.146 11676
189.124.210.225 4675
50.53.55.126 55170
173.66.140.59 41033
178.82.230.13 15374
212.139.217.146 11708
212.139.217.146 11681
212.139.217.146 11689
186.107.117.101 32771
212.139.217.146 11705
89.242.136.42 58883
212.139.217.146 11792
79.172.15.226 55121
188.2.40.106 35697
212.139.217.146 11682
222.223.191.149 1430
90.148.156.135 25885
24.177.161.62 35727
212.139.217.146 11693
24.15.140.50 39343
212.139.217.146 12034
178.222.191.26 10424
212.139.217.146 11659
92.244.240.183 45401
212.139.217.146 11706
88.182.24.189 17082
89.73.55.97 50357
121.54.32.149 12068
46.42.46.94 29505
212.139.217.146 11788
121.108.23.84 27819
74.111.124.181 13600
24.109.74.245 18373
88.103.43.81 27717
86.88.254.80 7146
109.86.206.38 54758
62.30.80.254 9090
184.57.56.28 18081
212.139.217.146 11805
99.194.42.156 22326
94.10.47.41 12834
81.15.207.71 44962
24.7.235.189 37054
69.125.230.16 51692
220.141.38.175 8921
223.132.67.43 15754
178.140.26.238 28931
78.36.208.59 62971
89.123.159.130 27517
2.219.35.144 31126
118.90.128.175 6812
212.54.29.154 48436
2.94.16.180 13053
212.139.217.146 11687
95.26.163.75 29744
178.45.9.29 1239
77.49.21.181 59165
94.213.103.5 37531
108.67.134.107 47364
98.253.91.238 46177
2.25.38.121 37947
212.139.217.146 11645
76.172.170.183 13553
95.132.7.71 56227
77.206.43.32 54191
124.102.13.102 45682
87.96.227.162 36782
60.238.250.73 21566
212.139.217.146 11842
41.237.186.57 33336
173.217.246.214 13494
122.162.152.124 60853
212.139.217.146 11844
109.150.82.218 19591
99.184.100.63 40205
81.191.108.58 32123
212.139.217.146 11769
184.56.117.74 31764
212.139.217.146 11699
41.178.83.92 42994
87.90.94.159 62640
186.4.6.162 44659
212.139.217.146 11806
212.139.217.146 11727
67.166.179.95 51679
82.114.79.194 60356
212.139.217.146 11768
188.16.13.177 34023
111.108.62.171 42735
212.139.217.146 11703
76.221.166.57 35192
91.214.31.241 6881
99.109.66.184 38309
92.249.121.191 23576
212.139.217.146 11852
81.231.75.170 45268
212.139.217.146 11870
178.72.97.192 37310
212.139.217.146 11936
178.218.42.155 1073
83.149.38.136 17408
95.37.63.97 46000
212.139.217.146 11668
117.206.68.126 16894
77.108.110.160 61890
77.38.24.51 9897
212.139.217.146 11947
212.139.217.146 11684
212.139.217.146 11928
188.26.171.65 37450
212.139.217.146 11764
46.175.64.4 65292
95.132.212.174 27012
212.139.217.146 11646
212.139.217.146 11913
212.139.217.146 11798
81.5.78.192 40262
95.76.135.137 36391
212.139.217.146 11720
80.108.110.218 19624
212.139.217.146 11903
212.139.217.146 11723
212.139.217.146 11894
212.139.217.146 11851
95.30.140.2 46257
212.139.217.146 11803
212.139.217.146 11920
212.139.217.146 11878
212.161.131.86 28547
212.139.217.146 11695
212.139.217.146 11791
212.139.217.146 11807
212.139.217.146 11801
212.139.217.146 11812
212.139.217.146 11762
212.139.217.146 11776
212.139.217.146 11809
212.139.217.146 11811
212.139.217.146 11799
212.139.217.146 11900

View File

@ -22,8 +22,10 @@ int main(int argc, char *argv[])
bool doFixedPort = false;
int portNumber = 0;
bool doLocalTesting = false;
int c;
while((c = getopt(argc, argv,"r:p:c:n")) != -1)
while((c = getopt(argc, argv,"r:p:c:nl")) != -1)
{
switch (c)
{
@ -46,6 +48,10 @@ int main(int argc, char *argv[])
std::cerr << "Disabling GUI" << std::endl;
showGUI = false;
break;
case 'l':
std::cerr << "Enabling Local Testing" << std::endl;
doLocalTesting = true;
break;
}
}
@ -75,6 +81,12 @@ int main(int argc, char *argv[])
}
}
if (doLocalTesting)
{
pnet->setLocalTesting();
}
pnet->init();
if (showGUI)

View File

@ -68,6 +68,13 @@ void MainWindow::updateNetStatus()
ui->peerLine->setText(status);
}
status = QString::fromStdString(mPeerNet->getPeerAddressString());
oldstatus = ui->peerAddressLabel->text();
if (oldstatus != status)
{
ui->peerAddressLabel->setText(status);
}
uint32_t netMode = mPeerNet->getNetStateNetworkMode();
QLabel *label = ui->networkLabel;
@ -349,6 +356,10 @@ void MainWindow::updateNetPeers()
/* remove it! */
itemCount--;
}
else
{
nIndex++;
}
}
else
{

View File

@ -39,7 +39,7 @@
<item>
<widget class="QLabel" name="netStatusLabel">
<property name="text">
<string>TextLabel</string>
<string>Net Status</string>
</property>
</widget>
</item>
@ -63,21 +63,21 @@
<item>
<widget class="QLabel" name="networkLabel">
<property name="text">
<string>TextLabel</string>
<string>Network Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="natTypeLabel">
<property name="text">
<string>proxyExtLabel</string>
<string>Nat Type</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="natHoleLabel">
<property name="text">
<string>dhtExtLabel</string>
<string>Nat Hole</string>
</property>
</widget>
</item>
@ -86,7 +86,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="connectStateLabel_2">
<widget class="QLabel" name="peerAddressLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -94,28 +94,14 @@
</sizepolicy>
</property>
<property name="text">
<string>TL1</string>
<string>Peer Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="extraLabel_2">
<widget class="QLabel" name="extraLabel">
<property name="text">
<string>TL2</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="proxyExtLabel">
<property name="text">
<string>proxyExtLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dhtExtLabel">
<property name="text">
<string>dhtExtLabel</string>
<string>Extra Label</string>
</property>
</widget>
</item>

View File

@ -89,6 +89,20 @@ void PeerNetStateBox::setAddressWebIP(bool active, struct sockaddr_in *addr)
}
void PeerNetStateBox::setDhtState(bool on, bool active)
{
if ((!mDhtSet) || (mDhtActive != active) || (mDhtOn != on))
{
mDhtSet = true;
mDhtActive = active;
mDhtOn = on;
mStatusOkay = false;
}
mDhtTS = time(NULL);
}
/* Extract Net State */
uint32_t PeerNetStateBox::getNetworkMode()
{
@ -162,7 +176,10 @@ PeerNetStateBox::PeerNetStateBox()
mPortForwardedSet = false;
mPortForwarded = 0;
mDhtSet = false;
mDhtActive = false;
mDhtOn = false;
}
#define NETSTATE_PARAM_TIMEOUT 600

View File

@ -77,6 +77,8 @@ class PeerNetStateBox
void setAddressNatPMP(bool active, struct sockaddr_in *addr);
void setAddressWebIP(bool active, struct sockaddr_in *addr);
void setDhtState(bool dhtOn, bool dhtActive);
uint32_t getNetStateMode();
uint32_t getNetworkMode();
uint32_t getNatTypeMode();
@ -115,8 +117,13 @@ class PeerNetStateBox
bool mStunProxyStable;
struct sockaddr_in mStunProxyAddr;
bool mDhtSet;
time_t mDhtTS;
bool mDhtOn;
bool mDhtActive;
bool mUPnPSet;
struct sockaddr_in mUPnPAddr;
struct sockaddr_in mUPnPAddr;
bool mUPnPActive;
time_t mUPnPTS;
@ -132,8 +139,6 @@ class PeerNetStateBox
bool mPortForwardedSet;
uint16_t mPortForwarded;
bool mDhtActive;
};
#endif

View File

@ -15,6 +15,7 @@
PeerNet::PeerNet(std::string id, std::string configpath, uint16_t port)
{
mDoUdpStackRestrictions = false;
mLocalNetTesting = false;
std::cerr << "PeerNet::PeerNet()" << std::endl;
@ -71,6 +72,10 @@ void PeerNet::setUdpStackRestrictions(std::list<std::pair<uint16_t, uint16_t> >
mUdpStackRestrictions = restrictions;
}
void PeerNet::setLocalTesting()
{
mLocalNetTesting = true;
}
void PeerNet::init()
{
@ -110,8 +115,14 @@ void PeerNet::init()
/* construct the rest of the stack, important to build them in the correct order! */
/* MOST OF THIS IS COMMENTED OUT UNTIL THE REST OF libretroshare IS READY FOR IT! */
UdpSubReceiver *udpReceivers[3];
int udpTypes[3];
#define PN_TOU_RECVER_DIRECT_IDX 0
#define PN_TOU_RECVER_PROXY_IDX 1
#define PN_TOU_RECVER_RELAY_IDX 2
#define PN_TOU_NUM_RECVERS 3
UdpSubReceiver *udpReceivers[PN_TOU_NUM_RECVERS];
int udpTypes[PN_TOU_NUM_RECVERS];
std::cerr << "PeerNet() startup ... creating UdpStunner on UdpStack";
@ -120,6 +131,8 @@ void PeerNet::init()
// STUNNER.
mDhtStunner = new UdpStunner(mUdpStack);
mUdpStack->addReceiver(mDhtStunner);
//mDhtStunner->setTargetStunPeriod(0); /* passive */
mDhtStunner->setTargetStunPeriod(300); /* very slow (300 = 5minutes) */
std::cerr << "PeerNet() startup ... creating BitDHT on UdpStack";
std::cerr << std::endl;
@ -136,18 +149,18 @@ void PeerNet::init()
std::cerr << std::endl;
// NEXT THE RELAY (NEED to keep a reference for installing RELAYS)
UdpRelayReceiver *mRelayRecver = new UdpRelayReceiver(mUdpStack);
udpReceivers[2] = mRelayRecver; /* RELAY Connections (DHT Port) */
udpTypes[2] = TOU_RECEIVER_TYPE_UDPRELAY;
mUdpStack->addReceiver(udpReceivers[2]);
mRelayReceiver = new UdpRelayReceiver(mUdpStack);
udpReceivers[PN_TOU_RECVER_RELAY_IDX] = mRelayReceiver; /* RELAY Connections (DHT Port) */
udpTypes[PN_TOU_RECVER_RELAY_IDX] = TOU_RECEIVER_TYPE_UDPRELAY;
mUdpStack->addReceiver(udpReceivers[PN_TOU_RECVER_RELAY_IDX]);
std::cerr << "PeerNet() startup ... creating UdpPeerReceiver on UdpStack";
std::cerr << std::endl;
// LAST ON THIS STACK IS STANDARD DIRECT TOU
udpReceivers[0] = new UdpPeerReceiver(mUdpStack); /* standard DIRECT Connections (DHT Port) */
udpTypes[0] = TOU_RECEIVER_TYPE_UDPPEER;
mUdpStack->addReceiver(udpReceivers[0]);
udpReceivers[PN_TOU_RECVER_DIRECT_IDX] = new UdpPeerReceiver(mUdpStack); /* standard DIRECT Connections (DHT Port) */
udpTypes[PN_TOU_RECVER_DIRECT_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
mUdpStack->addReceiver(udpReceivers[PN_TOU_RECVER_DIRECT_IDX]);
std::cerr << "PeerNet() startup ... creating UdpProxyStack";
std::cerr << std::endl;
@ -156,7 +169,7 @@ void PeerNet::init()
// Create the Second UdpStack... Port should be random (but openable!).
struct sockaddr_in sndladdr;
sockaddr_clear(&sndladdr);
sndladdr.sin_port = htons(mPort + 1111);
sndladdr.sin_port = htons(mPort + 11);
rsUdpStack *mUdpProxyStack = new rsUdpStack(sndladdr);
std::cerr << "PeerNet() startup ... creating UdpStunner on UdpProxyStack";
@ -165,19 +178,18 @@ void PeerNet::init()
// FIRSTLY THE PROXY STUNNER.
mProxyStunner = new UdpStunner(mUdpProxyStack);
mUdpProxyStack->addReceiver(mProxyStunner);
//mProxyStunner->setTargetStunPeriod(0); /* passive */
std::cerr << "PeerNet() startup ... creating UdpPeerReceiver(Proxy) on UdpProxyStack";
std::cerr << std::endl;
// FINALLY THE PROXY UDP CONNECTIONS
udpReceivers[1] = new UdpPeerReceiver(mUdpProxyStack); /* PROXY Connections (Alt UDP Port) */
udpTypes[1] = TOU_RECEIVER_TYPE_UDPPEER;
mUdpProxyStack->addReceiver(udpReceivers[1]);
udpReceivers[PN_TOU_RECVER_PROXY_IDX] = new UdpPeerReceiver(mUdpProxyStack); /* PROXY Connections (Alt UDP Port) */
udpTypes[PN_TOU_RECVER_PROXY_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
mUdpProxyStack->addReceiver(udpReceivers[PN_TOU_RECVER_PROXY_IDX]);
// NOW WE CAN PASS THE RECEIVERS TO TOU.
// REAL INITIALISATION - WITH THREE MODES - FOR LATER.
tou_init((void **) udpReceivers, udpTypes, 3);
tou_init((void **) udpReceivers, udpTypes, PN_TOU_NUM_RECVERS);
/* startup the Udp stuff! */
@ -189,14 +201,12 @@ void PeerNet::init()
storeConfig(mConfigFile);
/* enable local net stuns (for testing) */
if (mLocalNetTesting)
{
mProxyStunner->SetAcceptLocalNet();
mDhtStunner->SetAcceptLocalNet();
}
}
@ -366,27 +376,52 @@ std::string PeerNet::getPeerStatusString()
out << "OwnId: ";
bdStdPrintNodeId(out, &mOwnId);
return out.str();
}
std::string PeerNet::getPeerAddressString()
{
std::ostringstream out;
out << " LocalPort: " << mPort;
struct sockaddr_in extAddr;
uint8_t extStable;
if (mDhtStunner->externalAddr(extAddr, extStable))
{
out << " ExtAddress: " << inet_ntoa(extAddr.sin_addr);
out << " DhtExtAddr: " << inet_ntoa(extAddr.sin_addr);
out << ":" << ntohs(extAddr.sin_port);
if (extStable)
{
out << " is Stable";
out << " (Stable) ";
}
else
{
out << " is Unstable (symmetric NAT)";
out << " (Unstable) ";
}
}
else
{
out << " ExtAddress Unknown";
out << " DhtExtAddr: Unknown ";
}
if (mProxyStunner->externalAddr(extAddr, extStable))
{
out << " ProxyExtAddr: " << inet_ntoa(extAddr.sin_addr);
out << ":" << ntohs(extAddr.sin_port);
if (extStable)
{
out << " (Stable) ";
}
else
{
out << " (Unstable) ";
}
}
else
{
out << " ProxyExtAddr: Unknown ";
}
return out.str();
@ -460,7 +495,7 @@ int PeerNet::get_failedpeer_status(std::string id, PeerStatus &status)
{
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
std::map<std::string, PeerStatus>::iterator it = mPeers.find(id);
std::map<std::string, PeerStatus>::iterator it = mFailedPeers.find(id);
if (it != mFailedPeers.end())
{
status = it->second;
@ -599,7 +634,8 @@ int PeerNet::dhtNodeCallback(const bdId *id, uint32_t peerflags)
#endif
}
if (peerflags & BITDHT_PEER_STATUS_DHT_APPL)
if ((peerflags & BITDHT_PEER_STATUS_DHT_APPL)
&& (peerflags & BITDHT_PEER_STATUS_DHT_APPL_VERSION))
{
#ifdef PEERNET_DEBUG
std::cerr << "PeerNet::dhtNodeCallback() Passing Local Peer to DhtStunner: ";
@ -607,7 +643,17 @@ int PeerNet::dhtNodeCallback(const bdId *id, uint32_t peerflags)
std::cerr << std::endl;
#endif
if (mDhtStunner)
/* pass off to the Stunners
* but only if they need them.
* ideally don't pass to both peers... (XXX do later)
*/
if ((mProxyStunner) && (mProxyStunner->needStunPeers()))
{
mProxyStunner->addStunPeer(id->addr, strId.c_str());
}
/* else */ // removed else until we have lots of peers.
if ((mDhtStunner) && (mDhtStunner->needStunPeers()))
{
mDhtStunner->addStunPeer(id->addr, strId.c_str());
}
@ -657,30 +703,7 @@ int PeerNet::dhtPeerCallback(const bdId *id, uint32_t status)
it->second.mDhtState = PN_DHT_STATE_UNREACHABLE;
it->second.mDhtAddr = id->addr;
if ((it->second.mPeerState == PN_PEER_STATE_CONNECTION_INITIATED) ||
(it->second.mPeerState == PN_PEER_STATE_CONNECTION_AUTHORISED) ||
(it->second.mPeerState == PN_PEER_STATE_UDP_STARTED) ||
(it->second.mPeerState == PN_PEER_STATE_CONNECTED))
{
std::cerr << "dhtPeerCallback. Peer Unreachable, but connection already underway: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
}
else
{
std::cerr << "dhtPeerCallback. Peer Unreachable, triggering Proxy Connection for: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
/* Push Back PeerAction */
PeerAction ca;
ca.mType = PEERNET_ACTION_TYPE_CONNECT;
ca.mMode = BITDHT_CONNECT_MODE_PROXY;
ca.mDestId = *id;
mActions.push_back(ca);
}
UnreachablePeerCallback_locked(id, status, &(it->second));
}
break;
case BITDHT_MGR_QUERY_PEER_ONLINE:
@ -689,31 +712,7 @@ int PeerNet::dhtPeerCallback(const bdId *id, uint32_t status)
it->second.mDhtState = PN_DHT_STATE_ONLINE;
it->second.mDhtAddr = id->addr;
if ((it->second.mPeerState == PN_PEER_STATE_CONNECTION_INITIATED) ||
(it->second.mPeerState == PN_PEER_STATE_CONNECTION_AUTHORISED) ||
(it->second.mPeerState == PN_PEER_STATE_UDP_STARTED) ||
(it->second.mPeerState == PN_PEER_STATE_CONNECTED))
{
std::cerr << "dhtPeerCallback. Peer Online, but connection already underway: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
}
else
{
std::cerr << "dhtPeerCallback. Peer Online, triggering Direct Connection for: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
/* Push Back PeerAction */
PeerAction ca;
ca.mType = PEERNET_ACTION_TYPE_CONNECT;
ca.mMode = BITDHT_CONNECT_MODE_DIRECT;
ca.mDestId = *id;
mActions.push_back(ca);
}
OnlinePeerCallback_locked(id, status, &(it->second));
}
break;
}
@ -733,6 +732,125 @@ int PeerNet::dhtPeerCallback(const bdId *id, uint32_t status)
}
int PeerNet::OnlinePeerCallback_locked(const bdId *id, uint32_t status, PeerStatus *peerStatus)
{
if ((peerStatus->mPeerState == PN_PEER_STATE_CONNECTION_INITIATED) ||
(peerStatus->mPeerState == PN_PEER_STATE_CONNECTION_AUTHORISED) ||
(peerStatus->mPeerState == PN_PEER_STATE_UDP_STARTED) ||
(peerStatus->mPeerState == PN_PEER_STATE_CONNECTED))
{
std::cerr << "dhtPeerCallback. Peer Online, but connection already underway: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
}
else
{
std::cerr << "dhtPeerCallback. Peer Online, triggering Direct Connection for: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
/* Push Back PeerAction */
PeerAction ca;
ca.mType = PEERNET_ACTION_TYPE_CONNECT;
ca.mMode = BITDHT_CONNECT_MODE_DIRECT;
ca.mDestId = *id;
mActions.push_back(ca);
}
return 1;
}
/* Fn Was getting too big, so moved this specific callback here */
int PeerNet::UnreachablePeerCallback_locked(const bdId *id, uint32_t status, PeerStatus *peerStatus)
{
if ((peerStatus->mPeerState == PN_PEER_STATE_CONNECTION_INITIATED) ||
(peerStatus->mPeerState == PN_PEER_STATE_CONNECTION_AUTHORISED) ||
(peerStatus->mPeerState == PN_PEER_STATE_UDP_STARTED) ||
(peerStatus->mPeerState == PN_PEER_STATE_CONNECTED))
{
std::cerr << "dhtPeerCallback. Peer Unreachable, but connection already underway: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
return 1;
}
std::cerr << "dhtPeerCallback. Peer Unreachable, triggering Proxy | Relay Connection for: ";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
/*** At This point we need to be clever about re-connect attempts ....
* How do we store the historical attempts?
*/
bool proxyOk = false;
bool connectOk = true;
{
// must check for extAddress before starting connection.
struct sockaddr_in extaddr;
uint8_t extStable = 0;
sockaddr_clear(&extaddr);
if (mProxyStunner->externalAddr(extaddr, extStable))
{
if (extStable)
{
proxyOk = true;
}
}
}
/* determine if we should try and connect! */
if (proxyOk)
{
proxyOk = false;
//connectOk = false;
std::cerr << "dhtPeerCallback. Forcing all to RELAY for the moment.";
std::cerr << std::endl;
}
if (connectOk)
{
/* Push Back PeerAction */
PeerAction ca;
ca.mType = PEERNET_ACTION_TYPE_CONNECT;
ca.mDestId = *id;
if (proxyOk)
{
ca.mMode = BITDHT_CONNECT_MODE_PROXY;
std::cerr << "dhtPeerCallback. Trying Proxy Connection.";
std::cerr << std::endl;
}
else
{
std::cerr << "dhtPeerCallback. Trying Relay Connection.";
std::cerr << std::endl;
ca.mMode = BITDHT_CONNECT_MODE_RELAY;
}
mActions.push_back(ca);
}
else
{
std::cerr << "dhtPeerCallback. Cancelled Connection Attempt for";
bdStdPrintId(std::cerr, id);
std::cerr << std::endl;
}
return 1;
}
int PeerNet::dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status)
{
std::cerr << "PeerNet::dhtValueCallback()";
@ -837,7 +955,8 @@ int PeerNet::dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bd
if (mode == BITDHT_CONNECT_MODE_RELAY)
{
installRelayConnection(srcId, destId, mode);
//Installed at Request Now.
//installRelayConnection(srcId, destId, mode);
}
}
break;
@ -862,7 +981,7 @@ int PeerNet::dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bd
if (mode == BITDHT_CONNECT_MODE_RELAY)
{
removeRelayConnection(srcId, destId, mode);
removeRelayConnection(srcId, destId);
}
}
break;
@ -911,13 +1030,59 @@ int PeerNet::dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bd
/* Push Back PeerAction */
PeerAction ca;
ca.mType = PEERNET_ACTION_TYPE_AUTHORISE;
ca.mMode = mode;
ca.mProxyId = *proxyId;
ca.mSrcId = *srcId;
ca.mDestId = *destId;
/* Check Proxy ExtAddress Status */
if (mode == BITDHT_CONNECT_MODE_PROXY)
{
std::cerr << "dhtConnectionCallback() Checking Address for Proxy";
std::cerr << std::endl;
struct sockaddr_in extaddr;
uint8_t extStable = 0;
sockaddr_clear(&extaddr);
if (mProxyStunner->externalAddr(extaddr, extStable))
{
if (extStable)
{
std::cerr << "dhtConnectionCallback() Proxy Connection ";
std::cerr << " is OkGo as we have Stable Own External Proxy Address";
std::cerr << std::endl;
if (point == BD_PROXY_CONNECTION_END_POINT)
{
ca.mDestId.addr = extaddr;
}
else
{
ca.mSrcId.addr = extaddr;
}
}
else
{
connectionAllowed = 0;
std::cerr << "dhtConnectionCallback() Proxy Connection";
std::cerr << " is Discarded, as Own External Proxy Address is Not Stable!";
std::cerr << std::endl;
}
}
else
{
connectionAllowed = 0;
std::cerr << "PeerAction: ERROR Proxy Connection ";
std::cerr << " is Discarded, as Failed to get Own External Proxy Address.";
std::cerr << std::endl;
}
}
ca.mMode = mode;
ca.mPoint = point;
ca.mAnswer = connectionAllowed;
mActions.push_back(ca);
}
break;
@ -978,12 +1143,54 @@ int PeerNet::tick()
if (mDhtStunner)
mDhtStunner->tick();
if (mProxyStunner)
mProxyStunner->tick();
doActions();
monitorConnections();
minuteTick();
return 1;
}
#define MINUTE_IN_SECS 60
int PeerNet::minuteTick()
{
/* should be Mutex protected? Only one thread should get here for now */
time_t now = time(NULL);
if (now - mMinuteTS > MINUTE_IN_SECS)
{
mMinuteTS = now;
netStateTick();
mRelayReceiver->checkRelays();
}
}
#define DHT_PEERS_ACTIVE 2
int PeerNet::netStateTick()
{
bool dhtOn = true;
bool dhtActive = (mUdpBitDht->statsNetworkSize() > DHT_PEERS_ACTIVE);
mNetStateBox.setDhtState(dhtOn, dhtActive);
struct sockaddr_in extAddr;
uint8_t extStable;
if (mDhtStunner->externalAddr(extAddr, extStable))
{
mNetStateBox.setAddressStunDht(&extAddr, extStable != 0);
}
if (mProxyStunner->externalAddr(extAddr, extStable))
{
mNetStateBox.setAddressStunProxy(&extAddr, extStable != 0);
}
}
int PeerNet::doActions()
{
#ifdef PEERNET_DEBUG
@ -1017,17 +1224,45 @@ int PeerNet::doActions()
std::cerr << " mode: " << action.mMode;
std::cerr << std::endl;
if (action.mMode == BITDHT_CONNECT_MODE_DIRECT)
if ((action.mMode == BITDHT_CONNECT_MODE_DIRECT) ||
(action.mMode == BITDHT_CONNECT_MODE_RELAY))
{
struct sockaddr_in laddr; // THIS CANNOT BE FILLED UNTIL STUN IS FUNCTIONAL XXX.
struct sockaddr_in laddr; // We zero this address. The DHT layer should be able to handle this!
sockaddr_clear(&laddr);
mUdpBitDht->ConnectionRequest(&laddr, &(action.mDestId.id), action.mMode);
}
else if (action.mMode == BITDHT_CONNECT_MODE_PROXY)
{
struct sockaddr_in laddr; // THIS CANNOT BE FILLED UNTIL STUN IS FUNCTIONAL XXX.
sockaddr_clear(&laddr);
mUdpBitDht->ConnectionRequest(&laddr, &(action.mDestId.id), action.mMode);
struct sockaddr_in extaddr;
uint8_t extStable = 0;
sockaddr_clear(&extaddr);
if (mProxyStunner->externalAddr(extaddr, extStable))
{
if (extStable)
{
std::cerr << "PeerAction: Proxy Connection Attempt to: ";
bdStdPrintId(std::cerr, &(action.mDestId));
std::cerr << " is OkGo as we have Stable Own External Proxy Address";
std::cerr << std::endl;
mUdpBitDht->ConnectionRequest(&extaddr, &(action.mDestId.id), action.mMode);
}
else
{
std::cerr << "PeerAction: ERROR Proxy Connection Attempt to: ";
bdStdPrintId(std::cerr, &(action.mDestId));
std::cerr << " is Discarded, as Own External Proxy Address is Not Stable!";
std::cerr << std::endl;
}
}
else
{
std::cerr << "PeerAction: ERROR Proxy Connection Attempt to: ";
bdStdPrintId(std::cerr, &(action.mDestId));
std::cerr << " is Discarded, as Failed to get Own External Proxy Address.";
std::cerr << std::endl;
}
}
}
break;
@ -1051,7 +1286,7 @@ int PeerNet::doActions()
{
/* connect attempt */
std::cerr << "PeerAction. Start Connection between: ";
bdStdPrintId(std::cerr, &(action.mDestId));
bdStdPrintId(std::cerr, &(action.mSrcId));
std::cerr << " and ";
bdStdPrintId(std::cerr, &(action.mDestId));
std::cerr << " mode: " << action.mMode;
@ -1088,7 +1323,11 @@ int PeerNet::checkProxyAllowed(const bdId *srcId, const bdId *destId, int mode)
std::cerr << "PeerNet::checkProxyAllowed()";
std::cerr << std::endl;
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
// Dont think that a mutex is required here! But might be so just lock to ensure that it is possible.
{
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
}
if (mode == BITDHT_CONNECT_MODE_PROXY)
{
@ -1099,10 +1338,31 @@ int PeerNet::checkProxyAllowed(const bdId *srcId, const bdId *destId, int mode)
//return CONNECTION_OKAY;
}
std::cerr << "PeerNet::checkProxyAllowed() to finish RELAY connections, DENIED";
std::cerr << std::endl;
if (mode != BITDHT_CONNECT_MODE_RELAY)
{
std::cerr << "PeerNet::checkProxyAllowed() unknown Connect Mode DENIED";
std::cerr << std::endl;
return 0;
}
/* will install the Relay Here... so that we reserve the Relay Space for later. */
if (installRelayConnection(srcId, destId))
{
std::cerr << "PeerNet::checkProxyAllowed() Successfully added Relay, Connection OKAY";
std::cerr << std::endl;
return 1;
// CONNECT_OKAY.
}
else
{
std::cerr << "PeerNet::checkProxyAllowed() Failed to install Relay, Connection DENIED";
std::cerr << std::endl;
return 0;
//return CONNECT_MODE_OVERLOADED;
}
/* as we haven't finished relay code yet... just deny */
return 0;
//return CONNECT_MODE_NOTAVAILABLE;
//return CONNECT_MODE_OVERLOADED;
@ -1169,6 +1429,7 @@ int PeerNet::checkConnectionAllowed(const bdId *peerId, int mode)
//return ALREADY_CONNECTED;
}
#if 0
/* are we capable of making this type of connection? */
if (mode == BITDHT_CONNECT_MODE_RELAY)
{
@ -1181,6 +1442,7 @@ int PeerNet::checkConnectionAllowed(const bdId *peerId, int mode)
return 0;
//return NOT_CAPABLE;
}
#endif
it->second.mPeerAddr = peerId->addr;
it->second.mPeerStatusMsg = "Connection Authorised";
@ -1197,14 +1459,33 @@ void PeerNet::initiateConnection(const bdId *srcId, const bdId *proxyId, const b
std::cerr << " mode: " << mode;
std::cerr << std::endl;
bdId peerConnectId;
/* determine who the actual destination is.
* as we always specify the remote address, this is all we need.
*/
if (loc == BD_PROXY_CONNECTION_START_POINT)
{
peerConnectId = *destId;
}
else if (loc == BD_PROXY_CONNECTION_END_POINT)
{
peerConnectId = *srcId;
}
else
{
std::cerr << "PeerNet::initiateConnection() ERROR, NOT either START or END";
std::cerr << std::endl;
/* ERROR */
return;
}
std::ostringstream str;
bdStdPrintNodeId(str, &(proxyId->id));
bdStdPrintNodeId(str, &(peerConnectId.id));
std::string peerId = str.str();
struct sockaddr_in peerAddr = proxyId->addr;
std::cerr << "PeerNet::initiateConnection() Connecting to ";
bdStdPrintId(std::cerr, proxyId);
bdStdPrintId(std::cerr, &peerConnectId);
std::cerr << std::endl;
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
@ -1216,40 +1497,151 @@ void PeerNet::initiateConnection(const bdId *srcId, const bdId *proxyId, const b
return;
}
int fd = 0;
/* start the connection */
int fd = tou_socket(0, 0, 0);
/* These Socket Modes must match the TOU Stack - or it breaks. */
switch(mode)
{
default:
case BITDHT_CONNECT_MODE_DIRECT:
fd = tou_socket(PN_TOU_RECVER_DIRECT_IDX, TOU_RECEIVER_TYPE_UDPPEER, 0);
break;
case BITDHT_CONNECT_MODE_PROXY:
fd = tou_socket(PN_TOU_RECVER_PROXY_IDX, TOU_RECEIVER_TYPE_UDPPEER, 0);
break;
case BITDHT_CONNECT_MODE_RELAY:
fd = tou_socket(PN_TOU_RECVER_RELAY_IDX, TOU_RECEIVER_TYPE_UDPRELAY, 0);
break;
}
if (fd < 0)
{
std::cerr << "PeerNet::initiateConnection()";
std::cerr << " ERROR Open TOU Socket FAILED";
std::cerr << std::endl;
return;
}
it->second.mPeerFd = fd;
#define PEERNET_CONN_PERIOD 30
#define PEERNET_DIRECT_CONN_PERIOD 5
#define PEERNET_PROXY_CONN_PERIOD 30
#define PEERNET_CONNECT_TIMEOUT (60)
tou_connect(fd, (const struct sockaddr *) (&peerAddr), sizeof(peerAddr), PEERNET_CONN_PERIOD);
int connPeriod = PEERNET_PROXY_CONN_PERIOD;
switch(mode)
{
default:
case BITDHT_CONNECT_MODE_DIRECT:
connPeriod = PEERNET_DIRECT_CONN_PERIOD; // can be much smaller as we are already talking to the peer.
// Fall through.
case BITDHT_CONNECT_MODE_PROXY:
tou_connect(fd, (const struct sockaddr *) (&(peerConnectId.addr)), sizeof(peerConnectId.addr), connPeriod);
break;
case BITDHT_CONNECT_MODE_RELAY:
if (loc == BD_PROXY_CONNECTION_START_POINT)
{
/* standard order connection call */
tou_connect_via_relay(fd, &(srcId->addr), &(proxyId->addr), &(destId->addr));
}
else // END_POINT
{
/* reverse order connection call */
tou_connect_via_relay(fd, &(destId->addr), &(proxyId->addr), &(srcId->addr));
}
break;
}
/* store results in Status */
it->second.mPeerStatusMsg = "UDP started";
it->second.mPeerState = PN_PEER_STATE_UDP_STARTED;
it->second.mPeerConnTS = time(NULL);
it->second.mPeerConnectMode = mode;
it->second.mPeerConnectPoint = loc;
}
void PeerNet::installRelayConnection(const bdId *srcId, const bdId *destId, int mode)
int PeerNet::installRelayConnection(const bdId *srcId, const bdId *destId)
{
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
/* work out if either srcId or DestId is a friend */
int relayClass = UDP_RELAY_CLASS_GENERAL;
std::ostringstream str;
bdStdPrintNodeId(str, &(srcId->id));
std::string strId1 = str.str();
str.clear();
bdStdPrintNodeId(str, &(destId->id));
std::string strId2 = str.str();
/* grab a socket */
std::map<std::string, PeerStatus>::iterator it;
it = mPeers.find(strId1);
if (it != mPeers.end())
{
relayClass = UDP_RELAY_CLASS_FRIENDS;
}
it = mPeers.find(strId2);
if (it != mPeers.end())
{
relayClass = UDP_RELAY_CLASS_FRIENDS;
}
/* will install the Relay Here... so that we reserve the Relay Space for later. */
UdpRelayAddrSet relayAddrs(&(srcId->addr), &(destId->addr));
if (mRelayReceiver->addUdpRelay(&relayAddrs, relayClass))
{
std::cerr << "PeerNet::installRelayConnection() Successfully added Relay, Connection OKAY";
std::cerr << std::endl;
return 1;
// CONNECT_OKAY.
}
else
{
std::cerr << "PeerNet::installRelayConnection() Failed to install Relay, Connection DENIED";
std::cerr << std::endl;
return 0;
//return CONNECT_MODE_OVERLOADED;
}
/* these todo */
std::cerr << "PeerNet::installRelayConnection() TODO";
std::cerr << std::endl;
}
void PeerNet::removeRelayConnection(const bdId *srcId, const bdId *destId, int mode)
int PeerNet::removeRelayConnection(const bdId *srcId, const bdId *destId)
{
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
//bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
/* these shouldn't do anything yet */
std::cerr << "PeerNet::removeRelayConnection() TODO";
std::cerr << std::endl;
UdpRelayAddrSet relayAddrs(&(srcId->addr), &(destId->addr));
if (mRelayReceiver->removeUdpRelay(&relayAddrs))
{
std::cerr << "PeerNet::removeRelayConnection() Successfully removed Relay";
std::cerr << std::endl;
return 1;
}
else
{
std::cerr << "PeerNet::removeRelayConnection() ERROR Failed to remove Relay";
std::cerr << std::endl;
return 0;
}
}
/***************************************************** UDP Connections *****************************/

View File

@ -68,6 +68,7 @@ class PeerStatus
int mPeerFd;
uint32_t mPeerConnectMode;
uint32_t mPeerConnectPoint;
time_t mPeerConnTS;
std::string mPeerIncoming;
};
@ -96,7 +97,10 @@ class PeerNet: public BitDhtCallback
public:
PeerNet(std::string id, std::string bootstrapfile, uint16_t port);
/* setup functions. must be called before init() */
void setUdpStackRestrictions(std::list<std::pair<uint16_t, uint16_t> > &restrictions);
void setLocalTesting();
void init();
int getOwnId(bdNodeId *id);
@ -112,6 +116,7 @@ class PeerNet: public BitDhtCallback
uint32_t getNetStateNetStateMode();
std::string getPeerStatusString();
std::string getPeerAddressString();
std::string getDhtStatusString();
int get_dht_peers(int lvl, bdBucket &peers);
//int get_dht_peers(int lvl, std::list<DhtPeer> &peers);
@ -130,6 +135,9 @@ class PeerNet: public BitDhtCallback
/* under the hood */
int tick();
int minuteTick();
int netStateTick();
int doActions();
void sendMessage(std::string msg);
@ -142,17 +150,20 @@ virtual int dhtNodeCallback(const bdId *id, uint32_t peerflags);
// must be implemented.
virtual int dhtPeerCallback(const bdId *id, uint32_t status);
virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status);
// connection callback. Not required for basic behaviour, but forced for initial development.
virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
uint32_t mode, uint32_t point, uint32_t cbtype);
// Sub Callback Functions.
int OnlinePeerCallback_locked(const bdId *id,
uint32_t status, PeerStatus *peerStatus);
int UnreachablePeerCallback_locked(const bdId *id,
uint32_t status, PeerStatus *peerStatus);
/**** Connection Handling ******/
void monitorConnections();
void removeRelayConnection(const bdId *srcId, const bdId *destId, int mode);
void installRelayConnection(const bdId *srcId, const bdId *destId, int mode);
int removeRelayConnection(const bdId *srcId, const bdId *destId);
int installRelayConnection(const bdId *srcId, const bdId *destId);
void initiateConnection(const bdId *srcId, const bdId *proxyId, const bdId *destId,
uint32_t mode, uint32_t loc, uint32_t answer);
@ -186,10 +197,16 @@ virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdI
uint16_t mPort;
bool mLocalNetTesting;
/* port restrictions */
bool mDoUdpStackRestrictions;
std::list<std::pair<uint16_t, uint16_t> > mUdpStackRestrictions;
/* these probably should be protected - but aren't for now */
time_t mMinuteTS;
/* below here must be mutex protected */
bdMutex mPeerMutex;