mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-23 16:39:16 -04:00
Second Checkin of PeerNetQt. The client will now make DIRECT connections, and you can chat over TcpOnUdp.
* Added commandline options to allow GUI-free, fixed port, restricted ports, and different config path. * Re-organised PeerNet startup to allow various options. * Added UdpStunner into Udp stack, and display of ExtAddress. * Expanded PeerStatus to cover both DHT status and Connection status. * Added TOU connection logic. * Added FailedPeers -> so you can see who tried to connection to you. * Added Mutexes to protect state data. * Filled in ConnectCallback(). * Added PeerActions for CONNECT, AUTHORISE & START_UDP, completing the loop. * added tick() for executing actions and handling connections. * Added Connect Auth Checks. * Added Send/Recv Messages for Chat. * Added GUI components to handle above. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-peernet@4256 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4032f8242c
commit
4f8431ebf8
@ -1,500 +1,500 @@
|
||||
212.139.213.150 11032
|
||||
212.139.213.150 10990
|
||||
85.152.219.110 16300
|
||||
151.64.206.15 26860
|
||||
84.121.123.155 18218
|
||||
193.109.161.129 6881
|
||||
64.121.111.102 29081
|
||||
95.178.41.37 46715
|
||||
99.70.101.170 50784
|
||||
119.203.237.201 46148
|
||||
114.172.79.251 7922
|
||||
24.35.134.70 49031
|
||||
110.201.109.110 16001
|
||||
188.115.181.175 63651
|
||||
85.152.219.110 16466
|
||||
86.101.126.209 45168
|
||||
87.246.21.240 10255
|
||||
79.163.101.143 36097
|
||||
194.247.17.241 22817
|
||||
123.113.36.18 16001
|
||||
188.55.82.33 63068
|
||||
85.152.219.110 16471
|
||||
212.139.213.150 11167
|
||||
84.41.37.179 55364
|
||||
178.72.75.183 53646
|
||||
212.139.213.150 10920
|
||||
195.93.138.193 35691
|
||||
184.57.201.40 49252
|
||||
217.175.171.48 51413
|
||||
85.152.219.110 16277
|
||||
212.139.213.150 10925
|
||||
85.152.219.110 16317
|
||||
121.93.98.221 23082
|
||||
212.139.213.150 10899
|
||||
212.139.213.150 11065
|
||||
81.183.201.252 25094
|
||||
85.152.219.110 16327
|
||||
85.152.219.110 16478
|
||||
85.210.60.130 48512
|
||||
212.139.213.150 10945
|
||||
85.152.219.110 16386
|
||||
212.139.213.150 10869
|
||||
178.149.19.10 55995
|
||||
87.19.184.107 37322
|
||||
85.152.219.110 16382
|
||||
119.152.12.221 53113
|
||||
85.152.219.110 16394
|
||||
2.49.78.158 60971
|
||||
77.243.112.131 33702
|
||||
212.139.213.150 10885
|
||||
212.139.213.150 10905
|
||||
95.30.54.87 36323
|
||||
93.79.180.105 29600
|
||||
212.139.213.150 11128
|
||||
94.228.121.123 59898
|
||||
212.139.213.150 11078
|
||||
88.204.117.27 35691
|
||||
78.176.90.204 34412
|
||||
195.66.100.3 39983
|
||||
81.231.142.85 51709
|
||||
85.172.249.94 26350
|
||||
212.139.213.150 10999
|
||||
212.139.213.150 10857
|
||||
212.139.213.150 11008
|
||||
212.139.213.150 10929
|
||||
89.221.115.221 42474
|
||||
212.139.213.150 10898
|
||||
212.139.213.150 11211
|
||||
92.84.140.193 25245
|
||||
69.245.13.37 52765
|
||||
98.193.26.149 58998
|
||||
76.14.166.121 10553
|
||||
121.215.135.167 11589
|
||||
117.206.235.234 25206
|
||||
87.235.214.29 42817
|
||||
109.173.5.179 16516
|
||||
178.140.91.128 56909
|
||||
72.175.61.150 40290
|
||||
111.241.48.84 54660
|
||||
95.182.88.133 42313
|
||||
93.183.149.239 39456
|
||||
79.173.248.84 1043
|
||||
212.139.213.150 11202
|
||||
212.139.213.150 10937
|
||||
212.139.213.150 11035
|
||||
212.139.213.150 11212
|
||||
119.105.202.44 11184
|
||||
94.178.16.95 16741
|
||||
79.178.121.200 62324
|
||||
78.120.178.227 20444
|
||||
118.36.226.47 45090
|
||||
212.139.213.150 10856
|
||||
85.152.219.110 16504
|
||||
85.152.219.110 16503
|
||||
212.139.213.150 10852
|
||||
85.152.219.110 16402
|
||||
212.139.213.150 11105
|
||||
85.152.219.110 16506
|
||||
85.152.219.110 16509
|
||||
85.232.219.81 18084
|
||||
88.164.58.144 55857
|
||||
82.73.234.131 37018
|
||||
89.38.11.135 51816
|
||||
178.67.37.134 42202
|
||||
85.152.219.110 16511
|
||||
212.139.213.150 11054
|
||||
2.60.177.71 51413
|
||||
94.209.60.137 37161
|
||||
212.139.213.150 11069
|
||||
122.163.55.49 33709
|
||||
110.35.14.46 16394
|
||||
41.240.141.226 58157
|
||||
218.102.151.97 22792
|
||||
112.120.35.208 14845
|
||||
112.134.123.210 46374
|
||||
212.67.133.227 22110
|
||||
85.152.219.110 16408
|
||||
58.0.103.222 13868
|
||||
1.36.170.135 49888
|
||||
118.160.44.124 15529
|
||||
61.219.11.135 12967
|
||||
219.77.101.32 10168
|
||||
123.231.18.70 11935
|
||||
94.23.1.199 45846
|
||||
62.248.204.118 51000
|
||||
99.28.131.130 46291
|
||||
76.121.8.79 16599
|
||||
94.193.177.45 13254
|
||||
91.95.224.125 33937
|
||||
122.161.167.221 22840
|
||||
68.149.78.143 18261
|
||||
94.174.132.84 10493
|
||||
182.89.64.219 4041
|
||||
95.55.22.43 15346
|
||||
84.55.96.240 37839
|
||||
67.82.53.124 5931
|
||||
84.0.215.220 37787
|
||||
81.225.143.195 1256
|
||||
190.189.39.56 27211
|
||||
175.142.195.240 18988
|
||||
59.177.2.234 57683
|
||||
188.220.197.130 51413
|
||||
123.236.87.167 21823
|
||||
118.5.196.178 14373
|
||||
203.253.73.158 29843
|
||||
115.59.105.0 1041
|
||||
66.191.26.174 49995
|
||||
89.147.94.239 38144
|
||||
24.201.212.220 40489
|
||||
184.59.221.228 22428
|
||||
114.46.102.183 16881
|
||||
88.134.99.73 27052
|
||||
94.250.26.27 22979
|
||||
122.178.113.80 58012
|
||||
88.178.72.2 7812
|
||||
98.215.148.74 60357
|
||||
110.164.35.39 44112
|
||||
178.152.0.100 10888
|
||||
212.139.213.150 10972
|
||||
72.200.149.14 15712
|
||||
82.244.138.223 14284
|
||||
82.244.203.153 21428
|
||||
82.232.0.124 9156
|
||||
178.178.240.33 24988
|
||||
212.139.213.150 10943
|
||||
212.139.213.150 11087
|
||||
212.139.213.150 11086
|
||||
92.134.151.100 23522
|
||||
160.114.58.149 37689
|
||||
80.232.240.131 51413
|
||||
91.144.87.105 57933
|
||||
75.119.230.89 1723
|
||||
95.135.73.84 41175
|
||||
118.0.112.234 26755
|
||||
187.15.6.101 58525
|
||||
175.145.223.193 36964
|
||||
94.194.224.35 40927
|
||||
195.138.72.56 35691
|
||||
216.106.197.206 10476
|
||||
188.16.99.201 48712
|
||||
61.196.49.130 53264
|
||||
123.155.206.188 11935
|
||||
122.120.37.152 43097
|
||||
212.139.213.150 11004
|
||||
173.63.78.77 17310
|
||||
89.165.209.72 27145
|
||||
2.60.88.158 61218
|
||||
212.139.213.150 10913
|
||||
71.225.229.119 16709
|
||||
213.37.47.70 20727
|
||||
98.244.167.120 23246
|
||||
173.34.90.46 8222
|
||||
2.104.156.207 26387
|
||||
98.110.89.33 55302
|
||||
80.80.153.149 17610
|
||||
72.213.204.222 33471
|
||||
189.101.32.212 51413
|
||||
118.9.53.170 21739
|
||||
85.227.192.135 40053
|
||||
186.23.58.157 21301
|
||||
212.139.213.150 10930
|
||||
173.56.22.140 51413
|
||||
67.41.137.173 48302
|
||||
212.139.213.150 10895
|
||||
114.38.21.70 11904
|
||||
70.81.118.246 33106
|
||||
72.38.3.58 28012
|
||||
78.29.157.202 52896
|
||||
118.165.101.114 61471
|
||||
84.73.253.37 43354
|
||||
99.99.184.86 55431
|
||||
89.214.191.127 10467
|
||||
122.106.10.173 59931
|
||||
72.27.71.232 11746
|
||||
82.137.212.38 20621
|
||||
60.0.124.214 11935
|
||||
95.171.26.4 52382
|
||||
78.20.54.114 63681
|
||||
80.92.105.91 11255
|
||||
212.139.213.150 11146
|
||||
212.139.213.150 11113
|
||||
212.139.213.150 11124
|
||||
212.139.213.150 10963
|
||||
46.109.115.238 47440
|
||||
2.4.167.74 61574
|
||||
71.58.129.230 41859
|
||||
84.244.4.8 37691
|
||||
213.110.132.160 13564
|
||||
92.244.116.227 34939
|
||||
212.200.207.47 27440
|
||||
24.13.126.175 44715
|
||||
76.89.148.206 28183
|
||||
78.237.125.203 10595
|
||||
62.255.191.244 60457
|
||||
97.118.93.163 16283
|
||||
94.69.47.150 17350
|
||||
99.22.214.100 36244
|
||||
213.107.94.57 55377
|
||||
212.139.213.150 11143
|
||||
78.31.227.221 53171
|
||||
98.113.12.175 41060
|
||||
109.132.186.182 37836
|
||||
2.95.54.76 26871
|
||||
70.120.233.87 60139
|
||||
119.194.58.175 6881
|
||||
202.64.42.71 56584
|
||||
212.139.213.150 11084
|
||||
78.190.140.113 23526
|
||||
194.144.16.142 26935
|
||||
212.139.213.150 10896
|
||||
212.139.213.150 11085
|
||||
92.158.0.211 44981
|
||||
212.139.213.150 11068
|
||||
212.139.213.150 10843
|
||||
212.139.213.150 10900
|
||||
145.236.20.190 52156
|
||||
212.139.213.150 11028
|
||||
112.201.75.180 41616
|
||||
212.139.213.150 10894
|
||||
212.139.213.150 10846
|
||||
212.139.213.150 11197
|
||||
212.139.213.150 10868
|
||||
212.139.213.150 11081
|
||||
88.187.80.252 49180
|
||||
212.139.213.150 11175
|
||||
212.139.213.150 11226
|
||||
81.13.186.186 27652
|
||||
212.139.213.150 11110
|
||||
212.139.213.150 11201
|
||||
212.139.213.150 11213
|
||||
212.139.213.150 11101
|
||||
212.139.213.150 11017
|
||||
212.139.213.150 10936
|
||||
212.139.213.150 10891
|
||||
89.252.227.41 1751
|
||||
212.139.213.150 10870
|
||||
212.139.213.150 11064
|
||||
212.139.213.150 10837
|
||||
212.139.213.150 10941
|
||||
212.139.213.150 10841
|
||||
77.40.134.117 37692
|
||||
213.245.18.98 54416
|
||||
212.139.213.150 11122
|
||||
212.139.213.150 11132
|
||||
212.139.213.150 11127
|
||||
212.139.213.150 10838
|
||||
212.139.213.150 11005
|
||||
212.139.213.150 11092
|
||||
212.139.213.150 11013
|
||||
87.58.253.222 6881
|
||||
212.139.213.150 11219
|
||||
212.139.213.150 11224
|
||||
93.183.159.227 15234
|
||||
109.8.252.86 26646
|
||||
24.118.215.76 7000
|
||||
192.117.97.129 21181
|
||||
119.240.201.43 33331
|
||||
203.142.185.144 27235
|
||||
119.109.89.98 16001
|
||||
212.139.213.150 10983
|
||||
81.82.209.160 45974
|
||||
75.84.23.196 48501
|
||||
76.19.133.240 60301
|
||||
212.139.213.150 11152
|
||||
69.47.128.239 60159
|
||||
109.86.99.249 11362
|
||||
77.38.174.41 58764
|
||||
109.195.211.3 40416
|
||||
95.57.36.113 27439
|
||||
114.164.15.235 6882
|
||||
109.203.147.188 31679
|
||||
212.139.213.150 10956
|
||||
85.152.219.110 16373
|
||||
85.152.219.110 16375
|
||||
85.152.219.110 16374
|
||||
212.139.213.150 10923
|
||||
212.139.213.150 10909
|
||||
212.139.213.150 11002
|
||||
85.152.219.110 16378
|
||||
212.139.213.150 11188
|
||||
212.139.213.150 10848
|
||||
85.152.219.110 16383
|
||||
151.66.162.65 23067
|
||||
85.152.219.110 16387
|
||||
212.139.213.150 11193
|
||||
85.152.219.110 16389
|
||||
212.139.213.150 10977
|
||||
85.152.219.110 16392
|
||||
212.139.213.150 11038
|
||||
212.139.213.150 11147
|
||||
189.60.244.233 15861
|
||||
85.152.219.110 16397
|
||||
212.139.213.150 10971
|
||||
212.139.213.150 10893
|
||||
85.152.219.110 16404
|
||||
85.152.219.110 16418
|
||||
212.139.213.150 10984
|
||||
212.139.213.150 10962
|
||||
212.139.213.150 10839
|
||||
85.152.219.110 16429
|
||||
212.139.213.150 10874
|
||||
85.152.219.110 16437
|
||||
212.139.213.150 10955
|
||||
89.169.104.162 51800
|
||||
212.139.213.150 11136
|
||||
94.113.169.223 20959
|
||||
85.152.219.110 16444
|
||||
212.139.213.150 10917
|
||||
212.139.213.150 11063
|
||||
85.152.219.110 16449
|
||||
212.139.213.150 11050
|
||||
123.228.132.214 59802
|
||||
212.139.213.150 10912
|
||||
212.139.213.150 10966
|
||||
85.152.219.110 16452
|
||||
212.139.213.150 10987
|
||||
212.139.213.150 10924
|
||||
212.139.213.150 10847
|
||||
85.152.219.110 16459
|
||||
89.178.249.16 46584
|
||||
46.32.50.107 6881
|
||||
95.168.230.154 1210
|
||||
113.146.92.42 51413
|
||||
212.139.213.150 10866
|
||||
77.123.47.213 35741
|
||||
111.233.229.16 14221
|
||||
89.201.255.71 21940
|
||||
99.238.211.18 58061
|
||||
112.201.14.0 10301
|
||||
85.152.219.110 16461
|
||||
212.139.213.150 11042
|
||||
94.21.183.178 29943
|
||||
212.139.213.150 10978
|
||||
212.139.213.150 11102
|
||||
84.60.60.147 49860
|
||||
79.136.239.71 16688
|
||||
212.139.213.150 11121
|
||||
88.77.94.222 49860
|
||||
24.1.118.110 27704
|
||||
93.145.89.34 53568
|
||||
85.152.219.110 16464
|
||||
178.73.200.28 45416
|
||||
112.221.10.75 11811
|
||||
212.139.213.150 11010
|
||||
142.161.67.218 50221
|
||||
98.250.169.93 30165
|
||||
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
|
||||
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
|
||||
76.28.161.135 64289
|
||||
113.11.4.87 39907
|
||||
27.186.73.219 9371
|
||||
212.139.213.150 10994
|
||||
85.152.219.110 16297
|
||||
212.139.213.150 11022
|
||||
93.116.164.129 32793
|
||||
212.139.213.150 10833
|
||||
95.102.83.196 22931
|
||||
85.152.219.110 16465
|
||||
212.139.213.150 11060
|
||||
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
|
||||
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
|
||||
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 11107
|
||||
61.18.118.141 20822
|
||||
85.152.219.110 16299
|
||||
69.76.140.34 16157
|
||||
212.139.213.150 10985
|
||||
212.139.213.150 11046
|
||||
86.58.76.161 44032
|
||||
87.151.74.145 53760
|
||||
80.94.245.157 43332
|
||||
117.196.105.164 15076
|
||||
212.139.213.150 10948
|
||||
173.74.237.177 59850
|
||||
95.25.98.209 40615
|
||||
87.110.2.78 38633
|
||||
79.119.105.174 58851
|
||||
85.152.219.110 16302
|
||||
89.73.211.60 60335
|
||||
212.139.213.150 10836
|
||||
177.16.80.162 40000
|
||||
74.232.225.202 50908
|
||||
212.139.213.150 11067
|
||||
94.137.247.253 52053
|
||||
95.73.252.250 13214
|
||||
85.152.219.110 16467
|
||||
212.139.213.150 11062
|
||||
212.139.213.150 11214
|
||||
196.205.236.76 23958
|
||||
212.139.213.150 11048
|
||||
85.152.219.110 16291
|
||||
212.139.213.150 10961
|
||||
212.139.213.150 10897
|
||||
85.152.219.110 16309
|
||||
212.139.213.150 11218
|
||||
212.139.213.150 10944
|
||||
85.152.219.110 16311
|
||||
212.139.213.150 11015
|
||||
212.139.213.150 11000
|
||||
178.162.242.146 37592
|
||||
212.139.213.150 11161
|
||||
85.152.219.110 16319
|
||||
212.139.213.150 11189
|
||||
212.139.213.150 11033
|
||||
94.190.83.102 33102
|
||||
212.139.213.150 11044
|
||||
212.139.213.150 11144
|
||||
85.152.219.110 16322
|
||||
212.139.213.150 10991
|
||||
212.139.213.150 10975
|
||||
85.152.219.110 16324
|
||||
212.139.213.150 11049
|
||||
85.152.219.110 16295
|
||||
212.139.213.150 11134
|
||||
212.139.213.150 11183
|
||||
85.152.219.110 16284
|
||||
212.139.213.150 11135
|
||||
85.152.219.110 16339
|
||||
212.139.213.150 11168
|
||||
85.152.219.110 16343
|
||||
212.139.213.150 11115
|
||||
212.139.213.150 11047
|
||||
212.139.213.150 10884
|
||||
212.139.213.150 11210
|
||||
85.152.219.110 16469
|
||||
212.139.213.150 11108
|
||||
213.119.89.134 37949
|
||||
212.139.213.150 10919
|
||||
212.139.213.150 11198
|
||||
212.139.213.150 11220
|
||||
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
|
||||
212.139.213.150 11205
|
||||
212.139.213.150 11114
|
||||
212.139.213.150 10952
|
||||
212.139.213.150 11095
|
||||
212.139.213.150 11207
|
||||
212.139.213.150 11082
|
||||
212.139.213.150 10851
|
||||
212.139.213.150 11160
|
||||
212.139.213.150 11109
|
||||
212.139.213.150 11184
|
||||
212.139.213.150 10926
|
||||
212.139.213.150 10844
|
||||
212.139.213.150 10916
|
||||
118.11.81.144 55695
|
||||
212.139.213.150 11153
|
||||
212.139.213.150 10875
|
||||
212.139.213.150 10871
|
||||
212.139.213.150 11204
|
||||
212.139.213.150 10865
|
||||
212.139.213.150 11014
|
||||
212.139.213.150 11229
|
||||
212.139.213.150 11179
|
||||
212.139.213.150 11001
|
||||
212.139.213.150 11029
|
||||
212.139.213.150 10853
|
||||
212.139.213.150 10927
|
||||
212.139.213.150 11140
|
||||
212.139.213.150 11129
|
||||
212.139.213.150 11099
|
||||
212.139.213.150 10969
|
||||
212.139.213.150 10921
|
||||
212.139.213.150 11185
|
||||
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
|
||||
|
@ -4,21 +4,94 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
bool showGUI = true;
|
||||
|
||||
bool doConfig = false;
|
||||
|
||||
#ifdef __APPLE__
|
||||
std::string configPath = "../..";
|
||||
#else
|
||||
std::string configPath = ".";
|
||||
#endif
|
||||
|
||||
bool doRestricted = false;
|
||||
std::list<std::string> restrictions;
|
||||
|
||||
bool doFixedPort = false;
|
||||
int portNumber = 0;
|
||||
|
||||
int c;
|
||||
while((c = getopt(argc, argv,"r:p:c:n")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'r':
|
||||
std::cerr << "Adding Port Restriction: " << optarg << std::endl;
|
||||
doRestricted = true;
|
||||
restrictions.push_back(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
std::cerr << "Setting Fixed Port: " << optarg << std::endl;
|
||||
doFixedPort = true;
|
||||
portNumber = atoi(optarg);
|
||||
break;
|
||||
case 'c':
|
||||
std::cerr << "Switching default Config Location: " << optarg << std::endl;
|
||||
doConfig = true;
|
||||
configPath = std::string(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
std::cerr << "Disabling GUI" << std::endl;
|
||||
showGUI = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PeerNet *pnet = new PeerNet("", configPath, portNumber);
|
||||
|
||||
if (doRestricted)
|
||||
{
|
||||
std::list<std::pair<uint16_t, uint16_t> > portRestrictions;
|
||||
std::list<std::string>::iterator sit;
|
||||
|
||||
for(sit = restrictions.begin(); sit != restrictions.end(); sit++)
|
||||
{
|
||||
/* parse the string */
|
||||
unsigned int lport, uport;
|
||||
if (2 == sscanf(sit->c_str(), "%u-%u", &lport, &uport))
|
||||
{
|
||||
std::cerr << "Adding Port Restriction (" << lport << "-" << uport << ")";
|
||||
std::cerr << std::endl;
|
||||
portRestrictions.push_back(std::make_pair<uint16_t, uint16_t>(lport, uport));
|
||||
}
|
||||
}
|
||||
|
||||
if (portRestrictions.size() > 0)
|
||||
{
|
||||
pnet->setUdpStackRestrictions(portRestrictions);
|
||||
}
|
||||
}
|
||||
|
||||
pnet->init();
|
||||
|
||||
if (showGUI)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
#ifdef __APPLE__
|
||||
PeerNet pnet("", "../..", 0); // This is because of the apple APP structure.
|
||||
#else
|
||||
PeerNet pnet("", ".", 0);
|
||||
#endif
|
||||
w.setPeerNet(pnet);
|
||||
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
w.setPeerNet(&pnet);
|
||||
|
||||
|
||||
return a.exec();
|
||||
return a.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
sleep(1);
|
||||
pnet->tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
// connect add Peer button.
|
||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addPeer()));
|
||||
connect(ui->chatLineEdit, SIGNAL(returnPressed()), this, SLOT(sendChat()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -51,6 +52,9 @@ void MainWindow::update()
|
||||
updateDhtPeers();
|
||||
updateNetPeers();
|
||||
updateChat();
|
||||
|
||||
// Shouldn't do it here! but for now.
|
||||
mPeerNet->tick();
|
||||
}
|
||||
|
||||
|
||||
@ -177,12 +181,19 @@ void MainWindow::updateNetPeers()
|
||||
QTreeWidget *peerTreeWidget = ui->peerTreeWidget;
|
||||
|
||||
std::list<std::string> peerIds;
|
||||
std::list<std::string> failedPeerIds;
|
||||
std::list<std::string>::iterator it;
|
||||
mPeerNet->get_net_peers(peerIds);
|
||||
mPeerNet->get_net_failedpeers(failedPeerIds);
|
||||
|
||||
#define PTW_COL_PEERID 0
|
||||
#define PTW_COL_STATUS 1
|
||||
#define PTW_COL_UPDATETS 2
|
||||
#define PTW_COL_DHT_STATUS 1
|
||||
#define PTW_COL_DHT_ADDRESS 2
|
||||
#define PTW_COL_DHT_UPDATETS 3
|
||||
|
||||
#define PTW_COL_PEER_STATUS 4
|
||||
#define PTW_COL_PEER_ADDRESS 5
|
||||
#define PTW_COL_PEER_UPDATETS 6
|
||||
|
||||
/* clear old entries */
|
||||
int itemCount = peerTreeWidget->topLevelItemCount();
|
||||
@ -192,9 +203,12 @@ void MainWindow::updateNetPeers()
|
||||
std::string tmpid = tmp_item->data(PTW_COL_PEERID, Qt::DisplayRole).toString().toStdString();
|
||||
if (peerIds.end() == std::find(peerIds.begin(), peerIds.end(), tmpid))
|
||||
{
|
||||
peerTreeWidget->removeItemWidget(tmp_item, 0);
|
||||
/* remove it! */
|
||||
itemCount--;
|
||||
if (failedPeerIds.end() == std::find(failedPeerIds.begin(), failedPeerIds.end(), tmpid))
|
||||
{
|
||||
peerTreeWidget->removeItemWidget(tmp_item, 0);
|
||||
/* remove it! */
|
||||
itemCount--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -228,14 +242,86 @@ void MainWindow::updateNetPeers()
|
||||
/* update the data */
|
||||
PeerStatus status;
|
||||
mPeerNet->get_peer_status(*it, status);
|
||||
|
||||
std::ostringstream updatestr;
|
||||
time_t now = time(NULL);
|
||||
updatestr << now - status.mUpdateTS << " secs ago";
|
||||
|
||||
std::ostringstream dhtipstr;
|
||||
if ((status.mDhtState == PN_DHT_STATE_ONLINE) || (status.mDhtState == PN_DHT_STATE_UNREACHABLE))
|
||||
{
|
||||
dhtipstr << inet_ntoa(status.mDhtAddr.sin_addr);
|
||||
dhtipstr << ":" << ntohs(status.mDhtAddr.sin_port);
|
||||
}
|
||||
|
||||
std::ostringstream dhtupdatestr;
|
||||
dhtupdatestr << now - status.mDhtUpdateTS << " secs ago";
|
||||
|
||||
std::ostringstream peeripstr;
|
||||
//if (status.mPeerState == PN_PEER_STATE_ONLINE)
|
||||
{
|
||||
peeripstr << inet_ntoa(status.mPeerAddr.sin_addr);
|
||||
peeripstr << ":" << ntohs(status.mPeerAddr.sin_port);
|
||||
}
|
||||
|
||||
std::ostringstream peerupdatestr;
|
||||
peerupdatestr << now - status.mPeerUpdateTS << " secs ago";
|
||||
|
||||
|
||||
peer_item -> setData(PTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(*it));
|
||||
peer_item -> setData(PTW_COL_STATUS, Qt::DisplayRole, QString::fromStdString(status.mStatusMsg));
|
||||
peer_item -> setData(PTW_COL_UPDATETS, Qt::DisplayRole, QString::fromStdString(updatestr.str()));
|
||||
peer_item -> setData(PTW_COL_DHT_STATUS, Qt::DisplayRole, QString::fromStdString(status.mDhtStatusMsg));
|
||||
peer_item -> setData(PTW_COL_DHT_ADDRESS, Qt::DisplayRole, QString::fromStdString(dhtipstr.str()));
|
||||
peer_item -> setData(PTW_COL_DHT_UPDATETS, Qt::DisplayRole, QString::fromStdString(dhtupdatestr.str()));
|
||||
|
||||
peer_item -> setData(PTW_COL_PEER_STATUS, Qt::DisplayRole, QString::fromStdString(status.mPeerStatusMsg));
|
||||
peer_item -> setData(PTW_COL_PEER_ADDRESS, Qt::DisplayRole, QString::fromStdString(peeripstr.str()));
|
||||
peer_item -> setData(PTW_COL_PEER_UPDATETS, Qt::DisplayRole, QString::fromStdString(peerupdatestr.str()));
|
||||
}
|
||||
|
||||
for(it = failedPeerIds.begin(); it != failedPeerIds.end(); it++)
|
||||
{
|
||||
/* find the entry */
|
||||
QTreeWidgetItem *peer_item = NULL;
|
||||
QString qpeerid = QString::fromStdString(*it);
|
||||
int itemCount = peerTreeWidget->topLevelItemCount();
|
||||
for (int nIndex = 0; nIndex < itemCount; nIndex++)
|
||||
{
|
||||
QTreeWidgetItem *tmp_item = peerTreeWidget->topLevelItem(nIndex);
|
||||
if (tmp_item->data(PTW_COL_PEERID, Qt::DisplayRole).toString() == qpeerid)
|
||||
{
|
||||
peer_item = tmp_item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!peer_item)
|
||||
{
|
||||
/* insert */
|
||||
peer_item = new QTreeWidgetItem();
|
||||
peerTreeWidget->addTopLevelItem(peer_item);
|
||||
}
|
||||
|
||||
/* update the data */
|
||||
PeerStatus status;
|
||||
mPeerNet->get_failedpeer_status(*it, status);
|
||||
time_t now = time(NULL);
|
||||
|
||||
std::ostringstream peeripstr;
|
||||
//if (status.mPeerState == PN_PEER_STATE_ONLINE)
|
||||
{
|
||||
peeripstr << inet_ntoa(status.mPeerAddr.sin_addr);
|
||||
peeripstr << ":" << ntohs(status.mPeerAddr.sin_port);
|
||||
}
|
||||
|
||||
std::ostringstream peerupdatestr;
|
||||
peerupdatestr << now - status.mPeerUpdateTS << " secs ago";
|
||||
|
||||
|
||||
peer_item -> setData(PTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(*it));
|
||||
peer_item -> setData(PTW_COL_DHT_STATUS, Qt::DisplayRole, "Unknown Peer");
|
||||
peer_item -> setData(PTW_COL_DHT_ADDRESS, Qt::DisplayRole, "");
|
||||
peer_item -> setData(PTW_COL_DHT_UPDATETS, Qt::DisplayRole, "");
|
||||
|
||||
peer_item -> setData(PTW_COL_PEER_STATUS, Qt::DisplayRole, QString::fromStdString(status.mPeerStatusMsg));
|
||||
peer_item -> setData(PTW_COL_PEER_ADDRESS, Qt::DisplayRole, QString::fromStdString(peeripstr.str()));
|
||||
peer_item -> setData(PTW_COL_PEER_UPDATETS, Qt::DisplayRole, QString::fromStdString(peerupdatestr.str()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,15 +335,41 @@ void MainWindow::addPeer()
|
||||
|
||||
void MainWindow::sendChat()
|
||||
{
|
||||
std::string msg = ui->chatLineEdit->text().toStdString();
|
||||
ui->chatLineEdit->clear();
|
||||
|
||||
|
||||
if (msg.size() > 0)
|
||||
{
|
||||
mPeerNet->sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateChat()
|
||||
{
|
||||
|
||||
|
||||
|
||||
std::list<std::string> peerIds;
|
||||
std::list<std::string>::iterator it;
|
||||
mPeerNet->get_net_peers(peerIds);
|
||||
for(it = peerIds.begin(); it != peerIds.end(); it++)
|
||||
{
|
||||
std::string msg;
|
||||
if (mPeerNet->getMessage(*it, msg))
|
||||
{
|
||||
addChatMsg(*it, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::addChatMsg(std::string id, std::string msg)
|
||||
{
|
||||
QString chat = ui->chatBrowser->toPlainText();
|
||||
QString newmsg = "<";
|
||||
newmsg += QString::fromStdString(id);
|
||||
newmsg += "> ";
|
||||
newmsg += QString::fromStdString(msg);
|
||||
newmsg += "\n";
|
||||
|
||||
chat += newmsg;
|
||||
ui->chatBrowser->setPlainText(chat);
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,13 @@ public:
|
||||
void updateNetStatus();
|
||||
void updateDhtPeers();
|
||||
void updateNetPeers();
|
||||
void sendChat();
|
||||
void updateChat();
|
||||
void addChatMsg(std::string id, std::string msg);
|
||||
|
||||
public slots:
|
||||
void update();
|
||||
void addPeer();
|
||||
void sendChat();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -37,7 +37,7 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="peerLine">
|
||||
@ -61,19 +61,39 @@
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
<string>Dht Status</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Last Update</string>
|
||||
<string>Dht Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Dht Update</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Connect Status</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Connect Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Connect Update</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
@ -94,7 +114,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="dhtLabel">
|
||||
|
@ -5,13 +5,16 @@
|
||||
|
||||
|
||||
#include "bitdht/bdstddht.h"
|
||||
//#include "udp/udplayer.h"
|
||||
|
||||
#include "tcponudp/tou.h"
|
||||
#include "util/rsnet.h"
|
||||
|
||||
|
||||
PeerNet::PeerNet(std::string id, std::string configpath, uint16_t port)
|
||||
{
|
||||
std::string dhtVersion = "RS52"; // should come from elsewhere!
|
||||
mDoUdpStackRestrictions = false;
|
||||
|
||||
|
||||
std::cerr << "PeerNet::PeerNet()" << std::endl;
|
||||
std::cerr << "Using Id: " << id;
|
||||
@ -26,7 +29,7 @@ PeerNet::PeerNet(std::string id, std::string configpath, uint16_t port)
|
||||
|
||||
mConfigFile = configpath + "/peerconfig.txt";
|
||||
mPeersFile = configpath + "/peerlist.txt";
|
||||
std::string bootstrapfile = configpath + "/bdboot.txt";
|
||||
mBootstrapFile = configpath + "/bdboot.txt";
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
@ -59,7 +62,19 @@ PeerNet::PeerNet(std::string id, std::string configpath, uint16_t port)
|
||||
bdStdPrintNodeId(std::cerr, &mOwnId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
|
||||
void PeerNet::setUdpStackRestrictions(std::list<std::pair<uint16_t, uint16_t> > &restrictions)
|
||||
{
|
||||
mDoUdpStackRestrictions = true;
|
||||
mUdpStackRestrictions = restrictions;
|
||||
}
|
||||
|
||||
|
||||
void PeerNet::init()
|
||||
{
|
||||
/* standard dht behaviour */
|
||||
std::string dhtVersion = "RS52"; // should come from elsewhere!
|
||||
bdDhtFunctions *stdfns = new bdStdDht();
|
||||
|
||||
std::cerr << "PeerNet() startup ... creating UdpStack";
|
||||
@ -69,13 +84,35 @@ PeerNet::PeerNet(std::string id, std::string configpath, uint16_t port)
|
||||
struct sockaddr_in tmpladdr;
|
||||
sockaddr_clear(&tmpladdr);
|
||||
tmpladdr.sin_port = htons(mPort);
|
||||
mUdpStack = new UdpStack(tmpladdr);
|
||||
|
||||
if (mDoUdpStackRestrictions)
|
||||
{
|
||||
mUdpStack = new UdpStack(UDP_TEST_RESTRICTED_LAYER, tmpladdr);
|
||||
RestrictedUdpLayer *url = (RestrictedUdpLayer *) mUdpStack->getUdpLayer();
|
||||
|
||||
std::list<std::pair<uint16_t, uint16_t> >::iterator it;
|
||||
for(it = mUdpStackRestrictions.begin(); it != mUdpStackRestrictions.end(); it++)
|
||||
{
|
||||
url->addRestrictedPortRange(it->first, it->second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mUdpStack = new UdpStack(tmpladdr);
|
||||
}
|
||||
|
||||
std::cerr << "PeerNet() startup ... creating UdpStunner";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mDhtStunner = new UdpStunner(mUdpStack);
|
||||
//mDhtStunner->setStunKeepAlive(0); // default.
|
||||
//mDhtStunner->setStunKeepAlive(1);
|
||||
|
||||
std::cerr << "PeerNet() startup ... creating UdpBitDht";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* create dht */
|
||||
mUdpBitDht = new UdpBitDht(mUdpStack, &mOwnId, dhtVersion, bootstrapfile, stdfns);
|
||||
mUdpBitDht = new UdpBitDht(mUdpStack, &mOwnId, dhtVersion, mBootstrapFile, stdfns);
|
||||
mUdpStack->addReceiver(mUdpBitDht);
|
||||
|
||||
/* setup callback to here */
|
||||
@ -100,13 +137,6 @@ int PeerNet::getOwnId(bdNodeId *id)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define PN_PEER_STATE_UNKNOWN 0
|
||||
#define PN_PEER_STATE_SEARCHING 1
|
||||
#define PN_PEER_STATE_FAILURE 2
|
||||
#define PN_PEER_STATE_OFFLINE 3
|
||||
#define PN_PEER_STATE_UNREACHABLE 4
|
||||
#define PN_PEER_STATE_ONLINE 5
|
||||
|
||||
int PeerNet::add_peer(std::string id)
|
||||
{
|
||||
bdNodeId tmpId;
|
||||
@ -133,8 +163,13 @@ int PeerNet::add_peer(std::string id)
|
||||
bdStdPrintNodeId(std::cerr, &tmpId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (mPeers.end() == mPeers.find(filteredId))
|
||||
bool addedPeer = false;
|
||||
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
if (mPeers.end() == mPeers.find(filteredId))
|
||||
{
|
||||
std::cerr << "Adding New Peer: " << filteredId << std::endl;
|
||||
mPeers[filteredId] = PeerStatus();
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(filteredId);
|
||||
@ -142,12 +177,31 @@ int PeerNet::add_peer(std::string id)
|
||||
mUdpBitDht->addFindNode(&tmpId, BITDHT_QFLAGS_DO_IDLE);
|
||||
|
||||
it->second.mId = filteredId;
|
||||
it->second.mStatusMsg = "Just Added";
|
||||
it->second.mState = PN_PEER_STATE_SEARCHING;
|
||||
it->second.mUpdateTS = time(NULL);
|
||||
bdsockaddr_clear(&(it->second.mDhtAddr));
|
||||
it->second.mDhtStatusMsg = "Just Added";
|
||||
it->second.mDhtState = PN_DHT_STATE_SEARCHING;
|
||||
it->second.mDhtUpdateTS = time(NULL);
|
||||
|
||||
it->second.mPeerStatusMsg = "Disconnected";
|
||||
bdsockaddr_clear(&(it->second.mPeerAddr));
|
||||
it->second.mPeerState = PN_PEER_STATE_DISCONNECTED;
|
||||
it->second.mPeerUpdateTS = time(NULL);
|
||||
|
||||
addedPeer = true;
|
||||
}
|
||||
|
||||
/* remove from FailedPeers */
|
||||
std::map<std::string, PeerStatus>::iterator it = mFailedPeers.find(filteredId);
|
||||
if (it != mFailedPeers.end())
|
||||
{
|
||||
mFailedPeers.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
if (addedPeer)
|
||||
{
|
||||
// outside of mutex.
|
||||
storePeers(mPeersFile);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -171,6 +225,8 @@ int PeerNet::remove_peer(std::string id)
|
||||
bdStdPrintNodeId(str, &tmpId);
|
||||
std::string filteredId = str.str();
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(filteredId);
|
||||
|
||||
if (mPeers.end() != it)
|
||||
@ -242,6 +298,27 @@ std::string PeerNet::getPeerStatusString()
|
||||
|
||||
out << " LocalPort: " << mPort;
|
||||
|
||||
struct sockaddr_in extAddr;
|
||||
uint8_t extStable;
|
||||
if (mDhtStunner->externalAddr(extAddr, extStable))
|
||||
{
|
||||
out << " ExtAddress: " << inet_ntoa(extAddr.sin_addr);
|
||||
out << ":" << ntohs(extAddr.sin_port);
|
||||
|
||||
if (extStable)
|
||||
{
|
||||
out << " is Stable";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << " is Unstable (symmetric NAT)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
out << " ExtAddress Unknown";
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@ -251,6 +328,8 @@ std::string PeerNet::getPeerStatusString()
|
||||
|
||||
int PeerNet::get_net_peers(std::list<std::string> &peerIds)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it;
|
||||
for(it = mPeers.begin(); it != mPeers.end(); it++)
|
||||
{
|
||||
@ -261,6 +340,8 @@ int PeerNet::get_net_peers(std::list<std::string> &peerIds)
|
||||
|
||||
int PeerNet::get_peer_status(std::string id, PeerStatus &status)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(id);
|
||||
if (it != mPeers.end())
|
||||
{
|
||||
@ -270,6 +351,32 @@ int PeerNet::get_peer_status(std::string id, PeerStatus &status)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int PeerNet::get_net_failedpeers(std::list<std::string> &peerIds)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it;
|
||||
for(it = mFailedPeers.begin(); it != mFailedPeers.end(); it++)
|
||||
{
|
||||
peerIds.push_back(it->first);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
if (it != mFailedPeers.end())
|
||||
{
|
||||
status = it->second;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* remember peers */
|
||||
int PeerNet::storePeers(std::string filepath)
|
||||
{
|
||||
@ -284,6 +391,8 @@ int PeerNet::storePeers(std::string filepath)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it;
|
||||
for(it = mPeers.begin(); it != mPeers.end(); it++)
|
||||
{
|
||||
@ -390,10 +499,26 @@ int PeerNet::dhtNodeCallback(const bdId *id, uint32_t peerflags)
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(strId);
|
||||
if (it != mPeers.end())
|
||||
{
|
||||
#ifdef PEERNET_DEBUG
|
||||
std::cerr << "PeerNet::dhtNodeCallback() From KNOWN PEER: ";
|
||||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << " Flags: " << peerflags;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (peerflags & BITDHT_PEER_STATUS_DHT_APPL)
|
||||
{
|
||||
#ifdef PEERNET_DEBUG
|
||||
std::cerr << "PeerNet::dhtNodeCallback() Passing Local Peer to DhtStunner: ";
|
||||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (mDhtStunner)
|
||||
{
|
||||
mDhtStunner->addStunPeer(id->addr, strId.c_str());
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -407,6 +532,9 @@ int PeerNet::dhtPeerCallback(const bdId *id, uint32_t status)
|
||||
//std::cerr << "PeerNet::dhtPeerCallback()";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(strId);
|
||||
if (it != mPeers.end())
|
||||
{
|
||||
@ -414,38 +542,66 @@ int PeerNet::dhtPeerCallback(const bdId *id, uint32_t status)
|
||||
{
|
||||
default:
|
||||
{
|
||||
it->second.mStatusMsg = "Unknown Peer State";
|
||||
it->second.mState = PN_PEER_STATE_UNKNOWN;
|
||||
it->second.mDhtStatusMsg = "Unknown Dht State";
|
||||
it->second.mDhtState = PN_DHT_STATE_UNKNOWN;
|
||||
}
|
||||
break;
|
||||
|
||||
case BITDHT_MGR_QUERY_FAILURE:
|
||||
{
|
||||
it->second.mStatusMsg = "Search Failed (is DHT working?)";
|
||||
it->second.mState = PN_PEER_STATE_FAILURE;
|
||||
it->second.mDhtStatusMsg = "Search Failed (is DHT working?)";
|
||||
it->second.mDhtState = PN_DHT_STATE_FAILURE;
|
||||
}
|
||||
break;
|
||||
case BITDHT_MGR_QUERY_PEER_OFFLINE:
|
||||
{
|
||||
it->second.mStatusMsg = "Peer Offline";
|
||||
it->second.mState = PN_PEER_STATE_OFFLINE;
|
||||
it->second.mDhtStatusMsg = "Peer Offline";
|
||||
it->second.mDhtState = PN_DHT_STATE_OFFLINE;
|
||||
}
|
||||
break;
|
||||
case BITDHT_MGR_QUERY_PEER_UNREACHABLE:
|
||||
{
|
||||
it->second.mStatusMsg = "Peer Unreachable";
|
||||
it->second.mState = PN_PEER_STATE_UNREACHABLE;
|
||||
it->second.mDhtStatusMsg = "Peer Unreachable";
|
||||
it->second.mDhtState = PN_DHT_STATE_UNREACHABLE;
|
||||
it->second.mDhtAddr = id->addr;
|
||||
}
|
||||
break;
|
||||
case BITDHT_MGR_QUERY_PEER_ONLINE:
|
||||
{
|
||||
it->second.mStatusMsg = "Peer Online";
|
||||
it->second.mState = PN_PEER_STATE_ONLINE;
|
||||
it->second.mDhtStatusMsg = "Peer Online";
|
||||
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);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
time_t now = time(NULL);
|
||||
it->second.mUpdateTS = now;
|
||||
it->second.mDhtUpdateTS = now;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -474,39 +630,611 @@ int PeerNet::dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bd
|
||||
std::cerr << "PeerNet::dhtConnectCallback()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* we handle MID and START/END points differently... this is biggest difference.
|
||||
* so handle first.
|
||||
*/
|
||||
|
||||
bdId peerId;
|
||||
|
||||
switch(point)
|
||||
{
|
||||
default:
|
||||
case BD_PROXY_CONNECTION_UNKNOWN_POINT:
|
||||
{
|
||||
std::cerr << "PeerNet::dhtConnectCallback() UNKNOWN point, ignoring Callback";
|
||||
std::cerr << std::endl;
|
||||
return 0;
|
||||
}
|
||||
case BD_PROXY_CONNECTION_START_POINT:
|
||||
peerId = *destId;
|
||||
break;
|
||||
case BD_PROXY_CONNECTION_END_POINT:
|
||||
peerId = *srcId;
|
||||
break;
|
||||
case BD_PROXY_CONNECTION_MID_POINT:
|
||||
{
|
||||
/* AS a mid point, we can receive.... AUTH,PENDING,PROXY,FAILED */
|
||||
|
||||
switch(cbtype)
|
||||
{
|
||||
case BITDHT_CONNECT_CB_AUTH:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Proxy Connection Requested Between:";
|
||||
std::cerr << std::endl;
|
||||
bdStdPrintId(std::cerr, srcId);
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, destId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
int connectionAllowed = 0;
|
||||
if (checkProxyAllowed(srcId, destId, mode))
|
||||
{
|
||||
connectionAllowed = 1;
|
||||
std::cerr << "dhtConnectionCallback() Connection Allowed";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Connection Denied";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
/* Push Back PeerAction */
|
||||
PeerAction ca;
|
||||
ca.mType = PEERNET_ACTION_TYPE_AUTHORISE;
|
||||
ca.mMode = mode;
|
||||
ca.mProxyId = *proxyId;
|
||||
ca.mSrcId = *srcId;
|
||||
ca.mDestId = *destId;
|
||||
ca.mPoint = point;
|
||||
ca.mAnswer = connectionAllowed;
|
||||
|
||||
mActions.push_back(ca);
|
||||
}
|
||||
break;
|
||||
case BITDHT_CONNECT_CB_PENDING:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Proxy Connection Pending:";
|
||||
std::cerr << std::endl;
|
||||
bdStdPrintId(std::cerr, srcId);
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, destId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (mode == BITDHT_CONNECT_MODE_RELAY)
|
||||
{
|
||||
installRelayConnection(srcId, destId, mode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BITDHT_CONNECT_CB_PROXY:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Proxy Connection Starting:";
|
||||
std::cerr << std::endl;
|
||||
bdStdPrintId(std::cerr, srcId);
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, destId);
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
break;
|
||||
case BITDHT_CONNECT_CB_FAILED:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Proxy Connection Failed:";
|
||||
std::cerr << std::endl;
|
||||
bdStdPrintId(std::cerr, srcId);
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, destId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (mode == BITDHT_CONNECT_MODE_RELAY)
|
||||
{
|
||||
removeRelayConnection(srcId, destId, mode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case BITDHT_CONNECT_CB_START:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() ERROR unexpected Proxy ConnectionCallback:";
|
||||
std::cerr << std::endl;
|
||||
bdStdPrintId(std::cerr, srcId);
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, destId);
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* End the MID Point stuff */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we get here, we are an endpoint (peer specified in peerId) */
|
||||
|
||||
switch(cbtype)
|
||||
{
|
||||
case BITDHT_CONNECT_CB_AUTH:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Connection Requested By: ";
|
||||
bdStdPrintId(std::cerr, &(peerId));
|
||||
std::cerr << std::endl;
|
||||
|
||||
int connectionAllowed = 0;
|
||||
if (checkConnectionAllowed(&(peerId), mode))
|
||||
{
|
||||
connectionAllowed = 1;
|
||||
std::cerr << "dhtConnectionCallback() Connection Allowed";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Connection Denied";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
/* Push Back PeerAction */
|
||||
PeerAction ca;
|
||||
ca.mType = PEERNET_ACTION_TYPE_AUTHORISE;
|
||||
ca.mMode = mode;
|
||||
ca.mProxyId = *proxyId;
|
||||
ca.mSrcId = *srcId;
|
||||
ca.mDestId = *destId;
|
||||
ca.mPoint = point;
|
||||
ca.mAnswer = connectionAllowed;
|
||||
|
||||
mActions.push_back(ca);
|
||||
}
|
||||
break;
|
||||
case BITDHT_CONNECT_CB_PENDING:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case BITDHT_CONNECT_CB_START:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Connection Starting with: ";
|
||||
bdStdPrintId(std::cerr, &(peerId));
|
||||
std::cerr << std::endl;
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
/* Push Back PeerAction */
|
||||
PeerAction ca;
|
||||
ca.mType = PEERNET_ACTION_TYPE_START;
|
||||
ca.mMode = mode;
|
||||
ca.mProxyId = *proxyId;
|
||||
ca.mSrcId = *srcId;
|
||||
ca.mDestId = *destId;
|
||||
ca.mPoint = point;
|
||||
ca.mAnswer = 1;
|
||||
|
||||
mActions.push_back(ca);
|
||||
|
||||
}
|
||||
break;
|
||||
case BITDHT_CONNECT_CB_PROXY:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case BITDHT_CONNECT_CB_FAILED:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() Connection Attempt Failed with:";
|
||||
bdStdPrintId(std::cerr, &(peerId));
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case BITDHT_CONNECT_CB_PENDING:
|
||||
case BITDHT_CONNECT_CB_PROXY:
|
||||
{
|
||||
std::cerr << "dhtConnectionCallback() ERROR unexpected Connection ConnectionCallback:";
|
||||
std::cerr << std::endl;
|
||||
bdStdPrintId(std::cerr, srcId);
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, destId);
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* tick stuff that isn't in its own thread */
|
||||
|
||||
int PeerNet::tick()
|
||||
{
|
||||
if (mDhtStunner)
|
||||
mDhtStunner->tick();
|
||||
|
||||
doActions();
|
||||
monitorConnections();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int PeerNet::doActions()
|
||||
{
|
||||
#ifdef PEERNET_DEBUG
|
||||
std::cerr << "PeerNet::doActions()" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
while(mActions.size() > 0)
|
||||
{
|
||||
PeerAction action;
|
||||
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
if (mActions.size() < 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
action = mActions.front();
|
||||
mActions.pop_front();
|
||||
}
|
||||
|
||||
switch(action.mType)
|
||||
{
|
||||
case PEERNET_ACTION_TYPE_CONNECT:
|
||||
{
|
||||
/* connect attempt */
|
||||
std::cerr << "PeerAction. Connection Attempt to: ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " mode: " << action.mMode;
|
||||
std::cerr << std::endl;
|
||||
|
||||
struct sockaddr_in laddr; // THIS CANNOT BE FILLED UNTIL STUN IS FUNCTIONAL XXX.
|
||||
sockaddr_clear(&laddr);
|
||||
mUdpBitDht->ConnectionRequest(&laddr, &(action.mDestId.id), action.mMode);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEERNET_ACTION_TYPE_AUTHORISE:
|
||||
{
|
||||
/* connect attempt */
|
||||
std::cerr << "PeerAction. Authorise Connection between: ";
|
||||
bdStdPrintId(std::cerr, &(action.mSrcId));
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " mode: " << action.mMode;
|
||||
std::cerr << std::endl;
|
||||
|
||||
mUdpBitDht->ConnectionAuth(&(action.mSrcId), &(action.mProxyId), &(action.mDestId),
|
||||
action.mMode, action.mPoint, action.mAnswer);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEERNET_ACTION_TYPE_START:
|
||||
{
|
||||
/* connect attempt */
|
||||
std::cerr << "PeerAction. Start Connection between: ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " and ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " mode: " << action.mMode;
|
||||
std::cerr << std::endl;
|
||||
|
||||
initiateConnection(&(action.mSrcId), &(action.mProxyId), &(action.mDestId),
|
||||
action.mMode, action.mPoint, action.mAnswer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************** Connection Logic ***************************/
|
||||
|
||||
/* Proxies!.
|
||||
*
|
||||
* We can allow all PROXY connections, as it is just a couple of messages,
|
||||
* however, we should be smart about how many RELAY connections are allowed.
|
||||
*
|
||||
* e.g. Allow 20 Relay connections.
|
||||
* 15 for friends, 5 for randoms.
|
||||
*
|
||||
* Can also validate addresses with own secure connections.
|
||||
*/
|
||||
|
||||
int PeerNet::checkProxyAllowed(const bdId *srcId, const bdId *destId, int mode)
|
||||
{
|
||||
std::cerr << "PeerNet::checkProxyAllowed()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
if (mode == BITDHT_CONNECT_MODE_PROXY)
|
||||
{
|
||||
std::cerr << "PeerNet::checkProxyAllowed() Allowing all PROXY connections, OKAY";
|
||||
std::cerr << std::endl;
|
||||
|
||||
return 1;
|
||||
//return CONNECTION_OKAY;
|
||||
}
|
||||
|
||||
std::cerr << "PeerNet::checkProxyAllowed() to finish RELAY connections, DENIED";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* as we haven't finished relay code yet... just deny */
|
||||
return 0;
|
||||
//return CONNECT_MODE_NOTAVAILABLE;
|
||||
//return CONNECT_MODE_OVERLOADED;
|
||||
}
|
||||
|
||||
|
||||
int PeerNet::checkConnectionAllowed(const bdId *peerId, int mode)
|
||||
{
|
||||
std::cerr << "PeerNet::checkConnectionAllowed() to: ";
|
||||
bdStdPrintId(std::cerr,peerId);
|
||||
std::cerr << " mode: " << mode;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::ostringstream str;
|
||||
bdStdPrintNodeId(str, &(peerId->id));
|
||||
std::string id = str.str();
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
time_t now = time(NULL);
|
||||
|
||||
/* check if they are in our friend list */
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(id);
|
||||
|
||||
if (it == mPeers.end())
|
||||
{
|
||||
std::cerr << "PeerNet::checkConnectionAllowed() Peer Not Friend, DENIED";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* store as failed connection attempt */
|
||||
it = mFailedPeers.find(id);
|
||||
if (it == mFailedPeers.end())
|
||||
{
|
||||
mFailedPeers[id] = PeerStatus();
|
||||
it = mFailedPeers.find(id);
|
||||
}
|
||||
|
||||
/* flag as failed */
|
||||
it->second.mId = id;
|
||||
it->second.mPeerAddr = peerId->addr;
|
||||
|
||||
it->second.mDhtStatusMsg = "Unknown";
|
||||
it->second.mDhtState = PN_DHT_STATE_UNKNOWN;
|
||||
it->second.mDhtUpdateTS = now;
|
||||
|
||||
it->second.mPeerStatusMsg = "Denied Non-Friend";
|
||||
it->second.mPeerState = PN_PEER_STATE_DENIED_NOT_FRIEND;
|
||||
it->second.mPeerUpdateTS = now;
|
||||
|
||||
return 0;
|
||||
//return NOT_FRIEND;
|
||||
}
|
||||
|
||||
/* are a friend */
|
||||
|
||||
if (it->second.mPeerState == PN_PEER_STATE_CONNECTED)
|
||||
{
|
||||
std::cerr << "PeerNet::checkConnectionAllowed() Peer Already Connected, DENIED";
|
||||
std::cerr << std::endl;
|
||||
|
||||
it->second.mPeerStatusMsg = "2nd Connection Attempt!";
|
||||
it->second.mPeerUpdateTS = now;
|
||||
return 0;
|
||||
//return ALREADY_CONNECTED;
|
||||
}
|
||||
|
||||
/* are we capable of making this type of connection? */
|
||||
if (mode == BITDHT_CONNECT_MODE_RELAY)
|
||||
{
|
||||
std::cerr << "PeerNet::checkConnectionAllowed() RELAY connection not possible, DENIED";
|
||||
std::cerr << std::endl;
|
||||
|
||||
it->second.mPeerStatusMsg = "Attempt with Unavailable Mode";
|
||||
it->second.mPeerState = PN_PEER_STATE_DENIED_UNAVAILABLE_MODE;
|
||||
it->second.mPeerUpdateTS = now;
|
||||
return 0;
|
||||
//return NOT_CAPABLE;
|
||||
}
|
||||
|
||||
it->second.mPeerAddr = peerId->addr;
|
||||
it->second.mPeerStatusMsg = "Connection Authorised";
|
||||
it->second.mPeerState = PN_PEER_STATE_CONNECTION_AUTHORISED;
|
||||
it->second.mPeerUpdateTS = now;
|
||||
|
||||
return 1;
|
||||
//return CONNECTION_OKAY;
|
||||
}
|
||||
|
||||
void PeerNet::initiateConnection(const bdId *srcId, const bdId *proxyId, const bdId *destId, uint32_t mode, uint32_t loc, uint32_t answer)
|
||||
{
|
||||
std::cerr << "PeerNet::initiateConnection()";
|
||||
std::cerr << " mode: " << mode;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::ostringstream str;
|
||||
bdStdPrintNodeId(str, &(proxyId->id));
|
||||
std::string peerId = str.str();
|
||||
|
||||
struct sockaddr_in peerAddr = proxyId->addr;
|
||||
|
||||
std::cerr << "PeerNet::initiateConnection() Connecting to ";
|
||||
bdStdPrintId(std::cerr, proxyId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
/* grab a socket */
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(peerId);
|
||||
if (it == mPeers.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* start the connection */
|
||||
int fd = tou_socket(0, 0, 0);
|
||||
it->second.mPeerFd = fd;
|
||||
|
||||
#define PEERNET_CONN_PERIOD 30
|
||||
#define PEERNET_CONNECT_TIMEOUT (60)
|
||||
|
||||
tou_connect(fd, (const struct sockaddr *) (&peerAddr), sizeof(peerAddr), PEERNET_CONN_PERIOD);
|
||||
|
||||
/* store results in Status */
|
||||
it->second.mPeerStatusMsg = "UDP started";
|
||||
it->second.mPeerState = PN_PEER_STATE_UDP_STARTED;
|
||||
it->second.mPeerConnTS = time(NULL);
|
||||
}
|
||||
|
||||
|
||||
void PeerNet::installRelayConnection(const bdId *srcId, const bdId *destId, int mode)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
/* these todo */
|
||||
std::cerr << "PeerNet::installRelayConnection() TODO";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void PeerNet::removeRelayConnection(const bdId *srcId, const bdId *destId, int mode)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
/* these shouldn't do anything yet */
|
||||
std::cerr << "PeerNet::removeRelayConnection() TODO";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
/***************************************************** UDP Connections *****************************/
|
||||
|
||||
void PeerNet::monitorConnections()
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
std::map<std::string, PeerStatus>::iterator it;
|
||||
time_t now = time(NULL);
|
||||
for(it = mPeers.begin(); it != mPeers.end(); it++)
|
||||
{
|
||||
if (it->second.mPeerState == PN_PEER_STATE_UDP_STARTED)
|
||||
{
|
||||
std::cerr << "PeerNet::monitorConnections() Connection in progress to: " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
int fd = it->second.mPeerFd;
|
||||
if (tou_connected(fd))
|
||||
{
|
||||
std::cerr << "PeerNet::monitorConnections() InProgress Connection Now Active: " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* switch state! */
|
||||
it->second.mPeerState = PN_PEER_STATE_CONNECTED;
|
||||
it->second.mPeerStatusMsg = "Connected!";
|
||||
}
|
||||
else if (now - it->second.mPeerConnTS > PEERNET_CONNECT_TIMEOUT)
|
||||
{
|
||||
std::cerr << "PeerNet::monitorConnections() InProgress Connection Failed: " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* shut id down */
|
||||
it->second.mPeerState = PN_PEER_STATE_UDP_FAILED;
|
||||
it->second.mPeerStatusMsg = "UDP Failed";
|
||||
tou_close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
if (it->second.mPeerState == PN_PEER_STATE_CONNECTED)
|
||||
{
|
||||
/* fd should be valid, check it */
|
||||
int fd = it->second.mPeerFd;
|
||||
if (tou_connected(fd))
|
||||
{
|
||||
/* check for traffic */
|
||||
char buf[10240];
|
||||
memset(buf, 0, 10240); /* install \0 everywhere */
|
||||
int read = tou_read(fd, buf, 10240);
|
||||
if (read > 0)
|
||||
{
|
||||
it->second.mPeerIncoming += std::string(buf);
|
||||
std::cerr << "PeerNet::monitorConnections() Read from Connection: " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "PeerNet::monitorConnections() Active Connection Closed: " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
it->second.mPeerState = PN_PEER_STATE_UDP_CLOSED;
|
||||
it->second.mPeerStatusMsg = "Connection Closed";
|
||||
tou_close(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PeerNet::sendMessage(std::string msg)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::cerr << "PeerNet::sendMessage() : " << msg;
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it;
|
||||
for(it = mPeers.begin(); it != mPeers.end(); it++)
|
||||
{
|
||||
if (it->second.mPeerState == PN_PEER_STATE_CONNECTED)
|
||||
{
|
||||
/* fd should be valid, check it */
|
||||
int fd = it->second.mPeerFd;
|
||||
if (tou_connected(fd))
|
||||
{
|
||||
int written = tou_write(fd, msg.c_str(), msg.size());
|
||||
if (written != msg.size())
|
||||
{
|
||||
/* */
|
||||
std::cerr << "PeerNet::sendMessage() ERROR Sending to " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "PeerNet::sendMessage() Sent to " << it->second.mId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int PeerNet::getMessage(std::string id, std::string &msg)
|
||||
{
|
||||
bdStackMutex stack(mPeerMutex); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::map<std::string, PeerStatus>::iterator it = mPeers.find(id);
|
||||
if (it != mPeers.end())
|
||||
{
|
||||
if (it->second.mPeerIncoming.size() > 0)
|
||||
{
|
||||
msg = it->second.mPeerIncoming;
|
||||
it->second.mPeerIncoming.clear();
|
||||
|
||||
std::cerr << "PeerNet::getMessage() : " << msg;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -12,6 +12,27 @@
|
||||
|
||||
#include "bitdht/bdstddht.h"
|
||||
|
||||
#include "tcponudp/udpstunner.h"
|
||||
|
||||
#define PN_DHT_STATE_UNKNOWN 0
|
||||
#define PN_DHT_STATE_SEARCHING 1
|
||||
#define PN_DHT_STATE_FAILURE 2
|
||||
#define PN_DHT_STATE_OFFLINE 3
|
||||
#define PN_DHT_STATE_UNREACHABLE 4
|
||||
#define PN_DHT_STATE_ONLINE 5
|
||||
|
||||
#define PN_PEER_STATE_DISCONNECTED 1
|
||||
#define PN_PEER_STATE_DENIED_NOT_FRIEND 2
|
||||
#define PN_PEER_STATE_DENIED_UNAVAILABLE_MODE 3
|
||||
#define PN_PEER_STATE_DENIED_OVERLOADED_MODE 4
|
||||
#define PN_PEER_STATE_UDP_FAILED 5
|
||||
#define PN_PEER_STATE_UDP_CLOSED 6
|
||||
|
||||
#define PN_PEER_STATE_CONNECTION_INITIATED 7
|
||||
#define PN_PEER_STATE_CONNECTION_AUTHORISED 8
|
||||
#define PN_PEER_STATE_UDP_STARTED 9
|
||||
#define PN_PEER_STATE_CONNECTED 10
|
||||
|
||||
class DhtPeer
|
||||
{
|
||||
public:
|
||||
@ -22,9 +43,40 @@ class PeerStatus
|
||||
{
|
||||
public:
|
||||
std::string mId;
|
||||
std::string mStatusMsg;
|
||||
uint32_t mState;
|
||||
time_t mUpdateTS;
|
||||
|
||||
/* DHT Status */
|
||||
std::string mDhtStatusMsg;
|
||||
uint32_t mDhtState;
|
||||
struct sockaddr_in mDhtAddr;
|
||||
time_t mDhtUpdateTS;
|
||||
|
||||
/* Connection Status */
|
||||
std::string mPeerStatusMsg;
|
||||
uint32_t mPeerState;
|
||||
struct sockaddr_in mPeerAddr;
|
||||
time_t mPeerUpdateTS;
|
||||
|
||||
int mPeerFd;
|
||||
time_t mPeerConnTS;
|
||||
std::string mPeerIncoming;
|
||||
};
|
||||
|
||||
|
||||
#define PEERNET_ACTION_TYPE_CONNECT 1
|
||||
#define PEERNET_ACTION_TYPE_AUTHORISE 2
|
||||
#define PEERNET_ACTION_TYPE_START 3
|
||||
|
||||
class PeerAction
|
||||
{
|
||||
public:
|
||||
|
||||
uint32_t mType;
|
||||
bdId mSrcId;
|
||||
bdId mProxyId;
|
||||
bdId mDestId;
|
||||
uint32_t mMode;
|
||||
uint32_t mPoint;
|
||||
uint32_t mAnswer;
|
||||
};
|
||||
|
||||
|
||||
@ -32,14 +84,15 @@ class PeerNet: public BitDhtCallback
|
||||
{
|
||||
public:
|
||||
PeerNet(std::string id, std::string bootstrapfile, uint16_t port);
|
||||
/* GUI interface */
|
||||
|
||||
void setUdpStackRestrictions(std::list<std::pair<uint16_t, uint16_t> > &restrictions);
|
||||
void init();
|
||||
|
||||
int getOwnId(bdNodeId *id);
|
||||
|
||||
int add_peer(std::string id);
|
||||
int remove_peer(std::string id);
|
||||
|
||||
|
||||
std::string getPeerStatusString();
|
||||
std::string getDhtStatusString();
|
||||
int get_dht_peers(int lvl, bdBucket &peers);
|
||||
@ -47,6 +100,9 @@ class PeerNet: public BitDhtCallback
|
||||
int get_net_peers(std::list<std::string> &peerIds);
|
||||
int get_peer_status(std::string peerId, PeerStatus &status);
|
||||
|
||||
int get_net_failedpeers(std::list<std::string> &peerIds);
|
||||
int get_failedpeer_status(std::string peerId, PeerStatus &status);
|
||||
|
||||
/* remember peers */
|
||||
int storePeers(std::string filepath);
|
||||
int loadPeers(std::string filepath);
|
||||
@ -55,7 +111,11 @@ class PeerNet: public BitDhtCallback
|
||||
int loadConfig(std::string filepath);
|
||||
/* under the hood */
|
||||
|
||||
int tick();
|
||||
int doActions();
|
||||
|
||||
void sendMessage(std::string msg);
|
||||
int getMessage(std::string id, std::string &msg);
|
||||
|
||||
/**** dht Callback ****/
|
||||
// dummy cos not needed for standard dht behaviour;
|
||||
@ -70,19 +130,48 @@ virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdI
|
||||
uint32_t mode, uint32_t point, uint32_t cbtype);
|
||||
|
||||
|
||||
/**** Connection Handling ******/
|
||||
void monitorConnections();
|
||||
|
||||
void removeRelayConnection(const bdId *srcId, const bdId *destId, int mode);
|
||||
void installRelayConnection(const bdId *srcId, const bdId *destId, int mode);
|
||||
void initiateConnection(const bdId *srcId, const bdId *proxyId, const bdId *destId,
|
||||
uint32_t mode, uint32_t loc, uint32_t answer);
|
||||
|
||||
int checkConnectionAllowed(const bdId *peerId, int mode);
|
||||
int checkProxyAllowed(const bdId *srcId, const bdId *destId, int mode);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
UdpStack *mUdpStack;
|
||||
UdpBitDht *mUdpBitDht;
|
||||
|
||||
std::map<std::string, PeerStatus> mPeers;
|
||||
UdpStunner *mDhtStunner;
|
||||
//UdpStunner *mSyncStunner;
|
||||
|
||||
|
||||
bdNodeId mOwnId;
|
||||
|
||||
std::string mPeersFile;
|
||||
std::string mConfigFile;
|
||||
std::string mBootstrapFile;
|
||||
|
||||
uint16_t mPort;
|
||||
|
||||
/* port restrictions */
|
||||
bool mDoUdpStackRestrictions;
|
||||
std::list<std::pair<uint16_t, uint16_t> > mUdpStackRestrictions;
|
||||
|
||||
|
||||
/* below here must be mutex protected */
|
||||
bdMutex mPeerMutex;
|
||||
|
||||
std::map<std::string, PeerStatus> mPeers;
|
||||
std::map<std::string, PeerStatus> mFailedPeers; /* peers that have tried to connect to us */
|
||||
|
||||
/* Connection Action Queue */
|
||||
std::list<PeerAction> mActions;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user