forked from I2P_Developers/i2p.i2p
Compare commits
732 Commits
Author | SHA1 | Date | |
---|---|---|---|
0ddef91e16 | |||
b205af5a0d | |||
f446a5f1fc | |||
1cd54dc12e | |||
8ebc8bd209 | |||
![]() |
9d11866f86 | ||
![]() |
23d3c33a12 | ||
![]() |
ec8130f443 | ||
![]() |
4b7aeb8418 | ||
![]() |
18a0f01f8b | ||
![]() |
df2e639692 | ||
708b3a662c | |||
4fee7844f8 | |||
![]() |
891416e6b9 | ||
![]() |
978cd2c484 | ||
![]() |
c88c905926 | ||
f5c1acc749 | |||
c4e6148b9f | |||
43029de2f3 | |||
![]() |
454b2c8941 | ||
4c812c7bff | |||
f95b5324e0 | |||
64ee1b313b | |||
1ca651e803 | |||
f3a88398f2 | |||
![]() |
278b917494 | ||
![]() |
0642fa8093 | ||
![]() |
6371f66677 | ||
105524d9c0 | |||
95e0492b32 | |||
234c084c2a | |||
94faf74aa4 | |||
e78dd1fdc3 | |||
38045d876d | |||
8433724452 | |||
e9f9e0dabb | |||
6bdf750c19 | |||
647a09b5b9 | |||
6144bfb437 | |||
88dbd7710a | |||
26a71232f0 | |||
f58a1768b9 | |||
![]() |
125e6581e0 | ||
![]() |
54105086ad | ||
![]() |
3674ac2922 | ||
![]() |
18c023e6f7 | ||
312ba2599f | |||
746dc6f884 | |||
edd4d4c114 | |||
56e0c3e047 | |||
![]() |
1e83d1b304 | ||
![]() |
74aa84b183 | ||
![]() |
168c213288 | ||
![]() |
d268a3852c | ||
![]() |
01e87438c3 | ||
![]() |
060f4e6632 | ||
![]() |
3df5540a97 | ||
![]() |
30dec5b9f5 | ||
![]() |
43b437fc58 | ||
8e889cd292 | |||
eceac6def0 | |||
1e3d6776aa | |||
784ca67ddf | |||
![]() |
0f6b49cc31 | ||
![]() |
8cede2a2b2 | ||
![]() |
38ed04bbd8 | ||
c393e70ca9 | |||
1c25c0f408 | |||
![]() |
b7ebce48ee | ||
![]() |
d6814a0489 | ||
![]() |
6f24c74f8c | ||
![]() |
d8389dcc46 | ||
![]() |
9f939553ee | ||
![]() |
529988f394 | ||
![]() |
9f46aa1e18 | ||
![]() |
418c1b6f96 | ||
![]() |
8056fb9502 | ||
![]() |
ab2e21147f | ||
6c00bb20b6 | |||
573ac357d8 | |||
![]() |
5b139f9246 | ||
![]() |
76d75b712e | ||
8bc2fd7e42 | |||
4533a86712 | |||
a6239e2ce3 | |||
1f8e61f480 | |||
c40f845279 | |||
aa74962263 | |||
42cbd6c12b | |||
ee51f69a5a | |||
![]() |
0fb6e9cf6c | ||
e02845076d | |||
2dc3798116 | |||
![]() |
fa252f5e8f | ||
![]() |
580b9b450f | ||
![]() |
f0730cd1c8 | ||
b045fb3a45 | |||
![]() |
6c64111d7e | ||
37a2ccca95 | |||
b4615edfcc | |||
6019cf8148 | |||
e3d945201b | |||
05b17e5a00 | |||
![]() |
13b3edfb07 | ||
![]() |
f61372b2fd | ||
![]() |
f85d8f7060 | ||
a0b4b7db86 | |||
![]() |
827a92ef2f | ||
![]() |
625d76b914 | ||
![]() |
a1de894b64 | ||
413ab6d7e4 | |||
a3b1c79006 | |||
5a7d3ba4c8 | |||
8a1db31184 | |||
![]() |
5190b2db1f | ||
820c573476 | |||
ab40454bce | |||
![]() |
b65865b854 | ||
a5772e62c3 | |||
9976bea03f | |||
7997aeaca5 | |||
ba95084d27 | |||
e952e91b54 | |||
da21c0ddb7 | |||
0133711c3b | |||
![]() |
6eae2cd460 | ||
![]() |
9314eebc4f | ||
428cbdce2a | |||
![]() |
7594c4383b | ||
![]() |
e2f6911e9f | ||
9cdae03069 | |||
![]() |
06946f026e | ||
![]() |
d43dac5c04 | ||
b4d83b18fa | |||
![]() |
f9424dbd6d | ||
e5212937af | |||
aeb6635e71 | |||
e94b478317 | |||
![]() |
88216de42c | ||
![]() |
1fcf707bb2 | ||
![]() |
5101486fe7 | ||
![]() |
7ae4d0e981 | ||
![]() |
c644c128c0 | ||
![]() |
2603f6fe45 | ||
![]() |
957a296ca9 | ||
![]() |
e4f44fa1e9 | ||
![]() |
2b469567bb | ||
a2d90eebea | |||
850a8da0a9 | |||
ac6d711a99 | |||
5aa254a178 | |||
![]() |
ad396adf39 | ||
![]() |
05cce164f7 | ||
![]() |
935b69bc71 | ||
![]() |
61f800999a | ||
![]() |
9833743eb9 | ||
![]() |
ac65bc7302 | ||
![]() |
b36f207bb2 | ||
![]() |
e87a7c7bb4 | ||
![]() |
7e5128bb85 | ||
![]() |
0a178ec35e | ||
a5cd0bdd3f | |||
9cbf9d0422 | |||
![]() |
097a05aab9 | ||
![]() |
0e5b2598fb | ||
![]() |
4f492e33e6 | ||
![]() |
1828b2bd17 | ||
0c74e640df | |||
ffd2721627 | |||
f6ce4cb29f | |||
4863ef3360 | |||
![]() |
9f7807ee10 | ||
![]() |
b2285b0beb | ||
![]() |
8e4f4f82a8 | ||
![]() |
db2158d4c1 | ||
![]() |
1c461bbeda | ||
![]() |
0757f4f309 | ||
![]() |
a2f287cdfe | ||
![]() |
1ef448d518 | ||
![]() |
f44b1a35bc | ||
26f02a4771 | |||
dc3c730937 | |||
77d45e7a3a | |||
45a59f009b | |||
dc6d6ead69 | |||
27693826a2 | |||
8a647b42d5 | |||
eba9f3c03b | |||
eacf46b367 | |||
83cacaad05 | |||
cf10451d14 | |||
![]() |
44069645df | ||
4497463778 | |||
10b84418c3 | |||
![]() |
fadda4ceec | ||
011a32f741 | |||
![]() |
10bb3c100e | ||
![]() |
2738d5851d | ||
219095404a | |||
001c361338 | |||
e21a172e95 | |||
![]() |
4651b7007b | ||
![]() |
5b4be5ba1b | ||
![]() |
9c2c90c0b1 | ||
bdd0c3f961 | |||
b7013361c2 | |||
f73b3e522b | |||
fa6d17a1b8 | |||
![]() |
c3e646ca22 | ||
fdc9e11fb4 | |||
a1ec838282 | |||
7da46517ae | |||
d8e2939307 | |||
8cad72c654 | |||
![]() |
2cfc2bb60d | ||
![]() |
1811e3b9cd | ||
960cd18d0a | |||
405b85c4b4 | |||
![]() |
92e323df51 | ||
![]() |
3f2c34903d | ||
3c260aa333 | |||
da41f3a93b | |||
aeb711acde | |||
![]() |
a46ee9a5b2 | ||
088f9558ec | |||
376d61c155 | |||
285a2b92e5 | |||
![]() |
8939c573ea | ||
![]() |
3839d9873a | ||
116762ebce | |||
7dd8f00e95 | |||
![]() |
29a3db4b5c | ||
![]() |
5d95907996 | ||
![]() |
2f940d01b6 | ||
![]() |
517e170b88 | ||
![]() |
b27fbb9b8e | ||
9b97d32ea8 | |||
d4f3952a90 | |||
![]() |
f7840652ed | ||
![]() |
08634c1ff6 | ||
![]() |
dec4205890 | ||
![]() |
b49ab59e3b | ||
![]() |
7e1171ec9f | ||
![]() |
3eae787957 | ||
![]() |
9ecba4fc5e | ||
![]() |
4fb9eef198 | ||
![]() |
49ecfd8224 | ||
![]() |
09a2854b8b | ||
![]() |
82976e609f | ||
![]() |
b2d6b60300 | ||
90737493e6 | |||
fe3abc79d6 | |||
9931112387 | |||
1cd646afe2 | |||
0d262d28b7 | |||
f33e950780 | |||
7094489536 | |||
2dd650df01 | |||
![]() |
7e8037979f | ||
3a1c042cd2 | |||
ca81c35b3d | |||
6a2dfff34d | |||
![]() |
5eccc01de6 | ||
![]() |
1850e893e9 | ||
![]() |
2341793546 | ||
1f1d089fda | |||
5372a50bcc | |||
83588d9b98 | |||
58e960ceb5 | |||
de07705671 | |||
![]() |
49ff3cfbf3 | ||
e392469835 | |||
7745bd89a9 | |||
01bed932c7 | |||
157190757b | |||
e0f1047d72 | |||
15f0cda41f | |||
9a95122c7c | |||
d868f7c02a | |||
5ca2f306b8 | |||
c714c1a0c9 | |||
e6e6c00497 | |||
62a3da2fa6 | |||
![]() |
f1f97e8ec5 | ||
![]() |
6c361679c6 | ||
![]() |
ae89d2f2ab | ||
8053fb5eae | |||
ebf5eb6e20 | |||
2e2bff3f0a | |||
a3f290e4d8 | |||
e0dd1f13e3 | |||
787def6a1c | |||
1f5d7d7b5b | |||
4bc5215833 | |||
7736545f5b | |||
1ecf4377c6 | |||
593d4dc508 | |||
93d366fea1 | |||
7973f2e8b9 | |||
bb14fa0b4e | |||
95aba0c537 | |||
df4143f036 | |||
![]() |
ed0575e937 | ||
456ed0aab4 | |||
47c8389419 | |||
51fd4d70da | |||
79e32231fb | |||
80f9f857e5 | |||
5a4c2de425 | |||
7e547743c7 | |||
3f3d43df41 | |||
![]() |
0cc72a49c8 | ||
35c9e99914 | |||
![]() |
2e4bd1e440 | ||
22c0b8e524 | |||
faeb58f7e2 | |||
cdc184c5e5 | |||
![]() |
2f9a4f0fa5 | ||
37437da34d | |||
6d3a5856b4 | |||
![]() |
4d4538a346 | ||
327102a254 | |||
3602eb14f5 | |||
![]() |
cf82b51a1f | ||
![]() |
412d3bc2f8 | ||
![]() |
4735508a0a | ||
9225d01b29 | |||
7782970d51 | |||
6f053287d5 | |||
![]() |
7a88f59f08 | ||
![]() |
d56aae8913 | ||
![]() |
a309a14396 | ||
![]() |
b80cbbdd4a | ||
5bc2dab1d2 | |||
![]() |
8bbe7fabb3 | ||
c537d160a6 | |||
475187fcbc | |||
a379e36e24 | |||
a9054a3cab | |||
![]() |
ea7a9c259f | ||
![]() |
2cba48d4d7 | ||
![]() |
42b79c5a20 | ||
be9523f1e4 | |||
![]() |
6a8dd0f053 | ||
![]() |
1b63aa411b | ||
![]() |
33a7f3351b | ||
![]() |
f7af5e1329 | ||
![]() |
3a9a029d70 | ||
![]() |
0aaacc86e2 | ||
![]() |
1b8b7b741c | ||
66831c619b | |||
30628fb5f9 | |||
![]() |
064ff8a7d2 | ||
![]() |
9a18955de3 | ||
![]() |
35da3f3334 | ||
![]() |
335d45f03e | ||
![]() |
c466cd77ad | ||
![]() |
d998e2e9bb | ||
0a20315280 | |||
01753f5aea | |||
bcd22cfbf3 | |||
7e039d0339 | |||
ab08ac70aa | |||
5decf3cd7a | |||
5c6d757e35 | |||
4b75be804f | |||
6515e6ee17 | |||
55e8583663 | |||
![]() |
3fbff71861 | ||
![]() |
e5eea47b66 | ||
b10b0e8f57 | |||
631a367b1c | |||
8ea279fbe2 | |||
089572befd | |||
0f96b9569a | |||
d1114666de | |||
![]() |
f676abc0d4 | ||
![]() |
3492b7219b | ||
![]() |
a12ae6e399 | ||
9b2e18a65b | |||
c52ccf7eef | |||
1282434684 | |||
4e844187f7 | |||
ccd67d658d | |||
62383819cb | |||
3febcf6043 | |||
a431137f45 | |||
![]() |
5a6e14b9df | ||
536bc3112f | |||
![]() |
81b2e6b789 | ||
4cf376ec1d | |||
d3a0c91398 | |||
![]() |
43140d3efd | ||
3dd3bf829d | |||
bdcad06ece | |||
69fdfb0635 | |||
55a8002b9c | |||
![]() |
e36f9b2273 | ||
70ae99f31a | |||
15565ca09c | |||
f188e02a5d | |||
4d005349a7 | |||
c65a97882e | |||
cf880548d9 | |||
b5876e7f04 | |||
![]() |
2436ea1131 | ||
![]() |
5395b6829a | ||
c3af134a5b | |||
![]() |
cce72a5f1b | ||
![]() |
32c143f8d7 | ||
![]() |
895cb1f2e5 | ||
7986f5646e | |||
![]() |
59a5776f9d | ||
![]() |
fc8c0ccfe1 | ||
![]() |
0930ead814 | ||
b5a17637cb | |||
![]() |
460c8a319f | ||
7aa051ef4f | |||
![]() |
c7c132c0ac | ||
d84b1125eb | |||
8d4a1899f2 | |||
![]() |
3a0cdf1388 | ||
d8d76fd327 | |||
![]() |
abf7296de1 | ||
316c20ee44 | |||
13e8c95667 | |||
a14ad423a6 | |||
e1a5d5e19a | |||
![]() |
6e29eddaa7 | ||
![]() |
65ae26a961 | ||
![]() |
1afd946a94 | ||
![]() |
d6820634ac | ||
![]() |
95dd744633 | ||
![]() |
219af36090 | ||
![]() |
24e83398ba | ||
4172ed21a9 | |||
1cba7b8ec1 | |||
0bef85277e | |||
![]() |
2f4c428316 | ||
![]() |
4de0b73cd8 | ||
7ffb3f46b5 | |||
ad6cd05295 | |||
![]() |
6e7ad3ecdb | ||
![]() |
a6243d14c0 | ||
![]() |
b0a477c5ca | ||
![]() |
1d655c7abc | ||
![]() |
abf2bead33 | ||
![]() |
f1103bec7b | ||
![]() |
fb1a6534dc | ||
22b1d5fe75 | |||
d2c939bc09 | |||
![]() |
73f8cb4819 | ||
256bb771e1 | |||
cc533b0431 | |||
![]() |
3c76fda8d9 | ||
![]() |
c5555350ae | ||
![]() |
22744084dc | ||
![]() |
e4b212ec90 | ||
![]() |
4be0af5de5 | ||
d771745981 | |||
![]() |
7628842b0a | ||
![]() |
6bcdb7fd92 | ||
27561fb632 | |||
f6ec3f66f8 | |||
2f0b9a8f94 | |||
![]() |
3fb1a4ebc5 | ||
![]() |
9abb0a1581 | ||
![]() |
e60e29b70f | ||
![]() |
d84352896f | ||
![]() |
ee419454f4 | ||
![]() |
68445fe195 | ||
![]() |
12b2d4c00b | ||
![]() |
fbb4d3a636 | ||
![]() |
ca415376c7 | ||
![]() |
718f73ebb1 | ||
![]() |
fb47eef218 | ||
![]() |
87dd473148 | ||
![]() |
9bbbccee1a | ||
![]() |
0088750b16 | ||
![]() |
0aae2deb58 | ||
![]() |
0d62b37c13 | ||
![]() |
64ece1080c | ||
![]() |
b4256e484a | ||
![]() |
b0ea204be5 | ||
![]() |
118d7fce09 | ||
5e498e0bd6 | |||
c312fa869b | |||
![]() |
fe394b0b46 | ||
6039f3931d | |||
71d72b426f | |||
7d5042c507 | |||
e2b0e14771 | |||
![]() |
0e9bfba84d | ||
![]() |
99f53413a6 | ||
![]() |
f46600d7fe | ||
![]() |
0607a87514 | ||
1658690b97 | |||
eae0f3273b | |||
508beb2fc7 | |||
![]() |
0de2f492d1 | ||
72a7393844 | |||
99f8468f63 | |||
a9e8fc2f1f | |||
e225244887 | |||
cbde15b00f | |||
8e38047d43 | |||
dc1d0195eb | |||
7d7f264bc0 | |||
b3c30b4fd2 | |||
6c87005eeb | |||
8d2a516044 | |||
dc0cc49dbf | |||
![]() |
497bc5a414 | ||
![]() |
2a71baef90 | ||
![]() |
49a74e8610 | ||
![]() |
6340fbb3d4 | ||
![]() |
748203f4e7 | ||
![]() |
a91cc94228 | ||
029ac71e58 | |||
![]() |
e830b46173 | ||
![]() |
a4d053f555 | ||
![]() |
b298796060 | ||
![]() |
895490df3d | ||
![]() |
a09c06849b | ||
![]() |
37c494bf0a | ||
![]() |
d6fccc07be | ||
![]() |
819efc132b | ||
![]() |
8ffdae4182 | ||
efd6dcc8df | |||
70a17ecfaf | |||
![]() |
15dbf67983 | ||
![]() |
a43df30051 | ||
![]() |
1bff5a7b9e | ||
![]() |
ec49d9becf | ||
bc49f51dbb | |||
![]() |
b869860a83 | ||
![]() |
2772a0e5e4 | ||
![]() |
46970f5a4a | ||
![]() |
ccf9cd3f71 | ||
![]() |
b9c464f8cb | ||
![]() |
48510c1157 | ||
![]() |
3035fcf080 | ||
![]() |
930f402eb9 | ||
![]() |
4e93191312 | ||
9bc4f6bacb | |||
![]() |
9b42129fea | ||
![]() |
0650137e32 | ||
![]() |
a13e528972 | ||
![]() |
82f8dd5635 | ||
![]() |
7f93cb22ce | ||
![]() |
e6738053b2 | ||
![]() |
b74ab51438 | ||
![]() |
d7a591ce3a | ||
![]() |
cfe33a8bbd | ||
![]() |
ca7593cdf2 | ||
![]() |
b185d11daf | ||
![]() |
5106c37ac4 | ||
![]() |
5d40ad1749 | ||
![]() |
24edce3daf | ||
![]() |
cfd1ab7d78 | ||
![]() |
bfaa648edd | ||
![]() |
fd19210bce | ||
![]() |
9a3b103324 | ||
0ee5c905e4 | |||
5f22a226cc | |||
![]() |
56b3144c56 | ||
![]() |
dad4bef70c | ||
![]() |
13a04dba71 | ||
![]() |
ab66dfcb65 | ||
![]() |
ab349a5303 | ||
53a68ff5a3 | |||
29f13868b7 | |||
8ce71d724c | |||
![]() |
e3de3dcc1d | ||
![]() |
fa6a6fa4ef | ||
![]() |
e78e4c93c0 | ||
![]() |
0173f5877b | ||
![]() |
32e829da74 | ||
![]() |
68e81fa8c8 | ||
![]() |
9f84d13542 | ||
![]() |
48f591eea8 | ||
![]() |
cb6dce4e03 | ||
![]() |
e5e7f01e84 | ||
![]() |
f90a320d95 | ||
![]() |
96c94a294e | ||
![]() |
ab81887138 | ||
![]() |
d13e3d95d3 | ||
![]() |
64f1fe0b51 | ||
![]() |
0a77f88229 | ||
![]() |
12d34a50ff | ||
92daa920d2 | |||
![]() |
091d03b9d8 | ||
![]() |
f7ee11cb44 | ||
6226b8ae6d | |||
a6a61421d9 | |||
5c20574044 | |||
aca006253a | |||
7a752cc7a2 | |||
de7dc2c1f7 | |||
![]() |
35b5bf187e | ||
![]() |
efbc4c5184 | ||
![]() |
711c2b7dfd | ||
![]() |
a4adb4709b | ||
![]() |
7121b5fa31 | ||
c944648b99 | |||
![]() |
45cdd556c7 | ||
429bd0a4e3 | |||
135f8c1be2 | |||
![]() |
7b7a590e21 | ||
![]() |
95728ef29f | ||
![]() |
021b44724e | ||
![]() |
ba0efe64c7 | ||
1a247d8d3a | |||
21b03e8e8a | |||
03790e3e4d | |||
9af239aa65 | |||
02fc700ac0 | |||
1fb5238642 | |||
461af7d0a2 | |||
cf3efc11ba | |||
b6e24b5094 | |||
0b590763f3 | |||
![]() |
3cc4ee7199 | ||
![]() |
4828cd2f16 | ||
![]() |
45da7e8704 | ||
![]() |
e00b88ca32 | ||
![]() |
e497680ca8 | ||
![]() |
dbb9eefe70 | ||
![]() |
7388fdf820 | ||
![]() |
0c46d561ec | ||
![]() |
4248ab936c | ||
e5139113b1 | |||
0f1a4ad4cd | |||
![]() |
00d99fb1a9 | ||
![]() |
ee8dc4af2d | ||
![]() |
d7b4be1e74 | ||
![]() |
7ed509b76a | ||
![]() |
c616f66e83 | ||
![]() |
e8bfac27aa | ||
![]() |
df3b3bfc8f | ||
![]() |
ac358502ce | ||
![]() |
2b905d2ed5 | ||
![]() |
49c55ae12a | ||
![]() |
d280d7a389 | ||
![]() |
19ccdcd951 | ||
![]() |
cac9b2e1f1 | ||
![]() |
e0e42a0f87 | ||
![]() |
1d845dab03 | ||
![]() |
71b9bb67a6 | ||
![]() |
06be251032 | ||
![]() |
454a6ab177 | ||
![]() |
1e1c3cdff0 | ||
![]() |
52de5e569c | ||
![]() |
2f97942286 | ||
![]() |
4b1eabf1fc | ||
![]() |
6c7f1cbf8a | ||
![]() |
ffc582093b | ||
![]() |
cc833f3ca4 | ||
![]() |
00d0aa7830 | ||
![]() |
54f649a4b4 | ||
![]() |
1c2cd4dcb2 | ||
43d6851199 | |||
9527684cf7 | |||
1965815d7d | |||
cc2be105a6 | |||
e4c599b756 | |||
a8a21ddb73 | |||
![]() |
942c31621b | ||
ca14002bd1 | |||
5eec098e2b | |||
![]() |
37043195ba | ||
![]() |
ab8e2cf34d | ||
![]() |
882e08fc4f | ||
2e5caac8bf | |||
714fe82d2f | |||
1724e5b499 | |||
a5fa6acf5d | |||
59105a9ad6 | |||
abc23e9a49 | |||
72071566e7 | |||
055cd99dde | |||
d2c52e5c94 | |||
![]() |
c7541f819a | ||
7972c0c862 | |||
3fee5a3781 | |||
db45e74fcc | |||
206e45b9e8 | |||
a9345953f3 | |||
eb324d7652 | |||
85adfc40fb | |||
f1bb8910cb | |||
8ca794dc57 | |||
fe3cd65c62 | |||
256c5356fb | |||
0bc6fd246f | |||
77ce768cb4 | |||
b23256dc4e | |||
5906fb7139 | |||
0606050231 | |||
47cd9beefa | |||
a87f8e8687 | |||
978de73351 | |||
a1ec01ec2d | |||
7aa9949332 | |||
71f3cd648f | |||
7f379027ca | |||
279f3e4934 | |||
bdd75793bc | |||
58660bed3c | |||
2ca0ae7529 | |||
3ee09df6ce | |||
9b866b8e06 | |||
4d4954c5b8 | |||
17751ffd57 | |||
e8773f6a98 | |||
112ddc7156 | |||
e5ec72b09b | |||
24daf00616 | |||
718375419e | |||
a16bcf8e51 | |||
5c28125350 | |||
937de87dbf | |||
cadbe2c2c0 | |||
290af4c187 | |||
fd4e57aafc | |||
524a25eb2c | |||
5022575429 | |||
b8f22bf3bf | |||
5a8b3eb8f3 | |||
d26ac84126 | |||
82045b3fde | |||
14ce5a2432 |
@@ -3,9 +3,10 @@ Headless I2P installation instructions
|
||||
1) java -jar i2pinstall.exe -console (you've already done this)
|
||||
|
||||
This will run the installer in text mode, including running the postinstall.sh
|
||||
script, which will start the router and launch a browser.
|
||||
script. After that, you may run 'sh i2prouter start'
|
||||
which will start the router and attempt to launch a browser.
|
||||
|
||||
If you do not have an X server running, the browser launch will fail, and
|
||||
If you do not have an X server running, the browser launch will probably fail, and
|
||||
you may use:
|
||||
lynx http://localhost:7657/index.jsp
|
||||
to configure the router.
|
||||
@@ -13,6 +14,16 @@ to configure the router.
|
||||
If you're having trouble, swing by http://forum.i2p2.de/, check the
|
||||
website at http://www.i2p2.de/, or get on irc://irc.freenode.net/#i2p
|
||||
|
||||
I2P will create and store files and configuration data in the user directory
|
||||
~/.i2p/ on Linux and %APPDATA%\I2P\ on Windows. This directory is created
|
||||
when I2P is run for the first time. It also creates files in the system
|
||||
temporary directory specified by the Java Virtual Machine.
|
||||
To change the location of these directories, or to configure I2P to
|
||||
put all files in this directory (the so-called "portable" configuration),
|
||||
edit the files i2prouter (Linux) and wrapper.config (Linux and Windows)
|
||||
where there are comments labeled "PORTABLE". Do this before you
|
||||
run I2P for the first time.
|
||||
|
||||
To run I2P explicitly:
|
||||
(*nix): sh i2prouter start
|
||||
(win*): I2P.exe
|
||||
|
@@ -76,9 +76,6 @@ Public domain except as listed below:
|
||||
Copyright (C) 2003-2006 Satoshi Konno
|
||||
See licenses/LICENSE-UPnP.txt
|
||||
|
||||
XMLPull library used by UPnP:
|
||||
See licenses/LICENSE-Apache2.0.txt
|
||||
|
||||
GeoIP data free to use, courtesy http://ip-to-country.webhosting.info/
|
||||
|
||||
|
||||
@@ -177,7 +174,11 @@ Applications:
|
||||
|
||||
Router console:
|
||||
Public domain.
|
||||
Flag icons public domain, courtesy mjames@gmail.com http://www.famfamfam.com/
|
||||
Flag icons: public domain, courtesy mjames@gmail.com http://www.famfamfam.com/
|
||||
|
||||
GeoIP Data:
|
||||
Copyright (c) 2003 Direct Information Pvt. Ltd. All Rights Reserved.
|
||||
See licenses/LICENSE-GeoIP.txt
|
||||
|
||||
SAM:
|
||||
Public domain.
|
||||
|
51
Makefile.gcj
51
Makefile.gcj
@@ -5,7 +5,7 @@
|
||||
GCJ=gcj #/usr/local/gcc-4.0.2/bin/gcj
|
||||
EXTRA_LD_PATH= #/usr/local/gcc-4.0.2/lib
|
||||
ANT=ant #/opt/apache-ant-1.6.5/bin/ant
|
||||
ANT_TARGET=buildclean
|
||||
ANT_TARGET=build2
|
||||
NATIVE_DIR=native
|
||||
|
||||
##
|
||||
@@ -24,20 +24,22 @@ JAR_BASE=i2p.jar mstreaming.jar streaming.jar
|
||||
JAR_CLIENTS=i2ptunnel.jar sam.jar
|
||||
JAR_ROUTER=router.jar
|
||||
JAR_JBIGI=jbigi.jar
|
||||
JAR_XML=xml-apis.jar resolver.jar xercesImpl.jar
|
||||
JAR_CONSOLE=\
|
||||
i2psnark.jar \
|
||||
javax.servlet.jar \
|
||||
commons-el.jar \
|
||||
commons-logging.jar \
|
||||
jasper-runtime.jar \
|
||||
ant-apache-bcel.jar \
|
||||
ant.jar \
|
||||
jasper-compiler.jar \
|
||||
org.mortbay.jetty.jar \
|
||||
routerconsole.jar
|
||||
JAR_SUCKER=jdom.jar rome-0.7.jar sucker.jar
|
||||
LIBI2P_JARS=${JAR_BASE} ${JAR_CLIENTS} ${JAR_ROUTER} ${JAR_JBIGI}
|
||||
LIBSAM_JARS=${JAR_BASE} sam.jar
|
||||
LIBROUTER_JARS=i2p.jar ${JAR_ROUTER} ${JAR_JBIGI}
|
||||
LIBCONSOLE_JARS=${LIBROUTER_JARS} ${JAR_CONSOLE}
|
||||
LIBSNARK_JARS=${LIBROUTER_JARS} i2psnark.jar
|
||||
# update:
|
||||
# similar error with gcj 4.3.3.
|
||||
#
|
||||
# unfortunately, its not quite ready for most end users, as the
|
||||
# ${JAR_CONSOLE} fails to compile with:
|
||||
# org/apache/commons/logging/impl/LogKitLogger.java: In class 'org.apache.commons.logging.impl.LogKitLogger':
|
||||
@@ -95,7 +97,36 @@ native_shared: libi2p.so
|
||||
@echo " i2ptunnel will, so it will start all the proxies defined in i2ptunnel.config"
|
||||
|
||||
libi2p.so:
|
||||
@echo "* Building libi2p.so"
|
||||
@(cd build ; time ${GCJ} ${OPTIMIZE} -fPIC -fjni -shared -o ../${NATIVE_DIR}/libi2p.so ${LIBI2P_JARS} ; cd .. )
|
||||
@ls -l ${NATIVE_DIR}/libi2p.so
|
||||
@echo "* libi2p.so built"
|
||||
@echo "* Building $@"
|
||||
@(cd build ; time ${GCJ} ${OPTIMIZE} -fPIC -fjni -shared -o ../${NATIVE_DIR}/$@ ${LIBI2P_JARS} ; cd .. )
|
||||
@ls -l ${NATIVE_DIR}/$@
|
||||
@echo "* $@ built"
|
||||
|
||||
sam: jars libi2psam.so
|
||||
|
||||
libi2psam.so:
|
||||
@echo "* Building $@"
|
||||
@rm -f ${NATIVE_DIR}/$@
|
||||
@(cd build ; time ${GCJ} ${OPTIMIZE} -fPIC -fjni -shared -o ../${NATIVE_DIR}/$@ ${LIBSAM_JARS} ; cd .. )
|
||||
@ls -l ${NATIVE_DIR}/$@
|
||||
@echo "* $@ built"
|
||||
|
||||
router: jars libi2prouter.so
|
||||
|
||||
libi2prouter.so:
|
||||
@echo "* Building $@"
|
||||
@rm -f ${NATIVE_DIR}/$@
|
||||
@(cd build ; time ${GCJ} ${OPTIMIZE} -fPIC -fjni -shared -o ../${NATIVE_DIR}/$@ ${LIBROUTER_JARS} ; cd .. )
|
||||
@ls -l ${NATIVE_DIR}/$@
|
||||
@echo "* $@ built"
|
||||
|
||||
console: jars libi2pconsole.so
|
||||
|
||||
# doesn't work, see above
|
||||
libi2pconsole.so:
|
||||
@echo "* Building $@"
|
||||
@rm -f ${NATIVE_DIR}/$@
|
||||
@(cd build ; time ${GCJ} ${OPTIMIZE} -fPIC -fjni -shared -o ../${NATIVE_DIR}/$@ ${LIBCONSOLE_JARS} ; cd .. )
|
||||
@ls -l ${NATIVE_DIR}/$@
|
||||
@echo "* $@ built"
|
||||
|
||||
|
@@ -1,43 +1,155 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
# Now in the future we only need to look for '#I2P' and '#/I2P'
|
||||
# for modifications to rc.local and rc.local_shutdown.
|
||||
# I was a moron for not doing it this way in the first place :-) -- Sponge
|
||||
#
|
||||
#
|
||||
|
||||
touch /etc/rc.d/rc.local
|
||||
touch /etc/rc.d/rc.local_shutdown
|
||||
|
||||
I2PRCA=`grep -c /etc/rc.d/rc.local -e i2p`
|
||||
I2PRCB=`grep -c /etc/rc.d/rc.local_shutdown -e i2p`
|
||||
|
||||
echo
|
||||
echo -n "Check 1: /etc/rc.d/rc.local "
|
||||
I2PRCA=`grep -c /etc/rc.d/rc.local -e '/etc/rc.d/rc.i2p'`
|
||||
|
||||
if [ $I2PRCA -eq 0 ] ; then
|
||||
echo '#I2P' >> /etc/rc.d/rc.local
|
||||
echo '( cd /tmp ; rm -Rf i2p-*.tmp )' >> /etc/rc.d/rc.local
|
||||
echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local
|
||||
echo " sh /etc/rc.d/rc.i2p start" >> /etc/rc.d/rc.local
|
||||
echo "fi" >> /etc/rc.d/rc.local
|
||||
echo "/etc/rc.d/rc.local modified."
|
||||
echo '#/I2P' >> /etc/rc.d/rc.local
|
||||
echo "modified."
|
||||
else
|
||||
echo "/etc/rc.d/rc.local looks OK"
|
||||
echo -n "looks OK so far,"
|
||||
# Fix old installs, or where people have modified.
|
||||
|
||||
echo -n " Check 1A: "
|
||||
I2PRCC=`grep -c /etc/rc.d/rc.local -e 'i2p-\*\.tmp'`
|
||||
|
||||
if [ $I2PRCC -eq 0 ] ; then
|
||||
DATA=$(cat /etc/rc.d/rc.local | sed -re 's/if \[ -x \/etc\/rc\.d\/rc\.i2p \] ; then/#I2P\n\( cd \/tmp ; rm -Rf i2p-*.tmp \)\nif \[ -x \/etc\/rc.d\/rc.i2p \] ; then/')
|
||||
echo "${DATA}" > /etc/rc.d/rc.local
|
||||
echo -n "additional modifications applied,"
|
||||
else
|
||||
echo -n "looks OK so far,"
|
||||
fi
|
||||
|
||||
echo -n " Check 1B: "
|
||||
I2PRCE=`grep -c /etc/rc.d/rc.local -e 'i2p-\*\.tmp'`
|
||||
if [ $I2PRCE -eq 0 ] ; then
|
||||
DATATOP=$(cat /etc/rc.d/rc.local | sed -n '0,/i2p-\*\.tmp/p' | sed '$d' )
|
||||
DATABOT=$(cat /etc/rc.d/rc.local | sed -n '/i2p-\*\.tmp/,$p' | sed -n '/^fi/,$p' | sed "1d")
|
||||
echo "${DATATOP}" > /etc/rc.d/rc.local
|
||||
echo '#I2P' >> /etc/rc.d/rc.local
|
||||
echo '( cd /tmp ; rm -Rf i2p-*.tmp )' >> /etc/rc.d/rc.local
|
||||
echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local
|
||||
echo " sh /etc/rc.d/rc.i2p start" >> /etc/rc.d/rc.local
|
||||
echo "fi" >> /etc/rc.d/rc.local
|
||||
echo '#/I2P' >> /etc/rc.d/rc.local
|
||||
echo "${DATABOT}" >> /etc/rc.d/rc.local
|
||||
|
||||
echo -n "additional modifications applied,"
|
||||
else
|
||||
echo -n "looks ok so far,"
|
||||
fi
|
||||
echo -n " Check 1C: "
|
||||
I2PRCF=`grep -c /etc/rc.d/rc.local -e '#/I2P'`
|
||||
if [ $I2PRCF -eq 0 ] ; then
|
||||
DATATOP=$(cat /etc/rc.d/rc.local | sed -n '0,/^#I2P/p' | sed '$d' )
|
||||
DATABOT=$(cat /etc/rc.d/rc.local | sed -n '/^#I2P/,$p' | sed -n '/^fi/,$p' | sed "1d")
|
||||
echo "${DATATOP}" > /etc/rc.d/rc.local
|
||||
echo '#I2P' >> /etc/rc.d/rc.local
|
||||
echo '( cd /tmp ; rm -Rf i2p-*.tmp )' >> /etc/rc.d/rc.local
|
||||
echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local
|
||||
echo " sh /etc/rc.d/rc.i2p start" >> /etc/rc.d/rc.local
|
||||
echo "fi" >> /etc/rc.d/rc.local
|
||||
echo '#/I2P' >> /etc/rc.d/rc.local
|
||||
echo "${DATABOT}" >> /etc/rc.d/rc.local
|
||||
|
||||
echo -n "additional modifications applied,"
|
||||
else
|
||||
echo -n "looks ok so far,"
|
||||
fi
|
||||
echo " Done."
|
||||
fi
|
||||
|
||||
echo -n "Check 2: /etc/rc.d/rc.local_shutdown "
|
||||
I2PRCB=`grep -c /etc/rc.d/rc.local_shutdown -e '/etc/rc.d/rc.i2p'`
|
||||
if [ $I2PRCB -eq 0 ] ; then
|
||||
echo "#I2P" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local_shutdown
|
||||
echo " sh /etc/rc.d/rc.i2p stop" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "fi" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "/etc/rc.d/rc.local_shutdown modified."
|
||||
echo "#/I2P" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "modified."
|
||||
else
|
||||
echo "/etc/rc.d/rc.local_shutdown looks OK"
|
||||
echo -n "looks OK so far,"
|
||||
# Fix old installs
|
||||
|
||||
echo -n " Check 1A: "
|
||||
I2PRCG=`grep -c /etc/rc.d/rc.local_shutdown -e '#I2P'`
|
||||
if [ $I2PRCG -eq 0 ] ; then
|
||||
DATATOP=$(cat /etc/rc.d/rc.local_shutdown | sed -n '0,/^if \[ -x \/etc\/rc\.d\/rc\.i2p \] ; then/p' | sed '$d' )
|
||||
DATABOT=$(cat /etc/rc.d/rc.local_shutdown | sed -n '/^if \[ -x \/etc\/rc\.d\/rc\.i2p \] ; then/,$p' | sed -n '/^fi/,$p' | sed "1d")
|
||||
echo "${DATATOP}" > /etc/rc.d/rc.local_shutdown
|
||||
echo '#I2P' >> /etc/rc.d/rc.local_shutdown
|
||||
echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local_shutdown
|
||||
echo " sh /etc/rc.d/rc.i2p stop" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "fi" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "#/I2P" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "${DATABOT}" >> /etc/rc.d/rc.local_shutdown
|
||||
echo -n "additional modifications applied,"
|
||||
else
|
||||
echo -n "looks OK so far,"
|
||||
fi
|
||||
echo -n " Check 1B: "
|
||||
I2PRCH=`grep -c /etc/rc.d/rc.local_shutdown -e '#/I2P'`
|
||||
if [ $I2PRCH -eq 0 ] ; then
|
||||
DATATOP=$(cat /etc/rc.d/rc.local_shutdown | sed -n '0,/^#I2P/p' | sed '$d' )
|
||||
DATABOT=$(cat /etc/rc.d/rc.local_shutdown | sed -n '/^#I2P/,$p' | sed -n '/^fi/,$p' | sed "1d")
|
||||
echo "${DATATOP}" > /etc/rc.d/rc.local_shutdown
|
||||
echo '#I2P' >> /etc/rc.d/rc.local_shutdown
|
||||
echo "if [ -x /etc/rc.d/rc.i2p ] ; then" >> /etc/rc.d/rc.local_shutdown
|
||||
echo " sh /etc/rc.d/rc.i2p stop" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "fi" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "#/I2P" >> /etc/rc.d/rc.local_shutdown
|
||||
echo "${DATABOT}" >> /etc/rc.d/rc.local_shutdown
|
||||
echo -n "additional modifications applied,"
|
||||
else
|
||||
echo -n "looks OK so far,"
|
||||
fi
|
||||
echo " Done."
|
||||
fi
|
||||
|
||||
if [ -f /etc/rc.d/rc.i2p ] ; then
|
||||
if [ -x /etc/rc.d/rc.i2p ] ; then
|
||||
chmod +x /etc/rc.d/rc.i2p.new
|
||||
fi
|
||||
echo
|
||||
# Hopefully get admin's attention.
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -e "\007" ; sleep 0.3
|
||||
echo "It apears that you already have /etc/rc.d/rc.i2p"
|
||||
echo "You may wish to replace it with /etc/rc.d/rc.i2p.new"
|
||||
echo
|
||||
echo "You should replace it with /etc/rc.d/rc.i2p.new as soon as possible"
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -ne "\007" ; sleep 0.3
|
||||
echo -e "\007" ; sleep 0.3
|
||||
else
|
||||
mv /etc/rc.d/rc.i2p.new /etc/rc.d/rc.i2p
|
||||
echo
|
||||
echo "Installation finished. The i2p start/stop script has been"
|
||||
echo "installed on /etc/rc.d directory. You should chmod +x"
|
||||
echo "installed in /etc/rc.d . You should chmod +x"
|
||||
echo '/etc/rc.d/rc.i2p to start it on boot.'
|
||||
echo
|
||||
fi
|
||||
|
@@ -1,42 +1,57 @@
|
||||
#!/bin/sh
|
||||
# Heavily based on the Slackware 12.1 SlackBuild
|
||||
# Slackware build script for i2p
|
||||
|
||||
#
|
||||
# Heavily based on the Slackware 12.2 SlackBuild
|
||||
# Slackware build script for I2P
|
||||
#
|
||||
# PLEASE READ THIS:
|
||||
# Probably you will never have to update i2p packages with upgradepkg,
|
||||
# just because i2p have an auto-update function.
|
||||
# How to start i2p:
|
||||
# After installpkg command, doinst.sh will execute a postinstallation script
|
||||
# needed by i2p. After that you have to chmod +x /etc/rc.d/rc.i2p and start
|
||||
# i2p service with /etc/rc.d/rc.i2p start.
|
||||
# How to start I2P:
|
||||
# After installpkg command, doinst.sh will execute a post-installation script
|
||||
# needed by I2P. After that you have to chmod +x /etc/rc.d/rc.i2p and start
|
||||
# I2P service with /etc/rc.d/rc.i2p start.
|
||||
#
|
||||
# Now tell your browser to user this proxy: localhost on port 4444 and open
|
||||
# this page: http://localhost:7657/index.jsp
|
||||
# Here you can configure i2p, watch network status and navigate anonimously.
|
||||
#
|
||||
# Here you can configure I2P, watch network status and navigate anonimously.
|
||||
# It's suggested to subscribe to various dns host, like i2host.i2p
|
||||
# For any additional information, visit i2host.i2p and forum.i2p
|
||||
#
|
||||
|
||||
CWD=$(pwd)
|
||||
TMP=/tmp
|
||||
PKG=/$TMP/package-base-i2p
|
||||
rm -rf $PKG
|
||||
mkdir -p $PKG
|
||||
# put here installation dir, without first and last /
|
||||
# es: usr/local
|
||||
NAME=i2p-base
|
||||
VERSION=0.0.1
|
||||
BUILD=1sim
|
||||
VERSION=0.0.2
|
||||
BUILD=1sponge
|
||||
ARCH=noarch
|
||||
INSTALL_DIR=opt
|
||||
|
||||
# Less than slackware 13?
|
||||
SLKPLT=$(cat /etc/slackware-version | sed -re "s/(Slackware )([0-9]*)(.*)/\2/")
|
||||
if [ $SLKPLT -lt 13 ] ; then
|
||||
EXT=tgz
|
||||
else
|
||||
EXT=txz
|
||||
fi
|
||||
|
||||
rm -rf $PKG
|
||||
mkdir -p $PKG
|
||||
cd $PKG
|
||||
chown -R root:root .
|
||||
|
||||
mkdir -p $PKG/etc/rc.d
|
||||
mkdir -p $PKG/install
|
||||
sed "s|directory|/$INSTALL_DIR/i2p/i2prouter|g" $CWD/rc.i2p_def > $PKG/etc/rc.d/rc.i2p.new
|
||||
sed "s|directory|/$INSTALL_DIR/i2p/i2prouter|g" "$CWD/rc.i2p_def" > $PKG/etc/rc.d/rc.i2p.new
|
||||
chmod 644 $PKG/etc/rc.d/rc.i2p.new
|
||||
sed "s|directory|/$INSTALL_DIR/i2p/|g" $CWD/doinst.sh > $PKG/install/doinst.sh
|
||||
cat $CWD/slack-desc > $PKG/install/slack-desc
|
||||
cat "$CWD/doinst.sh" > $PKG/install/doinst.sh
|
||||
cat "$CWD/slack-desc" > $PKG/install/slack-desc
|
||||
|
||||
cd $PKG
|
||||
requiredbuilder -v -y -s $CWD $PKG
|
||||
makepkg -l y -c n $CWD/${NAME}-$VERSION-$ARCH-$BUILD.tgz
|
||||
#
|
||||
# Not really that important to exec this
|
||||
# as there aren't any deps we don't know.
|
||||
#
|
||||
# requiredbuilder -v -y -s $CWD $PKG
|
||||
#
|
||||
cat "$CWD/slack-required" > $PKG/install/slack-required
|
||||
makepkg -l y -c n $CWD/${NAME}-$VERSION-$ARCH-$BUILD.$EXT
|
||||
|
@@ -9,6 +9,22 @@ i2p_stop() {
|
||||
/bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory stop )"
|
||||
}
|
||||
|
||||
i2p_restart() {
|
||||
/bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory restart)"
|
||||
}
|
||||
|
||||
i2p_status() {
|
||||
/bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory status )"
|
||||
}
|
||||
|
||||
i2p_console() {
|
||||
/bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory console )"
|
||||
}
|
||||
|
||||
i2p_dump() {
|
||||
/bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory dump )"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
i2p_start
|
||||
@@ -17,11 +33,19 @@ case "$1" in
|
||||
i2p_stop
|
||||
;;
|
||||
'restart')
|
||||
i2p_stop
|
||||
i2p_start
|
||||
i2p_restart
|
||||
;;
|
||||
'status')
|
||||
i2p_status
|
||||
;;
|
||||
'console')
|
||||
i2p_console
|
||||
;;
|
||||
'dump')
|
||||
i2p_dump
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
echo "usage $0 start|stop|restart|status|console|dump"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@@ -49,16 +49,21 @@ echo
|
||||
echo "FINISHING I2P INSTALLATION. PLEASE WAIT."
|
||||
|
||||
cd $INST_DIR
|
||||
sh postinstall.sh || (
|
||||
echo "ERROR: failed execution of postinstall.sh. Please"
|
||||
echo "cd into i2p installation directory and run "
|
||||
echo "postinstall.sh manually with ./postinstall.sh"
|
||||
exit 1
|
||||
)
|
||||
|
||||
sleep 10
|
||||
|
||||
sh i2prouter stop || exit 1
|
||||
|
||||
OS_ARCH=`uname -m`
|
||||
X86_64=`echo "$OS_ARCH" | grep x86_64`
|
||||
if [ "X$X86_64" = "X" ]; then
|
||||
wrapperpath="./lib/wrapper/linux"
|
||||
else
|
||||
wrapperpath="./lib/wrapper/linux64"
|
||||
fi
|
||||
cp $wrapperpath/libwrapper.so ./lib/
|
||||
cp $wrapperpath/wrapper.jar ./lib/
|
||||
cp $wrapperpath/i2psvc .
|
||||
rm -rf ./lib/wrapper
|
||||
chmod 744 ./i2psvc
|
||||
|
||||
echo
|
||||
echo "Installation finished."
|
||||
|
@@ -1,28 +1,35 @@
|
||||
#!/bin/sh
|
||||
# Heavily based on the Slackware 12.1 SlackBuild
|
||||
# Slackware build script for i2p
|
||||
|
||||
#
|
||||
# Heavily based on the Slackware 12.2 SlackBuild
|
||||
# Slackware build script for I2P
|
||||
#
|
||||
# PLEASE READ THIS:
|
||||
# Probably you will never have to update i2p packages with upgradepkg,
|
||||
# just because i2p have an auto-update function.
|
||||
# How to start i2p:
|
||||
# After installpkg command, doinst.sh will execute a postinstallation script
|
||||
# needed by i2p. After that you have to chmod +x /etc/rc.d/rc.i2p and start
|
||||
# i2p service with /etc/rc.d/rc.i2p start.
|
||||
# Now tell your browser to user this proxy: localhost on port 4444 and open
|
||||
# this page: http://localhost:7657/index.jsp
|
||||
# Here you can configure i2p, watch network status and navigate anonimously.
|
||||
# It's suggested to subscribe to various dns host, like i2host.i2p
|
||||
# For any additional information, visit i2host.i2p and forum.i2p
|
||||
# Probably you will never have to update I2P packages with upgradepkg,
|
||||
# just because I2P has an auto-update function.
|
||||
# Really you should not ever use any "upgrade" method.
|
||||
#
|
||||
# The correct way to upgrade is to:
|
||||
# 1: install the upgrade
|
||||
# 2: remove the old package
|
||||
#
|
||||
# It is a terrible shame that upgradepkg doesn't do this, infact,
|
||||
# it would actually be the correct way for *any* package!
|
||||
#
|
||||
#
|
||||
|
||||
BUILD=1sim
|
||||
|
||||
# put here installation dir, without first and last /
|
||||
# es: usr/local
|
||||
BUILD=1sponge
|
||||
INSTALL_DIR=opt
|
||||
NAME=i2p
|
||||
ARCH=noarch
|
||||
|
||||
# Less than slackware 13?
|
||||
SLKPLT=$(cat /etc/slackware-version | sed -re "s/(Slackware )([0-9]*)(.*)/\2/")
|
||||
if [ $SLKPLT -lt 13 ] ; then
|
||||
EXT=tgz
|
||||
else
|
||||
EXT=txz
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# This mess is here due to the totally moronic way i2p does versioning.
|
||||
@@ -64,8 +71,8 @@ mkdir -p $PKG
|
||||
cd $CWD/../../
|
||||
|
||||
ant distclean
|
||||
ant dist
|
||||
|
||||
#ant dist
|
||||
ant tarball
|
||||
|
||||
tar xjvf i2p.tar.bz2 -C $TMP
|
||||
|
||||
@@ -76,6 +83,34 @@ mkdir -p $PKG/$INSTALL_DIR/
|
||||
cp -a ../i2p $PKG/$INSTALL_DIR/
|
||||
|
||||
mkdir -p $PKG/install
|
||||
|
||||
#############################################################################
|
||||
# Preconfigureation to make package smaller
|
||||
#############################################################################
|
||||
cd $PKG/$INSTALL_DIR/i2p
|
||||
|
||||
# wrapper.config $INSTALL_PATH and $SYSTEM_java_io_tmpdir
|
||||
sed "s|\$INSTALL_PATH|$INSTALL_DIR/i2p|g" wrapper.config > a
|
||||
sed "s|\$SYSTEM_java_io_tmpdir|/var/tmp|g" a > wrapper.config
|
||||
# eepget %INSTALL_PATH
|
||||
sed "s|\$INSTALL_PATH|$INSTALL_DIR/i2p|g" eepget > a
|
||||
rm eepget
|
||||
mv a eepget
|
||||
# runplain.sh %INSTALL_PATH and %SYSTEM_java_io_tmpdir
|
||||
sed "s|%INSTALL_PATH|$INSTALL_DIR/i2p|g" runplain.sh > a
|
||||
sed "s|%SYSTEM_java_io_tmpdir|/var/tmp|g" a > runplain.sh
|
||||
# i2prouter %INSTALL_PATH and %SYSTEM_java_io_tmpdir
|
||||
sed "s|%INSTALL_PATH|$INSTALL_DIR/i2p|g" i2prouter > a
|
||||
sed "s|%SYSTEM_java_io_tmpdir|/var/tmp|g" a > i2prouter
|
||||
|
||||
chmod 744 ./i2prouter
|
||||
chmod 744 ./osid
|
||||
chmod 744 ./runplain.sh
|
||||
chmod 744 ./eepget
|
||||
chmod 744 ./scripts/i2pbench.sh
|
||||
chmod 744 ./scripts/i2ptest.sh
|
||||
rm -Rf ./lib/*.dll ./*.bat ./*.exe ./installer ./icons ./a postinstall.sh
|
||||
|
||||
mv $PKG/$INSTALL_DIR/i2p/*.config $PKG/install
|
||||
mv $PKG/$INSTALL_DIR/i2p/blocklist.txt $PKG/$INSTALL_DIR/i2p/blocklist.txt.new
|
||||
mv $PKG/$INSTALL_DIR/i2p/eepsite/jetty.xml $PKG/$INSTALL_DIR/i2p/eepsite/jetty.xml.new
|
||||
@@ -83,6 +118,13 @@ mv $PKG/$INSTALL_DIR/i2p/eepsite/docroot/index.html $PKG/$INSTALL_DIR/i2p/eepsit
|
||||
mv $PKG/$INSTALL_DIR/i2p/eepsite/docroot/favicon.ico $PKG/$INSTALL_DIR/i2p/eepsite/docroot/favicon.ico.new
|
||||
sed "s|directory|/$INSTALL_DIR/i2p/|g" $CWD/doinst.sh > $PKG/install/doinst.sh
|
||||
cat $CWD/slack-desc > $PKG/install/slack-desc
|
||||
|
||||
cd $PKG
|
||||
requiredbuilder -v -y -s $CWD $PKG
|
||||
makepkg -l y -c n $CWD/${NAME}-$VERSION-$ARCH-$BUILD.tgz
|
||||
#
|
||||
# requiredbuilder fucks up REALLY bad, and thinks java is perl?!
|
||||
# It also did not catch the shell requirements! BOOOOOOOOOOO! HISSSSSSSS!
|
||||
#
|
||||
# requiredbuilder -v -y -s $CWD $PKG
|
||||
#
|
||||
cat $CWD/slack-required > $PKG/install/slack-required
|
||||
makepkg -l y -c n $CWD/${NAME}-$VERSION-$ARCH-$BUILD.$EXT
|
||||
|
@@ -1,2 +1,4 @@
|
||||
glibc >= 2.7-i486-17 | glibc-solibs >= 2.7-i486-17
|
||||
perl >= 5.10.0-i486-1
|
||||
jre >= 5
|
||||
i2p-base >= 0.0.1
|
||||
bash >= 3.1.017
|
||||
|
||||
|
19
android/AndroidManifest.xml
Normal file
19
android/AndroidManifest.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="net.i2p.router"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0.0">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 3 = 1.5, 2 = 1.1, 1 = 1.0; would probably work with 1 but don't have a 1.0 SDK to test against -->
|
||||
<uses-sdk android:minSdkVersion="2" />
|
||||
<application android:label="@string/app_name">
|
||||
<activity android:name=".I2PAndroid"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
29
android/README.txt
Normal file
29
android/README.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
These instructions are for the 1.5 Android SDK.
|
||||
The build file is not compatible with the 1.1 SDK any more.
|
||||
1.6 and 2.0 SDKs are untested.
|
||||
|
||||
#Unzip the android SDK in ../../
|
||||
#So then the android tools will be in ../../android-sdk-linux_x86-1.5_r2/tools/
|
||||
|
||||
# create a file local.properties with the following line:
|
||||
# sdk-location=/path/to/your/android-sdk-linux_x86-1.5_r2
|
||||
|
||||
#then build the android apk file:
|
||||
ant debug
|
||||
|
||||
# Create the android 1.5 virtual device
|
||||
# (don't make a custom hardware profile)
|
||||
../../android-sdk-linux_x86-1.5_r2/tools/android create avd --name i2p --target 2
|
||||
|
||||
#then run the emulator:
|
||||
../../android-sdk-linux_x86-1.5_r2/tools/emulator -avd i2p &
|
||||
|
||||
#then wait a couple minutes until the emulator is up
|
||||
#then install the I2P app
|
||||
ant install
|
||||
|
||||
#then run the debugger
|
||||
../../android-sdk-linux_x86-1.5_r2/tools/ddms &
|
||||
|
||||
#to rebuild and reinstall to emulator:
|
||||
ant reinstall
|
352
android/build.xml
Normal file
352
android/build.xml
Normal file
@@ -0,0 +1,352 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name=".I2PAndroid" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contain the path to the SDK. It should *NOT* be checked in in Version
|
||||
Control Systems. -->
|
||||
<property file="local.properties"/>
|
||||
|
||||
<!-- The build.properties file can be created by you and is never touched
|
||||
by the 'android' tool. This is the place to change some of the default property values
|
||||
used by the Ant rules.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
application-package
|
||||
the name of your application package as defined in the manifest. Used by the
|
||||
'uninstall' rule.
|
||||
source-folder
|
||||
the name of the source folder. Default is 'src'.
|
||||
out-folder
|
||||
the name of the output folder. Default is 'bin'.
|
||||
|
||||
Properties related to the SDK location or the project target should be updated
|
||||
using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your application and
|
||||
should be checked in in Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="build.properties"/>
|
||||
|
||||
<!-- The default.properties file is created and updated by the 'android' tool, as well
|
||||
as ADT.
|
||||
This file is an integral part of the build system for your application and
|
||||
should be checked in in Version Control Systems. -->
|
||||
<property file="default.properties"/>
|
||||
|
||||
<!-- Custom Android task to deal with the project target, and import the proper rules.
|
||||
This requires ant 1.6.0 or above. -->
|
||||
<path id="android.antlibs">
|
||||
<pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
|
||||
<pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
|
||||
<pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
|
||||
<pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
|
||||
<pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
|
||||
</path>
|
||||
|
||||
<taskdef name="setup"
|
||||
classname="com.android.ant.SetupTask"
|
||||
classpathref="android.antlibs"/>
|
||||
|
||||
<!-- Execute the Android Setup task that will setup some properties specific to the target,
|
||||
and import the rules files.
|
||||
To customize the rules, copy/paste them below the task, and disable import by setting
|
||||
the import attribute to false:
|
||||
<setup import="false" />
|
||||
|
||||
This will ensure that the properties are setup correctly but that your customized
|
||||
targets are used.
|
||||
-->
|
||||
<setup import="false" />
|
||||
|
||||
<!--
|
||||
================================================================================
|
||||
New I2P rules
|
||||
================================================================================
|
||||
-->
|
||||
|
||||
<target name="buildrouter" depends="dirs" >
|
||||
<!-- build router and core -->
|
||||
<ant dir=".." target="buildrouter" />
|
||||
|
||||
<!-- router -->
|
||||
<copy file="../build/router.jar" todir="${external-libs-folder}" />
|
||||
|
||||
<!-- core -->
|
||||
<mkdir dir="tmp" />
|
||||
<unjar src="../build/i2p.jar" dest="tmp/" />
|
||||
<delete file="tmp/net/i2p/util/LogWriter.class" />
|
||||
<!-- org.bouncycastle.crypto already in android
|
||||
but we need a little trickery because our HMac is incompatible...
|
||||
and the libs aren't in the SDK to compile against??? -->
|
||||
<jar destfile="${external-libs-folder}/crypto.jar" >
|
||||
<fileset dir="tmp/" >
|
||||
<include name="org/bouncycastle/crypto/Digest.class" />
|
||||
<include name="org/bouncycastle/crypto/Mac.class" />
|
||||
<include name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
|
||||
<include name="org/bouncycastle/crypto/digests/MD5Digest.class" />
|
||||
</fileset>
|
||||
</jar>
|
||||
<delete>
|
||||
<fileset dir="tmp/" >
|
||||
<include name="org/bouncycastle/crypto/Digest.class" />
|
||||
<include name="org/bouncycastle/crypto/Mac.class" />
|
||||
<include name="org/bouncycastle/crypto/digests/GeneralDigest.class" />
|
||||
<include name="org/bouncycastle/crypto/digests/MD5Digest.class" />
|
||||
</fileset>
|
||||
</delete>
|
||||
<!--
|
||||
<delete dir="tmp/org/bouncycastle/" />
|
||||
<delete file="tmp/net/i2p/crypto/HMACGenerator.class" />
|
||||
-->
|
||||
<delete file="tmp/org/bouncycastle/" />
|
||||
<!-- lots of unneeded stuff could be deleted here -->
|
||||
<jar destfile="${external-libs-folder}/i2p.jar" basedir="tmp/" />
|
||||
|
||||
<!-- some resources -->
|
||||
<mkdir dir="res/drawable/" />
|
||||
<copy file="../installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" />
|
||||
<copy file="../installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" />
|
||||
</target>
|
||||
|
||||
<target name="hackcleanup">
|
||||
<delete file="${external-libs-folder}/crypto.jar" />
|
||||
</target>
|
||||
|
||||
<!--
|
||||
================================================================================
|
||||
From here down copied from SDK platforms/android-1.1/templates/android_rules.xml
|
||||
and then modified
|
||||
================================================================================
|
||||
-->
|
||||
|
||||
<!--
|
||||
This rules file is meant to be imported by the custom Ant task:
|
||||
com.android.ant.AndroidInitTask
|
||||
|
||||
The following properties are put in place by the importing task:
|
||||
android-jar, android-aidl, aapt, aidl, and dx
|
||||
|
||||
Additionnaly, the task sets up the following classpath reference:
|
||||
android.target.classpath
|
||||
This is used by the compiler task as the boot classpath.
|
||||
-->
|
||||
|
||||
<!-- Custom tasks -->
|
||||
<taskdef name="aaptexec"
|
||||
classname="com.android.ant.AaptExecLoopTask"
|
||||
classpathref="android.antlibs"/>
|
||||
|
||||
<taskdef name="apkbuilder"
|
||||
classname="com.android.ant.ApkBuilderTask"
|
||||
classpathref="android.antlibs"/>
|
||||
|
||||
<!-- Properties -->
|
||||
|
||||
<property name="android-tools" value="${sdk-location}/tools" />
|
||||
|
||||
<!-- Input directories -->
|
||||
<property name="source-folder" value="src" />
|
||||
<property name="gen-folder" value="gen" />
|
||||
<property name="resource-folder" value="res" />
|
||||
<property name="asset-folder" value="assets" />
|
||||
<property name="source-location" value="${basedir}/${source-folder}" />
|
||||
|
||||
<!-- folder for the 3rd party java libraries -->
|
||||
<property name="external-libs-folder" value="libs" />
|
||||
|
||||
<!-- folder for the native libraries -->
|
||||
<property name="native-libs-folder" value="libs" />
|
||||
|
||||
<!-- Output directories -->
|
||||
<property name="gen-folder" value="gen" />
|
||||
<property name="out-folder" value="bin" />
|
||||
<property name="out-classes" value="${out-folder}/classes" />
|
||||
<property name="out-classes-location" value="${basedir}/${out-classes}"/>
|
||||
<!-- out folders for a parent project if this project is an instrumentation project -->
|
||||
<property name="main-out-folder" value="../${out-folder}" />
|
||||
<property name="main-out-classes" value="${main-out-folder}/classes"/>
|
||||
|
||||
<!-- Intermediate files -->
|
||||
<property name="dex-file" value="classes.dex" />
|
||||
<property name="intermediate-dex" value="${out-folder}/${dex-file}" />
|
||||
<!-- dx does not properly support incorrect / or \ based on the platform
|
||||
and Ant cannot convert them because the parameter is not a valid path.
|
||||
Because of this we have to compute different paths depending on the platform. -->
|
||||
<condition property="intermediate-dex-location"
|
||||
value="${basedir}\${intermediate-dex}"
|
||||
else="${basedir}/${intermediate-dex}" >
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
|
||||
<!-- The final package file to generate -->
|
||||
<property name="out-debug-package" value="${out-folder}/${ant.project.name}-debug.apk"/>
|
||||
|
||||
<!-- Tools -->
|
||||
<condition property="exe" value=".exe" else=""><os family="windows"/></condition>
|
||||
<property name="adb" value="${android-tools}/adb${exe}"/>
|
||||
|
||||
<!-- rules -->
|
||||
|
||||
<!-- Create the output directories if they don't exist yet. -->
|
||||
<target name="dirs">
|
||||
<echo>Creating output directories if needed...</echo>
|
||||
<mkdir dir="${resource-folder}" />
|
||||
<mkdir dir="${external-libs-folder}" />
|
||||
<mkdir dir="${gen-folder}" />
|
||||
<mkdir dir="${out-folder}" />
|
||||
<mkdir dir="${out-classes}" />
|
||||
</target>
|
||||
|
||||
<!-- Generate the R.java file for this project's resources. -->
|
||||
<target name="resource-src" depends="dirs">
|
||||
<echo>Generating R.java / Manifest.java from the resources...</echo>
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package" />
|
||||
<arg value="-m" />
|
||||
<arg value="-J" />
|
||||
<arg path="${gen-folder}" />
|
||||
<arg value="-M" />
|
||||
<arg path="AndroidManifest.xml" />
|
||||
<arg value="-S" />
|
||||
<arg path="${resource-folder}" />
|
||||
<arg value="-I" />
|
||||
<arg path="${android-jar}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Generate java classes from .aidl files. -->
|
||||
<target name="aidl" depends="dirs">
|
||||
<echo>Compiling aidl files into Java classes...</echo>
|
||||
<apply executable="${aidl}" failonerror="true">
|
||||
<arg value="-p${android-aidl}" />
|
||||
<arg value="-I${source-folder}" />
|
||||
<arg value="-o${gen-folder}" />
|
||||
<fileset dir="${source-folder}">
|
||||
<include name="**/*.aidl"/>
|
||||
</fileset>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<!-- Compile this project's .java files into .class files. -->
|
||||
<!-- I2P add buildrouter -->
|
||||
<target name="compile" depends="buildrouter, resource-src, aidl">
|
||||
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
|
||||
destdir="${out-classes}"
|
||||
bootclasspathref="android.target.classpath">
|
||||
<src path="${source-folder}" />
|
||||
<src path="${gen-folder}" />
|
||||
<classpath>
|
||||
<fileset dir="${external-libs-folder}" includes="*.jar"/>
|
||||
<pathelement path="${main-out-classes}"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Convert this project's .class files into .dex files. -->
|
||||
<!-- I2P add hackcleanup -->
|
||||
<target name="dex" depends="compile, hackcleanup">
|
||||
<echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo>
|
||||
<apply executable="${dx}" failonerror="true" parallel="true">
|
||||
<!-- I2P this is a bad sign that we need this -->
|
||||
<arg value="-JXmx256m" />
|
||||
<arg value="--dex" />
|
||||
<arg value="--output=${intermediate-dex-location}" />
|
||||
<arg path="${out-classes-location}" />
|
||||
<fileset dir="${external-libs-folder}" includes="*.jar"/>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<!-- Put the project's resources into the output package file
|
||||
This actually can create multiple resource package in case
|
||||
Some custom apk with specific configuration have been
|
||||
declared in default.properties.
|
||||
-->
|
||||
<target name="package-resources">
|
||||
<echo>Packaging resources</echo>
|
||||
<aaptexec executable="${aapt}"
|
||||
command="package"
|
||||
manifest="AndroidManifest.xml"
|
||||
resources="${resource-folder}"
|
||||
assets="${asset-folder}"
|
||||
androidjar="${android-jar}"
|
||||
outfolder="${out-folder}"
|
||||
basename="${ant.project.name}" />
|
||||
</target>
|
||||
|
||||
<!-- Package the application and sign it with a debug key.
|
||||
This is the default target when building. It is used for debug. -->
|
||||
<target name="debug" depends="dex, package-resources">
|
||||
<apkbuilder
|
||||
outfolder="${out-folder}"
|
||||
basename="${ant.project.name}"
|
||||
signed="true"
|
||||
verbose="false">
|
||||
<file path="${intermediate-dex}" />
|
||||
<sourcefolder path="${source-folder}" />
|
||||
<jarfolder path="${external-libs-folder}" />
|
||||
<nativefolder path="${native-libs-folder}" />
|
||||
</apkbuilder>
|
||||
</target>
|
||||
|
||||
<!-- Package the application without signing it.
|
||||
This allows for the application to be signed later with an official publishing key. -->
|
||||
<target name="release" depends="dex, package-resources">
|
||||
<apkbuilder
|
||||
outfolder="${out-folder}"
|
||||
basename="${ant.project.name}"
|
||||
signed="false"
|
||||
verbose="false">
|
||||
<file path="${intermediate-dex}" />
|
||||
<sourcefolder path="${source-folder}" />
|
||||
<jarfolder path="${external-libs-folder}" />
|
||||
<nativefolder path="${native-libs-folder}" />
|
||||
</apkbuilder>
|
||||
<echo>All generated packages need to be signed with jarsigner before they are published.</echo>
|
||||
</target>
|
||||
|
||||
<!-- Install the package on the default emulator -->
|
||||
<target name="install" depends="debug">
|
||||
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
||||
<exec executable="${adb}" failonerror="true">
|
||||
<arg value="install" />
|
||||
<arg path="${out-debug-package}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="reinstall" depends="debug">
|
||||
<echo>Installing ${out-debug-package} onto default emulator...</echo>
|
||||
<exec executable="${adb}" failonerror="true">
|
||||
<arg value="install" />
|
||||
<arg value="-r" />
|
||||
<arg path="${out-debug-package}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Uinstall the package from the default emulator -->
|
||||
<target name="uninstall">
|
||||
<echo>Uninstalling ${application-package} from the default emulator...</echo>
|
||||
<exec executable="${adb}" failonerror="true">
|
||||
<arg value="uninstall" />
|
||||
<arg path="${application-package}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="help">
|
||||
<!-- displays starts at col 13
|
||||
|13 80| -->
|
||||
<echo>Android Ant Build. Available targets:</echo>
|
||||
<echo> help: Displays this help.</echo>
|
||||
<echo> debug: Builds the application and sign it with a debug key.</echo>
|
||||
<echo> release: Builds the application. The generated apk file must be</echo>
|
||||
<echo> signed before it is published.</echo>
|
||||
<echo> install: Installs the debug package onto a running emulator or</echo>
|
||||
<echo> device. This can only be used if the application has </echo>
|
||||
<echo> not yet been installed.</echo>
|
||||
<echo> reinstall: Installs the debug package on a running emulator or</echo>
|
||||
<echo> device that already has the application.</echo>
|
||||
<echo> The signatures must match.</echo>
|
||||
<echo> uninstall: uninstall the application from a running emulator or</echo>
|
||||
<echo> device.</echo>
|
||||
</target>
|
||||
</project>
|
11
android/default.properties
Normal file
11
android/default.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-2
|
18
android/res/layout/main.xml
Normal file
18
android/res/layout/main.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World, I2PAndroid"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/i2plogo"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
3
android/res/raw/logger_config
Normal file
3
android/res/raw/logger_config
Normal file
@@ -0,0 +1,3 @@
|
||||
logger.defaultLevel=INFO
|
||||
logger.record.net.i2p.router.transport.FIFOBandwidthRefiller=ERROR
|
||||
logger.record.net.i2p.stat.Rate=ERROR
|
16
android/res/raw/router_config
Normal file
16
android/res/raw/router_config
Normal file
@@ -0,0 +1,16 @@
|
||||
# initial router.config
|
||||
# temp directory
|
||||
i2p.dir.temp=/data/data/net.i2p.router/files/tmp
|
||||
i2p.dir.pid=/data/data/net.i2p.router/files/tmp
|
||||
# save memory
|
||||
prng.buffers=2
|
||||
router.decayingBloomFilterM=20
|
||||
stat.full=false
|
||||
i2np.udp.maxConnections=30
|
||||
# no I2CP
|
||||
i2p.dummyClientFacade=true
|
||||
# for now
|
||||
i2np.ntcp.enable=false
|
||||
# not on android
|
||||
i2np.upnp.enable=false
|
||||
routerconsole.geoip.enable=false
|
4
android/res/values/strings.xml
Normal file
4
android/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">I2PAndroid</string>
|
||||
</resources>
|
142
android/src/net/i2p/router/I2PAndroid.java
Normal file
142
android/src/net/i2p/router/I2PAndroid.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package net.i2p.router;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.NotFoundException;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterLaunch;
|
||||
// import net.i2p.util.NativeBigInteger;
|
||||
|
||||
public class I2PAndroid extends Activity
|
||||
{
|
||||
static Context _context;
|
||||
private static final String DIR = "/data/data/net.i2p.router/files";
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
_context = this; // Activity extends Context
|
||||
debugStuff();
|
||||
initialize();
|
||||
// 300ms per run
|
||||
// 5x slower than java on my server and 50x slower than native on my server
|
||||
// NativeBigInteger.main(null);
|
||||
}
|
||||
|
||||
public void onRestart()
|
||||
{
|
||||
System.err.println("onRestart called");
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
public void onStart()
|
||||
{
|
||||
System.err.println("onStart called");
|
||||
super.onStart();
|
||||
RouterLaunch.main(null);
|
||||
System.err.println("Router.main finished");
|
||||
}
|
||||
|
||||
public void onResume()
|
||||
{
|
||||
System.err.println("onResume called");
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void onPause()
|
||||
{
|
||||
System.err.println("onPause called");
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void onStop()
|
||||
{
|
||||
System.err.println("onStop called");
|
||||
super.onStop();
|
||||
|
||||
// from routerconsole ContextHelper
|
||||
List contexts = RouterContext.listContexts();
|
||||
if ( (contexts == null) || (contexts.size() <= 0) )
|
||||
throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down.");
|
||||
RouterContext ctx = (RouterContext)contexts.get(0);
|
||||
|
||||
// shutdown() doesn't return so use shutdownGracefully()
|
||||
ctx.router().shutdownGracefully(Router.EXIT_HARD);
|
||||
System.err.println("shutdown complete");
|
||||
}
|
||||
|
||||
public void onDestroy()
|
||||
{
|
||||
System.err.println("onDestroy called");
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return _context;
|
||||
}
|
||||
|
||||
private void debugStuff() {
|
||||
System.err.println("java.io.tmpdir" + ": " + System.getProperty("java.io.tmpdir"));
|
||||
System.err.println("java.vendor" + ": " + System.getProperty("java.vendor"));
|
||||
System.err.println("java.version" + ": " + System.getProperty("java.version"));
|
||||
System.err.println("os.arch" + ": " + System.getProperty("os.arch"));
|
||||
System.err.println("os.name" + ": " + System.getProperty("os.name"));
|
||||
System.err.println("os.version" + ": " + System.getProperty("os.version"));
|
||||
System.err.println("user.dir" + ": " + System.getProperty("user.dir"));
|
||||
System.err.println("user.home" + ": " + System.getProperty("user.home"));
|
||||
System.err.println("user.name" + ": " + System.getProperty("user.name"));
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
// Until we can edit the router.config on the device,
|
||||
// copy it from the resource every time.
|
||||
// File f = new I2PFile("router.config");
|
||||
// if (!f.exists()) {
|
||||
copyResourceToFile(R.raw.router_config, "router.config");
|
||||
copyResourceToFile(R.raw.logger_config, "logger.config");
|
||||
copyResourceToFile(R.raw.blocklist_txt, "blocklist.txt");
|
||||
// }
|
||||
|
||||
// Set up the locations so Router and WorkingDir can find them
|
||||
System.setProperty("i2p.dir.base", DIR);
|
||||
System.setProperty("i2p.dir.config", DIR);
|
||||
System.setProperty("wrapper.logfile", DIR + "/wrapper.log");
|
||||
}
|
||||
|
||||
private void copyResourceToFile(int resID, String f) {
|
||||
InputStream in = null;
|
||||
FileOutputStream out = null;
|
||||
|
||||
System.err.println("Creating file " + f + " from resource");
|
||||
byte buf[] = new byte[4096];
|
||||
try {
|
||||
// Context methods
|
||||
in = getResources().openRawResource(resID);
|
||||
out = openFileOutput(f, 0);
|
||||
|
||||
int read = 0;
|
||||
while ( (read = in.read(buf)) != -1)
|
||||
out.write(buf, 0, read);
|
||||
|
||||
} catch (IOException ioe) {
|
||||
} catch (Resources.NotFoundException nfe) {
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (out != null) try { out.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
163
android/src/net/i2p/util/LogWriter.java
Normal file
163
android/src/net/i2p/util/LogWriter.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package net.i2p.util;
|
||||
|
||||
/*
|
||||
* public domain
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* bridge to android logging
|
||||
*
|
||||
* @author zzz
|
||||
*/
|
||||
class LogWriter implements Runnable {
|
||||
private final static long CONFIG_READ_ITERVAL = 10 * 1000;
|
||||
private long _lastReadConfig = 0;
|
||||
private long _numBytesInCurrentFile = 0;
|
||||
private OutputStream _currentOut; // = System.out
|
||||
private int _rotationNum = -1;
|
||||
private String _logFilenamePattern;
|
||||
private File _currentFile;
|
||||
private LogManager _manager;
|
||||
|
||||
private boolean _write;
|
||||
|
||||
private LogWriter() { // nop
|
||||
}
|
||||
|
||||
public LogWriter(LogManager manager) {
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void stopWriting() {
|
||||
_write = false;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
_write = true;
|
||||
try {
|
||||
while (_write) {
|
||||
flushRecords();
|
||||
rereadConfig();
|
||||
}
|
||||
System.err.println("Done writing");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error writing the logs: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void flushRecords() { flushRecords(true); }
|
||||
public void flushRecords(boolean shouldWait) {
|
||||
try {
|
||||
List records = _manager._removeAll();
|
||||
if (records == null) return;
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
LogRecord rec = (LogRecord) records.get(i);
|
||||
writeRecord(rec);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
} finally {
|
||||
if (shouldWait) {
|
||||
try {
|
||||
synchronized (this) {
|
||||
this.wait(10*1000);
|
||||
}
|
||||
} catch (InterruptedException ie) { // nop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String currentFile() {
|
||||
return _currentFile != null ? _currentFile.getAbsolutePath() : "uninitialized";
|
||||
}
|
||||
|
||||
private void rereadConfig() {
|
||||
long now = Clock.getInstance().now();
|
||||
if (now - _lastReadConfig > CONFIG_READ_ITERVAL) {
|
||||
_manager.rereadConfig();
|
||||
_lastReadConfig = now;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeRecord(LogRecord rec) {
|
||||
if (rec.getThrowable() == null)
|
||||
log(rec.getPriority(), rec.getSource(), rec.getSourceName(), rec.getThreadName(), rec.getMessage());
|
||||
else
|
||||
log(rec.getPriority(), rec.getSource(), rec.getSourceName(), rec.getThreadName(), rec.getMessage(), rec.getThrowable());
|
||||
}
|
||||
|
||||
public void log(int priority, Class src, String name, String threadName, String msg) {
|
||||
if (src != null) {
|
||||
String tag = src.getName();
|
||||
int dot = tag.lastIndexOf(".");
|
||||
if (dot >= 0)
|
||||
tag = tag.substring(dot + 1);
|
||||
android.util.Log.println(toAndroidLevel(priority),
|
||||
tag,
|
||||
'[' + threadName + "] " + msg);
|
||||
} else if (name != null)
|
||||
android.util.Log.println(toAndroidLevel(priority),
|
||||
name,
|
||||
'[' + threadName + "] " + msg);
|
||||
else
|
||||
android.util.Log.println(toAndroidLevel(priority),
|
||||
threadName, msg);
|
||||
}
|
||||
|
||||
public void log(int priority, Class src, String name, String threadName, String msg, Throwable t) {
|
||||
if (src != null) {
|
||||
String tag = src.getName();
|
||||
int dot = tag.lastIndexOf(".");
|
||||
if (dot >= 0)
|
||||
tag = tag.substring(dot + 1);
|
||||
android.util.Log.println(toAndroidLevel(priority),
|
||||
tag,
|
||||
'[' + threadName + "] " + msg +
|
||||
' ' + t.toString() + ' ' + android.util.Log.getStackTraceString(t));
|
||||
} else if (name != null)
|
||||
android.util.Log.println(toAndroidLevel(priority),
|
||||
name,
|
||||
'[' + threadName + "] " + msg +
|
||||
' ' + t.toString() + ' ' + android.util.Log.getStackTraceString(t));
|
||||
else
|
||||
android.util.Log.println(toAndroidLevel(priority),
|
||||
threadName,
|
||||
msg + ' ' + t.toString() + ' ' + android.util.Log.getStackTraceString(t));
|
||||
}
|
||||
|
||||
private static int toAndroidLevel(int level) {
|
||||
switch (level) {
|
||||
case Log.DEBUG:
|
||||
return android.util.Log.DEBUG;
|
||||
case Log.INFO:
|
||||
return android.util.Log.INFO;
|
||||
case Log.WARN:
|
||||
return android.util.Log.WARN;
|
||||
case Log.ERROR:
|
||||
case Log.CRIT:
|
||||
default:
|
||||
return android.util.Log.ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String replace(String pattern, int num) {
|
||||
char c[] = pattern.toCharArray();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if ( (c[i] != '#') && (c[i] != '@') )
|
||||
buf.append(c[i]);
|
||||
else
|
||||
buf.append(num);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
@@ -1,4 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
|
||||
<file>file:/usblv/NetBeansProjects/i2p.i2p/apps/BOB/src/net/i2p/BOB/TCPio.java</file>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
package net.i2p.BOB;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -34,6 +35,8 @@ import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.I2PClient;
|
||||
import net.i2p.client.streaming.RetransmissionTimer;
|
||||
import net.i2p.util.Log;
|
||||
@@ -163,6 +166,7 @@ public class BOB {
|
||||
public static void stop() {
|
||||
spin.set(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for incoming connections and handle them
|
||||
*
|
||||
@@ -185,16 +189,20 @@ public class BOB {
|
||||
i = Y2.hashCode();
|
||||
try {
|
||||
{
|
||||
File cfg = new File(configLocation);
|
||||
if (!cfg.isAbsolute()) {
|
||||
cfg = new File(I2PAppContext.getGlobalContext().getConfigDir(), configLocation);
|
||||
}
|
||||
try {
|
||||
FileInputStream fi = new FileInputStream(configLocation);
|
||||
FileInputStream fi = new FileInputStream(cfg);
|
||||
props.load(fi);
|
||||
fi.close();
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
warn("Unable to load up the BOB config file " + configLocation + ", Using defaults.");
|
||||
warn("Unable to load up the BOB config file " + cfg.getAbsolutePath() + ", Using defaults.");
|
||||
warn(fnfe.toString());
|
||||
save = true;
|
||||
} catch (IOException ioe) {
|
||||
warn("IOException on BOB config file " + configLocation + ", using defaults.");
|
||||
warn("IOException on BOB config file " + cfg.getAbsolutePath() + ", using defaults.");
|
||||
warn(ioe.toString());
|
||||
}
|
||||
}
|
||||
@@ -227,13 +235,17 @@ public class BOB {
|
||||
props.setProperty(PROP_BOB_HOST, "localhost");
|
||||
}
|
||||
if (save) {
|
||||
File cfg = new File(configLocation);
|
||||
if (!cfg.isAbsolute()) {
|
||||
cfg = new File(I2PAppContext.getGlobalContext().getConfigDir(), configLocation);
|
||||
}
|
||||
try {
|
||||
warn("Writing new defaults file " + configLocation);
|
||||
FileOutputStream fo = new FileOutputStream(configLocation);
|
||||
props.store(fo, configLocation);
|
||||
warn("Writing new defaults file " + cfg.getAbsolutePath());
|
||||
FileOutputStream fo = new FileOutputStream(cfg);
|
||||
props.store(fo, cfg.getAbsolutePath());
|
||||
fo.close();
|
||||
} catch (IOException ioe) {
|
||||
error("IOException on BOB config file " + configLocation + ", " + ioe);
|
||||
error("IOException on BOB config file " + cfg.getAbsolutePath() + ", " + ioe);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@ package net.i2p.BOB;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.i2p.I2PException;
|
||||
import net.i2p.client.streaming.I2PServerSocket;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
@@ -43,6 +44,7 @@ public class I2Plistener implements Runnable {
|
||||
// private int tgwatch;
|
||||
public I2PSocketManager socketManager;
|
||||
public I2PServerSocket serverSocket;
|
||||
private AtomicBoolean lives;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -52,23 +54,13 @@ public class I2Plistener implements Runnable {
|
||||
* @param database
|
||||
* @param _log
|
||||
*/
|
||||
I2Plistener(I2PServerSocket SS, I2PSocketManager S, NamedDB info, NamedDB database, Log _log) {
|
||||
I2Plistener(I2PServerSocket SS, I2PSocketManager S, NamedDB info, NamedDB database, Log _log, AtomicBoolean lives) {
|
||||
this.database = database;
|
||||
this.info = info;
|
||||
this._log = _log;
|
||||
this.socketManager = S;
|
||||
serverSocket = SS;
|
||||
// tgwatch = 1;
|
||||
}
|
||||
|
||||
private void rlock() throws Exception {
|
||||
database.getReadLock();
|
||||
info.getReadLock();
|
||||
}
|
||||
|
||||
private void runlock() throws Exception {
|
||||
database.releaseReadLock();
|
||||
info.releaseReadLock();
|
||||
this.serverSocket = SS;
|
||||
this.lives = lives;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,50 +72,31 @@ public class I2Plistener implements Runnable {
|
||||
I2PSocket sessSocket = null;
|
||||
int conn = 0;
|
||||
try {
|
||||
die:
|
||||
{
|
||||
|
||||
try {
|
||||
serverSocket.setSoTimeout(50);
|
||||
boolean spin = true;
|
||||
while (spin) {
|
||||
|
||||
while (lives.get()) {
|
||||
try {
|
||||
rlock();
|
||||
} catch (Exception e) {
|
||||
break die;
|
||||
sessSocket = serverSocket.accept();
|
||||
g = true;
|
||||
} catch (ConnectException ce) {
|
||||
g = false;
|
||||
} catch (SocketTimeoutException ste) {
|
||||
g = false;
|
||||
}
|
||||
try {
|
||||
spin = info.get("RUNNING").equals(Boolean.TRUE);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
runlock();
|
||||
} catch (Exception e2) {
|
||||
break die;
|
||||
}
|
||||
break die;
|
||||
if (g) {
|
||||
g = false;
|
||||
conn++;
|
||||
// toss the connection to a new thread.
|
||||
I2PtoTCP conn_c = new I2PtoTCP(sessSocket, info, database, lives);
|
||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " I2PtoTCP " + conn);
|
||||
t.start();
|
||||
}
|
||||
try {
|
||||
try {
|
||||
sessSocket = serverSocket.accept();
|
||||
g = true;
|
||||
} catch (ConnectException ce) {
|
||||
g = false;
|
||||
} catch (SocketTimeoutException ste) {
|
||||
g = false;
|
||||
}
|
||||
if (g) {
|
||||
g = false;
|
||||
conn++;
|
||||
// toss the connection to a new thread.
|
||||
I2PtoTCP conn_c = new I2PtoTCP(sessSocket, info, database);
|
||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " I2PtoTCP " + conn);
|
||||
t.start();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// System.out.println("Exception " + e);
|
||||
}
|
||||
}
|
||||
} catch (I2PException e) {
|
||||
// bad shit
|
||||
System.out.println("Exception " + e);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
|
@@ -26,6 +26,7 @@ package net.i2p.BOB;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ public class I2PtoTCP implements Runnable {
|
||||
private I2PSocket I2P;
|
||||
private NamedDB info, database;
|
||||
private Socket sock;
|
||||
private AtomicBoolean lives;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -46,10 +48,11 @@ public class I2PtoTCP implements Runnable {
|
||||
* @param info
|
||||
* @param database
|
||||
*/
|
||||
I2PtoTCP(I2PSocket I2Psock, NamedDB info, NamedDB database) {
|
||||
I2PtoTCP(I2PSocket I2Psock, NamedDB info, NamedDB database, AtomicBoolean lives) {
|
||||
this.I2P = I2Psock;
|
||||
this.info = info;
|
||||
this.database = database;
|
||||
this.lives = lives;
|
||||
}
|
||||
|
||||
private void rlock() {
|
||||
@@ -113,35 +116,19 @@ public class I2PtoTCP implements Runnable {
|
||||
out.flush(); // not really needed, but...
|
||||
}
|
||||
// setup to cross the streams
|
||||
TCPio conn_c = new TCPio(in, Iout /*, info, database */); // app -> I2P
|
||||
TCPio conn_a = new TCPio(Iin, out /* , info, database */); // I2P -> app
|
||||
TCPio conn_c = new TCPio(in, Iout, lives); // app -> I2P
|
||||
TCPio conn_a = new TCPio(Iin, out, lives); // I2P -> app
|
||||
t = new Thread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
||||
q = new Thread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
||||
// Fire!
|
||||
t.start();
|
||||
q.start();
|
||||
boolean spin = true;
|
||||
while (t.isAlive() && q.isAlive() && spin) { // AND is used here to kill off the other thread
|
||||
while (t.isAlive() && q.isAlive() && lives.get()) { // AND is used here to kill off the other thread
|
||||
try {
|
||||
Thread.sleep(10); //sleep for 10 ms
|
||||
} catch (InterruptedException e) {
|
||||
break die;
|
||||
}
|
||||
try {
|
||||
rlock();
|
||||
} catch (Exception e) {
|
||||
break die;
|
||||
}
|
||||
try {
|
||||
spin = info.get("RUNNING").equals(Boolean.TRUE);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
runlock();
|
||||
} catch (Exception e2) {
|
||||
break die;
|
||||
}
|
||||
break die;
|
||||
}
|
||||
}
|
||||
// System.out.println("I2PtoTCP: Going away...");
|
||||
} catch (Exception e) {
|
||||
@@ -150,14 +137,6 @@ public class I2PtoTCP implements Runnable {
|
||||
}
|
||||
} // die
|
||||
} finally {
|
||||
try {
|
||||
t.interrupt();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
q.interrupt();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
in.close();
|
||||
} catch (Exception ex) {
|
||||
@@ -174,6 +153,14 @@ public class I2PtoTCP implements Runnable {
|
||||
Iout.close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
t.interrupt();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
q.interrupt();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
// System.out.println("I2PtoTCP: Close I2P");
|
||||
I2P.close();
|
||||
|
@@ -43,7 +43,7 @@ import net.i2p.util.Log;
|
||||
*/
|
||||
public class MUXlisten implements Runnable {
|
||||
|
||||
private NamedDB database, info;
|
||||
private NamedDB database, info;
|
||||
private Log _log;
|
||||
private I2PSocketManager socketManager;
|
||||
private ByteArrayInputStream prikey;
|
||||
@@ -54,6 +54,7 @@ public class MUXlisten implements Runnable {
|
||||
boolean go_out;
|
||||
boolean come_in;
|
||||
private AtomicBoolean lock;
|
||||
private AtomicBoolean lives;
|
||||
|
||||
/**
|
||||
* Constructor Will fail if INPORT is occupied.
|
||||
@@ -65,47 +66,84 @@ public class MUXlisten implements Runnable {
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
MUXlisten(AtomicBoolean lock, NamedDB database, NamedDB info, Log _log) throws I2PException, IOException, RuntimeException {
|
||||
int port = 0;
|
||||
InetAddress host = null;
|
||||
this.lock = lock;
|
||||
this.tg = null;
|
||||
this.database = database;
|
||||
this.info = info;
|
||||
this._log = _log;
|
||||
try {
|
||||
int port = 0;
|
||||
InetAddress host = null;
|
||||
this.lock = lock;
|
||||
this.tg = null;
|
||||
this.database = database;
|
||||
this.info = info;
|
||||
this._log = _log;
|
||||
lives = new AtomicBoolean(false);
|
||||
|
||||
this.database.getReadLock();
|
||||
this.info.getReadLock();
|
||||
N = this.info.get("NICKNAME").toString();
|
||||
prikey = new ByteArrayInputStream((byte[]) info.get("KEYS"));
|
||||
// Make a new copy so that anything else won't muck with our database.
|
||||
Properties R = (Properties) info.get("PROPERTIES");
|
||||
Properties Q = new Properties();
|
||||
Lifted.copyProperties(R, Q);
|
||||
this.database.releaseReadLock();
|
||||
this.info.releaseReadLock();
|
||||
this.database.getWriteLock();
|
||||
this.info.getWriteLock();
|
||||
this.info.add("STARTING", new Boolean(true));
|
||||
this.info.releaseWriteLock();
|
||||
this.database.releaseWriteLock();
|
||||
this.database.getReadLock();
|
||||
this.info.getReadLock();
|
||||
|
||||
this.database.getReadLock();
|
||||
this.info.getReadLock();
|
||||
this.go_out = info.exists("OUTPORT");
|
||||
this.come_in = info.exists("INPORT");
|
||||
if (this.come_in) {
|
||||
port = Integer.parseInt(info.get("INPORT").toString());
|
||||
host = InetAddress.getByName(info.get("INHOST").toString());
|
||||
N = this.info.get("NICKNAME").toString();
|
||||
prikey = new ByteArrayInputStream((byte[]) info.get("KEYS"));
|
||||
// Make a new copy so that anything else won't muck with our database.
|
||||
Properties R = (Properties) info.get("PROPERTIES");
|
||||
Properties Q = new Properties();
|
||||
Lifted.copyProperties(R, Q);
|
||||
this.database.releaseReadLock();
|
||||
this.info.releaseReadLock();
|
||||
|
||||
this.database.getReadLock();
|
||||
this.info.getReadLock();
|
||||
this.go_out = info.exists("OUTPORT");
|
||||
this.come_in = info.exists("INPORT");
|
||||
if (this.come_in) {
|
||||
port = Integer.parseInt(info.get("INPORT").toString());
|
||||
host = InetAddress.getByName(info.get("INHOST").toString());
|
||||
}
|
||||
this.database.releaseReadLock();
|
||||
this.info.releaseReadLock();
|
||||
|
||||
if (this.come_in) {
|
||||
this.listener = new ServerSocket(port, backlog, host);
|
||||
}
|
||||
socketManager = I2PSocketManagerFactory.createManager(prikey, Q);
|
||||
// I2PException, IOException, RuntimeException
|
||||
// To bad we can't just catch and enumerate....
|
||||
// } catch (I2PException e) {
|
||||
// Something went bad.
|
||||
// this.database.getWriteLock();
|
||||
// this.info.getWriteLock();
|
||||
// this.info.add("STARTING", new Boolean(false));
|
||||
// this.info.releaseWriteLock();
|
||||
// this.database.releaseWriteLock();
|
||||
// throw new I2PException(e);
|
||||
} catch (IOException e) {
|
||||
// Something went bad.
|
||||
this.database.getWriteLock();
|
||||
this.info.getWriteLock();
|
||||
this.info.add("STARTING", new Boolean(false));
|
||||
this.info.releaseWriteLock();
|
||||
this.database.releaseWriteLock();
|
||||
throw new IOException(e.toString());
|
||||
} catch (RuntimeException e) {
|
||||
// Something went bad.
|
||||
this.database.getWriteLock();
|
||||
this.info.getWriteLock();
|
||||
this.info.add("STARTING", new Boolean(false));
|
||||
this.info.releaseWriteLock();
|
||||
this.database.releaseWriteLock();
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
// Something else went bad.
|
||||
this.database.getWriteLock();
|
||||
this.info.getWriteLock();
|
||||
this.info.add("STARTING", new Boolean(false));
|
||||
this.info.releaseWriteLock();
|
||||
this.database.releaseWriteLock();
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.database.releaseReadLock();
|
||||
this.info.releaseReadLock();
|
||||
|
||||
socketManager = I2PSocketManagerFactory.createManager(prikey, Q);
|
||||
if (this.come_in) {
|
||||
this.listener = new ServerSocket(port, backlog, host);
|
||||
}
|
||||
|
||||
// Everything is OK as far as we can tell.
|
||||
this.database.getWriteLock();
|
||||
this.info.getWriteLock();
|
||||
this.info.add("STARTING", new Boolean(true));
|
||||
this.info.releaseWriteLock();
|
||||
this.database.releaseWriteLock();
|
||||
}
|
||||
|
||||
private void rlock() throws Exception {
|
||||
@@ -142,18 +180,22 @@ public class MUXlisten implements Runnable {
|
||||
try {
|
||||
info.add("RUNNING", new Boolean(true));
|
||||
} catch (Exception e) {
|
||||
lock.set(false);
|
||||
wunlock();
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
lock.set(false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
wunlock();
|
||||
} catch (Exception e) {
|
||||
lock.set(false);
|
||||
return;
|
||||
}
|
||||
// socketManager.addDisconnectListener(new DisconnectListener());
|
||||
lives.set(true);
|
||||
lock.set(false);
|
||||
quit:
|
||||
{
|
||||
@@ -166,14 +208,14 @@ public class MUXlisten implements Runnable {
|
||||
if (go_out) {
|
||||
// I2P -> TCP
|
||||
SS = socketManager.getServerSocket();
|
||||
I2Plistener conn = new I2Plistener(SS, socketManager, info, database, _log);
|
||||
I2Plistener conn = new I2Plistener(SS, socketManager, info, database, _log, lives);
|
||||
t = new Thread(tg, conn, "BOBI2Plistener " + N);
|
||||
t.start();
|
||||
}
|
||||
|
||||
if (come_in) {
|
||||
// TCP -> I2P
|
||||
TCPlistener conn = new TCPlistener(listener, socketManager, info, database, _log);
|
||||
TCPlistener conn = new TCPlistener(listener, socketManager, info, database, _log, lives);
|
||||
q = new Thread(tg, conn, "BOBTCPlistener " + N);
|
||||
q.start();
|
||||
}
|
||||
@@ -195,7 +237,7 @@ public class MUXlisten implements Runnable {
|
||||
break quit;
|
||||
}
|
||||
boolean spin = true;
|
||||
while (spin) {
|
||||
while (spin && lives.get()) {
|
||||
try {
|
||||
Thread.sleep(1000); //sleep for 1 second
|
||||
} catch (InterruptedException e) {
|
||||
@@ -226,26 +268,30 @@ public class MUXlisten implements Runnable {
|
||||
}
|
||||
} // quit
|
||||
} finally {
|
||||
// Start cleanup.
|
||||
while (!lock.compareAndSet(false, true)) {
|
||||
// wait
|
||||
lives.set(false);
|
||||
// Some grace time.
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
|
||||
// zero out everything.
|
||||
try {
|
||||
wlock();
|
||||
try {
|
||||
info.add("STARTING", new Boolean(false));
|
||||
info.add("STOPPING", new Boolean(false));
|
||||
info.add("STOPPING", new Boolean(true));
|
||||
info.add("RUNNING", new Boolean(false));
|
||||
} catch (Exception e) {
|
||||
lock.set(false);
|
||||
wunlock();
|
||||
return;
|
||||
}
|
||||
wunlock();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// Start cleanup.
|
||||
while (!lock.compareAndSet(false, true)) {
|
||||
// wait
|
||||
}
|
||||
if (SS != null) {
|
||||
try {
|
||||
SS.close();
|
||||
@@ -261,11 +307,28 @@ public class MUXlisten implements Runnable {
|
||||
|
||||
// Some grace time.
|
||||
try {
|
||||
Thread.sleep(250);
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
|
||||
// zero out everything.
|
||||
try {
|
||||
wlock();
|
||||
try {
|
||||
info.add("STARTING", new Boolean(false));
|
||||
info.add("STOPPING", new Boolean(false));
|
||||
info.add("RUNNING", new Boolean(false));
|
||||
} catch (Exception e) {
|
||||
lock.set(false);
|
||||
wunlock();
|
||||
return;
|
||||
}
|
||||
wunlock();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
lock.set(false); // Should we force waiting for all threads??
|
||||
|
||||
// Wait around till all threads are collected.
|
||||
if (tg != null) {
|
||||
String boner = tg.getName();
|
||||
@@ -276,7 +339,7 @@ public class MUXlisten implements Runnable {
|
||||
// visit(tg, 0, boner);
|
||||
int foo = tg.activeCount() + tg.activeGroupCount();
|
||||
// hopefully no longer needed!
|
||||
// int bar = foo;
|
||||
// int bar = lives;
|
||||
// System.out.println("BOB: MUXlisten: Waiting on threads for " + boner);
|
||||
// System.out.println("\nBOB: MUXlisten: ThreadGroup dump BEGIN " + boner);
|
||||
// visit(tg, 0, boner);
|
||||
@@ -284,12 +347,12 @@ public class MUXlisten implements Runnable {
|
||||
// Happily spin forever :-(
|
||||
while (foo != 0) {
|
||||
foo = tg.activeCount() + tg.activeGroupCount();
|
||||
// if (foo != bar && foo != 0) {
|
||||
// if (lives != bar && lives != 0) {
|
||||
// System.out.println("\nBOB: MUXlisten: ThreadGroup dump BEGIN " + boner);
|
||||
// visit(tg, 0, boner);
|
||||
// System.out.println("BOB: MUXlisten: ThreadGroup dump END " + boner + "\n");
|
||||
// }
|
||||
// bar = foo;
|
||||
// bar = lives;
|
||||
try {
|
||||
Thread.sleep(100); //sleep for 100 ms (One tenth second)
|
||||
} catch (InterruptedException ex) {
|
||||
@@ -356,5 +419,4 @@ public class MUXlisten implements Runnable {
|
||||
visit(groups[i], level + 1, groups[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ package net.i2p.BOB;
|
||||
import net.i2p.client.streaming.RetransmissionTimer;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer2;
|
||||
|
||||
/**
|
||||
* Start from command line
|
||||
*
|
||||
|
@@ -43,10 +43,10 @@ public class NamedDB {
|
||||
}
|
||||
|
||||
synchronized public void getReadLock() {
|
||||
while((writersWaiting != 0)) {
|
||||
while ((writersWaiting != 0)) {
|
||||
try {
|
||||
wait();
|
||||
} catch(InterruptedException ie) {
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
readers++;
|
||||
@@ -59,10 +59,10 @@ public class NamedDB {
|
||||
|
||||
synchronized public void getWriteLock() {
|
||||
writersWaiting++;
|
||||
while(readers != 0 && writersWaiting != 1 ) {
|
||||
while (readers != 0 && writersWaiting != 1) {
|
||||
try {
|
||||
wait();
|
||||
} catch(InterruptedException ie) {
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,8 +79,8 @@ public class NamedDB {
|
||||
* @throws ArrayIndexOutOfBoundsException when key does not exist
|
||||
*/
|
||||
public int idx(Object key) throws ArrayIndexOutOfBoundsException {
|
||||
for(int i = 0; i < index; i++) {
|
||||
if(key.equals(data[i][0])) {
|
||||
for (int i = 0; i < index; i++) {
|
||||
if (key.equals(data[i][0])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -100,17 +100,17 @@ public class NamedDB {
|
||||
|
||||
try {
|
||||
k = idx(key);
|
||||
} catch(ArrayIndexOutOfBoundsException b) {
|
||||
} catch (ArrayIndexOutOfBoundsException b) {
|
||||
return;
|
||||
}
|
||||
olddata = new Object[index + 2][2];
|
||||
// copy to olddata, skipping 'k'
|
||||
for(i = 0 , l = 0; l < index; i++, l++) {
|
||||
if(i == k) {
|
||||
for (i = 0, l = 0; l < index; i++, l++) {
|
||||
if (i == k) {
|
||||
l++;
|
||||
didsomething++;
|
||||
}
|
||||
for(j = 0; j < 2; j++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
olddata[i][j] = data[l][j];
|
||||
}
|
||||
}
|
||||
@@ -132,13 +132,13 @@ public class NamedDB {
|
||||
|
||||
olddata = new Object[index + 2][2];
|
||||
// copy to olddata
|
||||
for(i = 0; i < index; i++) {
|
||||
for(j = 0; j < 2; j++) {
|
||||
for (i = 0; i < index; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
olddata[i][j] = data[i][j];
|
||||
}
|
||||
}
|
||||
data = olddata;
|
||||
data[index++] = new Object[] {key, val};
|
||||
data[index++] = new Object[]{key, val};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,8 +149,8 @@ public class NamedDB {
|
||||
* @throws java.lang.RuntimeException
|
||||
*/
|
||||
public Object get(Object key) throws RuntimeException {
|
||||
for(int i = 0; i < index; i++) {
|
||||
if(key.equals(data[i][0])) {
|
||||
for (int i = 0; i < index; i++) {
|
||||
if (key.equals(data[i][0])) {
|
||||
return data[i][1];
|
||||
}
|
||||
}
|
||||
@@ -164,8 +164,8 @@ public class NamedDB {
|
||||
* @return true if an object exists, else returns false
|
||||
*/
|
||||
public boolean exists(Object key) {
|
||||
for(int i = 0; i < index; i++) {
|
||||
if(key.equals(data[i][0])) {
|
||||
for (int i = 0; i < index; i++) {
|
||||
if (key.equals(data[i][0])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class NamedDB {
|
||||
* @throws java.lang.RuntimeException
|
||||
*/
|
||||
public Object getnext(int i) throws RuntimeException {
|
||||
if(i < index && i > -1) {
|
||||
if (i < index && i > -1) {
|
||||
return data[i][1];
|
||||
}
|
||||
throw new RuntimeException("No more data");
|
||||
|
@@ -26,6 +26,7 @@ package net.i2p.BOB;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Shove data from one stream to the other.
|
||||
@@ -36,7 +37,7 @@ public class TCPio implements Runnable {
|
||||
|
||||
private InputStream Ain;
|
||||
private OutputStream Aout;
|
||||
// private NamedDB info, database;
|
||||
private AtomicBoolean lives;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -46,11 +47,10 @@ public class TCPio implements Runnable {
|
||||
*
|
||||
* param database
|
||||
*/
|
||||
TCPio(InputStream Ain, OutputStream Aout /*, NamedDB info , NamedDB database */) {
|
||||
TCPio(InputStream Ain, OutputStream Aout, AtomicBoolean lives) {
|
||||
this.Ain = Ain;
|
||||
this.Aout = Aout;
|
||||
// this.info = info;
|
||||
// this.database = database;
|
||||
this.lives = lives;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,17 +78,20 @@ public class TCPio implements Runnable {
|
||||
* --Sponge
|
||||
*
|
||||
* Tested with 128 bytes, and there was no performance gain.
|
||||
* 8192 bytes did lower load average across many connections.
|
||||
* Should I raise it higer? The correct thing to do would be to
|
||||
* override... perhaps use NTCP, but I2P's streaming lib lacks
|
||||
* anything NTCP compatable.
|
||||
*
|
||||
* --Sponge
|
||||
*/
|
||||
|
||||
int b;
|
||||
byte a[] = new byte[1];
|
||||
boolean spin = true;
|
||||
byte a[] = new byte[8192];
|
||||
try {
|
||||
try {
|
||||
while (spin) {
|
||||
b = Ain.read(a, 0, 1);
|
||||
while (lives.get()) {
|
||||
b = Ain.read(a, 0, 8192);
|
||||
if (b > 0) {
|
||||
Aout.write(a, 0, b);
|
||||
} else if (b == 0) {
|
||||
@@ -105,9 +108,6 @@ public class TCPio implements Runnable {
|
||||
*
|
||||
*/
|
||||
// System.out.println("TCPio: End Of Stream");
|
||||
// Ain.close();
|
||||
// Aout.close();
|
||||
//return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
// import net.i2p.client.I2PSession;
|
||||
// import net.i2p.client.I2PSessionException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.i2p.client.streaming.I2PServerSocket;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.util.Log;
|
||||
@@ -45,6 +46,7 @@ public class TCPlistener implements Runnable {
|
||||
public I2PSocketManager socketManager;
|
||||
public I2PServerSocket serverSocket;
|
||||
private ServerSocket listener;
|
||||
private AtomicBoolean lives;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -53,22 +55,13 @@ public class TCPlistener implements Runnable {
|
||||
* @param database
|
||||
* @param _log
|
||||
*/
|
||||
TCPlistener(ServerSocket listener, I2PSocketManager S, NamedDB info, NamedDB database, Log _log) {
|
||||
TCPlistener(ServerSocket listener, I2PSocketManager S, NamedDB info, NamedDB database, Log _log, AtomicBoolean lives) {
|
||||
this.database = database;
|
||||
this.info = info;
|
||||
this._log = _log;
|
||||
this.socketManager = S;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
private void rlock() throws Exception {
|
||||
database.getReadLock();
|
||||
info.getReadLock();
|
||||
}
|
||||
|
||||
private void runlock() throws Exception {
|
||||
database.releaseReadLock();
|
||||
info.releaseReadLock();
|
||||
this.lives = lives;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,47 +70,28 @@ public class TCPlistener implements Runnable {
|
||||
*/
|
||||
public void run() {
|
||||
boolean g = false;
|
||||
boolean spin = true;
|
||||
int conn = 0;
|
||||
Socket server = null;
|
||||
try {
|
||||
die:
|
||||
{
|
||||
try {
|
||||
Socket server = new Socket();
|
||||
listener.setSoTimeout(50); // We don't block, we cycle and check.
|
||||
while (spin) {
|
||||
try {
|
||||
rlock();
|
||||
} catch (Exception e) {
|
||||
break die;
|
||||
}
|
||||
try {
|
||||
spin = info.get("RUNNING").equals(Boolean.TRUE);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
runlock();
|
||||
} catch (Exception e2) {
|
||||
break die;
|
||||
}
|
||||
break die;
|
||||
}
|
||||
try {
|
||||
server = listener.accept();
|
||||
g = true;
|
||||
} catch (SocketTimeoutException ste) {
|
||||
g = false;
|
||||
}
|
||||
if (g) {
|
||||
conn++;
|
||||
// toss the connection to a new thread.
|
||||
TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database);
|
||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn);
|
||||
t.start();
|
||||
g = false;
|
||||
}
|
||||
try {
|
||||
listener.setSoTimeout(50); // We don't block, we cycle and check.
|
||||
while (lives.get()) {
|
||||
try {
|
||||
server = listener.accept();
|
||||
g = true;
|
||||
} catch (SocketTimeoutException ste) {
|
||||
g = false;
|
||||
}
|
||||
if (g) {
|
||||
conn++;
|
||||
// toss the connection to a new thread.
|
||||
TCPtoI2P conn_c = new TCPtoI2P(socketManager, server, info, database, lives);
|
||||
Thread t = new Thread(conn_c, Thread.currentThread().getName() + " TCPtoI2P " + conn);
|
||||
t.start();
|
||||
g = false;
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
|
@@ -30,6 +30,7 @@ import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.NoRouteToHostException;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.i2p.I2PException;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
@@ -49,6 +50,7 @@ public class TCPtoI2P implements Runnable {
|
||||
private NamedDB info, database;
|
||||
private Socket sock;
|
||||
private I2PSocketManager socketManager;
|
||||
private AtomicBoolean lives;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -57,11 +59,12 @@ public class TCPtoI2P implements Runnable {
|
||||
* param info
|
||||
* param database
|
||||
*/
|
||||
TCPtoI2P(I2PSocketManager i2p, Socket socket , NamedDB info, NamedDB database) {
|
||||
TCPtoI2P(I2PSocketManager i2p, Socket socket, NamedDB info, NamedDB database, AtomicBoolean lives) {
|
||||
this.sock = socket;
|
||||
this.info = info;
|
||||
this.database = database;
|
||||
this.socketManager = i2p;
|
||||
this.lives = lives;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,19 +160,15 @@ public class TCPtoI2P implements Runnable {
|
||||
Iin = I2P.getInputStream();
|
||||
Iout = I2P.getOutputStream();
|
||||
// setup to cross the streams
|
||||
TCPio conn_c = new TCPio(in, Iout /*, info, database */); // app -> I2P
|
||||
TCPio conn_a = new TCPio(Iin, out /*, info, database */); // I2P -> app
|
||||
TCPio conn_c = new TCPio(in, Iout, lives); // app -> I2P
|
||||
TCPio conn_a = new TCPio(Iin, out, lives); // I2P -> app
|
||||
t = new Thread(conn_c, Thread.currentThread().getName() + " TCPioA");
|
||||
q = new Thread(conn_a, Thread.currentThread().getName() + " TCPioB");
|
||||
// Fire!
|
||||
t.start();
|
||||
q.start();
|
||||
boolean spin = true;
|
||||
while (t.isAlive() && q.isAlive()) { // AND is used here to kill off the other thread
|
||||
while (t.isAlive() && q.isAlive() && lives.get()) { // AND is used here to kill off the other thread
|
||||
Thread.sleep(10); //sleep for 10 ms
|
||||
rlock();
|
||||
spin = info.get("RUNNING").equals(Boolean.TRUE);
|
||||
runlock();
|
||||
}
|
||||
} catch (I2PException e) {
|
||||
Emsg(e.toString(), out);
|
||||
|
@@ -78,26 +78,26 @@ public class UDPIOthread implements I2PSessionListener, Runnable {
|
||||
try {
|
||||
in = new DataInputStream(socket.getInputStream());
|
||||
out = new DataOutputStream(socket.getOutputStream());
|
||||
while(up) {
|
||||
while (up) {
|
||||
int c = in.read(data);
|
||||
// Note: could do a loopback test here with a wrapper.
|
||||
boolean ok = _session.sendMessage(_peerDestination, data, 0, c);
|
||||
|
||||
if(!ok) {
|
||||
if (!ok) {
|
||||
up = false; // Is this the right thing to do??
|
||||
}
|
||||
}
|
||||
} catch(IOException ioe) {
|
||||
} catch (IOException ioe) {
|
||||
_log.error("Error running", ioe);
|
||||
} catch(I2PSessionException ise) {
|
||||
} catch (I2PSessionException ise) {
|
||||
_log.error("Error communicating", ise);
|
||||
// } catch(DataFormatException dfe) {
|
||||
// _log.error("Peer destination file is not valid", dfe);
|
||||
} finally {
|
||||
if(_session != null) {
|
||||
if (_session != null) {
|
||||
try {
|
||||
_session.destroySession();
|
||||
} catch(I2PSessionException ise) {
|
||||
} catch (I2PSessionException ise) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -116,9 +116,9 @@ public class UDPIOthread implements I2PSessionListener, Runnable {
|
||||
byte msg[] = session.receiveMessage(msgId);
|
||||
out.write(msg);
|
||||
out.flush();
|
||||
} catch(I2PSessionException ise) {
|
||||
} catch (I2PSessionException ise) {
|
||||
up = false;
|
||||
} catch(IOException ioe) {
|
||||
} catch (IOException ioe) {
|
||||
up = false;
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -94,20 +94,21 @@ public class AddressBook {
|
||||
* @param proxyPort port number of proxy
|
||||
*/
|
||||
public AddressBook(Subscription subscription, String proxyHost, int proxyPort) {
|
||||
File tmp = new File(I2PAppContext.getGlobalContext().getTempDir(), "addressbook.tmp");
|
||||
this.location = subscription.getLocation();
|
||||
EepGet get = new EepGet(I2PAppContext.getGlobalContext(), true,
|
||||
proxyHost, proxyPort, 0, -1l, MAX_SUB_SIZE, "addressbook.tmp", null,
|
||||
proxyHost, proxyPort, 0, -1l, MAX_SUB_SIZE, tmp.getAbsolutePath(), null,
|
||||
subscription.getLocation(), true, subscription.getEtag(), subscription.getLastModified(), null);
|
||||
if (get.fetch()) {
|
||||
subscription.setEtag(get.getETag());
|
||||
subscription.setLastModified(get.getLastModified());
|
||||
}
|
||||
try {
|
||||
this.addresses = ConfigParser.parse(new File("addressbook.tmp"));
|
||||
this.addresses = ConfigParser.parse(tmp);
|
||||
} catch (IOException exp) {
|
||||
this.addresses = new HashMap();
|
||||
}
|
||||
new File("addressbook.tmp").delete();
|
||||
tmp.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +193,8 @@ public class AddressBook {
|
||||
(! host.endsWith(".router.i2p")) &&
|
||||
(! host.endsWith(".console.i2p")) &&
|
||||
|
||||
((dest.length() == MIN_DEST_LENGTH && dest.endsWith("AAAA")) ||
|
||||
// null cert ends with AAAA but other zero-length certs would be AA
|
||||
((dest.length() == MIN_DEST_LENGTH && dest.endsWith("AA")) ||
|
||||
(dest.length() > MIN_DEST_LENGTH && dest.length() <= MAX_DEST_LENGTH)) &&
|
||||
dest.replaceAll("[a-zA-Z0-9~-]", "").length() == 0
|
||||
;
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@@ -39,6 +39,9 @@ import java.util.Map;
|
||||
* Utility class providing methods to parse and write files in config file
|
||||
* format, and subscription file format.
|
||||
*
|
||||
* TODO: Change file encoding from default to UTF-8?
|
||||
* Or switch to the DataHelper loadProps/storeProps methods?
|
||||
*
|
||||
* @author Ragnarok
|
||||
*/
|
||||
public class ConfigParser {
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@@ -28,6 +28,8 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
|
||||
/**
|
||||
* Main class of addressbook. Performs updates, and runs the main loop.
|
||||
*
|
||||
@@ -125,11 +127,13 @@ public class Daemon {
|
||||
|
||||
public void run(String[] args) {
|
||||
String settingsLocation = "config.txt";
|
||||
String home;
|
||||
File homeFile;
|
||||
if (args.length > 0) {
|
||||
home = args[0];
|
||||
homeFile = new File(args[0]);
|
||||
if (!homeFile.isAbsolute())
|
||||
homeFile = new File(I2PAppContext.getGlobalContext().getRouterDir(), args[0]);
|
||||
} else {
|
||||
home = ".";
|
||||
homeFile = new File(System.getProperty("user.dir"));
|
||||
}
|
||||
|
||||
Map defaultSettings = new HashMap();
|
||||
@@ -145,7 +149,6 @@ public class Daemon {
|
||||
defaultSettings.put("last_modified", "last_modified");
|
||||
defaultSettings.put("update_delay", "12");
|
||||
|
||||
File homeFile = new File(home);
|
||||
if (!homeFile.exists()) {
|
||||
boolean created = homeFile.mkdirs();
|
||||
if (created)
|
||||
@@ -169,7 +172,7 @@ public class Daemon {
|
||||
delay = 1;
|
||||
}
|
||||
|
||||
update(settings, home);
|
||||
update(settings, homeFile.getAbsolutePath());
|
||||
try {
|
||||
synchronized (this) {
|
||||
wait(delay * 60 * 60 * 1000);
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
/**
|
||||
* A thread that waits five minutes, then runs the addressbook daemon.
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import javax.servlet.GenericServlet;
|
||||
import javax.servlet.ServletConfig;
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
/**
|
||||
* A subscription to a remote address book.
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
@@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package addressbook;
|
||||
package net.i2p.addressbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
@@ -6,11 +6,11 @@
|
||||
<web-app>
|
||||
<servlet>
|
||||
<servlet-name>addressbook</servlet-name>
|
||||
<servlet-class>addressbook.Servlet</servlet-class>
|
||||
<servlet-class>net.i2p.addressbook.Servlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>home</param-name>
|
||||
<param-value>./addressbook</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
</web-app>
|
||||
</web-app>
|
||||
|
@@ -73,7 +73,7 @@ class AdminRunner implements Runnable {
|
||||
}
|
||||
|
||||
private void reply(OutputStream out, String content) throws IOException {
|
||||
StringBuffer reply = new StringBuffer(10240);
|
||||
StringBuilder reply = new StringBuilder(10240);
|
||||
reply.append("HTTP/1.1 200 OK\n");
|
||||
reply.append("Connection: close\n");
|
||||
reply.append("Cache-control: no-cache\n");
|
||||
@@ -90,7 +90,7 @@ class AdminRunner implements Runnable {
|
||||
}
|
||||
|
||||
private void replyText(OutputStream out, String content) throws IOException {
|
||||
StringBuffer reply = new StringBuffer(10240);
|
||||
StringBuilder reply = new StringBuilder(10240);
|
||||
reply.append("HTTP/1.1 200 OK\n");
|
||||
reply.append("Connection: close\n");
|
||||
reply.append("Cache-control: no-cache\n");
|
@@ -1 +1,7 @@
|
||||
# NOTE: This I2P config file must use UTF-8 encoding
|
||||
#
|
||||
# If you have a 'split' directory installation, with configuration
|
||||
# files in ~/.i2p (Linux) or %APPDATA%\I2P (Windows), be sure to
|
||||
# edit the file in the configuration directory, NOT the install directory.
|
||||
#
|
||||
i2psnark.dir=i2psnark
|
||||
|
@@ -37,16 +37,23 @@
|
||||
</javac>
|
||||
</target>
|
||||
<target name="jar" depends="builddep, compile">
|
||||
<jar destfile="./build/i2psnark.jar" basedir="./build/obj" includes="**/*.class" excludes="**/*Servlet.class">
|
||||
<jar destfile="./build/i2psnark.jar" basedir="./build/obj" includes="**/*.class" excludes="**/I2PSnarkServlet*.class">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="org.klomp.snark.Snark" />
|
||||
<attribute name="Class-Path" value="i2p.jar mstreaming.jar streaming.jar" />
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
<!-- Ideally we would include
|
||||
- only include the servlet, everything else is in the jar.
|
||||
- However, the wrapper.config classpath in existing installs
|
||||
- does not include i2psnark.jar.
|
||||
- So we must continue to duplicate everything in the war.
|
||||
<classes dir="./build/obj" includes="**/I2PSnarkServlet*.class" />
|
||||
-->
|
||||
<target name="war" depends="jar">
|
||||
<war destfile="../i2psnark.war" webxml="../web.xml">
|
||||
<classes dir="./build/obj" includes="**/*" />
|
||||
<classes dir="./build/obj" includes="**/*.class" excludes="**/RunStandalone.class" />
|
||||
</war>
|
||||
</target>
|
||||
|
||||
@@ -56,31 +63,13 @@
|
||||
</zip>
|
||||
</target>
|
||||
<target name="standalone_prep" depends="war">
|
||||
<javac debug="true" deprecation="on" source="1.5" target="1.5"
|
||||
destdir="./build" srcdir="src/" includes="org/klomp/snark/web/RunStandalone.java" >
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
<classpath>
|
||||
<pathelement location="../../jetty/jettylib/commons-logging.jar" />
|
||||
<pathelement location="../../jetty/jettylib/commons-el.jar" />
|
||||
<pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
|
||||
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />
|
||||
<pathelement location="../../../core/java/build/i2p.jar" />
|
||||
</classpath>
|
||||
</javac>
|
||||
|
||||
<jar destfile="./build/launch-i2psnark.jar" basedir="./build/" includes="org/klomp/snark/web/RunStandalone.class">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="org.klomp.snark.web.RunStandalone" />
|
||||
<attribute name="Class-Path" value="lib/i2p.jar lib/mstreaming.jar lib/streaming.jar lib/commons-el.jar lib/commons-logging.jar lib/jasper-compiler.jar lib/jasper-runtime.jar lib/javax.servlet.jar lib/org.mortbay.jetty.jar" />
|
||||
</manifest>
|
||||
</jar>
|
||||
|
||||
<delete dir="./dist" />
|
||||
<mkdir dir="./dist" />
|
||||
<copy file="./build/launch-i2psnark.jar" tofile="./dist/launch-i2psnark.jar" />
|
||||
<copy file="../launch-i2psnark" todir="./dist/" />
|
||||
<mkdir dir="./dist/webapps" />
|
||||
<copy file="../i2psnark.war" tofile="./dist/webapps/i2psnark.war" />
|
||||
<mkdir dir="./dist/lib" />
|
||||
<copy file="./build/i2psnark.jar" tofile="./dist/lib/i2psnark.jar" />
|
||||
<copy file="../../../core/java/build/i2p.jar" tofile="./dist/lib/i2p.jar" />
|
||||
<copy file="../../jetty/jettylib/commons-el.jar" tofile="./dist/lib/commons-el.jar" />
|
||||
<copy file="../../jetty/jettylib/commons-logging.jar" tofile="./dist/lib/commons-logging.jar" />
|
||||
@@ -92,7 +81,6 @@
|
||||
<copy file="../../streaming/java/build/streaming.jar" tofile="./dist/lib/streaming.jar" />
|
||||
<copy file="../jetty-i2psnark.xml" tofile="./dist/jetty-i2psnark.xml" />
|
||||
<copy file="../readme-standalone.txt" tofile="./dist/readme.txt" />
|
||||
<mkdir dir="./dist/work" />
|
||||
<mkdir dir="./dist/logs" />
|
||||
|
||||
<zip destfile="i2psnark-standalone.zip">
|
||||
@@ -104,6 +92,7 @@
|
||||
<delete dir="./build" />
|
||||
<delete file="../i2psnark.war" />
|
||||
<delete file="./i2psnark-standalone.zip" />
|
||||
<delete dir="./dist" />
|
||||
</target>
|
||||
<target name="cleandep" depends="clean">
|
||||
<ant dir="../../ministreaming/java/" target="distclean" />
|
||||
|
@@ -7,7 +7,6 @@ package org.klomp.snark;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.I2PSessionException;
|
||||
import net.i2p.client.I2PClient;
|
||||
import net.i2p.client.I2PSession;
|
||||
|
@@ -137,10 +137,11 @@ public class BitField
|
||||
return count >= size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
// Not very efficient
|
||||
StringBuffer sb = new StringBuffer("BitField(");
|
||||
StringBuilder sb = new StringBuilder("BitField(");
|
||||
sb.append(size).append(")[");
|
||||
for (int i = 0; i < size; i++)
|
||||
if (get(i))
|
||||
|
@@ -17,6 +17,7 @@ import net.i2p.I2PException;
|
||||
import net.i2p.client.I2PSession;
|
||||
import net.i2p.client.streaming.I2PServerSocket;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.client.streaming.I2PSocketEepGet;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.client.streaming.I2PSocketManagerFactory;
|
||||
import net.i2p.data.DataFormatException;
|
||||
@@ -46,7 +47,7 @@ public class I2PSnarkUtil {
|
||||
private Map _opts;
|
||||
private I2PSocketManager _manager;
|
||||
private boolean _configured;
|
||||
private Set _shitlist;
|
||||
private final Set _shitlist;
|
||||
private int _maxUploaders;
|
||||
private int _maxUpBW;
|
||||
private int _maxConnections;
|
||||
@@ -73,7 +74,7 @@ public class I2PSnarkUtil {
|
||||
// This is used for both announce replies and .torrent file downloads,
|
||||
// so it must be available even if not connected to I2CP.
|
||||
// so much for multiple instances
|
||||
_tmpDir = new File("tmp", "i2psnark");
|
||||
_tmpDir = new File(ctx.getTempDir(), "i2psnark");
|
||||
FileUtil.rmdir(_tmpDir, false);
|
||||
_tmpDir.mkdirs();
|
||||
}
|
||||
@@ -231,7 +232,13 @@ public class I2PSnarkUtil {
|
||||
if (rewrite)
|
||||
fetchURL = rewriteAnnounce(url);
|
||||
//_log.debug("Rewritten url [" + fetchURL + "]");
|
||||
EepGet get = new EepGet(_context, _shouldProxy, _proxyHost, _proxyPort, retries, out.getAbsolutePath(), fetchURL);
|
||||
//EepGet get = new EepGet(_context, _shouldProxy, _proxyHost, _proxyPort, retries, out.getAbsolutePath(), fetchURL);
|
||||
// Use our tunnel for announces and .torrent fetches too! Make sure we're connected first...
|
||||
if (!connected()) {
|
||||
if (!connect())
|
||||
return null;
|
||||
}
|
||||
EepGet get = new I2PSocketEepGet(_context, _manager, retries, out.getAbsolutePath(), fetchURL);
|
||||
if (get.fetch()) {
|
||||
_log.debug("Fetch successful [" + url + "]: size=" + out.length());
|
||||
return out;
|
||||
@@ -327,6 +334,11 @@ public class I2PSnarkUtil {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/** @param ot non-null */
|
||||
public void setOpenTrackerString(String ot) {
|
||||
_opts.put(PROP_OPENTRACKERS, ot);
|
||||
}
|
||||
|
||||
public String getOpenTrackerString() {
|
||||
String rv = (String) _opts.get(PROP_OPENTRACKERS);
|
||||
if (rv == null)
|
||||
|
@@ -110,6 +110,7 @@ class Message
|
||||
dos.write(data, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
switch (type)
|
||||
|
@@ -345,6 +345,7 @@ public class MetaInfo
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "MetaInfo[info_hash='" + hexencode(info_hash)
|
||||
@@ -362,7 +363,7 @@ public class MetaInfo
|
||||
*/
|
||||
private static String hexencode(byte[] bs)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer(bs.length*2);
|
||||
StringBuilder sb = new StringBuilder(bs.length*2);
|
||||
for (int i = 0; i < bs.length; i++)
|
||||
{
|
||||
int c = bs[i] & 0xFF;
|
||||
@@ -432,7 +433,7 @@ public class MetaInfo
|
||||
private byte[] calculateInfoHash()
|
||||
{
|
||||
Map info = createInfoMap();
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("info: ");
|
||||
for (Iterator iter = info.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
|
@@ -106,6 +106,7 @@ public class Peer implements Comparable
|
||||
/**
|
||||
* Returns the String representation of the peerID.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if (peerID != null)
|
||||
@@ -125,6 +126,7 @@ public class Peer implements Comparable
|
||||
/**
|
||||
* The hash code of a Peer is the hash code of the peerID.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return peerID.hashCode() ^ (2 << _id);
|
||||
@@ -134,6 +136,7 @@ public class Peer implements Comparable
|
||||
* Two Peers are equal when they have the same PeerID.
|
||||
* All other properties are ignored.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof Peer)
|
||||
|
@@ -41,7 +41,7 @@ class PeerConnectionOut implements Runnable
|
||||
private boolean quit;
|
||||
|
||||
// Contains Messages.
|
||||
private List sendQueue = new ArrayList();
|
||||
private final List sendQueue = new ArrayList();
|
||||
|
||||
private static long __id = 0;
|
||||
private long _id;
|
||||
|
@@ -236,10 +236,21 @@ public class PeerCoordinator implements PeerListener
|
||||
{
|
||||
synchronized(peers)
|
||||
{
|
||||
return !halted && peers.size() < _util.getMaxConnections();
|
||||
return !halted && peers.size() < getMaxConnections();
|
||||
}
|
||||
}
|
||||
|
||||
/** reduce max if huge pieces to keep from ooming */
|
||||
private int getMaxConnections() {
|
||||
int size = metainfo.getPieceLength(0);
|
||||
int max = _util.getMaxConnections();
|
||||
if (size <= 1024*1024)
|
||||
return max;
|
||||
if (size <= 2*1024*1024)
|
||||
return (max + 1) / 2;
|
||||
return (max + 3) / 4;
|
||||
}
|
||||
|
||||
public boolean halted() { return halted; }
|
||||
|
||||
public void halt()
|
||||
@@ -294,7 +305,7 @@ public class PeerCoordinator implements PeerListener
|
||||
peer.disconnect(false); // Don't deregister this connection/peer.
|
||||
}
|
||||
// This is already checked in addPeer() but we could have gone over the limit since then
|
||||
else if (peers.size() >= _util.getMaxConnections())
|
||||
else if (peers.size() >= getMaxConnections())
|
||||
{
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Already at MAX_CONNECTIONS in connected() with peer: " + peer);
|
||||
@@ -350,7 +361,7 @@ public class PeerCoordinator implements PeerListener
|
||||
peersize = peers.size();
|
||||
// This isn't a strict limit, as we may have several pending connections;
|
||||
// thus there is an additional check in connected()
|
||||
need_more = (!peer.isConnected()) && peersize < _util.getMaxConnections();
|
||||
need_more = (!peer.isConnected()) && peersize < getMaxConnections();
|
||||
// Check if we already have this peer before we build the connection
|
||||
Peer old = peerIDInList(peer.getPeerID(), peers);
|
||||
need_more = need_more && ((old == null) || (old.getInactiveTime() > 8*60*1000));
|
||||
@@ -378,7 +389,7 @@ public class PeerCoordinator implements PeerListener
|
||||
if (peer.isConnected())
|
||||
_log.info("Add peer already connected: " + peer);
|
||||
else
|
||||
_log.info("Connections: " + peersize + "/" + _util.getMaxConnections()
|
||||
_log.info("Connections: " + peersize + "/" + getMaxConnections()
|
||||
+ " not accepting extra peer: " + peer);
|
||||
}
|
||||
return false;
|
||||
|
@@ -12,7 +12,7 @@ import java.util.Set;
|
||||
* from it there too)
|
||||
*/
|
||||
public class PeerCoordinatorSet {
|
||||
private Set _coordinators;
|
||||
private final Set _coordinators;
|
||||
|
||||
public PeerCoordinatorSet() {
|
||||
_coordinators = new HashSet();
|
||||
|
@@ -107,6 +107,7 @@ public class PeerID implements Comparable
|
||||
/**
|
||||
* The hash code of a PeerID is the exclusive or of all id bytes.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return hash;
|
||||
@@ -127,6 +128,7 @@ public class PeerID implements Comparable
|
||||
/**
|
||||
* Two PeerIDs are equal when they have the same id, address and port.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof PeerID)
|
||||
@@ -171,6 +173,7 @@ public class PeerID implements Comparable
|
||||
* and address is the base64 dest (was the base64 hash of the dest) which
|
||||
* should match what the bytemonsoon tracker reports on its web pages.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
int nonZero = 0;
|
||||
@@ -190,7 +193,7 @@ public class PeerID implements Comparable
|
||||
{
|
||||
boolean leading_zeros = true;
|
||||
|
||||
StringBuffer sb = new StringBuffer(bs.length*2);
|
||||
StringBuilder sb = new StringBuilder(bs.length*2);
|
||||
for (int i = 0; i < bs.length; i++)
|
||||
{
|
||||
int c = bs[i] & 0xFF;
|
||||
|
@@ -151,7 +151,7 @@ public interface PeerListener
|
||||
*
|
||||
* @param state the PeerState for the peer
|
||||
*/
|
||||
void savePeerPartial(PeerState state);
|
||||
void savePeerPartial(PeerState state); /* FIXME Exporting non-public type through public API FIXME */
|
||||
|
||||
/**
|
||||
* Called when a peer has connected and there may be a partially
|
||||
@@ -161,7 +161,7 @@ public interface PeerListener
|
||||
*
|
||||
* @return request (contains the partial data and valid length)
|
||||
*/
|
||||
Request getPeerPartial(BitField havePieces);
|
||||
Request getPeerPartial(BitField havePieces); /* FIXME Exporting non-public type through public API FIXME */
|
||||
|
||||
/** Mark a peer's requested pieces unrequested when it is disconnected
|
||||
* This prevents premature end game
|
||||
|
@@ -20,13 +20,20 @@ public class Piece implements Comparable {
|
||||
return this.peers.size() - ((Piece)o).peers.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) return false;
|
||||
try {
|
||||
if (o instanceof Piece) {
|
||||
if (o == null) return false;
|
||||
return this.id == ((Piece)o).id;
|
||||
} catch (ClassCastException cce) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 31 * hash + this.id;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public int getId() { return this.id; }
|
||||
@@ -36,6 +43,7 @@ public class Piece implements Comparable {
|
||||
public boolean isRequested() { return this.requested; }
|
||||
public void setRequested(boolean requested) { this.requested = requested; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(id);
|
||||
}
|
||||
|
@@ -51,11 +51,13 @@ class Request
|
||||
throw new IndexOutOfBoundsException("Illegal Request " + toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return piece ^ off ^ len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof Request)
|
||||
@@ -67,6 +69,7 @@ class Request
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "(" + piece + "," + off + "," + len + ")";
|
||||
|
@@ -28,7 +28,6 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.StringTokenizer;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,7 @@ public class SnarkShutdown extends I2PAppThread
|
||||
|
||||
private final ShutdownListener listener;
|
||||
|
||||
/* FIXME Exporting non-public type through public API FIXME */
|
||||
public SnarkShutdown(Storage storage,
|
||||
PeerCoordinator coordinator,
|
||||
ConnectionAcceptor acceptor,
|
||||
@@ -49,6 +50,7 @@ public class SnarkShutdown extends I2PAppThread
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
//Snark.debug("Shutting down...", Snark.NOTICE);
|
||||
|
@@ -46,7 +46,7 @@ public class Storage
|
||||
private final StorageListener listener;
|
||||
private I2PSnarkUtil _util;
|
||||
|
||||
private BitField bitfield; // BitField to represent the pieces
|
||||
private /* FIXME final FIXME */ BitField bitfield; // BitField to represent the pieces
|
||||
private int needed; // Number of pieces needed
|
||||
private boolean _probablyComplete; // use this to decide whether to open files RO
|
||||
|
||||
@@ -57,7 +57,8 @@ public class Storage
|
||||
|
||||
/** The default piece size. */
|
||||
private static final int MIN_PIECE_SIZE = 256*1024;
|
||||
public static final int MAX_PIECE_SIZE = 1024*1024;
|
||||
/** note that we start reducing max number of peer connections above 1MB */
|
||||
public static final int MAX_PIECE_SIZE = 2*1024*1024;
|
||||
/** The maximum number of pieces in a torrent. */
|
||||
public static final int MAX_PIECES = 10*1024;
|
||||
public static final long MAX_TOTAL_SIZE = MAX_PIECE_SIZE * (long) MAX_PIECES;
|
||||
@@ -190,6 +191,9 @@ public class Storage
|
||||
}
|
||||
*/
|
||||
|
||||
/** FIXME we can run out of fd's doing this,
|
||||
* maybe some sort of global close-RAF-right-away flag
|
||||
* would do the trick */
|
||||
private void fast_digestCreate() throws IOException {
|
||||
// Calculate piece_hashes
|
||||
SHA1 digest = new SHA1();
|
||||
|
@@ -81,6 +81,7 @@ public class TrackerClient extends I2PAppThread
|
||||
started = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (stop) throw new RuntimeException("Dont rerun me, create a copy");
|
||||
super.start();
|
||||
@@ -109,6 +110,7 @@ public class TrackerClient extends I2PAppThread
|
||||
return !stop && _util.connected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String infoHash = urlencode(meta.getInfoHash());
|
||||
@@ -162,7 +164,7 @@ public class TrackerClient extends I2PAppThread
|
||||
try
|
||||
{
|
||||
if (!verifyConnected()) return;
|
||||
boolean started = false;
|
||||
boolean runStarted = false;
|
||||
boolean firstTime = true;
|
||||
int consecutiveFails = 0;
|
||||
Random r = new Random();
|
||||
@@ -178,7 +180,7 @@ public class TrackerClient extends I2PAppThread
|
||||
if (firstTime) {
|
||||
delay = r.nextInt(30*1000);
|
||||
firstTime = false;
|
||||
} else if (completed && started)
|
||||
} else if (completed && runStarted)
|
||||
delay = 3*SLEEP*60*1000 + random;
|
||||
else if (coordinator.trackerProblems != null && ++consecutiveFails < MAX_CONSEC_FAILS)
|
||||
delay = INITIAL_SLEEP;
|
||||
@@ -221,7 +223,7 @@ public class TrackerClient extends I2PAppThread
|
||||
Tracker tr = (Tracker)iter.next();
|
||||
if ((!stop) && (!tr.stop) &&
|
||||
(completed || coordinator.needPeers()) &&
|
||||
(event == COMPLETED_EVENT || System.currentTimeMillis() > tr.lastRequestTime + tr.interval))
|
||||
(event.equals(COMPLETED_EVENT) || System.currentTimeMillis() > tr.lastRequestTime + tr.interval))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -237,7 +239,7 @@ public class TrackerClient extends I2PAppThread
|
||||
tr.consecutiveFails = 0;
|
||||
if (tr.isPrimary)
|
||||
consecutiveFails = 0;
|
||||
started = true;
|
||||
runStarted = true;
|
||||
tr.started = true;
|
||||
|
||||
Set peers = info.getPeers();
|
||||
@@ -296,7 +298,7 @@ public class TrackerClient extends I2PAppThread
|
||||
|
||||
// we could try and total the unique peers but that's too hard for now
|
||||
coordinator.trackerSeenPeers = maxSeenPeers;
|
||||
if (!started)
|
||||
if (!runStarted)
|
||||
_util.debug(" Retrying in one minute...", Snark.DEBUG);
|
||||
} // *** end of while loop
|
||||
} // try
|
||||
@@ -311,9 +313,9 @@ public class TrackerClient extends I2PAppThread
|
||||
try
|
||||
{
|
||||
// try to contact everybody we can
|
||||
// We don't need I2CP connection for eepget
|
||||
// if (!verifyConnected()) return;
|
||||
// Don't try to restart I2CP connection just to say goodbye
|
||||
for (Iterator iter = trackers.iterator(); iter.hasNext(); ) {
|
||||
if (!verifyConnected()) return;
|
||||
Tracker tr = (Tracker)iter.next();
|
||||
if (tr.started && (!tr.stop) && tr.trackerProblems == null)
|
||||
doRequest(tr, infoHash, peerID, uploaded,
|
||||
@@ -338,7 +340,7 @@ public class TrackerClient extends I2PAppThread
|
||||
+ "&uploaded=" + uploaded
|
||||
+ "&downloaded=" + downloaded
|
||||
+ "&left=" + left
|
||||
+ ((event != NO_EVENT) ? ("&event=" + event) : "");
|
||||
+ ((! event.equals(NO_EVENT)) ? ("&event=" + event) : "");
|
||||
_util.debug("Sending TrackerClient request: " + s, Snark.INFO);
|
||||
|
||||
tr.lastRequestTime = System.currentTimeMillis();
|
||||
@@ -373,7 +375,7 @@ public class TrackerClient extends I2PAppThread
|
||||
*/
|
||||
public static String urlencode(byte[] bs)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer(bs.length*3);
|
||||
StringBuilder sb = new StringBuilder(bs.length*3);
|
||||
for (int i = 0; i < bs.length; i++)
|
||||
{
|
||||
int c = bs[i] & 0xFF;
|
||||
|
@@ -125,6 +125,7 @@ public class TrackerInfo
|
||||
return interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if (failure_reason != null)
|
||||
|
@@ -172,6 +172,7 @@ public class BEValue
|
||||
/** return the untyped value */
|
||||
public Object getValue() { return value; }
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String valueString;
|
||||
|
@@ -27,7 +27,6 @@ import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
import org.klomp.snark.I2PSnarkUtil;
|
||||
import org.klomp.snark.MetaInfo;
|
||||
import org.klomp.snark.Peer;
|
||||
import org.klomp.snark.Snark;
|
||||
@@ -46,6 +45,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
|
||||
public static final String PROP_CONFIG_FILE = "i2psnark.configFile";
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig cfg) throws ServletException {
|
||||
super.init(cfg);
|
||||
_context = I2PAppContext.getGlobalContext();
|
||||
@@ -59,11 +59,13 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
_manager.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
req.setCharacterEncoding("UTF-8");
|
||||
resp.setCharacterEncoding("UTF-8");
|
||||
resp.setContentType("text/html; charset=UTF-8");
|
||||
long stats[] = {0,0,0,0,0};
|
||||
/** dl, ul, down rate, up rate, peers, size */
|
||||
final long stats[] = {0,0,0,0,0,0};
|
||||
|
||||
String nonce = req.getParameter("nonce");
|
||||
if ( (nonce != null) && (nonce.equals(String.valueOf(_nonce))) )
|
||||
@@ -82,14 +84,9 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
// we want it to go to the base URI so we don't refresh with some funky action= value
|
||||
out.write("<meta http-equiv=\"refresh\" content=\"60;" + req.getRequestURI() + peerString + "\">\n");
|
||||
out.write(HEADER);
|
||||
|
||||
out.write("<table border=\"0\" width=\"100%\">\n");
|
||||
out.write("<tr><td width=\"20%\" class=\"snarkTitle\" valign=\"top\" align=\"left\">");
|
||||
out.write("I2PSnark<br />\n");
|
||||
out.write("<table border=\"0\" width=\"100%\">\n");
|
||||
out.write("<tr><td><a href=\"" + req.getRequestURI() + peerString + "\" class=\"snarkRefresh\">Refresh</a>\n");
|
||||
out.write("<td><a href=\"http://forum.i2p/viewforum.php?f=21\" class=\"snarkRefresh\">Forum</a>\n");
|
||||
int count = 0;
|
||||
out.write("</head><body>");
|
||||
out.write("<center>");
|
||||
out.write("<div class=\"snarknavbar\"><a href=\"" + req.getRequestURI() + peerString + "\" title=\"Refresh page\" class=\"snarkRefresh\">I2PSnark</a> <a href=\"http://forum.i2p/viewforum.php?f=21\" class=\"snarkRefresh\" target=\"_blank\">Forum</a>\n");
|
||||
Map trackers = _manager.getTrackers();
|
||||
for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
@@ -99,38 +96,34 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
if (e < 0)
|
||||
continue;
|
||||
baseURL = baseURL.substring(e + 1);
|
||||
if (count++ % 2 == 0)
|
||||
out.write("<tr>");
|
||||
out.write("<td><a href=\"" + baseURL + "\" class=\"snarkRefresh\">" + name + "</a>\n");
|
||||
out.write(" <a href=\"" + baseURL + "\" class=\"snarkRefresh\" target=\"_blank\">" + name + "</a>");
|
||||
}
|
||||
if (count % 2 == 1)
|
||||
out.write("<td> \n");
|
||||
out.write("</table>\n");
|
||||
out.write("</td><td width=\"80%\" class=\"snarkMessages\" valign=\"top\" align=\"left\"><pre>");
|
||||
out.write("</div>\n");
|
||||
out.write("<div class=\"page\"><div class=\"mainsection\"><div class=\"snarkMessages\"><table><tr><td align=\"left\"><pre>");
|
||||
List msgs = _manager.getMessages();
|
||||
for (int i = msgs.size()-1; i >= 0; i--) {
|
||||
String msg = (String)msgs.get(i);
|
||||
out.write(msg + "\n");
|
||||
}
|
||||
out.write("</pre></td></tr></table>\n");
|
||||
out.write("</pre></td></tr></table></div>");
|
||||
|
||||
List snarks = getSortedSnarks(req);
|
||||
String uri = req.getRequestURI();
|
||||
out.write(TABLE_HEADER);
|
||||
if (_manager.util().connected() && snarks.size() > 0) {
|
||||
if (peerParam != null)
|
||||
out.write("(<a href=\"" + req.getRequestURI() + "\">Hide Peers</a>)<br />\n");
|
||||
out.write("(<a href=\"" + req.getRequestURI() + "\">Hide Peers</a>)<br>\n");
|
||||
else
|
||||
out.write("(<a href=\"" + req.getRequestURI() + "?p=1" + "\">Show Peers</a>)<br />\n");
|
||||
out.write("(<a href=\"" + req.getRequestURI() + "?p=1" + "\">Show Peers</a>)<br>\n");
|
||||
}
|
||||
out.write(TABLE_HEADER2);
|
||||
out.write("<th align=\"left\" valign=\"top\">");
|
||||
out.write("<th align=\"center\">");
|
||||
if (_manager.util().connected())
|
||||
out.write("<a href=\"" + uri + "?action=StopAll&nonce=" + _nonce +
|
||||
"\" title=\"Stop all torrents and the i2p tunnel\">Stop All</a>");
|
||||
"\" title=\"Stop all torrents and the I2P tunnel\">Stop All</a>");
|
||||
else if (snarks.size() > 0)
|
||||
out.write("<a href=\"" + uri + "?action=StartAll&nonce=" + _nonce +
|
||||
"\" title=\"Start all torrents and the i2p tunnel\">Start All</a>");
|
||||
"\" title=\"Start all torrents and the I2P tunnel\">Start All</a>");
|
||||
else
|
||||
out.write(" ");
|
||||
out.write("</th></tr></thead>\n");
|
||||
@@ -144,12 +137,15 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
out.write(TABLE_EMPTY);
|
||||
} else if (snarks.size() > 1) {
|
||||
out.write("<tfoot><tr>\n" +
|
||||
" <th align=\"left\" valign=\"top\" colspan=\"2\">Totals (" + snarks.size() + " torrents, " + stats[4] + " connected peers)</th>\n" +
|
||||
" <th align=\"left\" colspan=\"2\">Totals (" +
|
||||
snarks.size() + " torrents, " +
|
||||
DataHelper.formatSize(stats[5]) + "B, " +
|
||||
stats[4] + " connected peers)</th>\n" +
|
||||
" <th> </th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">" + formatSize(stats[0]) + "</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">" + formatSize(stats[1]) + "</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">" + formatSize(stats[2]) + "ps</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">" + formatSize(stats[3]) + "ps</th>\n" +
|
||||
" <th align=\"right\">" + formatSize(stats[0]) + "</th>\n" +
|
||||
" <th align=\"right\">" + formatSize(stats[1]) + "</th>\n" +
|
||||
" <th align=\"right\">" + formatSize(stats[2]) + "ps</th>\n" +
|
||||
" <th align=\"right\">" + formatSize(stats[3]) + "ps</th>\n" +
|
||||
" <th> </th></tr>\n" +
|
||||
"</tfoot>\n");
|
||||
}
|
||||
@@ -173,6 +169,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
} else if ("Add torrent".equals(action)) {
|
||||
String newFile = req.getParameter("newFile");
|
||||
String newURL = req.getParameter("newURL");
|
||||
// NOTE - newFile currently disabled in HTML form - see below
|
||||
File f = null;
|
||||
if ( (newFile != null) && (newFile.trim().length() > 0) )
|
||||
f = new File(newFile.trim());
|
||||
@@ -326,7 +323,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
_manager.updateConfig(dataDir, autoStart, seedPct, eepHost, eepPort, i2cpHost, i2cpPort, i2cpOpts, upLimit, upBW, useOpenTrackers, openTrackers);
|
||||
} else if ("Create torrent".equals(action)) {
|
||||
String baseData = req.getParameter("baseFile");
|
||||
if (baseData != null) {
|
||||
if (baseData != null && baseData.trim().length() > 0) {
|
||||
File baseFile = new File(_manager.getDataDir(), baseData);
|
||||
String announceURL = req.getParameter("announceURL");
|
||||
String announceURLOther = req.getParameter("announceURLOther");
|
||||
@@ -359,9 +356,11 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
} else {
|
||||
_manager.addMessage("Cannot create a torrent for the nonexistent data: " + baseFile.getAbsolutePath());
|
||||
}
|
||||
} else {
|
||||
_manager.addMessage("Error creating torrent - you must enter a file or directory");
|
||||
}
|
||||
} else if ("StopAll".equals(action)) {
|
||||
_manager.addMessage("Stopping all torrents and closing the I2P tunnel");
|
||||
_manager.addMessage("Stopping all torrents and closing the I2P tunnel.");
|
||||
List snarks = getSortedSnarks(req);
|
||||
for (int i = 0; i < snarks.size(); i++) {
|
||||
Snark snark = (Snark)snarks.get(i);
|
||||
@@ -370,10 +369,10 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
}
|
||||
if (_manager.util().connected()) {
|
||||
_manager.util().disconnect();
|
||||
_manager.addMessage("I2P tunnel closed");
|
||||
_manager.addMessage("I2P tunnel closed.");
|
||||
}
|
||||
} else if ("StartAll".equals(action)) {
|
||||
_manager.addMessage("Opening the I2P tunnel and starting all torrents");
|
||||
_manager.addMessage("Opening the I2P tunnel and starting all torrents.");
|
||||
List snarks = getSortedSnarks(req);
|
||||
for (int i = 0; i < snarks.size(); i++) {
|
||||
Snark snark = (Snark)snarks.get(i);
|
||||
@@ -397,7 +396,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
return rv;
|
||||
}
|
||||
|
||||
private static final int MAX_DISPLAYED_FILENAME_LENGTH = 60;
|
||||
private static final int MAX_DISPLAYED_FILENAME_LENGTH = 44;
|
||||
private static final int MAX_DISPLAYED_ERROR_LENGTH = 40;
|
||||
private void displaySnark(PrintWriter out, Snark snark, String uri, int row, long stats[], boolean showPeers, boolean showDebug) throws IOException {
|
||||
String filename = snark.torrent;
|
||||
@@ -407,7 +406,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
if (i > 0)
|
||||
filename = filename.substring(0, i);
|
||||
if (filename.length() > MAX_DISPLAYED_FILENAME_LENGTH)
|
||||
filename = filename.substring(0, MAX_DISPLAYED_FILENAME_LENGTH) + "...";
|
||||
filename = filename.substring(0, MAX_DISPLAYED_FILENAME_LENGTH) + "…";
|
||||
long total = snark.meta.getTotalLength();
|
||||
// Early typecast, avoid possibly overflowing a temp integer
|
||||
long remaining = (long) snark.storage.needed() * (long) snark.meta.getPieceLength(0);
|
||||
@@ -435,6 +434,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
stats[2] += downBps;
|
||||
stats[3] += upBps;
|
||||
}
|
||||
stats[5] += total;
|
||||
|
||||
boolean isValid = snark.meta != null;
|
||||
boolean singleFile = snark.meta.getFiles() == null;
|
||||
@@ -459,8 +459,8 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
statusString = "<a title=\"" + err + "\">TrackerErr (" + curPeers + "/" + knownPeers + " peers)";
|
||||
else {
|
||||
if (err.length() > MAX_DISPLAYED_ERROR_LENGTH)
|
||||
err = err.substring(0, MAX_DISPLAYED_ERROR_LENGTH) + "...";
|
||||
statusString = "TrackerErr<br />(" + err + ")";
|
||||
err = err.substring(0, MAX_DISPLAYED_ERROR_LENGTH) + "…";
|
||||
statusString = "TrackerErr<br>(" + err + ")";
|
||||
}
|
||||
} else if (remaining <= 0) {
|
||||
if (isRunning && curPeers > 0 && !showPeers)
|
||||
@@ -492,60 +492,61 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
|
||||
String rowClass = (row % 2 == 0 ? "snarkTorrentEven" : "snarkTorrentOdd");
|
||||
out.write("<tr class=\"" + rowClass + "\">");
|
||||
out.write("<td valign=\"top\" align=\"left\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("<td align=\"center\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write(statusString + "</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"left\" class=\"snarkTorrentName " + rowClass + "\">");
|
||||
out.write("<td align=\"left\" class=\"snarkTorrentName " + rowClass + "\">");
|
||||
|
||||
if (remaining == 0)
|
||||
out.write("<a href=\"" + _manager.linkPrefix() + snark.meta.getName()
|
||||
+ "\" title=\"Download the completed file\">");
|
||||
+ "\" title=\"View file\">");
|
||||
out.write(filename);
|
||||
if (remaining == 0)
|
||||
out.write("</a>");
|
||||
// temporarily hardcoded for postman* and anonymity, requires bytemonsoon patch for lookup by info_hash
|
||||
String announce = snark.meta.getAnnounce();
|
||||
if (announce.startsWith("http://YRgrgTLG") || announce.startsWith("http://8EoJZIKr") ||
|
||||
announce.startsWith("http://lnQ6yoBT")) {
|
||||
announce.startsWith("http://lnQ6yoBT") || announce.startsWith("http://tracker2.postman.i2p/")) {
|
||||
Map trackers = _manager.getTrackers();
|
||||
for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
String name = (String)entry.getKey();
|
||||
String baseURL = (String)entry.getValue();
|
||||
if (!baseURL.startsWith(announce))
|
||||
if (!(baseURL.startsWith(announce) || // vvv hack for non-b64 announce in list vvv
|
||||
(announce.startsWith("http://lnQ6yoBT") && baseURL.startsWith("http://tracker2.postman.i2p/"))))
|
||||
continue;
|
||||
int e = baseURL.indexOf('=');
|
||||
if (e < 0)
|
||||
continue;
|
||||
baseURL = baseURL.substring(e + 1);
|
||||
out.write(" (<a href=\"" + baseURL + "details.php?dllist=1&filelist=1&info_hash=");
|
||||
out.write(" [<a href=\"" + baseURL + "details.php?dllist=1&filelist=1&info_hash=");
|
||||
out.write(TrackerClient.urlencode(snark.meta.getInfoHash()));
|
||||
out.write("\" title=\"" + name + " Tracker\">Details</a>)");
|
||||
out.write("\" title=\"" + name + " Tracker\">Details</a>]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
out.write("</td>\n\t");
|
||||
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentETA " + rowClass + "\">");
|
||||
out.write("<td align=\"center\" class=\"snarkTorrentETA " + rowClass + "\">");
|
||||
if(isRunning && remainingSeconds > 0)
|
||||
out.write(DataHelper.formatDuration(remainingSeconds*1000)); // (eta 6h)
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentDownloaded " + rowClass + "\">");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentDownloaded " + rowClass + "\">");
|
||||
if (remaining > 0)
|
||||
out.write(formatSize(total-remaining) + "/" + formatSize(total)); // 18MB/3GB
|
||||
else
|
||||
out.write(formatSize(total)); // 3GB
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentUploaded " + rowClass
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentUploaded " + rowClass
|
||||
+ "\">" + formatSize(uploaded) + "</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentRate\">");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentRate\">");
|
||||
if(isRunning && remaining > 0)
|
||||
out.write(formatSize(downBps) + "ps");
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentRate\">");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentRate\">");
|
||||
if(isRunning)
|
||||
out.write(formatSize(upBps) + "ps");
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"left\" class=\"snarkTorrentAction " + rowClass + "\">");
|
||||
out.write("<td align=\"center\" class=\"snarkTorrentAction " + rowClass + "\">");
|
||||
String parameters = "&nonce=" + _nonce + "&torrent=" + Base64.encode(snark.meta.getInfoHash());
|
||||
if (showPeers)
|
||||
parameters = parameters + "&p=1";
|
||||
@@ -557,7 +558,7 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
out.write("<a href=\"" + uri + "?action=Start" + parameters
|
||||
+ "\" title=\"Start the torrent\">Start</a> ");
|
||||
out.write("<a href=\"" + uri + "?action=Remove" + parameters
|
||||
+ "\" title=\"Remove the torrent from the active list, deleting the .torrent file\">Remove</a><br />");
|
||||
+ "\" title=\"Remove the torrent from the active list, deleting the .torrent file\">Remove</a><br>");
|
||||
out.write("<a href=\"" + uri + "?action=Delete" + parameters
|
||||
+ "\" title=\"Delete the .torrent file and the associated data file(s)\">Delete</a> ");
|
||||
}
|
||||
@@ -570,9 +571,9 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
if (!peer.isConnected())
|
||||
continue;
|
||||
out.write("<tr class=\"" + rowClass + "\">");
|
||||
out.write("<td class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("<td align=\"center\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("<td align=\"left\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
String ch = peer.toString().substring(0, 4);
|
||||
String client;
|
||||
if ("AwMD".equals(ch))
|
||||
@@ -591,52 +592,52 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
client = "Robert";
|
||||
else
|
||||
client = "Unknown (" + ch + ')';
|
||||
out.write("<font size=-1>" + client + "</font> <tt>" + peer.toString().substring(5, 9) + "</tt>");
|
||||
out.write(client + " " + peer.toString().substring(5, 9));
|
||||
if (showDebug)
|
||||
out.write(" inactive " + (peer.getInactiveTime() / 1000) + "s");
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
float pct = (float) (100.0 * (float) peer.completed() / snark.meta.getPieces());
|
||||
if (pct == 100.0)
|
||||
out.write("<font size=-1>Seed</font>");
|
||||
out.write("Seed");
|
||||
else {
|
||||
String ps = String.valueOf(pct);
|
||||
if (ps.length() > 5)
|
||||
ps = ps.substring(0, 5);
|
||||
out.write("<font size=-1>" + ps + "%</font>");
|
||||
out.write(ps + "%");
|
||||
}
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
if (remaining > 0) {
|
||||
if (peer.isInteresting() && !peer.isChoked()) {
|
||||
out.write("<font color=#008000>");
|
||||
out.write("<font size=-1>" + formatSize(peer.getDownloadRate()) + "ps</font></font>");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</font>");
|
||||
} else {
|
||||
out.write("<font color=#a00000><font size=-1><a title=\"");
|
||||
out.write("<font color=#a00000><a title=\"");
|
||||
if (!peer.isInteresting())
|
||||
out.write("Uninteresting\">");
|
||||
else
|
||||
out.write("Choked\">");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</a></font></font>");
|
||||
out.write(formatSize(peer.getDownloadRate()) + "ps</a></font>");
|
||||
}
|
||||
}
|
||||
out.write("</td>\n\t");
|
||||
out.write("<td valign=\"top\" align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
out.write("<td align=\"right\" class=\"snarkTorrentStatus " + rowClass + "\">");
|
||||
if (pct != 100.0) {
|
||||
if (peer.isInterested() && !peer.isChoking()) {
|
||||
out.write("<font color=#008000>");
|
||||
out.write("<font size=-1>" + formatSize(peer.getUploadRate()) + "ps</font></font>");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</font>");
|
||||
} else {
|
||||
out.write("<font color=#a00000><font size=-1><a title=\"");
|
||||
out.write("<font color=#a00000><a title=\"");
|
||||
if (!peer.isInterested())
|
||||
out.write("Uninterested\">");
|
||||
else
|
||||
out.write("Choking\">");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</a></font></font>");
|
||||
out.write(formatSize(peer.getUploadRate()) + "ps</a></font>");
|
||||
}
|
||||
}
|
||||
out.write("</td>\n\t");
|
||||
@@ -658,15 +659,15 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
out.write("<span class=\"snarkNewTorrent\">\n");
|
||||
// *not* enctype="multipart/form-data", so that the input type=file sends the filename, not the file
|
||||
out.write("<form action=\"" + uri + "\" method=\"POST\">\n");
|
||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" />\n");
|
||||
out.write("<span class=\"snarkConfigTitle\">Add Torrent:</span><br />\n");
|
||||
out.write("From URL : <input type=\"text\" name=\"newURL\" size=\"80\" value=\"" + newURL + "\" /> \n");
|
||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" >\n");
|
||||
out.write("<div class=\"addtorrentsection\"><span class=\"snarkConfigTitle\">Add Torrent</span><br>\n");
|
||||
out.write("From URL : <input type=\"text\" name=\"newURL\" size=\"80\" value=\"" + newURL + "\" > \n");
|
||||
// not supporting from file at the moment, since the file name passed isn't always absolute (so it may not resolve)
|
||||
//out.write("From file: <input type=\"file\" name=\"newFile\" size=\"50\" value=\"" + newFile + "\" /><br />\n");
|
||||
out.write("<input type=\"submit\" value=\"Add torrent\" name=\"action\" /><br />\n");
|
||||
out.write("<span class=\"snarkAddInfo\">Alternately, you can copy .torrent files to " + _manager.getDataDir().getAbsolutePath() + "<br />\n");
|
||||
out.write("Removing that .torrent file will cause the torrent to stop.<br /></span>\n");
|
||||
out.write("</form>\n</span>\n");
|
||||
//out.write("From file: <input type=\"file\" name=\"newFile\" size=\"50\" value=\"" + newFile + "\" /><br>\n");
|
||||
out.write("<input type=\"submit\" value=\"Add torrent\" name=\"action\" ><br>\n");
|
||||
out.write("<span class=\"snarkAddInfo\">Alternately, you can copy .torrent files to " + _manager.getDataDir().getAbsolutePath() + "<br>\n");
|
||||
out.write("Removing that .torrent file will cause the torrent to stop.<br></span>\n");
|
||||
out.write("</form>\n</span></div>");
|
||||
}
|
||||
|
||||
private void writeSeedForm(PrintWriter out, HttpServletRequest req) throws IOException {
|
||||
@@ -675,15 +676,15 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
if (baseFile == null)
|
||||
baseFile = "";
|
||||
|
||||
out.write("<span class=\"snarkNewTorrent\"><hr />\n");
|
||||
out.write("<div class=\"newtorrentsection\"><span class=\"snarkNewTorrent\">\n");
|
||||
// *not* enctype="multipart/form-data", so that the input type=file sends the filename, not the file
|
||||
out.write("<form action=\"" + uri + "\" method=\"POST\">\n");
|
||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" />\n");
|
||||
out.write("<span class=\"snarkConfigTitle\">Create Torrent:</span><br />\n");
|
||||
//out.write("From file: <input type=\"file\" name=\"newFile\" size=\"50\" value=\"" + newFile + "\" /><br />\n");
|
||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" >\n");
|
||||
out.write("<span class=\"snarkConfigTitle\">Create Torrent</span><br>\n");
|
||||
//out.write("From file: <input type=\"file\" name=\"newFile\" size=\"50\" value=\"" + newFile + "\" /><br>\n");
|
||||
out.write("Data to seed: " + _manager.getDataDir().getAbsolutePath() + File.separatorChar
|
||||
+ "<input type=\"text\" name=\"baseFile\" size=\"20\" value=\"" + baseFile
|
||||
+ "\" title=\"File to seed (must be within the specified path)\" /><br />\n");
|
||||
+ "\" title=\"File to seed (must be within the specified path)\" ><br>\n");
|
||||
out.write("Tracker: <select name=\"announceURL\"><option value=\"\">Select a tracker</option>\n");
|
||||
Map trackers = _manager.getTrackers();
|
||||
for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
|
||||
@@ -697,9 +698,9 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
}
|
||||
out.write("</select>\n");
|
||||
out.write("or <input type=\"text\" name=\"announceURLOther\" size=\"50\" value=\"http://\" " +
|
||||
"title=\"Custom tracker URL\" /> ");
|
||||
out.write("<input type=\"submit\" value=\"Create torrent\" name=\"action\" />\n");
|
||||
out.write("</form>\n</span>\n");
|
||||
"title=\"Custom tracker URL\" > ");
|
||||
out.write("<input type=\"submit\" value=\"Create torrent\" name=\"action\" >\n");
|
||||
out.write("</form>\n</span></div>");
|
||||
}
|
||||
|
||||
private void writeConfigForm(PrintWriter out, HttpServletRequest req) throws IOException {
|
||||
@@ -711,17 +712,17 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
//int seedPct = 0;
|
||||
|
||||
out.write("<form action=\"" + uri + "\" method=\"POST\">\n");
|
||||
out.write("<span class=\"snarkConfig\"><hr />\n");
|
||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" />\n");
|
||||
out.write("<span class=\"snarkConfigTitle\">Configuration:</span><br />\n");
|
||||
out.write("Data directory: <input type=\"text\" size=\"40\" name=\"dataDir\" value=\"" + dataDir + "\" ");
|
||||
out.write("title=\"Directory to store torrents and data\" disabled=\"true\" /> <i>(Edit i2psnark.config and restart to change)</i><br />\n");
|
||||
out.write("Auto start: <input type=\"checkbox\" name=\"autoStart\" value=\"true\" "
|
||||
out.write("<div class=\"configsection\"><span class=\"snarkConfig\">\n");
|
||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" >\n");
|
||||
out.write("<span class=\"snarkConfigTitle\">Configuration</span><br>\n");
|
||||
out.write("<table border=\"0\"><tr><td>Data directory: <td><input type=\"text\" size=\"50\" name=\"dataDir\" value=\"" + dataDir + "\" ");
|
||||
out.write("title=\"Directory to store torrents and data\" disabled=\"true\" ><br><i>(Edit i2psnark.config and restart to change)</i><br>\n");
|
||||
out.write("<tr><td>Auto start: <td><input type=\"checkbox\" class=\"optbox\" name=\"autoStart\" value=\"true\" "
|
||||
+ (autoStart ? "checked " : "")
|
||||
+ "title=\"If true, automatically start torrents that are added\" />");
|
||||
+ "title=\"If true, automatically start torrents that are added\" >");
|
||||
//Auto add: <input type="checkbox" name="autoAdd" value="true" title="If true, automatically add torrents that are found in the data directory" />
|
||||
//Auto stop: <input type="checkbox" name="autoStop" value="true" title="If true, automatically stop torrents that are removed from the data directory" />
|
||||
//out.write("<br />\n");
|
||||
//out.write("<br>\n");
|
||||
/*
|
||||
out.write("Seed percentage: <select name=\"seedPct\" disabled=\"true\" >\n\t");
|
||||
if (seedPct <= 0)
|
||||
@@ -736,29 +737,29 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
out.write("<option value=\"150\" selected=\"true\">150%</option>\n\t");
|
||||
else
|
||||
out.write("<option value=\"150\">150%</option>\n\t");
|
||||
out.write("</select><br />\n");
|
||||
out.write("</select><br>\n");
|
||||
*/
|
||||
out.write("Total uploader limit: <input type=\"text\" name=\"upLimit\" value=\""
|
||||
+ _manager.util().getMaxUploaders() + "\" size=\"3\" maxlength=\"3\" /> peers<br />\n");
|
||||
out.write("Up bandwidth limit: <input type=\"text\" name=\"upBW\" value=\""
|
||||
+ _manager.util().getMaxUpBW() + "\" size=\"3\" maxlength=\"3\" /> KBps <i>(Router Up BW / 2 recommended)</i><br />\n");
|
||||
out.write("<tr><td>Total uploader limit: <td><input type=\"text\" name=\"upLimit\" value=\""
|
||||
+ _manager.util().getMaxUploaders() + "\" size=\"3\" maxlength=\"3\" > peers<br>\n");
|
||||
out.write("<tr><td>Up bandwidth limit: <td><input type=\"text\" name=\"upBW\" value=\""
|
||||
+ _manager.util().getMaxUpBW() + "\" size=\"3\" maxlength=\"3\" > KBps <i>(Half <a href=\"/config.jsp\" target=\"blank\">available bandwidth</a> recommended.)</i><br>\n");
|
||||
|
||||
out.write("Use open trackers also: <input type=\"checkbox\" name=\"useOpenTrackers\" value=\"true\" "
|
||||
out.write("<tr><td>Use open trackers also: <td><input type=\"checkbox\" class=\"optbox\" name=\"useOpenTrackers\" value=\"true\" "
|
||||
+ (useOpenTrackers ? "checked " : "")
|
||||
+ "title=\"If true, uses open trackers in addition\" /> ");
|
||||
out.write("Announce URLs: <input type=\"text\" name=\"openTrackers\" value=\""
|
||||
+ openTrackers + "\" size=\"50\" /><br />\n");
|
||||
+ "title=\"If true, uses open trackers in addition\" > ");
|
||||
out.write("<tr><td>Open tracker announce URLs: <td><input type=\"text\" name=\"openTrackers\" value=\""
|
||||
+ openTrackers + "\" size=\"50\" ><br>\n");
|
||||
|
||||
//out.write("<hr />\n");
|
||||
out.write("EepProxy host: <input type=\"text\" name=\"eepHost\" value=\""
|
||||
+ _manager.util().getEepProxyHost() + "\" size=\"15\" /> ");
|
||||
out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
|
||||
+ _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br />\n");
|
||||
out.write("I2CP host: <input type=\"text\" name=\"i2cpHost\" value=\""
|
||||
+ _manager.util().getI2CPHost() + "\" size=\"15\" /> ");
|
||||
out.write("port: <input type=\"text\" name=\"i2cpPort\" value=\"" +
|
||||
+ _manager.util().getI2CPPort() + "\" size=\"5\" maxlength=\"5\" /> <br />\n");
|
||||
StringBuffer opts = new StringBuffer(64);
|
||||
//out.write("\n");
|
||||
//out.write("EepProxy host: <input type=\"text\" name=\"eepHost\" value=\""
|
||||
// + _manager.util().getEepProxyHost() + "\" size=\"15\" /> ");
|
||||
//out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
|
||||
// + _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br>\n");
|
||||
out.write("<tr><td>I2CP host: <td><input type=\"text\" name=\"i2cpHost\" value=\""
|
||||
+ _manager.util().getI2CPHost() + "\" size=\"15\" > ");
|
||||
out.write("<tr><td>I2CP port: <td><input type=\"text\" name=\"i2cpPort\" value=\"" +
|
||||
+ _manager.util().getI2CPPort() + "\" size=\"5\" maxlength=\"5\" > <br>\n");
|
||||
StringBuilder opts = new StringBuilder(64);
|
||||
Map options = new TreeMap(_manager.util().getI2CPOptions());
|
||||
for (Iterator iter = options.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
@@ -766,11 +767,11 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
String val = (String)entry.getValue();
|
||||
opts.append(key).append('=').append(val).append(' ');
|
||||
}
|
||||
out.write("I2CP opts: <input type=\"text\" name=\"i2cpOpts\" size=\"80\" value=\""
|
||||
+ opts.toString() + "\" /><br />\n");
|
||||
out.write("<input type=\"submit\" value=\"Save configuration\" name=\"action\" />\n");
|
||||
out.write("</span>\n");
|
||||
out.write("</form>\n");
|
||||
out.write("<tr><td>I2CP options: <td><textarea name=\"i2cpOpts\" cols=\"60\" rows=\"1\" wrap=\"off\" >"
|
||||
+ opts.toString() + "</textarea><br>\n");
|
||||
out.write("<tr><td> <td><input type=\"submit\" value=\"Save configuration\" name=\"action\" >\n");
|
||||
out.write("</table></span>\n");
|
||||
out.write("</form></div>");
|
||||
}
|
||||
|
||||
// rounding makes us look faster :)
|
||||
@@ -787,98 +788,33 @@ public class I2PSnarkServlet extends HttpServlet {
|
||||
|
||||
private static final String HEADER_BEGIN = "<html>\n" +
|
||||
"<head>\n" +
|
||||
"<title>I2PSnark - anonymous bittorrent</title>\n";
|
||||
"<title>I2PSnark - Anonymous BitTorrent Client</title>\n";
|
||||
|
||||
private static final String HEADER = "<style>\n" +
|
||||
"body {\n" +
|
||||
" background-color: #C7CFB4;\n" +
|
||||
"}\n" +
|
||||
".snarkTitle {\n" +
|
||||
" text-align: left;\n" +
|
||||
" float: left;\n" +
|
||||
" margin: 0px 0px 5px 5px;\n" +
|
||||
" display: inline;\n" +
|
||||
" font-size: 16pt;\n" +
|
||||
" font-weight: bold;\n" +
|
||||
"}\n" +
|
||||
".snarkRefresh {\n" +
|
||||
" font-size: 10pt;\n" +
|
||||
"}\n" +
|
||||
".snarkMessages {\n" +
|
||||
" border: none;\n" +
|
||||
" background-color: #CECFC6;\n" +
|
||||
" font-family: monospace;\n" +
|
||||
" font-size: 10pt;\n" +
|
||||
" font-weight: 100;\n" +
|
||||
" width: 100%;\n" +
|
||||
" text-align: left;\n" +
|
||||
" margin: 0px 0px 0px 0px;\n" +
|
||||
" border: 0px;\n" +
|
||||
" padding: 5px;\n" +
|
||||
" border-width: 0px;\n" +
|
||||
" border-spacing: 0px;\n" +
|
||||
"}\n" +
|
||||
"table {\n" +
|
||||
" margin: 0px 0px 0px 0px;\n" +
|
||||
" border: 0px;\n" +
|
||||
" padding: 0px;\n" +
|
||||
" border-width: 0px;\n" +
|
||||
" border-spacing: 0px;\n" +
|
||||
"}\n" +
|
||||
"th {\n" +
|
||||
" background-color: #C7D5D5;\n" +
|
||||
" padding: 0px 7px 0px 3px;\n" +
|
||||
"}\n" +
|
||||
"td {\n" +
|
||||
" padding: 0px 7px 0px 3px;\n" +
|
||||
"}\n" +
|
||||
".snarkTorrentEven {\n" +
|
||||
" background-color: #E7E7E7;\n" +
|
||||
"}\n" +
|
||||
".snarkTorrentOdd {\n" +
|
||||
" background-color: #DDDDCC;\n" +
|
||||
"}\n" +
|
||||
".snarkNewTorrent {\n" +
|
||||
" font-size: 10pt;\n" +
|
||||
"}\n" +
|
||||
".snarkAddInfo {\n" +
|
||||
" font-size: 10pt;\n" +
|
||||
"}\n" +
|
||||
".snarkConfigTitle {\n" +
|
||||
" font-size: 12pt;\n" +
|
||||
" font-weight: bold;\n" +
|
||||
"}\n" +
|
||||
".snarkConfig {\n" +
|
||||
" font-size: 10pt;\n" +
|
||||
"}\n" +
|
||||
"</style>\n" +
|
||||
"</head>\n" +
|
||||
"<body>\n";
|
||||
|
||||
private static final String HEADER = "<link href=\"../themes/console/snark.css\" rel=\"stylesheet\" type=\"text/css\" >";
|
||||
|
||||
|
||||
private static final String TABLE_HEADER = "<table border=\"0\" class=\"snarkTorrents\" width=\"100%\" cellpadding=\"0 10px\">\n" +
|
||||
"<thead>\n" +
|
||||
"<tr><th align=\"left\" valign=\"top\">Status \n";
|
||||
"<tr><th align=\"center\">Status \n";
|
||||
|
||||
private static final String TABLE_HEADER2 = "</th>\n" +
|
||||
" <th align=\"left\" valign=\"top\">Torrent</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">ETA</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">Downloaded</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">Uploaded</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">Down Rate</th>\n" +
|
||||
" <th align=\"right\" valign=\"top\">Up Rate</th>\n";
|
||||
" <th align=\"left\">Torrent</th>\n" +
|
||||
" <th align=\"center\">ETA</th>\n" +
|
||||
" <th align=\"right\">Downloaded</th>\n" +
|
||||
" <th align=\"right\">Uploaded</th>\n" +
|
||||
" <th align=\"right\">Down Rate</th>\n" +
|
||||
" <th align=\"right\">Up Rate</th>\n";
|
||||
|
||||
private static final String TABLE_EMPTY = "<tr class=\"snarkTorrentEven\">" +
|
||||
"<td class=\"snarkTorrentEven\" align=\"left\"" +
|
||||
" valign=\"top\" colspan=\"8\">No torrents</td></tr>\n";
|
||||
"<td class=\"snarkTorrentEven\" align=\"center\"" +
|
||||
" colspan=\"8\"><i>No torrents loaded.</i></td></tr>\n";
|
||||
|
||||
private static final String TABLE_FOOTER = "</table>\n";
|
||||
private static final String TABLE_FOOTER = "</table></div>\n";
|
||||
|
||||
private static final String FOOTER = "</body></html>";
|
||||
}
|
||||
private static final String FOOTER = "</div></div></div></center></body></html>";
|
||||
|
||||
|
||||
class FetchAndAdd implements Runnable {
|
||||
/** inner class, don't bother reindenting */
|
||||
private static class FetchAndAdd implements Runnable {
|
||||
private SnarkManager _manager;
|
||||
private String _url;
|
||||
public FetchAndAdd(SnarkManager mgr, String url) {
|
||||
@@ -930,3 +866,5 @@ class FetchAndAdd implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package org.klomp.snark.web;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.FileUtil;
|
||||
|
||||
import org.mortbay.jetty.Server;
|
||||
@@ -22,7 +23,7 @@ public class RunStandalone {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
File workDir = new File("work");
|
||||
File workDir = new File(I2PAppContext.getGlobalContext().getTempDir(), "jetty-work");
|
||||
boolean workDirRemoved = FileUtil.rmdir(workDir, false);
|
||||
if (!workDirRemoved)
|
||||
System.err.println("ERROR: Unable to remove Jetty temporary work directory");
|
||||
@@ -32,6 +33,8 @@ public class RunStandalone {
|
||||
|
||||
try {
|
||||
_server = new Server("jetty-i2psnark.xml");
|
||||
// just blow up NPE if we don't have a context
|
||||
(_server.getContexts()[0]).setTempDirectory(workDir);
|
||||
_server.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- This is the configuration for a standalone i2psnark and -->
|
||||
<!-- jetty instance connecting to a router in another jvm. -->
|
||||
<!-- Run it with the launch-i2psnark script. -->
|
||||
<!-- i2psnark will be accessed at http://127.0.0.1:8002/ -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Jetty Server -->
|
||||
@@ -12,7 +18,7 @@
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Add and configure a HTTP listener to port 8080 -->
|
||||
<!-- Add and configure a HTTP listener to port 8002 -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<Call name="addListener">
|
||||
<Arg>
|
||||
@@ -23,7 +29,7 @@
|
||||
<Set name="port">8002</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
<Set name="MinThreads">3</Set>
|
||||
<Set name="MinThreads">1</Set>
|
||||
<Set name="MaxThreads">10</Set>
|
||||
<Set name="MaxIdleTimeMs">30000</Set>
|
||||
<Set name="LowResourcePersistTimeMs">1000</Set>
|
||||
@@ -34,45 +40,6 @@
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Add a HTTPS SSL listener on port 8443 -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- UNCOMMENT TO ACTIVATE
|
||||
<Call name="addListener">
|
||||
<Arg>
|
||||
<New class="org.mortbay.http.SunJsseListener">
|
||||
<Set name="Port">8443</Set>
|
||||
<Set name="PoolName">main</Set>
|
||||
<Set name="Keystore"><SystemProperty name="jetty.home" default="."/>/etc/demokeystore</Set>
|
||||
<Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
|
||||
<Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
|
||||
<Set name="NonPersistentUserAgent">MSIE 5</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Add a AJP13 listener on port 8009 -->
|
||||
<!-- This protocol can be used with mod_jk in apache, IIS etc. -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!--
|
||||
<Call name="addListener">
|
||||
<Arg>
|
||||
<New class="org.mortbay.http.ajp.AJP13Listener">
|
||||
<Set name="PoolName">ajp</Set>
|
||||
<Set name="Port">8009</Set>
|
||||
<Set name="MinThreads">3</Set>
|
||||
<Set name="MaxThreads">20</Set>
|
||||
<Set name="MaxIdleTimeMs">0</Set>
|
||||
<Set name="confidentialPort">443</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Contexts -->
|
||||
<!-- =============================================================== -->
|
||||
@@ -91,20 +58,6 @@
|
||||
<Arg>webapps/i2psnark.war</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Request Log -->
|
||||
<!-- =============================================================== -->
|
||||
<Set name="RequestLog">
|
||||
<New class="org.mortbay.http.NCSARequestLog">
|
||||
<Arg>./logs/yyyy_mm_dd.i2psnark-request.log</Arg>
|
||||
<Set name="retainDays">90</Set>
|
||||
<Set name="append">true</Set>
|
||||
<Set name="extended">false</Set>
|
||||
<Set name="buffered">false</Set>
|
||||
<Set name="LogTimeZone">GMT</Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Other Server Options -->
|
||||
<!-- =============================================================== -->
|
||||
|
8
apps/i2psnark/launch-i2psnark
Executable file
8
apps/i2psnark/launch-i2psnark
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This launches i2psnark and jetty in a separate jvm.
|
||||
# The file jetty-i2psnark.xml must be present in the current directory.
|
||||
# i2psnark will be accessed at http://127.0.0.1:8002/
|
||||
#
|
||||
I2P="."
|
||||
java -cp "$I2P/lib/i2psnark.jar:$I2P/lib/i2p.jar:$I2P/lib/mstreaming.jar:$I2P/lib/streaming.jar:$I2P/lib/commons-el.jar:$I2P/lib/commons-logging.jar:$I2P/lib/jasper-compiler.jar:$I2P/lib/jasper-runtime.jar:$I2P/lib/javax.servlet.jar:$I2P/lib/org.mortbay.jetty.jar" org.klomp.snark.web.RunStandalone "$@"
|
@@ -1,6 +1,6 @@
|
||||
To run I2PSnark from the command line, run "java -jar lib/i2psnark.jar", but
|
||||
to run it with the web UI, run "java -jar launch-i2psnark.jar". I2PSnark is
|
||||
to run it with the web UI, run "launch-i2psnark". I2PSnark is
|
||||
GPL'ed software, based on Snark (http://www.klomp.org/) to run on top of I2P
|
||||
(http://www.i2p.net/) within a webserver (such as the bundled Jetty from
|
||||
(http://www.i2p2.de/) within a webserver (such as the bundled Jetty from
|
||||
http://jetty.mortbay.org/). For more information about I2PSnark, get in touch
|
||||
with the folks at http://forum.i2p.net/
|
||||
with the folks at http://forum.i2p2.de/
|
||||
|
@@ -14,7 +14,7 @@ import net.i2p.util.Log;
|
||||
*/
|
||||
class BufferLogger implements Logging {
|
||||
private final static Log _log = new Log(BufferLogger.class);
|
||||
private ByteArrayOutputStream _baos; // should be final and use a factory. LINT
|
||||
private ByteArrayOutputStream _baos; // FIXME should be final and use a factory. FIXME
|
||||
private boolean _ignore;
|
||||
|
||||
/**
|
||||
|
@@ -372,6 +372,8 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
}
|
||||
|
||||
privKeyFile = new File(args[2]);
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[2]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
@@ -419,6 +421,8 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
}
|
||||
|
||||
privKeyFile = new File(args[2]);
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[2]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[2]);
|
||||
@@ -476,6 +480,8 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
String spoofedHost = args[2];
|
||||
|
||||
privKeyFile = new File(args[3]);
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[3]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[3]);
|
||||
@@ -870,6 +876,8 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
}
|
||||
|
||||
File privKeyFile = new File(args[1]);
|
||||
if (!privKeyFile.isAbsolute())
|
||||
privKeyFile = new File(_context.getConfigDir(), args[1]);
|
||||
if (!privKeyFile.canRead()) {
|
||||
l.log("private key file does not exist");
|
||||
_log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[3]);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
package net.i2p.i2ptunnel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
@@ -66,7 +67,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
// private Object conLock = new Object();
|
||||
|
||||
/** List of Socket for those accept()ed but not yet started up */
|
||||
private List _waitingSockets = new ArrayList(); // should be final and use a factory. LINT
|
||||
private List _waitingSockets = new ArrayList(); // FIXME should be final and use a factory. FIXME
|
||||
/** How many connections will we allow to be in the process of being built at once? */
|
||||
private int _numConnectionBuilders;
|
||||
/** How long will we allow sockets to sit in the _waitingSockets map before killing them? */
|
||||
@@ -114,7 +115,6 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
this.localPort = localPort;
|
||||
this.l = l;
|
||||
this.handlerName = handlerName + _clientId;
|
||||
this.privKeyFile = pkf;
|
||||
_ownDest = ownDest; // == ! shared client
|
||||
|
||||
|
||||
@@ -124,6 +124,14 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
_context.statManager().createRateStat("i2ptunnel.client.manageTime", "How long it takes to accept a socket and fire it into an i2ptunnel runner (or queue it for the pool)?", "I2PTunnel", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
|
||||
_context.statManager().createRateStat("i2ptunnel.client.buildRunTime", "How long it takes to run a queued socket into an i2ptunnel runner?", "I2PTunnel", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
|
||||
|
||||
// normalize path so we can find it
|
||||
if (pkf != null) {
|
||||
File keyFile = new File(pkf);
|
||||
if (!keyFile.isAbsolute())
|
||||
keyFile = new File(_context.getConfigDir(), pkf);
|
||||
this.privKeyFile = keyFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
// no need to load the netDb with leaseSets for destinations that will never
|
||||
// be looked up
|
||||
tunnel.getClientOptions().setProperty("i2cp.dontPublishLeaseSet", "true");
|
||||
@@ -277,6 +285,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel) {
|
||||
return buildSocketManager(tunnel, null);
|
||||
}
|
||||
|
||||
/** @param pkf absolute path or null */
|
||||
protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel, String pkf) {
|
||||
Properties props = new Properties();
|
||||
props.putAll(tunnel.getClientOptions());
|
||||
|
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
package net.i2p.i2ptunnel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -106,6 +107,8 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
/** used to assign unique IDs to the threads / clients. no logic or functionality */
|
||||
private static volatile long __clientId = 0;
|
||||
|
||||
private static final File _errorDir = new File(I2PAppContext.getGlobalContext().getBaseDir(), "docs");
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the I2PTunnel does not contain
|
||||
* valid config to contact the router
|
||||
@@ -150,6 +153,7 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
* create the default options (using the default timeout, etc)
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected I2PSocketOptions getDefaultOptions() {
|
||||
Properties defaultOpts = getTunnel().getClientOptions();
|
||||
if (!defaultOpts.contains(I2PSocketOptions.PROP_READ_TIMEOUT))
|
||||
@@ -176,7 +180,7 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
out = s.getOutputStream();
|
||||
in = s.getInputStream();
|
||||
String line, method = null, host = null, destination = null, restofline = null;
|
||||
StringBuffer newRequest = new StringBuffer();
|
||||
StringBuilder newRequest = new StringBuilder();
|
||||
int ahelper = 0;
|
||||
while (true) {
|
||||
// Use this rather than BufferedReader because we can't have readahead,
|
||||
@@ -256,14 +260,14 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
return;
|
||||
}
|
||||
|
||||
Destination dest = I2PTunnel.destFromName(destination);
|
||||
if (dest == null) {
|
||||
Destination clientDest = I2PTunnel.destFromName(destination);
|
||||
if (clientDest == null) {
|
||||
String str;
|
||||
byte[] header;
|
||||
if (usingWWWProxy)
|
||||
str = FileUtil.readTextFile("docs/dnfp-header.ht", 100, true);
|
||||
str = FileUtil.readTextFile((new File(_errorDir, "dnfp-header.ht")).getAbsolutePath(), 100, true);
|
||||
else
|
||||
str = FileUtil.readTextFile("docs/dnfh-header.ht", 100, true);
|
||||
str = FileUtil.readTextFile((new File(_errorDir, "dnfh-header.ht")).getAbsolutePath(), 100, true);
|
||||
if (str != null)
|
||||
header = str.getBytes();
|
||||
else
|
||||
@@ -273,7 +277,7 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
return;
|
||||
}
|
||||
|
||||
I2PSocket i2ps = createI2PSocket(dest, getDefaultOptions());
|
||||
I2PSocket i2ps = createI2PSocket(clientDest, getDefaultOptions());
|
||||
byte[] data = null;
|
||||
byte[] response = null;
|
||||
if (usingWWWProxy)
|
||||
@@ -341,7 +345,7 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
if (targetRequest != null) {
|
||||
out.write(targetRequest.getBytes());
|
||||
if (usingWWWProxy)
|
||||
out.write(("<br>WWW proxy: " + wwwProxy).getBytes());
|
||||
out.write(("<br />WWW proxy: " + wwwProxy).getBytes());
|
||||
}
|
||||
out.write("</div>".getBytes());
|
||||
out.write("\n</body></html>\n".getBytes());
|
||||
@@ -357,9 +361,9 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
|
||||
String str;
|
||||
byte[] header;
|
||||
if (usingWWWProxy)
|
||||
str = FileUtil.readTextFile("docs/dnfp-header.ht", 100, true);
|
||||
str = FileUtil.readTextFile((new File(_errorDir, "dnfp-header.ht")).getAbsolutePath(), 100, true);
|
||||
else
|
||||
str = FileUtil.readTextFile("docs/dnf-header.ht", 100, true);
|
||||
str = FileUtil.readTextFile((new File(_errorDir, "dnf-header.ht")).getAbsolutePath(), 100, true);
|
||||
if (str != null)
|
||||
header = str.getBytes();
|
||||
else
|
||||
|
@@ -3,7 +3,10 @@
|
||||
*/
|
||||
package net.i2p.i2ptunnel;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -14,6 +17,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
@@ -36,7 +40,7 @@ import net.i2p.util.Log;
|
||||
* or
|
||||
* $method $path $protocolVersion\nHost: $site
|
||||
* or
|
||||
* $method http://i2p/$site/$path $protocolVersion
|
||||
* $method http://i2p/$b64key/$path $protocolVersion
|
||||
* or
|
||||
* $method /$site/$path $protocolVersion
|
||||
* </pre>
|
||||
@@ -54,6 +58,10 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
|
||||
private HashMap addressHelpers = new HashMap();
|
||||
|
||||
/**
|
||||
* These are backups if the xxx.ht error page is missing.
|
||||
*/
|
||||
|
||||
private final static byte[] ERR_REQUEST_DENIED =
|
||||
("HTTP/1.1 403 Access Denied\r\n"+
|
||||
"Content-Type: text/html; charset=iso-8859-1\r\n"+
|
||||
@@ -76,6 +84,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
"Could not find the following Destination:<BR><BR><div>")
|
||||
.getBytes();
|
||||
|
||||
/*****
|
||||
private final static byte[] ERR_TIMEOUT =
|
||||
("HTTP/1.1 504 Gateway Timeout\r\n"+
|
||||
"Content-Type: text/html; charset=iso-8859-1\r\n"+
|
||||
@@ -87,6 +96,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
"destination may have issues. Could not get a response from "+
|
||||
"the following Destination:<BR><BR>")
|
||||
.getBytes();
|
||||
*****/
|
||||
|
||||
private final static byte[] ERR_NO_OUTPROXY =
|
||||
("HTTP/1.1 503 Service Unavailable\r\n"+
|
||||
@@ -107,11 +117,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
"The addresshelper link you followed specifies a different destination key "+
|
||||
"than a host entry in your host database. "+
|
||||
"Someone could be trying to impersonate another eepsite, "+
|
||||
"or people have given two eepsites identical names.<P/>"+
|
||||
"or people have given two eepsites identical names.<p>"+
|
||||
"You can resolve the conflict by considering which key you trust, "+
|
||||
"and either discarding the addresshelper link, "+
|
||||
"discarding the host entry from your host database, "+
|
||||
"or naming one of them differently.<P/>")
|
||||
"or naming one of them differently.<p>")
|
||||
.getBytes();
|
||||
|
||||
private final static byte[] ERR_BAD_PROTOCOL =
|
||||
@@ -136,6 +146,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
/** used to assign unique IDs to the threads / clients. no logic or functionality */
|
||||
private static volatile long __clientId = 0;
|
||||
|
||||
private static final File _errorDir = new File(I2PAppContext.getGlobalContext().getBaseDir(), "docs");
|
||||
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the I2PTunnel does not contain
|
||||
* valid config to contact the router
|
||||
@@ -187,6 +200,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
* create the default options (using the default timeout, etc)
|
||||
* unused?
|
||||
*/
|
||||
@Override
|
||||
protected I2PSocketOptions getDefaultOptions() {
|
||||
Properties defaultOpts = getTunnel().getClientOptions();
|
||||
if (!defaultOpts.contains(I2PSocketOptions.PROP_READ_TIMEOUT))
|
||||
@@ -203,6 +217,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
* create the default options (using the default timeout, etc)
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected I2PSocketOptions getDefaultOptions(Properties overrides) {
|
||||
Properties defaultOpts = getTunnel().getClientOptions();
|
||||
defaultOpts.putAll(overrides);
|
||||
@@ -230,13 +245,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
OutputStream out = null;
|
||||
String targetRequest = null;
|
||||
boolean usingWWWProxy = false;
|
||||
boolean usingInternalServer = false;
|
||||
String currentProxy = null;
|
||||
long requestId = ++__requestId;
|
||||
try {
|
||||
out = s.getOutputStream();
|
||||
InputReader reader = new InputReader(s.getInputStream());
|
||||
String line, method = null, protocol = null, host = null, destination = null;
|
||||
StringBuffer newRequest = new StringBuffer();
|
||||
StringBuilder newRequest = new StringBuilder();
|
||||
int ahelper = 0;
|
||||
while ((line = reader.readLine(method)) != null) {
|
||||
line = line.trim();
|
||||
@@ -256,6 +272,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
int pos = line.indexOf(" ");
|
||||
if (pos == -1) break;
|
||||
method = line.substring(0, pos);
|
||||
// TODO use Java URL class to make all this simpler and more robust
|
||||
String request = line.substring(pos + 1);
|
||||
if (request.startsWith("/") && getTunnel().getClientOptions().getProperty("i2ptunnel.noproxy") != null) {
|
||||
request = "http://i2p" + request;
|
||||
@@ -301,8 +318,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
// Quick hack for foo.bar.i2p
|
||||
if (host.toLowerCase().endsWith(".i2p")) {
|
||||
if (host.toLowerCase().equals("proxy.i2p")) {
|
||||
// so we don't do any naming service lookups
|
||||
destination = "proxy.i2p";
|
||||
usingInternalServer = true;
|
||||
} else if (host.toLowerCase().endsWith(".i2p")) {
|
||||
// Destination gets the host name
|
||||
destination = host;
|
||||
// Host becomes the destination key
|
||||
@@ -370,22 +390,16 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
// Did addresshelper key conflict?
|
||||
if (ahelperConflict)
|
||||
{
|
||||
String str;
|
||||
byte[] header;
|
||||
str = FileUtil.readTextFile("docs/ahelper-conflict-header.ht", 100, true);
|
||||
if (str != null) header = str.getBytes();
|
||||
else header = ERR_AHELPER_CONFLICT;
|
||||
|
||||
if (out != null) {
|
||||
// Fixme untranslated
|
||||
long alias = I2PAppContext.getGlobalContext().random().nextLong();
|
||||
String trustedURL = protocol + uriPath + urlEncoding;
|
||||
String conflictURL = protocol + alias + ".i2p/?" + initialFragments;
|
||||
byte[] header = getErrorPage("ahelper-conflict", ERR_AHELPER_CONFLICT);
|
||||
out.write(header);
|
||||
out.write(("To visit the destination in your host database, click <a href=\"" + trustedURL + "\">here</a>. To visit the conflicting addresshelper link by temporarily giving it a random alias, click <a href=\"" + conflictURL + "\">here</a>.<P/>").getBytes());
|
||||
out.write("</div><p><i>I2P HTTP Proxy Server<br>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
out.write(("To visit the destination in your host database, click <a href=\"" + trustedURL + "\">here</a>. To visit the conflicting addresshelper link by temporarily giving it a random alias, click <a href=\"" + conflictURL + "\">here</a>.<p></div>").getBytes());
|
||||
writeFooter(out);
|
||||
}
|
||||
s.close();
|
||||
return;
|
||||
@@ -400,6 +414,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
}
|
||||
|
||||
line = method + " " + request.substring(pos);
|
||||
} else if (host.toLowerCase().equals("localhost") || host.equals("127.0.0.1")) {
|
||||
if (out != null) {
|
||||
out.write(getErrorPage("localhost", ERR_LOCALHOST));
|
||||
writeFooter(out);
|
||||
}
|
||||
s.close();
|
||||
return;
|
||||
} else if (host.indexOf(".") != -1) {
|
||||
// rebuild host
|
||||
host = host + ":" + port;
|
||||
@@ -414,11 +435,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
_log.warn(getPrefix(requestId) + "Host wants to be outproxied, but we dont have any!");
|
||||
l.log("No HTTP outproxy found for the request.");
|
||||
if (out != null) {
|
||||
out.write(ERR_NO_OUTPROXY);
|
||||
out.write("<p /><i>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
out.write(getErrorPage("noproxy", ERR_NO_OUTPROXY));
|
||||
writeFooter(out);
|
||||
}
|
||||
s.close();
|
||||
return;
|
||||
@@ -427,42 +445,29 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
usingWWWProxy = true;
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(getPrefix(requestId) + "Host doesnt end with .i2p and it contains a period [" + host + "]: wwwProxy!");
|
||||
} else if (host.toLowerCase().startsWith("localhost:")) {
|
||||
if (out != null) {
|
||||
out.write(ERR_LOCALHOST);
|
||||
out.write("<p /><i>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
}
|
||||
s.close();
|
||||
return;
|
||||
} else {
|
||||
request = request.substring(pos + 1);
|
||||
pos = request.indexOf("/");
|
||||
if (pos < 0) {
|
||||
l.log("Invalid request url [" + request + "]");
|
||||
if (out != null) {
|
||||
out.write(ERR_REQUEST_DENIED);
|
||||
out.write("<p /><i>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
out.write(getErrorPage("denied", ERR_REQUEST_DENIED));
|
||||
writeFooter(out);
|
||||
}
|
||||
s.close();
|
||||
return;
|
||||
}
|
||||
destination = request.substring(0, pos);
|
||||
line = method + " " + request.substring(pos);
|
||||
}
|
||||
} // end host name processing
|
||||
|
||||
boolean isValid = usingWWWProxy || isSupportedAddress(host, protocol);
|
||||
boolean isValid = usingWWWProxy || usingInternalServer || isSupportedAddress(host, protocol);
|
||||
if (!isValid) {
|
||||
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix(requestId) + "notValid(" + host + ")");
|
||||
method = null;
|
||||
destination = null;
|
||||
break;
|
||||
} else if (!usingWWWProxy) {
|
||||
} else if ((!usingWWWProxy) && (!usingInternalServer)) {
|
||||
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix(requestId) + "host=getHostName(" + destination + ")");
|
||||
host = getHostName(destination); // hide original host
|
||||
}
|
||||
@@ -473,7 +478,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
_log.debug(getPrefix(requestId) + "HOST :" + host + ":");
|
||||
_log.debug(getPrefix(requestId) + "DEST :" + destination + ":");
|
||||
}
|
||||
|
||||
|
||||
// end first line processing
|
||||
|
||||
} else {
|
||||
if (lowercaseLine.startsWith("host: ") && !usingWWWProxy) {
|
||||
line = "Host: " + host;
|
||||
@@ -505,14 +512,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
continue; // completely strip the line
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (line.length() == 0) {
|
||||
|
||||
String ok = getTunnel().getClientOptions().getProperty("i2ptunnel.gzip");
|
||||
boolean gzip = DEFAULT_GZIP;
|
||||
if (ok != null)
|
||||
gzip = Boolean.valueOf(ok).booleanValue();
|
||||
if (gzip) {
|
||||
if (gzip && !usingInternalServer) {
|
||||
// according to rfc2616 s14.3, this *should* force identity, even if
|
||||
// an explicit q=0 for gzip doesn't. tested against orion.i2p, and it
|
||||
// seems to work.
|
||||
@@ -526,7 +533,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
} else {
|
||||
newRequest.append(line).append("\r\n"); // HTTP spec
|
||||
}
|
||||
}
|
||||
} // end header processing
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(getPrefix(requestId) + "NewRequest header: [" + newRequest.toString() + "]");
|
||||
|
||||
@@ -534,13 +542,10 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
l.log("No HTTP method found in the request.");
|
||||
if (out != null) {
|
||||
if ("http://".equalsIgnoreCase(protocol))
|
||||
out.write(ERR_REQUEST_DENIED);
|
||||
out.write(getErrorPage("denied", ERR_REQUEST_DENIED));
|
||||
else
|
||||
out.write(ERR_BAD_PROTOCOL);
|
||||
out.write("<p /><i>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
out.write(getErrorPage("protocol", ERR_BAD_PROTOCOL));
|
||||
writeFooter(out);
|
||||
}
|
||||
s.close();
|
||||
return;
|
||||
@@ -549,28 +554,31 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(getPrefix(requestId) + "Destination: " + destination);
|
||||
|
||||
Destination dest = I2PTunnel.destFromName(destination);
|
||||
if (dest == null) {
|
||||
// Serve local proxy files (images, css linked from error pages)
|
||||
// Ignore all the headers
|
||||
if (usingInternalServer) {
|
||||
serveLocalFile(out, method, targetRequest);
|
||||
s.close();
|
||||
return;
|
||||
}
|
||||
|
||||
Destination clientDest = I2PTunnel.destFromName(destination);
|
||||
if (clientDest == null) {
|
||||
//l.log("Could not resolve " + destination + ".");
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Unable to resolve " + destination + " (proxy? " + usingWWWProxy + ", request: " + targetRequest);
|
||||
String str;
|
||||
byte[] header;
|
||||
boolean showAddrHelper = false;
|
||||
if (usingWWWProxy)
|
||||
str = FileUtil.readTextFile("docs/dnfp-header.ht", 100, true);
|
||||
header = getErrorPage("dnfp", ERR_DESTINATION_UNKNOWN);
|
||||
else if(ahelper != 0)
|
||||
str = FileUtil.readTextFile("docs/dnfb-header.ht", 100, true);
|
||||
header = getErrorPage("dnfb", ERR_DESTINATION_UNKNOWN);
|
||||
else if (destination.length() == 60 && destination.endsWith(".b32.i2p"))
|
||||
str = FileUtil.readTextFile("docs/dnf-header.ht", 100, true);
|
||||
header = getErrorPage("dnf", ERR_DESTINATION_UNKNOWN);
|
||||
else {
|
||||
str = FileUtil.readTextFile("docs/dnfh-header.ht", 100, true);
|
||||
header = getErrorPage("dnfh", ERR_DESTINATION_UNKNOWN);
|
||||
showAddrHelper = true;
|
||||
}
|
||||
if (str != null)
|
||||
header = str.getBytes();
|
||||
else
|
||||
header = ERR_DESTINATION_UNKNOWN;
|
||||
writeErrorMessage(header, out, targetRequest, usingWWWProxy, destination, showAddrHelper);
|
||||
s.close();
|
||||
return;
|
||||
@@ -582,7 +590,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
// 1 == disconnect. see ConnectionOptions in the new streaming lib, which i
|
||||
// dont want to hard link to here
|
||||
//opts.setProperty("i2p.streaming.inactivityTimeoutAction", ""+1);
|
||||
I2PSocket i2ps = createI2PSocket(dest, getDefaultOptions(opts));
|
||||
I2PSocket i2ps = createI2PSocket(clientDest, getDefaultOptions(opts));
|
||||
byte[] data = newRequest.toString().getBytes("ISO-8859-1");
|
||||
Runnable onTimeout = new OnTimeout(s, s.getOutputStream(), targetRequest, usingWWWProxy, currentProxy, requestId);
|
||||
I2PTunnelRunner runner = new I2PTunnelHTTPClientRunner(s, i2ps, sockLock, data, mySockets, onTimeout);
|
||||
@@ -644,6 +652,64 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht,
|
||||
* or the backup byte array on fail.
|
||||
*
|
||||
* .ht files must be UTF-8 encoded and use \r\n terminators so the
|
||||
* HTTP headers are conformant.
|
||||
* We can't use FileUtil.readFile() because it strips \r
|
||||
*
|
||||
* @return non-null
|
||||
*/
|
||||
private byte[] getErrorPage(String base, byte[] backup) {
|
||||
return getErrorPage(getTunnel().getContext(), base, backup);
|
||||
}
|
||||
|
||||
private static byte[] getErrorPage(I2PAppContext ctx, String base, byte[] backup) {
|
||||
File errorDir = new File(ctx.getBaseDir(), "docs");
|
||||
String lang = ctx.getProperty("routerconsole.lang", Locale.getDefault().getLanguage());
|
||||
if (lang != null && lang.length() > 0 && !lang.equals("en")) {
|
||||
File file = new File(errorDir, base + "-header_" + lang + ".ht");
|
||||
try {
|
||||
return readFile(file);
|
||||
} catch (IOException ioe) {
|
||||
// try the english version now
|
||||
}
|
||||
}
|
||||
File file = new File(errorDir, base + "-header.ht");
|
||||
try {
|
||||
return readFile(file);
|
||||
} catch (IOException ioe) {
|
||||
return backup;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] readFile(File file) throws IOException {
|
||||
FileInputStream fis = null;
|
||||
byte[] buf = new byte[512];
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
|
||||
try {
|
||||
int len = 0;
|
||||
fis = new FileInputStream(file);
|
||||
while ((len = fis.read(buf)) > 0) {
|
||||
baos.write(buf, 0, len);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
} finally {
|
||||
try { if (fis != null) fis.close(); } catch (IOException foo) {}
|
||||
}
|
||||
// we won't ever get here
|
||||
}
|
||||
|
||||
private static void writeFooter(OutputStream out) throws IOException {
|
||||
// the css is hiding this div for now, but we'll keep it here anyway
|
||||
out.write("<div class=\"proxyfooter\"><p><i>I2P HTTP Proxy Server<br>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></div></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
}
|
||||
|
||||
private static class OnTimeout implements Runnable {
|
||||
private Socket _socket;
|
||||
private OutputStream _out;
|
||||
@@ -693,6 +759,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
out.write("</a>".getBytes());
|
||||
if (usingWWWProxy) out.write(("<br>WWW proxy: " + wwwProxy).getBytes());
|
||||
if (showAddrHelper) {
|
||||
// Fixme untranslated
|
||||
out.write("<br><br>Click a link below to look for an address helper by using a \"jump\" service:<br>".getBytes());
|
||||
for (int i = 0; i < jumpServers.length; i++) {
|
||||
// Skip jump servers we don't know
|
||||
@@ -715,10 +782,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
}
|
||||
}
|
||||
}
|
||||
out.write("</div><p><i>I2P HTTP Proxy Server<br>Generated on: ".getBytes());
|
||||
out.write(new Date().toString().getBytes());
|
||||
out.write("</i></body></html>\n".getBytes());
|
||||
out.flush();
|
||||
out.write("</div>".getBytes());
|
||||
writeFooter(out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,16 +795,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
// _log.warn(getPrefix(requestId) + "Error sending to " + wwwProxy + " (proxy? " + usingWWWProxy + ", request: " + targetRequest, ex);
|
||||
if (out != null) {
|
||||
try {
|
||||
String str;
|
||||
byte[] header;
|
||||
if (usingWWWProxy)
|
||||
str = FileUtil.readTextFile("docs/dnfp-header.ht", 100, true);
|
||||
header = getErrorPage(I2PAppContext.getGlobalContext(), "dnfp", ERR_DESTINATION_UNKNOWN);
|
||||
else
|
||||
str = FileUtil.readTextFile("docs/dnf-header.ht", 100, true);
|
||||
if (str != null)
|
||||
header = str.getBytes();
|
||||
else
|
||||
header = ERR_DESTINATION_UNKNOWN;
|
||||
header = getErrorPage(I2PAppContext.getGlobalContext(), "dnf", ERR_DESTINATION_UNKNOWN);
|
||||
writeErrorMessage(header, out, targetRequest, usingWWWProxy, wwwProxy, false);
|
||||
} catch (IOException ioe) {
|
||||
// static
|
||||
@@ -774,4 +834,80 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
|
||||
return protocol.equalsIgnoreCase("http://");
|
||||
}
|
||||
|
||||
private final static byte[] ERR_404 =
|
||||
("HTTP/1.1 404 Not Found\r\n"+
|
||||
"Content-Type: text/plain\r\n"+
|
||||
"\r\n"+
|
||||
"HTTP Proxy local file not found")
|
||||
.getBytes();
|
||||
|
||||
/**
|
||||
* Very simple web server.
|
||||
*
|
||||
* Serve local files in the docs/ directory, for CSS and images in
|
||||
* error pages, using the reserved address proxy.i2p
|
||||
* (similar to p.p in privoxy).
|
||||
* This solves the problems with including links to the router console,
|
||||
* as assuming the router console is at 127.0.0.1 leads to broken
|
||||
* links if it isn't.
|
||||
*
|
||||
* Ignore all request headers (If-Modified-Since, etc.)
|
||||
*
|
||||
* There is basic protection here -
|
||||
* FileUtil.readFile() prevents traversal above the base directory -
|
||||
* but inproxy/gateway ops would be wise to block proxy.i2p to prevent
|
||||
* exposing the docs/ directory or perhaps other issues through
|
||||
* uncaught vulnerabilities.
|
||||
* Restrict to the /themes/ directory for now.
|
||||
*
|
||||
* @param targetRequest "proxy.i2p/themes/foo.png HTTP/1.1"
|
||||
*/
|
||||
private static void serveLocalFile(OutputStream out, String method, String targetRequest) {
|
||||
// a home page message for the curious...
|
||||
if (targetRequest.startsWith("proxy.i2p/ ")) {
|
||||
try {
|
||||
out.write(("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nCache-Control: max-age=86400\r\n\r\nI2P HTTP proxy OK").getBytes());
|
||||
out.flush();
|
||||
} catch (IOException ioe) {}
|
||||
return;
|
||||
}
|
||||
if ((method.equals("GET") || method.equals("HEAD")) &&
|
||||
targetRequest.startsWith("proxy.i2p/themes/") &&
|
||||
!targetRequest.contains("..")) {
|
||||
int space = targetRequest.indexOf(' ');
|
||||
String filename = null;
|
||||
try {
|
||||
filename = targetRequest.substring(17, space); // "proxy.i2p/themes/".length
|
||||
} catch (IndexOutOfBoundsException ioobe) {}
|
||||
// theme hack
|
||||
if (filename.startsWith("console/default/"))
|
||||
filename = filename.replaceFirst("default", I2PAppContext.getGlobalContext().getProperty("routerconsole.theme", "light"));
|
||||
File themesDir = new File(_errorDir, "themes");
|
||||
File file = new File(themesDir, filename);
|
||||
if (file.exists() && !file.isDirectory()) {
|
||||
String type;
|
||||
if (filename.endsWith(".css"))
|
||||
type = "text/css";
|
||||
else if (filename.endsWith(".ico"))
|
||||
type = "image/x-icon";
|
||||
else if (filename.endsWith(".png"))
|
||||
type = "image/png";
|
||||
else if (filename.endsWith(".jpg"))
|
||||
type = "image/jpeg";
|
||||
else type = "text/html";
|
||||
try {
|
||||
out.write("HTTP/1.1 200 OK\r\nContent-Type: ".getBytes());
|
||||
out.write(type.getBytes());
|
||||
out.write("\r\nCache-Control: max-age=86400\r\n\r\n".getBytes());
|
||||
FileUtil.readFile(filename, themesDir.getAbsolutePath(), out);
|
||||
return;
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
try {
|
||||
out.write(ERR_404);
|
||||
out.flush();
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.data.Base32;
|
||||
|
||||
/**
|
||||
* Simple extension to the I2PTunnelServer that filters the HTTP
|
||||
@@ -33,6 +34,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
/** what Host: should we seem to be to the webserver? */
|
||||
private String _spoofHost;
|
||||
private static final String HASH_HEADER = "X-I2P-DestHash";
|
||||
private static final String DEST64_HEADER = "X-I2P-DestB64";
|
||||
private static final String DEST32_HEADER = "X-I2P-DestB32";
|
||||
|
||||
public I2PTunnelHTTPServer(InetAddress host, int port, String privData, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) {
|
||||
super(host, port, privData, l, notifyThis, tunnel);
|
||||
@@ -71,9 +74,12 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
|
||||
InputStream in = socket.getInputStream();
|
||||
|
||||
StringBuffer command = new StringBuffer(128);
|
||||
StringBuilder command = new StringBuilder(128);
|
||||
Properties headers = readHeaders(in, command);
|
||||
headers.setProperty(HASH_HEADER, socket.getPeerDestination().calculateHash().toBase64());
|
||||
headers.setProperty(DEST32_HEADER, Base32.encode(socket.getPeerDestination().calculateHash().getData()) + ".b32.i2p" );
|
||||
headers.setProperty(DEST64_HEADER, socket.getPeerDestination().toBase64());
|
||||
|
||||
if ( (_spoofHost != null) && (_spoofHost.trim().length() > 0) )
|
||||
headers.setProperty("Host", _spoofHost);
|
||||
headers.setProperty("Connection", "close");
|
||||
@@ -303,8 +309,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
}
|
||||
}
|
||||
|
||||
private String formatHeaders(Properties headers, StringBuffer command) {
|
||||
StringBuffer buf = new StringBuffer(command.length() + headers.size() * 64);
|
||||
private String formatHeaders(Properties headers, StringBuilder command) {
|
||||
StringBuilder buf = new StringBuilder(command.length() + headers.size() * 64);
|
||||
buf.append(command.toString().trim()).append("\r\n");
|
||||
for (Iterator iter = headers.keySet().iterator(); iter.hasNext(); ) {
|
||||
String name = (String)iter.next();
|
||||
@@ -315,9 +321,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private Properties readHeaders(InputStream in, StringBuffer command) throws IOException {
|
||||
private Properties readHeaders(InputStream in, StringBuilder command) throws IOException {
|
||||
Properties headers = new Properties();
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
|
||||
boolean ok = DataHelper.readLine(in, command);
|
||||
if (!ok) throw new IOException("EOF reached while reading the HTTP command [" + command.toString() + "]");
|
||||
@@ -361,6 +367,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
name = "X-Accept-encoding";
|
||||
else if (HASH_HEADER.equalsIgnoreCase(name))
|
||||
continue; // Prevent spoofing
|
||||
else if (DEST64_HEADER.equalsIgnoreCase(name))
|
||||
continue; // Prevent spoofing
|
||||
else if (DEST32_HEADER.equalsIgnoreCase(name))
|
||||
continue; // Prevent spoofing
|
||||
headers.setProperty(name, value);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Read the header [" + name + "] = [" + value + "]");
|
||||
|
@@ -77,12 +77,12 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
protected void clientConnectionRun(Socket s) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("got a connection.");
|
||||
Destination dest = pickDestination();
|
||||
Destination clientDest = pickDestination();
|
||||
I2PSocket i2ps = null;
|
||||
try {
|
||||
i2ps = createI2PSocket(dest);
|
||||
i2ps = createI2PSocket(clientDest);
|
||||
i2ps.setReadTimeout(readTimeout);
|
||||
StringBuffer expectedPong = new StringBuffer();
|
||||
StringBuilder expectedPong = new StringBuilder();
|
||||
Thread in = new I2PThread(new IrcInboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " in");
|
||||
in.start();
|
||||
Thread out = new I2PThread(new IrcOutboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " out");
|
||||
@@ -121,9 +121,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
|
||||
private Socket local;
|
||||
private I2PSocket remote;
|
||||
private StringBuffer expectedPong;
|
||||
private StringBuilder expectedPong;
|
||||
|
||||
IrcInboundFilter(Socket _local, I2PSocket _remote, StringBuffer pong) {
|
||||
IrcInboundFilter(Socket _local, I2PSocket _remote, StringBuilder pong) {
|
||||
local=_local;
|
||||
remote=_remote;
|
||||
expectedPong=pong;
|
||||
@@ -195,9 +195,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
|
||||
private Socket local;
|
||||
private I2PSocket remote;
|
||||
private StringBuffer expectedPong;
|
||||
private StringBuilder expectedPong;
|
||||
|
||||
IrcOutboundFilter(Socket _local, I2PSocket _remote, StringBuffer pong) {
|
||||
IrcOutboundFilter(Socket _local, I2PSocket _remote, StringBuilder pong) {
|
||||
local=_local;
|
||||
remote=_remote;
|
||||
expectedPong=pong;
|
||||
@@ -266,7 +266,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
*
|
||||
*/
|
||||
|
||||
public String inboundFilter(String s, StringBuffer expectedPong) {
|
||||
public String inboundFilter(String s, StringBuilder expectedPong) {
|
||||
|
||||
String field[]=s.split(" ",4);
|
||||
String command;
|
||||
@@ -353,7 +353,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
return null;
|
||||
}
|
||||
|
||||
public String outboundFilter(String s, StringBuffer expectedPong) {
|
||||
public String outboundFilter(String s, StringBuilder expectedPong) {
|
||||
|
||||
String field[]=s.split(" ",3);
|
||||
String command;
|
||||
|
@@ -135,7 +135,7 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
|
||||
|
||||
/** keep reading until we see USER or SERVER */
|
||||
private String filterRegistration(InputStream in, String newHostname) throws IOException {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
int lineCount = 0;
|
||||
|
||||
while (true) {
|
||||
|
@@ -211,7 +211,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable {
|
||||
int fail = 0;
|
||||
long totalTime = 0;
|
||||
int cnt = countPing ? CPING_COUNT : PING_COUNT;
|
||||
StringBuffer pingResults = new StringBuffer(2 * cnt + destination.length() + 3);
|
||||
StringBuilder pingResults = new StringBuilder(2 * cnt + destination.length() + 3);
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
boolean sent;
|
||||
sent = ping(dest);
|
||||
|
@@ -72,6 +72,8 @@ public class TunnelController implements Logging {
|
||||
}
|
||||
|
||||
File keyFile = new File(getPrivKeyFile());
|
||||
if (!keyFile.isAbsolute())
|
||||
keyFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), getPrivKeyFile());
|
||||
if (keyFile.exists()) {
|
||||
//log("Not overwriting existing private keys in " + keyFile.getAbsolutePath());
|
||||
return;
|
||||
@@ -383,7 +385,7 @@ public class TunnelController implements Logging {
|
||||
public String getI2CPHost() { return _config.getProperty("i2cpHost"); }
|
||||
public String getI2CPPort() { return _config.getProperty("i2cpPort"); }
|
||||
public String getClientOptions() {
|
||||
StringBuffer opts = new StringBuffer(64);
|
||||
StringBuilder opts = new StringBuilder(64);
|
||||
for (Iterator iter = _config.keySet().iterator(); iter.hasNext(); ) {
|
||||
String key = (String)iter.next();
|
||||
String val = _config.getProperty(key);
|
||||
@@ -445,7 +447,7 @@ public class TunnelController implements Logging {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void getSummary(StringBuffer buf) {
|
||||
public void getSummary(StringBuilder buf) {
|
||||
String type = getType();
|
||||
if ("httpclient".equals(type))
|
||||
getHttpClientSummary(buf);
|
||||
@@ -459,7 +461,7 @@ public class TunnelController implements Logging {
|
||||
buf.append("Unknown type ").append(type);
|
||||
}
|
||||
|
||||
private void getHttpClientSummary(StringBuffer buf) {
|
||||
private void getHttpClientSummary(StringBuilder buf) {
|
||||
String description = getDescription();
|
||||
if ( (description != null) && (description.trim().length() > 0) )
|
||||
buf.append("<i>").append(description).append("</i><br />\n");
|
||||
@@ -480,7 +482,7 @@ public class TunnelController implements Logging {
|
||||
getOptionSummary(buf);
|
||||
}
|
||||
|
||||
private void getClientSummary(StringBuffer buf) {
|
||||
private void getClientSummary(StringBuilder buf) {
|
||||
String description = getDescription();
|
||||
if ( (description != null) && (description.trim().length() > 0) )
|
||||
buf.append("<i>").append(description).append("</i><br />\n");
|
||||
@@ -497,7 +499,7 @@ public class TunnelController implements Logging {
|
||||
getOptionSummary(buf);
|
||||
}
|
||||
|
||||
private void getServerSummary(StringBuffer buf) {
|
||||
private void getServerSummary(StringBuilder buf) {
|
||||
String description = getDescription();
|
||||
if ( (description != null) && (description.trim().length() > 0) )
|
||||
buf.append("<i>").append(description).append("</i><br />\n");
|
||||
@@ -508,7 +510,7 @@ public class TunnelController implements Logging {
|
||||
getOptionSummary(buf);
|
||||
}
|
||||
|
||||
private void getHttpServerSummary(StringBuffer buf) {
|
||||
private void getHttpServerSummary(StringBuilder buf) {
|
||||
String description = getDescription();
|
||||
if ( (description != null) && (description.trim().length() > 0) )
|
||||
buf.append("<i>").append(description).append("</i><br />\n");
|
||||
@@ -520,7 +522,7 @@ public class TunnelController implements Logging {
|
||||
getOptionSummary(buf);
|
||||
}
|
||||
|
||||
private void getOptionSummary(StringBuffer buf) {
|
||||
private void getOptionSummary(StringBuilder buf) {
|
||||
String opts = getClientOptions();
|
||||
if ( (opts != null) && (opts.length() > 0) )
|
||||
buf.append("Network options: ").append(opts).append("<br />\n");
|
||||
|
@@ -231,6 +231,8 @@ public class TunnelControllerGroup {
|
||||
public void saveConfig(String configFile) {
|
||||
_configFile = configFile;
|
||||
File cfgFile = new File(configFile);
|
||||
if (!cfgFile.isAbsolute())
|
||||
cfgFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), configFile);
|
||||
File parent = cfgFile.getParentFile();
|
||||
if ( (parent != null) && (!parent.exists()) )
|
||||
parent.mkdirs();
|
||||
@@ -243,7 +245,7 @@ public class TunnelControllerGroup {
|
||||
map.putAll(cur);
|
||||
}
|
||||
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
|
||||
String key = (String)iter.next();
|
||||
String val = (String)map.get(key);
|
||||
@@ -253,7 +255,7 @@ public class TunnelControllerGroup {
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(cfgFile);
|
||||
fos.write(buf.toString().getBytes());
|
||||
fos.write(buf.toString().getBytes("UTF-8"));
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Config written to " + cfgFile.getPath());
|
||||
} catch (IOException ioe) {
|
||||
@@ -270,9 +272,11 @@ public class TunnelControllerGroup {
|
||||
*/
|
||||
private Properties loadConfig(String configFile) {
|
||||
File cfgFile = new File(configFile);
|
||||
if (!cfgFile.isAbsolute())
|
||||
cfgFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), configFile);
|
||||
if (!cfgFile.exists()) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Unable to load the controllers from " + configFile);
|
||||
_log.error("Unable to load the controllers from " + cfgFile.getAbsolutePath());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -282,7 +286,7 @@ public class TunnelControllerGroup {
|
||||
return props;
|
||||
} catch (IOException ioe) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error reading the controllers from " + configFile, ioe);
|
||||
_log.error("Error reading the controllers from " + cfgFile.getAbsolutePath(), ioe);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase {
|
||||
I2PSocket destSock = serv.getDestinationI2PSocket(this);
|
||||
new I2PTunnelRunner(clientSock, destSock, sockLock, null, mySockets);
|
||||
} catch (SOCKSException e) {
|
||||
_log.error("Error from SOCKS connection: " + e.getMessage());
|
||||
_log.error("Error from SOCKS connection", e);
|
||||
closeSocket(s);
|
||||
}
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ public class SOCKS4aServer extends SOCKSServer {
|
||||
}
|
||||
|
||||
private String readString(DataInputStream in) throws IOException {
|
||||
StringBuffer sb = new StringBuffer(16);
|
||||
StringBuilder sb = new StringBuilder(16);
|
||||
char c;
|
||||
while ((c = (char) (in.readByte() & 0xff)) != 0)
|
||||
sb.append(c);
|
||||
|
@@ -54,6 +54,6 @@ public class Pinger implements Source, Runnable {
|
||||
|
||||
protected Sink sink;
|
||||
protected Thread thread;
|
||||
protected Object waitlock; // should be final and use a factory. LINT
|
||||
protected Object waitlock; // FIXME should be final and use a factory. FIXME
|
||||
protected boolean running;
|
||||
}
|
||||
|
@@ -69,5 +69,5 @@ public class I2PSink implements Sink {
|
||||
protected boolean raw;
|
||||
protected I2PSession sess;
|
||||
protected Destination dest;
|
||||
protected I2PDatagramMaker maker; // should be final and use a factory. LINT
|
||||
protected I2PDatagramMaker maker; // FIXME should be final and use a factory. FIXME
|
||||
}
|
||||
|
@@ -67,5 +67,5 @@ public class I2PSinkAnywhere implements Sink {
|
||||
protected boolean raw;
|
||||
protected I2PSession sess;
|
||||
protected Destination dest;
|
||||
protected I2PDatagramMaker maker; // should be final and use a factory. LINT
|
||||
protected I2PDatagramMaker maker; // FIXME should be final and use a factory. FIXME
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ import net.i2p.util.Log;
|
||||
|
||||
private ServerSocket ss;
|
||||
|
||||
private Object startLock = new Object();
|
||||
private final Object startLock = new Object();
|
||||
private boolean startRunning = false;
|
||||
|
||||
private byte[] pubkey;
|
||||
|
@@ -223,7 +223,7 @@ public class EditBean extends IndexBean {
|
||||
if (tun != null) {
|
||||
Properties opts = getOptions(tun);
|
||||
if (opts == null) return "";
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
int i = 0;
|
||||
for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) {
|
||||
String key = (String)iter.next();
|
||||
|
@@ -84,6 +84,7 @@ public class IndexBean {
|
||||
static final String CLIENT_NICKNAME = "shared clients";
|
||||
|
||||
public static final String PROP_THEME_NAME = "routerconsole.theme";
|
||||
public static final String DEFAULT_THEME = "light";
|
||||
public static final String PROP_CSS_DISABLED = "routerconsole.css.disabled";
|
||||
public static final String PROP_JS_DISABLED = "routerconsole.javascript.disabled";
|
||||
|
||||
@@ -302,7 +303,7 @@ public class IndexBean {
|
||||
if (_group == null)
|
||||
return "";
|
||||
|
||||
StringBuffer buf = new StringBuffer(512);
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
if (_action != null) {
|
||||
try {
|
||||
buf.append(processAction()).append("\n");
|
||||
@@ -319,11 +320,8 @@ public class IndexBean {
|
||||
////
|
||||
|
||||
public String getTheme() {
|
||||
String theme = _context.getProperty(PROP_THEME_NAME);
|
||||
if (theme != null)
|
||||
return "/themes/console/" + theme + "/";
|
||||
else
|
||||
return "/themes/console/";
|
||||
String theme = _context.getProperty(PROP_THEME_NAME, DEFAULT_THEME);
|
||||
return "/themes/console/" + theme + "/";
|
||||
}
|
||||
|
||||
public boolean allowCSS() {
|
||||
@@ -927,11 +925,11 @@ public class IndexBean {
|
||||
}
|
||||
|
||||
private String getMessages(List msgs) {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
getMessages(msgs, buf);
|
||||
return buf.toString();
|
||||
}
|
||||
private void getMessages(List msgs, StringBuffer buf) {
|
||||
private void getMessages(List msgs, StringBuilder buf) {
|
||||
if (msgs == null) return;
|
||||
for (int i = 0; i < msgs.size(); i++) {
|
||||
buf.append((String)msgs.get(i)).append("\n");
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean" %><%
|
||||
String tun = request.getParameter("tunnel");
|
||||
if (tun != null) {
|
||||
|
@@ -13,12 +13,12 @@
|
||||
%>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>I2PTunnel Webmanager - Edit</title>
|
||||
<title>I2P Tunnel Manager - Edit</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
|
||||
<% if (editBean.allowCSS()) {
|
||||
%><link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
|
||||
%><link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
|
||||
<link href="<%=editBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<%=editBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
|
||||
<% }
|
||||
@@ -192,7 +192,7 @@
|
||||
|
||||
<div id="tunnelAdvancedNetworking" class="panel">
|
||||
<div class="header">
|
||||
<h4>Advanced networking options</h4>
|
||||
<h4>Advanced networking options</h4><br />
|
||||
<span class="comment">(NOTE: when this client proxy is configured to share tunnels, then these options are for all the shared proxy clients!)</span>
|
||||
</div>
|
||||
|
||||
@@ -319,7 +319,7 @@
|
||||
|
||||
<div id="optionsField" class="rowItem">
|
||||
<label for="reduce" accesskey="c">
|
||||
<span class="accessKey">C</span>lose tunnels when idle: <i>Experimental</i>
|
||||
<span class="accessKey">C</span>lose tunnels when idle:
|
||||
</label>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
@@ -335,10 +335,10 @@
|
||||
<table border="0"><tr><!-- I give up -->
|
||||
<td><input value="1" type="radio" id="startOnLoad" name="newDest" title="New Destination"
|
||||
<%=(editBean.getNewDest(curTunnel) ? " checked=\"checked\"" : "")%> class="tickbox" />
|
||||
<td valign="center">Enable
|
||||
<td>Enable
|
||||
<td><input value="0" type="radio" id="startOnLoad" name="newDest" title="New Destination"
|
||||
<%=(editBean.getNewDest(curTunnel) || editBean.getPersistentClientKey(curTunnel) ? "" : " checked=\"checked\"")%> class="tickbox" />
|
||||
<td valign="center">Disable
|
||||
<td>Disable
|
||||
</table>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
@@ -354,7 +354,7 @@
|
||||
|
||||
<div id="optionsField" class="rowItem">
|
||||
<label for="reduce" accesskey="c">
|
||||
<span class="accessKey">D</span>elay tunnel open until required: <i>Experimental</i>
|
||||
<span class="accessKey">D</span>elay tunnel open until required:
|
||||
</label>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
@@ -388,7 +388,7 @@
|
||||
<label for="localDestination" accesskey="L">
|
||||
<span class="accessKey">L</span>ocal destination:
|
||||
</label>
|
||||
<textarea rows="1" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
|
||||
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
|
||||
<span class="comment">(if known)</span>
|
||||
</div>
|
||||
|
||||
@@ -411,7 +411,8 @@
|
||||
<div class="header"></div>
|
||||
<div class="footer">
|
||||
<div class="toolbox">
|
||||
<span class="comment">NOTE: If tunnel is currently running, most changes will not take effect until tunnel is stopped and restarted</span>
|
||||
<span class="comment">NOTE: If tunnel is currently running, most changes will not take effect until tunnel is stopped and restarted.</span>
|
||||
<div class="separator"><hr /></div>
|
||||
<input type="hidden" value="true" name="removeConfirm" />
|
||||
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><span class="accessKey">S</span>ave</button>
|
||||
<button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><span class="accessKey">D</span>elete</button>
|
||||
|
@@ -13,12 +13,12 @@
|
||||
%>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>I2PTunnel Webmanager - Edit</title>
|
||||
<title>I2P Tunnel Manager - Edit</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
|
||||
<% if (editBean.allowCSS()) {
|
||||
%><link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
|
||||
%><link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
|
||||
<link href="<%=editBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<%=editBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
|
||||
<% }
|
||||
@@ -148,7 +148,7 @@
|
||||
<label for="localDestination" accesskey="L">
|
||||
<span class="accessKey">L</span>ocal destination:
|
||||
</label>
|
||||
<textarea rows="1" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
|
||||
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
|
||||
<% if (!"".equals(editBean.getDestinationBase64(curTunnel))) { %>
|
||||
<a href="/susidns/addressbook.jsp?book=private&hostname=<%=editBean.getTunnelName(curTunnel)%>&destination=<%=editBean.getDestinationBase64(curTunnel)%>#add">Add to local addressbook</a>
|
||||
<% } %>
|
||||
@@ -270,7 +270,7 @@
|
||||
<label for="encrypt" accesskey="e">
|
||||
Encryption Key:
|
||||
</label>
|
||||
<textarea rows="1" cols="44" id="portField" name="encryptKey" title="Encrypt Key" wrap="off"><%=editBean.getEncryptKey(curTunnel)%></textarea>
|
||||
<textarea rows="1" style="height: 3em;" cols="44" id="portField" name="encryptKey" title="Encrypt Key" wrap="off"><%=editBean.getEncryptKey(curTunnel)%></textarea>
|
||||
</div>
|
||||
<div id="portField" class="rowItem">
|
||||
<label for="force" accesskey="c">
|
||||
@@ -299,7 +299,7 @@
|
||||
<label for="accessList" accesskey="s">
|
||||
Access List:
|
||||
</label>
|
||||
<textarea rows="2" cols="60" id="hostField" name="accessList" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea>
|
||||
<textarea rows="2" style="height: 4em;" cols="60" id="hostField" name="accessList" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea>
|
||||
<span class="comment">(Restrict to these clients only)</span>
|
||||
</div>
|
||||
|
||||
@@ -399,7 +399,8 @@
|
||||
<div class="header"></div>
|
||||
<div class="footer">
|
||||
<div class="toolbox">
|
||||
<span class="comment">NOTE: If tunnel is currently running, most changes will not take effect until tunnel is stopped and restarted</span>
|
||||
<span class="comment">NOTE: If tunnel is currently running, most changes will not take effect until tunnel is stopped and restarted.</span>
|
||||
<div class="separator"><hr /></div>
|
||||
<input type="hidden" value="true" name="removeConfirm" />
|
||||
<button id="controlSave" accesskey="S" class="control" type="submit" name="action" value="Save changes" title="Save Changes"><span class="accessKey">S</span>ave</button>
|
||||
<button id="controlDelete" <%=(editBean.allowJS() ? "onclick=\"if (!confirm('Are you sure you want to delete?')) { return false; }\" " : "")%>accesskey="D" class="control" type="submit" name="action" value="Delete this proxy" title="Delete this Proxy"><span class="accessKey">D</span>elete</button>
|
||||
|
@@ -1,290 +1,300 @@
|
||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.IndexBean"%><?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<jsp:useBean class="net.i2p.i2ptunnel.web.IndexBean" id="indexBean" scope="request" />
|
||||
<jsp:setProperty name="indexBean" property="*" />
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>I2PTunnel Webmanager - List</title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
|
||||
<% if (indexBean.allowCSS()) {
|
||||
%><link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
|
||||
<link href="<%=indexBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<%=indexBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
|
||||
<% }
|
||||
%>
|
||||
</head>
|
||||
<body id="tunnelListPage">
|
||||
<div id="pageHeader">
|
||||
</div>
|
||||
|
||||
<div id="statusMessagePanel" class="panel">
|
||||
<div class="header">
|
||||
<h4>Status Messages</h4>
|
||||
</div>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<textarea id="statusMessages" rows="3" cols="60" readonly="readonly"><jsp:getProperty name="indexBean" property="messages" /></textarea>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="toolbox">
|
||||
<a class="control" href="index.jsp">Refresh</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="localClientTunnelList" class="panel">
|
||||
<div class="header">
|
||||
<h4>Local Client Tunnels</h4>
|
||||
</div>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="nameHeaderField rowItem">
|
||||
<label>Name:</label>
|
||||
</div>
|
||||
<div class="portHeaderField rowItem">
|
||||
<label>Port:</label>
|
||||
</div>
|
||||
<div class="typeHeaderField rowItem">
|
||||
<label>Type:</label>
|
||||
</div>
|
||||
<div class="interfaceHeaderField rowItem">
|
||||
<label>Interface:</label>
|
||||
</div>
|
||||
<div class="statusHeaderField rowItem">
|
||||
<label>Status:</label>
|
||||
</div>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
<%
|
||||
for (int curClient = 0; curClient < indexBean.getTunnelCount(); curClient++) {
|
||||
if (!indexBean.isClient(curClient)) continue;
|
||||
%>
|
||||
<div class="nameField rowItem">
|
||||
<label>Name:</label>
|
||||
<span class="text"><a href="edit.jsp?tunnel=<%=curClient%>" title="Edit Tunnel Settings for <%=indexBean.getTunnelName(curClient)%>"><%=indexBean.getTunnelName(curClient)%></a></span>
|
||||
</div>
|
||||
<div class="portField rowItem">
|
||||
<label>Port:</label>
|
||||
<span class="text"><%=indexBean.getClientPort(curClient)%></span>
|
||||
</div>
|
||||
<div class="typeField rowItem">
|
||||
<label>Type:</label>
|
||||
<span class="text"><%=indexBean.getTunnelType(curClient)%></span>
|
||||
</div>
|
||||
<div class="interfaceField rowItem">
|
||||
<label>Interface:</label>
|
||||
<span class="text"><%=indexBean.getClientInterface(curClient)%></span>
|
||||
</div>
|
||||
<div class="statusField rowItem">
|
||||
<label>Status:</label>
|
||||
<%
|
||||
switch (indexBean.getTunnelStatus(curClient)) {
|
||||
case IndexBean.STARTING:
|
||||
%><div class="statusStarting text">Starting...</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.STANDBY:
|
||||
%><div class="statusStarting text">Standby</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.RUNNING:
|
||||
%><div class="statusRunning text">Running</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.NOT_RUNNING:
|
||||
%><div class="statusNotRunning text">Stopped</div>
|
||||
<a class="control" title="Start this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=start&tunnel=<%=curClient%>">Start</a>
|
||||
<%
|
||||
break;
|
||||
}
|
||||
%></div>
|
||||
|
||||
<% if (!"sockstunnel".equals(indexBean.getInternalType(curClient))) { %>
|
||||
<div class="destinationField rowItem">
|
||||
<label>
|
||||
<% if ("httpclient".equals(indexBean.getInternalType(curClient)) || "connectclient".equals(indexBean.getInternalType(curClient))) { %>
|
||||
Outproxy:
|
||||
<% } else { %>
|
||||
Destination:
|
||||
<% } %>
|
||||
</label>
|
||||
<input class="freetext" size="40" readonly="readonly" value="<%=indexBean.getClientDestination(curClient)%>" />
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="descriptionField rowItem">
|
||||
<label>Description:</label>
|
||||
<div class="text"><%=indexBean.getTunnelDescription(curClient)%></div>
|
||||
</div>
|
||||
|
||||
<div class="subdivider">
|
||||
<hr />
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<form id="addNewClientTunnelForm" action="edit.jsp">
|
||||
<div class="toolbox">
|
||||
<label>Add new client tunnel:</label>
|
||||
<select name="type">
|
||||
<option value="client">Standard</option>
|
||||
<option value="httpclient">HTTP</option>
|
||||
<option value="ircclient">IRC</option>
|
||||
<option value="sockstunnel">SOCKS 4/4a/5</option>
|
||||
<option value="connectclient">CONNECT</option>
|
||||
<option value="streamrclient">Streamr</option>
|
||||
</select>
|
||||
<input class="control" type="submit" value="Create" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="localServerTunnelList" class="panel">
|
||||
<div class="header">
|
||||
<h4>Local Server Tunnels</h4>
|
||||
</div>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="nameHeaderField rowItem">
|
||||
<label>Name:</label>
|
||||
</div>
|
||||
<div class="previewHeaderField rowItem">
|
||||
<label>Points at:</label>
|
||||
</div>
|
||||
<div class="targetHeaderField rowItem">
|
||||
<label>Preview:</label>
|
||||
</div>
|
||||
<div class="statusHeaderField rowItem">
|
||||
<label>Status:</label>
|
||||
</div>
|
||||
|
||||
<%
|
||||
for (int curServer = 0; curServer < indexBean.getTunnelCount(); curServer++) {
|
||||
if (indexBean.isClient(curServer)) continue;
|
||||
|
||||
%>
|
||||
<div class="nameField rowItem">
|
||||
<label>Name:</label>
|
||||
<span class="text"><a href="edit.jsp?tunnel=<%=curServer%>" title="Edit Server Tunnel Settings for <%=indexBean.getTunnelName(curServer)%>"><%=indexBean.getTunnelName(curServer)%></a></span>
|
||||
</div>
|
||||
<div class="previewField rowItem">
|
||||
<label>Points at:</label>
|
||||
<span class="text">
|
||||
<%
|
||||
if ("httpserver".equals(indexBean.getInternalType(curServer))) {
|
||||
%>
|
||||
<a href="http://<%=indexBean.getServerTarget(curServer)%>/" title="Test HTTP server, bypassing I2P"><%=indexBean.getServerTarget(curServer)%></a>
|
||||
<%
|
||||
} else {
|
||||
%><%=indexBean.getServerTarget(curServer)%>
|
||||
<%
|
||||
}
|
||||
%></span>
|
||||
</div>
|
||||
<div class="targetField rowItem">
|
||||
<%
|
||||
if ("httpserver".equals(indexBean.getInternalType(curServer)) && indexBean.getTunnelStatus(curServer) == IndexBean.RUNNING) {
|
||||
%><label>Preview:</label>
|
||||
<a class="control" title="Test HTTP server through I2P" href="http://<%=indexBean.getDestHashBase32(curServer)%>.b32.i2p">Preview</a>
|
||||
<%
|
||||
} else if (indexBean.getTunnelStatus(curServer) == IndexBean.RUNNING) {
|
||||
%><span class="text">Base32 Address:<br><%=indexBean.getDestHashBase32(curServer)%>.b32.i2p</span>
|
||||
<%
|
||||
} else {
|
||||
%><span class="comment">No Preview</span>
|
||||
<%
|
||||
}
|
||||
%></div>
|
||||
<div class="statusField rowItem">
|
||||
<label>Status:</label>
|
||||
<%
|
||||
switch (indexBean.getTunnelStatus(curServer)) {
|
||||
case IndexBean.STARTING:
|
||||
%><div class="statusStarting text">Starting...</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curServer%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.RUNNING:
|
||||
%><div class="statusRunning text">Running</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curServer%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.NOT_RUNNING:
|
||||
%><div class="statusNotRunning text">Stopped</div>
|
||||
<a class="control" title="Start this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=start&tunnel=<%=curServer%>">Start</a>
|
||||
<%
|
||||
break;
|
||||
}
|
||||
%></div>
|
||||
|
||||
<div class="descriptionField rowItem">
|
||||
<label>Description:</label>
|
||||
<div class="text"><%=indexBean.getTunnelDescription(curServer)%></div>
|
||||
</div>
|
||||
|
||||
<div class="subdivider">
|
||||
<hr />
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<form id="addNewServerTunnelForm" action="edit.jsp">
|
||||
<div class="toolbox">
|
||||
<label>Add new server tunnel:</label>
|
||||
<select name="type">
|
||||
<option value="server">Standard</option>
|
||||
<option value="httpserver">HTTP</option>
|
||||
<option value="ircserver">IRC</option>
|
||||
<option value="streamrserver">Streamr</option>
|
||||
</select>
|
||||
<input class="control" type="submit" value="Create" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="globalOperationsPanel" class="panel">
|
||||
<div class="header"></div>
|
||||
<div class="footer">
|
||||
<div class="toolbox">
|
||||
<a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Stop%20all">Stop All</a><a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Start%20all">Start All</a><a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Restart%20all">Restart All</a><a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Reload%20configuration">Reload Config</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="pageFooter">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<%
|
||||
// http://www.crazysquirrel.com/computing/general/form-encoding.jspx
|
||||
if (request.getCharacterEncoding() == null)
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.IndexBean"%><?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<jsp:useBean class="net.i2p.i2ptunnel.web.IndexBean" id="indexBean" scope="request" />
|
||||
<jsp:setProperty name="indexBean" property="*" />
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>I2P Tunnel Manager - List</title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
|
||||
|
||||
<% if (indexBean.allowCSS()) {
|
||||
%><link href="<%=indexBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<%=indexBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
|
||||
<% }
|
||||
%>
|
||||
</head>
|
||||
<body id="tunnelListPage">
|
||||
<div id="pageHeader">
|
||||
</div>
|
||||
|
||||
<div id="statusMessagePanel" class="panel">
|
||||
<div class="header">
|
||||
<h4>Status Messages</h4>
|
||||
</div>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<textarea id="statusMessages" rows="4" cols="60" readonly="readonly"><jsp:getProperty name="indexBean" property="messages" /></textarea>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="toolbox">
|
||||
<a class="control" href="index.jsp">Refresh</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="globalOperationsPanel" class="panel">
|
||||
<div class="header"></div>
|
||||
<div class="footer">
|
||||
<div class="toolbox">
|
||||
<a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Stop%20all">Stop All</a> <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Start%20all">Start All</a> <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Restart%20all">Restart All</a> <a class="control" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=Reload%20configuration">Reload Config</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="localServerTunnelList" class="panel">
|
||||
<div class="header">
|
||||
|
||||
<h4>I2P Server Tunnels</h4>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="separator"> </div>
|
||||
|
||||
<div class="nameHeaderField rowItem">
|
||||
<label>Name:</label>
|
||||
</div>
|
||||
<div class="previewHeaderField rowItem">
|
||||
<label>Points at:</label>
|
||||
</div>
|
||||
<div class="targetHeaderField rowItem">
|
||||
<label>Preview:</label>
|
||||
</div>
|
||||
<div class="statusHeaderField rowItem">
|
||||
<label>Status:</label>
|
||||
<hr /> </div>
|
||||
|
||||
<%
|
||||
for (int curServer = 0; curServer < indexBean.getTunnelCount(); curServer++) {
|
||||
if (indexBean.isClient(curServer)) continue;
|
||||
|
||||
%>
|
||||
<div class="nameField rowItem">
|
||||
<label>Name:</label>
|
||||
<span class="text"><a href="edit.jsp?tunnel=<%=curServer%>" title="Edit Server Tunnel Settings for <%=indexBean.getTunnelName(curServer)%>"><%=indexBean.getTunnelName(curServer)%></a></span>
|
||||
</div>
|
||||
<div class="previewField rowItem">
|
||||
<label>Points at:</label>
|
||||
<span class="text">
|
||||
<%
|
||||
if ("httpserver".equals(indexBean.getInternalType(curServer))) {
|
||||
%>
|
||||
<a href="http://<%=indexBean.getServerTarget(curServer)%>/" title="Test HTTP server, bypassing I2P"><%=indexBean.getServerTarget(curServer)%></a>
|
||||
<%
|
||||
} else {
|
||||
%><%=indexBean.getServerTarget(curServer)%>
|
||||
<%
|
||||
}
|
||||
%></span>
|
||||
</div>
|
||||
<div class="targetField rowItem">
|
||||
<%
|
||||
if ("httpserver".equals(indexBean.getInternalType(curServer)) && indexBean.getTunnelStatus(curServer) == IndexBean.RUNNING) {
|
||||
%><label>Preview:</label>
|
||||
<a class="control" title="Test HTTP server through I2P" href="http://<%=indexBean.getDestHashBase32(curServer)%>.b32.i2p">Preview</a>
|
||||
<%
|
||||
} else if (indexBean.getTunnelStatus(curServer) == IndexBean.RUNNING) {
|
||||
%><span class="text">Base32 Address:<br /><%=indexBean.getDestHashBase32(curServer)%>.b32.i2p</span>
|
||||
<%
|
||||
} else {
|
||||
%><span class="comment">No Preview</span>
|
||||
<%
|
||||
}
|
||||
%></div>
|
||||
<div class="statusField rowItem">
|
||||
<label>Status:</label>
|
||||
<%
|
||||
switch (indexBean.getTunnelStatus(curServer)) {
|
||||
case IndexBean.STARTING:
|
||||
%><div class="statusStarting text">Starting...</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curServer%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.RUNNING:
|
||||
%><div class="statusRunning text">Running</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curServer%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.NOT_RUNNING:
|
||||
%><div class="statusNotRunning text">Stopped</div>
|
||||
<a class="control" title="Start this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=start&tunnel=<%=curServer%>">Start</a>
|
||||
<%
|
||||
break;
|
||||
}
|
||||
%></div>
|
||||
|
||||
<div class="descriptionField rowItem">
|
||||
<label>Description:</label>
|
||||
<div class="text"><%=indexBean.getTunnelDescription(curServer)%></div>
|
||||
</div>
|
||||
|
||||
<div class="subdivider">
|
||||
<hr />
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<form id="addNewServerTunnelForm" action="edit.jsp">
|
||||
<div class="toolbox">
|
||||
|
||||
<label>New server tunnel:</label>
|
||||
<select name="type">
|
||||
<option value="server">Standard</option>
|
||||
<option value="httpserver">HTTP</option>
|
||||
<option value="ircserver">IRC</option>
|
||||
<option value="streamrserver">Streamr</option>
|
||||
</select>
|
||||
<input class="control" type="submit" value="Create" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="localClientTunnelList" class="panel">
|
||||
<div class="header">
|
||||
|
||||
<h4>I2P Client Tunnels</h4>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="separator"> </div>
|
||||
|
||||
<div class="nameHeaderField rowItem">
|
||||
<label>Name:</label>
|
||||
</div>
|
||||
<div class="portHeaderField rowItem">
|
||||
<label>Port:</label>
|
||||
</div>
|
||||
<div class="typeHeaderField rowItem">
|
||||
<label>Type:</label>
|
||||
</div>
|
||||
<div class="interfaceHeaderField rowItem">
|
||||
<label>Interface:</label>
|
||||
</div>
|
||||
<div class="statusHeaderField rowItem">
|
||||
<label>Status:</label>
|
||||
</div>
|
||||
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
<%
|
||||
for (int curClient = 0; curClient < indexBean.getTunnelCount(); curClient++) {
|
||||
if (!indexBean.isClient(curClient)) continue;
|
||||
%>
|
||||
<div class="nameField rowItem">
|
||||
<label>Name:</label>
|
||||
<span class="text"><a href="edit.jsp?tunnel=<%=curClient%>" title="Edit Tunnel Settings for <%=indexBean.getTunnelName(curClient)%>"><%=indexBean.getTunnelName(curClient)%></a></span>
|
||||
</div>
|
||||
<div class="portField rowItem">
|
||||
<label>Port:</label>
|
||||
<span class="text"><%=indexBean.getClientPort(curClient)%></span>
|
||||
</div>
|
||||
<div class="typeField rowItem">
|
||||
<label>Type:</label>
|
||||
<span class="text"><%=indexBean.getTunnelType(curClient)%></span>
|
||||
</div>
|
||||
<div class="interfaceField rowItem">
|
||||
<label>Interface:</label>
|
||||
<span class="text"><%=indexBean.getClientInterface(curClient)%></span>
|
||||
</div>
|
||||
<div class="statusField rowItem">
|
||||
<label>Status:</label>
|
||||
<%
|
||||
switch (indexBean.getTunnelStatus(curClient)) {
|
||||
case IndexBean.STARTING:
|
||||
%><div class="statusStarting text">Starting...</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.STANDBY:
|
||||
%><div class="statusStarting text">Standby</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.RUNNING:
|
||||
%><div class="statusRunning text">Running</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.NOT_RUNNING:
|
||||
%><div class="statusNotRunning text">Stopped</div>
|
||||
<a class="control" title="Start this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=start&tunnel=<%=curClient%>">Start</a>
|
||||
<%
|
||||
break;
|
||||
}
|
||||
%></div>
|
||||
|
||||
<% if (!"sockstunnel".equals(indexBean.getInternalType(curClient))) { %>
|
||||
<div class="destinationField rowItem">
|
||||
<label>
|
||||
<% if ("httpclient".equals(indexBean.getInternalType(curClient)) || "connectclient".equals(indexBean.getInternalType(curClient))) { %>
|
||||
Outproxy:
|
||||
<% } else { %>
|
||||
Destination:
|
||||
<% } %>
|
||||
</label>
|
||||
<input class="freetext" size="40" readonly="readonly" value="<%=indexBean.getClientDestination(curClient)%>" />
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="descriptionField rowItem">
|
||||
<label>Description:</label>
|
||||
<div class="text"><%=indexBean.getTunnelDescription(curClient)%></div>
|
||||
</div>
|
||||
|
||||
<div class="subdivider">
|
||||
<hr />
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<div class="separator">
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<form id="addNewClientTunnelForm" action="edit.jsp">
|
||||
<div class="toolbox">
|
||||
|
||||
<label>New client tunnel:</label>
|
||||
<select name="type">
|
||||
<option value="client">Standard</option>
|
||||
<option value="httpclient">HTTP</option>
|
||||
<option value="ircclient">IRC</option>
|
||||
<option value="sockstunnel">SOCKS 4/4a/5</option>
|
||||
<option value="connectclient">CONNECT</option>
|
||||
<option value="streamrclient">Streamr</option>
|
||||
</select>
|
||||
<input class="control" type="submit" value="Create" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="pageFooter">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -109,6 +109,13 @@
|
||||
<target name="distclean" depends="clean">
|
||||
<echo message="Not actually deleting the jetty libs (since they're so large)" />
|
||||
</target>
|
||||
<target name="reallyclean" depends="distclean">
|
||||
<delete dir="./jettylib" />
|
||||
</target>
|
||||
<target name="totallyclean" depends="clean">
|
||||
<delete dir="./jettylib" />
|
||||
<delete file="${jetty.filename}" />
|
||||
</target>
|
||||
<target name="javadoc" >
|
||||
<available property="jetty.zip.available" file="${jetty.filename}" type="file" />
|
||||
<available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
|
||||
|
@@ -88,7 +88,7 @@ public class I2PRequestLog extends NCSARequestLog
|
||||
if (_fileOut==null)
|
||||
return;
|
||||
|
||||
StringBuffer buf = new StringBuffer(160);
|
||||
StringBuilder buf = new StringBuilder(160);
|
||||
|
||||
String addr = request.getField("X-I2P-DestHash");
|
||||
if(addr != null)
|
||||
|
@@ -23,7 +23,8 @@
|
||||
<target name="compile" depends="depend">
|
||||
<mkdir dir="./build" />
|
||||
<mkdir dir="./build/obj" />
|
||||
<javac srcdir="./src" debug="true" deprecation="on" source="1.5" target="1.5" destdir="./build/obj" classpath="../../../core/java/build/i2p.jar" >
|
||||
<!-- half of this is deprecated classes so turn deprecation off -->
|
||||
<javac srcdir="./src" debug="true" deprecation="off" source="1.5" target="1.5" destdir="./build/obj" classpath="../../../core/java/build/i2p.jar" >
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
</javac>
|
||||
</target>
|
||||
|
@@ -15,20 +15,21 @@ import net.i2p.util.Log;
|
||||
* and pull from a queue populated by various threads (each of whom have their own
|
||||
* timeout)
|
||||
*
|
||||
* @deprecated use I2PServerSocketFull
|
||||
*/
|
||||
class I2PServerSocketImpl implements I2PServerSocket {
|
||||
private final static Log _log = new Log(I2PServerSocketImpl.class);
|
||||
private I2PSocketManager mgr;
|
||||
/** list of sockets waiting for the client to accept them */
|
||||
private List<I2PSocket> pendingSockets = Collections.synchronizedList(new ArrayList<I2PSocket>(4));
|
||||
private final List<I2PSocket> pendingSockets = Collections.synchronizedList(new ArrayList<I2PSocket>(4));
|
||||
|
||||
/** have we been closed */
|
||||
private volatile boolean closing = false;
|
||||
|
||||
/** lock on this when accepting a pending socket, and wait on it for notification of acceptance */
|
||||
private Object socketAcceptedLock = new Object();
|
||||
private final Object socketAcceptedLock = new Object();
|
||||
/** lock on this when adding a new socket to the pending list, and wait on it accordingly */
|
||||
private Object socketAddedLock = new Object();
|
||||
private final Object socketAddedLock = new Object();
|
||||
|
||||
/**
|
||||
* Set Sock Option accept timeout stub, does nothing in ministreaming
|
||||
|
@@ -0,0 +1,242 @@
|
||||
package net.i2p.client.streaming;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.I2PException;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.EepGet;
|
||||
import net.i2p.util.SocketTimeout;
|
||||
|
||||
/**
|
||||
* Fetch a URL using a socket from the supplied I2PSocketManager.
|
||||
* Hostname must resolve to an i2p destination - no routing to an outproxy.
|
||||
* Does not support response gzip decompression (unlike I2PTunnelHTTPProxy) (yet),
|
||||
* but of course there is still gzip at the I2CP layer.
|
||||
*
|
||||
* This is designed for Java apps such as bittorrent clients that wish to
|
||||
* do HTTP fetches and use other protocols on a single set of tunnels.
|
||||
* This may provide anonymity benefits over using the shared clients HTTP proxy,
|
||||
* preventing inadvertent outproxy usage, reduce resource usage by eliminating
|
||||
* a second set of tunnels, and eliminate the requirement to
|
||||
* to separately configure the proxy host and port.
|
||||
*
|
||||
* For additional documentation see the superclass.
|
||||
*
|
||||
* Supports http://example.i2p/blah
|
||||
* Supports http://B32KEY.b32.i2p/blah
|
||||
* Supports http://i2p/B64KEY/blah for compatibility with the eepproxy
|
||||
* Supports http://B64KEY/blah for compatibility with the eepproxy
|
||||
* Warning - does not support /eepproxy/blah, address helpers, http://B64KEY.i2p/blah,
|
||||
* or other odd things that may be found in the HTTP proxy.
|
||||
*
|
||||
* @author zzz
|
||||
*/
|
||||
public class I2PSocketEepGet extends EepGet {
|
||||
private I2PSocketManager _socketManager;
|
||||
/** this replaces _proxy in the superclass. Sadly, I2PSocket does not extend Socket. */
|
||||
private I2PSocket _socket;
|
||||
|
||||
public I2PSocketEepGet(I2PAppContext ctx, I2PSocketManager mgr, int numRetries, String outputFile, String url) {
|
||||
this(ctx, mgr, numRetries, -1, -1, outputFile, null, url);
|
||||
}
|
||||
|
||||
public I2PSocketEepGet(I2PAppContext ctx, I2PSocketManager mgr, int numRetries, long minSize, long maxSize,
|
||||
String outputFile, OutputStream outputStream, String url) {
|
||||
// we're using this constructor:
|
||||
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String postData) {
|
||||
super(ctx, false, null, -1, numRetries, minSize, maxSize, outputFile, outputStream, url, true, null, null);
|
||||
_socketManager = mgr;
|
||||
_log = ctx.logManager().getLog(I2PSocketEepGet.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* We have to override this to close _socket, since we can't use _proxy in super as the I2PSocket.
|
||||
*/
|
||||
@Override
|
||||
public boolean fetch(long fetchHeaderTimeout, long totalTimeout, long inactivityTimeout) {
|
||||
boolean rv = super.fetch(fetchHeaderTimeout, totalTimeout, inactivityTimeout);
|
||||
if (_socket != null) {
|
||||
try {
|
||||
_socket.close();
|
||||
_socket = null;
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the address, get a socket from the I2PSocketManager supplied in the constructor,
|
||||
* and send the request.
|
||||
*
|
||||
* @param timeout ignored
|
||||
*/
|
||||
@Override
|
||||
protected void sendRequest(SocketTimeout timeout) throws IOException {
|
||||
if (_outputStream == null) {
|
||||
File outFile = new File(_outputFile);
|
||||
if (outFile.exists())
|
||||
_alreadyTransferred = outFile.length();
|
||||
}
|
||||
|
||||
if (_proxyIn != null) try { _proxyIn.close(); } catch (IOException ioe) {}
|
||||
if (_proxyOut != null) try { _proxyOut.close(); } catch (IOException ioe) {}
|
||||
if (_socket != null) try { _socket.close(); } catch (IOException ioe) {}
|
||||
|
||||
try {
|
||||
URL url = new URL(_actualURL);
|
||||
if ("http".equals(url.getProtocol())) {
|
||||
String host = url.getHost();
|
||||
int port = url.getPort();
|
||||
if (port != -1)
|
||||
throw new IOException("Ports not supported in i2p: " + _actualURL);
|
||||
|
||||
// HTTP Proxy compatibility http://i2p/B64KEY/blah
|
||||
// Rewrite the url to strip out the /i2p/,
|
||||
// as the naming service accepts B64KEY (but not B64KEY.i2p atm)
|
||||
if ("i2p".equals(host)) {
|
||||
String file = url.getFile();
|
||||
try {
|
||||
int slash = 1 + file.substring(1).indexOf("/");
|
||||
host = file.substring(1, slash);
|
||||
_actualURL = "http://" + host + file.substring(slash);
|
||||
} catch (IndexOutOfBoundsException ioobe) {
|
||||
throw new IOException("Bad /i2p/ format: " + _actualURL);
|
||||
}
|
||||
}
|
||||
|
||||
Destination dest = _context.namingService().lookup(host);
|
||||
if (dest == null)
|
||||
throw new UnknownHostException("Unknown or non-i2p host");
|
||||
|
||||
// Set the timeouts, using the other existing options in the socket manager
|
||||
// This currently duplicates what SocketTimeout is doing in EepGet,
|
||||
// but when that's ripped out of EepGet to use setsotimeout, we'll need this.
|
||||
Properties props = new Properties();
|
||||
props.setProperty(I2PSocketOptions.PROP_CONNECT_TIMEOUT, "" + CONNECT_TIMEOUT);
|
||||
props.setProperty(I2PSocketOptions.PROP_READ_TIMEOUT, "" + INACTIVITY_TIMEOUT);
|
||||
I2PSocketOptions opts = _socketManager.buildOptions(props);
|
||||
_socket = _socketManager.connect(dest, opts);
|
||||
} else {
|
||||
throw new IOException("Unsupported protocol: " + _actualURL);
|
||||
}
|
||||
} catch (MalformedURLException mue) {
|
||||
throw new IOException("Request URL is invalid: " + _actualURL);
|
||||
} catch (I2PException ie) {
|
||||
throw new IOException(ie.toString());
|
||||
}
|
||||
|
||||
_proxyIn = _socket.getInputStream();
|
||||
_proxyOut = _socket.getOutputStream();
|
||||
|
||||
// SocketTimeout doesn't take an I2PSocket, but no matter, because we
|
||||
// always close our socket in fetch() above.
|
||||
//timeout.setSocket(_socket);
|
||||
|
||||
String req = getRequest();
|
||||
_proxyOut.write(DataHelper.getUTF8(req));
|
||||
_proxyOut.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess we have to override this since
|
||||
* super doesn't strip the http://host from the GET line
|
||||
* which hoses some servers (opentracker)
|
||||
* HTTP proxy was kind enough to do this for us
|
||||
*/
|
||||
@Override
|
||||
protected String getRequest() throws IOException {
|
||||
StringBuilder buf = new StringBuilder(2048);
|
||||
URL url = new URL(_actualURL);
|
||||
String host = url.getHost();
|
||||
String path = url.getPath();
|
||||
String query = url.getQuery();
|
||||
if (query != null)
|
||||
path = path + '?' + query;
|
||||
if (!path.startsWith("/"))
|
||||
path = '/' + path;
|
||||
buf.append("GET ").append(path).append(" HTTP/1.1\r\n" +
|
||||
"Host: ").append(url.getHost()).append("\r\n");
|
||||
if (_alreadyTransferred > 0) {
|
||||
buf.append("Range: bytes=");
|
||||
buf.append(_alreadyTransferred);
|
||||
buf.append("-\r\n");
|
||||
}
|
||||
buf.append("Accept-Encoding: \r\n" +
|
||||
"Cache-control: no-cache\r\n" +
|
||||
"Pragma: no-cache\r\n" +
|
||||
"User-Agent: " + USER_AGENT + "\r\n" +
|
||||
"Connection: close\r\n\r\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* I2PSocketEepGet [-n #retries] [-t timeout] url
|
||||
* Uses I2CP at localhost:7654 with a single 1-hop tunnel each direction.
|
||||
* Tunnel build time not included in the timeout.
|
||||
*
|
||||
* This is just for testing, it will be commented out someday.
|
||||
* Real command line apps should use EepGet.main(),
|
||||
* which has more options, and you don't have to wait for tunnels to be built.
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
int numRetries = 0;
|
||||
long inactivityTimeout = INACTIVITY_TIMEOUT;
|
||||
String url = null;
|
||||
try {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals("-n")) {
|
||||
numRetries = Integer.parseInt(args[i+1]);
|
||||
i++;
|
||||
} else if (args[i].equals("-t")) {
|
||||
inactivityTimeout = 1000 * Integer.parseInt(args[i+1]);
|
||||
i++;
|
||||
} else if (args[i].startsWith("-")) {
|
||||
usage();
|
||||
return;
|
||||
} else {
|
||||
url = args[i];
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (url == null) {
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
Properties opts = new Properties();
|
||||
opts.setProperty("i2cp.dontPublishLeaseSet", "true");
|
||||
opts.setProperty("inbound.quantity", "1");
|
||||
opts.setProperty("outbound.quantity", "1");
|
||||
opts.setProperty("inbound.length", "1");
|
||||
opts.setProperty("outbound.length", "1");
|
||||
opts.setProperty("inbound.nickname", "I2PSocketEepGet");
|
||||
I2PSocketManager mgr = I2PSocketManagerFactory.createManager(opts);
|
||||
if (mgr == null) {
|
||||
System.err.println("Error creating the socket manager");
|
||||
return;
|
||||
}
|
||||
I2PSocketEepGet get = new I2PSocketEepGet(I2PAppContext.getGlobalContext(),
|
||||
mgr, numRetries, suggestName(url), url);
|
||||
get.addStatusListener(get.new CLIStatusListener(1024, 40));
|
||||
get.fetch(inactivityTimeout, -1, inactivityTimeout);
|
||||
mgr.destroySocketManager();
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
System.err.println("I2PSocketEepGet [-n #retries] [-t timeout] url");
|
||||
}
|
||||
}
|
@@ -17,6 +17,7 @@ import net.i2p.util.Log;
|
||||
/**
|
||||
* Initial stub implementation for the socket
|
||||
*
|
||||
* @deprecated use I2PSocketFull
|
||||
*/
|
||||
class I2PSocketImpl implements I2PSocket {
|
||||
private final static Log _log = new Log(I2PSocketImpl.class);
|
||||
@@ -29,7 +30,7 @@ class I2PSocketImpl implements I2PSocket {
|
||||
private Destination remote;
|
||||
private String localID;
|
||||
private String remoteID;
|
||||
private Object remoteIDWaiter = new Object();
|
||||
private final Object remoteIDWaiter = new Object();
|
||||
private I2PInputStream in;
|
||||
private I2POutputStream out;
|
||||
private I2PSocket.SocketErrorListener _socketErrorListener;
|
||||
@@ -42,7 +43,7 @@ class I2PSocketImpl implements I2PSocket {
|
||||
private long _closedOn;
|
||||
private long _remoteIdSetTime;
|
||||
private I2PSocketOptions _options;
|
||||
private Object flagLock = new Object();
|
||||
private final Object flagLock = new Object();
|
||||
|
||||
/**
|
||||
* Whether the I2P socket has already been closed.
|
||||
@@ -306,7 +307,7 @@ class I2PSocketImpl implements I2PSocket {
|
||||
//--------------------------------------------------
|
||||
private class I2PInputStream extends InputStream {
|
||||
private String streamName;
|
||||
private ByteCollector bc = new ByteCollector();
|
||||
private final ByteCollector bc = new ByteCollector();
|
||||
private boolean inStreamClosed = false;
|
||||
|
||||
private long readTimeout = -1;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user