Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69c86b987b | ||
|
|
c2d3470a35 | ||
|
|
734ba1d970 | ||
|
|
e666e4a35b | ||
|
|
b131f45cbb | ||
|
|
dc41b35333 | ||
|
|
f44d0f387b | ||
|
|
04f68e21e7 | ||
|
|
9f4ed46c0a | ||
|
|
a662c11b8d | ||
|
|
8333a4bb1a | ||
|
|
e2a92ea334 | ||
|
|
4c9289802a | ||
|
|
3eb3c2c099 | ||
|
|
a5e6d343d7 | ||
|
|
56f30a4386 | ||
|
|
89b2c68b2b | ||
|
|
ec95d8b553 | ||
|
|
c651664720 | ||
|
|
0aad2f5b92 | ||
|
|
ae0cbfe3f2 | ||
|
|
badb6435d6 | ||
|
|
8d0ea71486 | ||
|
|
09979629c0 | ||
|
|
a53f62a212 | ||
|
|
b8c6a2127d | ||
|
|
e78b461607 | ||
|
|
057cf06805 | ||
|
|
9cde492d68 | ||
|
|
39132b9787 | ||
|
|
86632a91eb | ||
|
|
e1c11c47db | ||
|
|
bf76aeeba1 | ||
|
|
4d9891e59e | ||
|
|
81ea4feb2e | ||
|
|
c7c88e9c59 | ||
|
|
9acb0cb16c | ||
|
|
af1d7ab510 | ||
|
|
bd04ed00d8 | ||
|
|
8db511b9bf | ||
|
|
1ebfd2a2d1 | ||
|
|
7a3fd81a8d | ||
|
|
8906b0734e | ||
|
|
116e59e933 | ||
|
|
9bb699628f | ||
|
|
e9e0f0b4f0 | ||
|
|
08a9fbb041 | ||
|
|
ccbbb81aa9 | ||
|
|
64b29c5f4e | ||
|
|
d97d486d53 | ||
|
|
5062b78740 | ||
|
|
caf0ff3be8 | ||
|
|
86a9a6729e | ||
|
|
d67c48a49b | ||
|
|
cb6f868739 | ||
|
|
46cbe5357c | ||
|
|
a71cebb094 | ||
|
|
f149b62475 | ||
|
|
3f6179a1fd | ||
|
|
2c574e9afe | ||
|
|
aade379acb | ||
|
|
1e93411810 | ||
|
|
1b8a6ef561 | ||
|
|
802a6aa93f | ||
|
|
302738dee5 | ||
|
|
f9024c7186 | ||
|
|
fdb1aae3a9 | ||
|
|
540069551d | ||
|
|
e4ae0d10d2 | ||
|
|
06281857a4 | ||
|
|
6c98f2cc27 | ||
|
|
ff880a5e13 | ||
|
|
67fc3b54ba | ||
|
|
841fed4afd | ||
|
|
c98f1cd25a | ||
|
|
c3cc308cc8 | ||
|
|
81a93f9e4f | ||
|
|
39c92a3f70 | ||
|
|
90df510932 | ||
|
|
909528e29c | ||
|
|
4e0951afd9 | ||
|
|
2f4e6403f9 | ||
|
|
1bb255c3f8 | ||
|
|
85c73d68bd | ||
|
|
7f3fe02d47 | ||
|
|
271c4ecdcb | ||
|
|
0d3ca13398 | ||
|
|
82ce991b3d | ||
|
|
af6e236521 | ||
|
|
e541456ee7 | ||
|
|
60e5fc7c57 | ||
|
|
c5da1cc934 | ||
|
|
186bbc3efb | ||
|
|
b036d2e055 | ||
|
|
ee83293285 | ||
|
|
800c3a250c | ||
|
|
545463c75d | ||
|
|
308305d827 | ||
|
|
ab6255393d | ||
|
|
24087f743a | ||
|
|
b59ecd0c66 | ||
|
|
ffa3a56ab8 | ||
|
|
76bd008cf9 | ||
|
|
b3ac7d2c7b | ||
|
|
b92d70be07 | ||
|
|
3710accf72 | ||
|
|
e07c363df2 | ||
|
|
c82840bfcb | ||
|
|
49c55ed26c | ||
|
|
198600ce42 | ||
|
|
38ef36d998 | ||
|
|
0a99803425 | ||
|
|
9efa5799f0 | ||
|
|
c27b6d15e2 | ||
|
|
68bd0b61b5 | ||
|
|
2004abc1e3 | ||
|
|
a244c1d4aa | ||
|
|
0f18e4fc3a | ||
|
|
9f43cfd488 | ||
|
|
98f77ef8c7 | ||
|
|
69c348ce6d | ||
|
|
bb2e894e0d | ||
|
|
7e1d8154de | ||
|
|
836d4534d6 | ||
|
|
e82080a5f6 | ||
|
|
d0732f9ade | ||
|
|
e40b91974a | ||
|
|
22587d3d41 | ||
|
|
0698e4d180 | ||
|
|
d7f67768eb | ||
|
|
157879d4f6 | ||
|
|
a7898a2c98 | ||
|
|
947e255d19 | ||
|
|
b41d140984 | ||
|
|
5392e9829c | ||
|
|
fa26ad4d56 | ||
|
|
2ebfd456ef | ||
|
|
070d621534 | ||
|
|
2bd919f01e | ||
|
|
7eea1638bc | ||
|
|
4bbd6e8626 | ||
|
|
d652681e8a | ||
|
|
c8b8247f70 | ||
|
|
3cc59ec3be | ||
|
|
983d241db6 | ||
|
|
2e4ea496b3 | ||
|
|
e5fd1fd556 | ||
|
|
32563a4ed6 | ||
|
|
ec86c15d5a | ||
|
|
e8426f6662 | ||
|
|
97b9984484 | ||
|
|
5ad24ba99d | ||
|
|
7378c97524 | ||
|
|
2d02e2211e | ||
|
|
8fd3808ad3 | ||
|
|
62443a6391 | ||
|
|
58ac635a17 | ||
|
|
b672ca03fe | ||
|
|
52cad36352 | ||
|
|
691415a8f9 | ||
|
|
56257d3da3 | ||
|
|
df9e6d3163 | ||
|
|
a7933bdd36 | ||
|
|
50e3a0f6d9 | ||
|
|
f84fb98766 | ||
|
|
0963c4c71f | ||
|
|
7c39cdfe1d | ||
|
|
7da3e4854c | ||
|
|
7edb6e047c | ||
|
|
d30ee746a7 | ||
|
|
1e0ad98f7f | ||
|
|
34088e2175 | ||
|
|
b108162dfb | ||
|
|
d37a6b2c12 | ||
|
|
2f86b79d85 | ||
|
|
243526d493 | ||
|
|
e87c856487 | ||
|
|
cfa5792880 | ||
|
|
f640c6fbb1 | ||
|
|
fcf5fd2129 | ||
|
|
7a9abc2a04 | ||
|
|
2235a97f05 | ||
|
|
f923649a11 | ||
|
|
3f1632603c | ||
|
|
7c15563430 | ||
|
|
ee1f1e38f2 | ||
|
|
752e4419a6 | ||
|
|
d133eee36b | ||
|
|
2f6840fd85 | ||
|
|
719b5f6049 | ||
|
|
907a6c2420 | ||
|
|
c6d4c68c99 | ||
|
|
3efcfd2345 | ||
|
|
a9b42c491f | ||
|
|
9434b27cc1 | ||
|
|
2d85a69e49 | ||
|
|
0697a9047d | ||
|
|
41d80861e3 | ||
|
|
19b9bff888 | ||
|
|
13eb2258e0 | ||
|
|
2447e38618 | ||
|
|
d9d66e6280 | ||
|
|
70885bf029 | ||
|
|
9b9d8c10f8 | ||
|
|
b08420ec13 | ||
|
|
e11a01f0b1 | ||
|
|
7ac13d7924 | ||
|
|
edea7e37d0 | ||
|
|
f3fe3d8e79 | ||
|
|
510655e447 | ||
|
|
9e7dac7996 | ||
|
|
b21270ffa5 | ||
|
|
84d5926bdb | ||
|
|
8631a9d531 | ||
|
|
d396e5592b | ||
|
|
ff2a7a2bdc | ||
|
|
26cfec06a0 | ||
|
|
9c500d06f2 | ||
|
|
aea157d7c9 | ||
|
|
9c68b94136 | ||
|
|
26b4ab07a4 | ||
|
|
a34ce8f4f9 | ||
|
|
e2b367a169 | ||
|
|
8070023643 | ||
|
|
54a613b9db | ||
|
|
d3df735f89 | ||
|
|
74334a7700 | ||
|
|
09d11ace60 | ||
|
|
bf820013df | ||
|
|
21c6164910 | ||
|
|
6da10fa438 | ||
|
|
bbccb57929 | ||
|
|
5980512a08 | ||
|
|
3700e1fc5b | ||
|
|
46deecdb53 | ||
|
|
eb67b4c407 | ||
|
|
ee17131bdf | ||
|
|
fa45b3cb79 | ||
|
|
d3b1619b06 | ||
|
|
3101d7ebb4 | ||
|
|
157a79216f | ||
|
|
a61f6018f2 | ||
|
|
a639f3fca2 | ||
|
|
3baa5f6f7c | ||
|
|
184d07e47c | ||
|
|
8963c84dad | ||
|
|
7e9a022c74 | ||
|
|
7ca792043c | ||
|
|
028cad3c3b | ||
|
|
5e387e6ee7 | ||
|
|
dc86ebaf28 | ||
|
|
fa0c4963e9 | ||
|
|
9fec507daf | ||
|
|
74b0b63da8 | ||
|
|
fb07cb380c | ||
|
|
d6a247cc04 | ||
|
|
bcca20a3e6 | ||
|
|
1dd1c2796a | ||
|
|
65ef313cc4 | ||
|
|
b106091343 | ||
|
|
594df6bf43 | ||
|
|
52e333af0b | ||
|
|
12026c32de | ||
|
|
6c9a647576 | ||
|
|
e1e9e53d45 | ||
|
|
0bfc0e90c1 | ||
|
|
9c0c3d5ced | ||
|
|
b96a3a3250 | ||
|
|
e5abe844d1 | ||
|
|
9e79e9975f | ||
|
|
70e8197344 | ||
|
|
34f9e5f95e | ||
|
|
e42d1cf9fd | ||
|
|
8077fd8936 | ||
|
|
df08d801fe | ||
|
|
e0fabc6127 | ||
|
|
5e8c8508ef | ||
|
|
4a11f9f08f | ||
|
|
c07cd2e44e | ||
|
|
71a035d619 | ||
|
|
bc10479452 | ||
|
|
adf4640104 | ||
|
|
0466526b1d | ||
|
|
8346a20aa0 | ||
|
|
fb2e65f40b | ||
|
|
c4b9454807 | ||
|
|
f3c8424515 | ||
|
|
2c14f89bfc | ||
|
|
210e82d08d | ||
|
|
891846f23e | ||
|
|
649b2c0683 | ||
|
|
479562ad2b | ||
|
|
91492773b1 | ||
|
|
e9baa2977c | ||
|
|
f7419c60be | ||
|
|
93dfb1ac5b | ||
|
|
8bf91ce80f | ||
|
|
72632f6569 | ||
|
|
6ea160ffff | ||
|
|
c15434df2b | ||
|
|
d3d31b434a | ||
|
|
6a5faa0bec | ||
|
|
d522221668 | ||
|
|
5bba62bcde | ||
|
|
0ba5cbea4f | ||
|
|
7290691142 | ||
|
|
34e4be193e | ||
|
|
4b54fc203f | ||
|
|
ad2f478c46 | ||
|
|
947d85cefc | ||
|
|
0d0de2fcc5 | ||
|
|
2ccebf7a95 | ||
|
|
dcbf99d334 | ||
|
|
1360f530f1 | ||
|
|
d0a91c2f9b | ||
|
|
fa073543c4 | ||
|
|
4c0a4d985f | ||
|
|
c981b246ce | ||
|
|
8cb182e1b8 | ||
|
|
6266197e92 | ||
|
|
2e6999df4a | ||
|
|
3f1201c8b3 | ||
|
|
624d146cd6 | ||
|
|
21aa3ecf60 | ||
|
|
4a8ea0d23b | ||
|
|
22fba83df2 | ||
|
|
fd987e97f0 | ||
|
|
56ba3d45bd | ||
|
|
34dbeb3626 | ||
|
|
c853cec164 | ||
|
|
073233b9f1 | ||
|
|
055c11f63c | ||
|
|
f60aa47715 | ||
|
|
5e399a7e17 | ||
|
|
0480185d07 | ||
|
|
607e8ec0e7 | ||
|
|
ec4b4d979f | ||
|
|
a664dee4f6 | ||
|
|
45a56e468d | ||
|
|
d7fada25e5 | ||
|
|
4b6a25ac06 | ||
|
|
238e3ffb34 | ||
|
|
2f05d8dd32 | ||
|
|
fba81e4174 | ||
|
|
a09dd9cd00 | ||
|
|
8945d9f0ae | ||
|
|
ea2eaef173 | ||
|
|
d8da7f55f7 | ||
|
|
9274b5556e | ||
|
|
c42fbaaf80 | ||
|
|
2061a18313 | ||
|
|
66abbbe72d | ||
|
|
e71b3e08a6 | ||
|
|
d8062ed35f | ||
|
|
276ca8369d | ||
|
|
feea6db815 | ||
|
|
c3f29ce4ac | ||
|
|
444ad35250 | ||
|
|
c0c6db0a5e | ||
|
|
6f56738ab0 | ||
|
|
41dd25d8e6 | ||
|
|
cbb179ef0b | ||
|
|
e54a3827df | ||
|
|
fd879e45c8 | ||
|
|
f63c29c886 | ||
|
|
60d738626b | ||
|
|
4292fe7795 | ||
|
|
2b73e2183f | ||
|
|
f4f14419c4 | ||
|
|
cd834de190 | ||
|
|
c8c9abc669 | ||
|
|
6f93737d8e | ||
|
|
c978015af1 | ||
|
|
25057baf54 | ||
|
|
3474de599f | ||
|
|
1b4d130cf5 | ||
|
|
b837e65b21 | ||
|
|
83987babd3 | ||
|
|
79527fb6f7 | ||
|
|
f43dd6ae18 | ||
|
|
cbaa4b9fd2 | ||
|
|
e793a729f6 | ||
|
|
582a8dc624 | ||
|
|
7b8171fe01 | ||
|
|
db7f340b3a | ||
|
|
1c0bda0e7c | ||
|
|
7671ac1ae2 | ||
|
|
f208b1222b | ||
|
|
f46aeca9a5 | ||
|
|
03b8e8bc19 | ||
|
|
add2685a55 | ||
|
|
cbe52ca43c | ||
|
|
07d993cbc1 | ||
|
|
a89d987e8a | ||
|
|
1fda61b5a0 | ||
|
|
641e5823c0 | ||
|
|
eb4d01cc46 | ||
|
|
297274ca15 | ||
|
|
8ff437236f | ||
|
|
eab4ae000b | ||
|
|
931b038b27 | ||
|
|
323a4d0147 | ||
|
|
21c8d7a7ed | ||
|
|
92378a9085 | ||
|
|
03c8a415e3 | ||
|
|
afcd38536b | ||
|
|
5a77c9744a | ||
|
|
f0cbc35ca9 | ||
|
|
9ff9bd18fe | ||
|
|
f1e5360ef1 | ||
|
|
33872928d5 | ||
|
|
8c31287805 | ||
|
|
42b072b863 | ||
|
|
553b95b3ed | ||
|
|
9574bf0855 | ||
|
|
bc1b7def01 | ||
|
|
078040731c | ||
|
|
5198ae644b | ||
|
|
2beaac96d3 | ||
|
|
f08f0218af | ||
|
|
f0263c5823 | ||
|
|
e58f392e57 | ||
|
|
44e32f15d7 | ||
|
|
bf38e2e68b | ||
|
|
630d44e67b | ||
|
|
4668ae9e06 | ||
|
|
7710dc4a8c | ||
|
|
c8a0a1efdc | ||
|
|
95f2584883 | ||
|
|
577e95880e | ||
|
|
eecf145dbb | ||
|
|
0539be08b4 | ||
|
|
79e994dd97 | ||
|
|
039537cbe7 | ||
|
|
2fd7417f56 | ||
|
|
1cdec54029 | ||
|
|
54f4e8a91f | ||
|
|
43d0af85af | ||
|
|
1c72d8f063 | ||
|
|
38c20cd867 | ||
|
|
c8be0250cd | ||
|
|
0dda30295e | ||
|
|
00931dfc68 | ||
|
|
3f0ccdef3c | ||
|
|
0ecb688269 | ||
|
|
1586b39138 | ||
|
|
003df7454a | ||
|
|
616c03a9fb | ||
|
|
fc7415a5b0 | ||
|
|
d102ed4ed3 | ||
|
|
50c781d0c9 | ||
|
|
e8cbd7088c | ||
|
|
7b07477ebd | ||
|
|
93219ea0db | ||
|
|
92c64cabc1 | ||
|
|
df6e8ae046 | ||
|
|
f0cc213c5a | ||
|
|
e9f8212560 | ||
|
|
0cc707b3ff | ||
|
|
9d5a15ed2d | ||
|
|
d7ae6e4653 | ||
|
|
eccc765057 | ||
|
|
b424ec2865 | ||
|
|
b95f7b9ffb | ||
|
|
fcb053a77c | ||
|
|
87f7a79e89 | ||
|
|
2208bebeac | ||
|
|
30cb3f89ab | ||
|
|
ad8f0feb4f | ||
|
|
23464e88ad | ||
|
|
73409c9fe1 | ||
|
|
919eedc7f9 | ||
|
|
403fd7cc25 | ||
|
|
0978decbac | ||
|
|
a1725f6297 | ||
|
|
1a5d1b4833 | ||
|
|
753010f571 | ||
|
|
07ad8ad1b2 | ||
|
|
1196cc11b9 | ||
|
|
abafcf08ab | ||
|
|
90e7d07f44 | ||
|
|
6f9fa5287f | ||
|
|
fbc0549540 | ||
|
|
851ef02fbe | ||
|
|
e33fb9f77b | ||
|
|
9dfe1f1a56 | ||
|
|
9f0bf550af | ||
|
|
371e13e44f | ||
|
|
b6433522eb | ||
|
|
f7d494d9f7 | ||
|
|
0def858576 | ||
|
|
4d4f7d2a09 | ||
|
|
d1c8a68375 | ||
|
|
aae8ae5d8d | ||
|
|
b7d9256a7a | ||
|
|
4ef7901115 | ||
|
|
b5a69151fa | ||
|
|
f648d82edc | ||
|
|
574a65c28e | ||
|
|
c240ca3bcc | ||
|
|
93b00446b9 | ||
|
|
9594b8889e | ||
|
|
f3312c22a0 | ||
|
|
551e041638 | ||
|
|
42d2e10c93 | ||
|
|
83ebd74d87 | ||
|
|
d243515fa7 | ||
|
|
ce55167487 | ||
|
|
b3065b6d18 | ||
|
|
34e23233ce | ||
|
|
1d744eb4c9 | ||
|
|
56748c5e65 | ||
|
|
5ec5449194 | ||
|
|
f25b0e2872 | ||
|
|
c8e1696a22 | ||
|
|
b6413068e2 | ||
|
|
96303e10f3 | ||
|
|
7b9234f394 | ||
|
|
2cb6777592 | ||
|
|
26b95f7b81 | ||
|
|
5d48ba3c66 | ||
|
|
df4892d939 | ||
|
|
8c5391ab6e | ||
|
|
78502e4565 | ||
|
|
e06aaa5c79 | ||
|
|
0491411807 | ||
|
|
325d12b01d | ||
|
|
caba182038 | ||
|
|
05ee13a649 | ||
|
|
017ba5d42f | ||
|
|
00614c1523 | ||
|
|
675c7492c1 | ||
|
|
19add5471b | ||
|
|
b3e3fe6647 | ||
|
|
cdb9d54dca | ||
|
|
afacc3d80b | ||
|
|
8f8f99098e | ||
|
|
b952bc6595 | ||
|
|
f1a586648e | ||
|
|
282ec11792 | ||
|
|
5a96099cde | ||
|
|
abb2283e2e | ||
|
|
71f3721bb1 | ||
|
|
7aa5482754 | ||
|
|
168935344a | ||
|
|
9b6975c9eb | ||
|
|
49971a76b9 | ||
|
|
7b4f67ecef | ||
|
|
9d7bd43d8e | ||
|
|
c44264ddaa | ||
|
|
4cbc6b0359 | ||
|
|
13ccc059d0 | ||
|
|
ce97014bc0 | ||
|
|
f3e06436b5 | ||
|
|
d7296318a0 | ||
|
|
a4a93917c9 | ||
|
|
31f98e9adc | ||
|
|
6c83a49bbb | ||
|
|
26aa8648b6 | ||
|
|
389f5d1464 | ||
|
|
735c9cb70f | ||
|
|
408c781d14 | ||
|
|
dfa1763af9 | ||
|
|
bc1da1cbb5 | ||
|
|
290c4f581e | ||
|
|
4d4f8bffef | ||
|
|
974be68476 | ||
|
|
449af292dc | ||
|
|
526c70f687 | ||
|
|
158f8a7e15 | ||
|
|
a39d7cd8d8 | ||
|
|
e39da7d0b2 | ||
|
|
4092c70b06 | ||
|
|
0d585dca8d | ||
|
|
c59d012d11 | ||
|
|
1bfe8b6bea | ||
|
|
3b6bc45c37 | ||
|
|
bfca4019b7 | ||
|
|
43fcc9ea37 | ||
|
|
00fd84586c | ||
|
|
ed23ceef64 | ||
|
|
bfa2c8ed77 | ||
|
|
eb0deeb966 | ||
|
|
caee88c774 | ||
|
|
947e8eb838 | ||
|
|
c535939a9c | ||
|
|
b450ad76ff | ||
|
|
2fff622819 | ||
|
|
4434dd24f1 | ||
|
|
8a27e29f7e | ||
|
|
87f5657db0 | ||
|
|
1052502b63 | ||
|
|
f99edadc92 | ||
|
|
baf634194c | ||
|
|
6a35704cdb | ||
|
|
8f50875740 | ||
|
|
ab9e8a59e2 | ||
|
|
181b03d729 | ||
|
|
02e7bc7545 | ||
|
|
3adec81872 | ||
|
|
76dadf47d3 | ||
|
|
1c3c268b50 | ||
|
|
c8ee85702e | ||
|
|
20b606b6f5 | ||
|
|
251a975126 | ||
|
|
05d1b2b372 | ||
|
|
3127baa4c6 | ||
|
|
bb067eb13c | ||
|
|
6f255d0900 | ||
|
|
4518e4334d | ||
|
|
59d273fdcc | ||
|
|
402b662def | ||
|
|
a21cd7e3ed | ||
|
|
b5089fecc7 | ||
|
|
f904831acd | ||
|
|
2ca1f9027b | ||
|
|
c6475974b5 | ||
|
|
caf20d786b | ||
|
|
1cdd76af31 | ||
|
|
867b4c9813 | ||
|
|
f0a46fd71c | ||
|
|
5b81dec879 | ||
|
|
0aa45b0d34 | ||
|
|
60de38ceaa | ||
|
|
b4d8c5b9bf | ||
|
|
23b09947c6 | ||
|
|
35abbbc26d | ||
|
|
0b583194b7 | ||
|
|
f52be1a2a1 | ||
|
|
e6ac4b28cd | ||
|
|
32c7caf710 | ||
|
|
8f955d5543 | ||
|
|
50dbd61063 | ||
|
|
e5e665b0c6 | ||
|
|
88dbe04c81 | ||
|
|
f5c80119ca | ||
|
|
25344751eb | ||
|
|
ab4df6edb8 | ||
|
|
14a3e187ee | ||
|
|
64ff313260 | ||
|
|
0abd82b7e9 | ||
|
|
b9f2325c54 | ||
|
|
a34276feee | ||
|
|
67628dcc63 | ||
|
|
590f99ef2d | ||
|
|
c2c7245030 | ||
|
|
c409e0f9d8 | ||
|
|
04b19ac8b4 | ||
|
|
9d971cb2d0 | ||
|
|
1491483c35 | ||
|
|
3ebb2ce607 | ||
|
|
0b191f16fe | ||
|
|
024b317de0 | ||
|
|
6e6f992f8c | ||
|
|
4c1ede779e | ||
|
|
a257703e59 | ||
|
|
448c19077c | ||
|
|
a37a81db2d | ||
|
|
c15fc551da | ||
|
|
8c1beab96e | ||
|
|
fadb98ee55 | ||
|
|
82cd6c765b | ||
|
|
fce253253a | ||
|
|
62ddbd5e74 | ||
|
|
90c1bb4b73 | ||
|
|
039273c134 | ||
|
|
f613cec7ad | ||
|
|
fc06880f81 | ||
|
|
7c1c547fc8 | ||
|
|
aa95c34004 | ||
|
|
2fe213d777 | ||
|
|
7e5ac7c58a | ||
|
|
7bdd47d030 | ||
|
|
7b9e178a76 | ||
|
|
7f12f71f94 | ||
|
|
8b26558254 | ||
|
|
74f5c3e417 | ||
|
|
4caa397ec5 | ||
|
|
4f0b24ff9a | ||
|
|
fea8dafe0c | ||
|
|
922e0be574 | ||
|
|
7751efc218 | ||
|
|
7bac0827f6 | ||
|
|
1b99c216fe | ||
|
|
20a7e61360 | ||
|
|
7dcb5f9061 | ||
|
|
c8cf89a954 | ||
|
|
51fb15be2c | ||
|
|
95c1f39f60 | ||
|
|
5ea289d82e | ||
|
|
445e4cb09c | ||
|
|
b092de72f8 | ||
|
|
8938b9cd86 | ||
|
|
2038d4ca8c | ||
|
|
e7ecb1dabb | ||
|
|
8949675e5d | ||
|
|
cc1f04ecba | ||
|
|
6f9ee262e5 | ||
|
|
06a08b28de | ||
|
|
20ad96495c | ||
|
|
868a4561fe | ||
|
|
b0a3568de0 | ||
|
|
249d4b7f33 | ||
|
|
b441485b5e | ||
|
|
eb7c535d4e | ||
|
|
fa7ecaca6d | ||
|
|
b110332ed3 | ||
|
|
ff72f5426e | ||
|
|
12501d599c | ||
|
|
bd8f8807ff | ||
|
|
6a6a3b0409 | ||
|
|
e6d9bb2150 | ||
|
|
14edbda9f0 | ||
|
|
e229b36083 | ||
|
|
d9c41d4e4d | ||
|
|
13cf5ae0d5 | ||
|
|
d0ae798f71 | ||
|
|
44d91bdf6b | ||
|
|
fdf7e4ea8b | ||
|
|
b11c74637f | ||
|
|
fc62283164 | ||
|
|
8848b647d7 | ||
|
|
0ac647ab98 | ||
|
|
2db8c8f2d1 | ||
|
|
31766cce90 | ||
|
|
d5472ec0bd | ||
|
|
376caf8f25 | ||
|
|
e2ef2479d8 | ||
|
|
2f5118046d | ||
|
|
72e1731092 | ||
|
|
ffec04c65e | ||
|
|
bed712ffa7 | ||
|
|
4c58663041 | ||
|
|
808bdbd1e9 | ||
|
|
c0299e1868 | ||
|
|
38f0b3a103 | ||
|
|
a59117c7ca | ||
|
|
6042483a0e | ||
|
|
51096e2944 | ||
|
|
bf172f9242 | ||
|
|
7e91fdd975 | ||
|
|
7af47907be | ||
|
|
ab270dc35c | ||
|
|
c3b2bf38e2 | ||
|
|
893aed8eef | ||
|
|
019b91c3f9 | ||
|
|
c446e19003 | ||
|
|
79d40a536a | ||
|
|
35196f7d8e | ||
|
|
d41260fe2d | ||
|
|
337af524dd | ||
|
|
7b0f1fe562 | ||
|
|
93fbb5ff49 | ||
|
|
5c02939533 | ||
|
|
c5307363be | ||
|
|
9f4323a562 | ||
|
|
52562b49df | ||
|
|
febb521bfd | ||
|
|
1d2e4fc2c3 | ||
|
|
9d04667848 | ||
|
|
b3943c21f2 | ||
|
|
28dd133623 | ||
|
|
924da17c17 | ||
|
|
fd4b67bbb4 | ||
|
|
badc7673d0 | ||
|
|
18df4910a4 | ||
|
|
3b961ec66b | ||
|
|
095d0d0142 | ||
|
|
5ecd9157ce | ||
|
|
c21df1ea0f | ||
|
|
02893c3489 | ||
|
|
aee5a63849 | ||
|
|
bf22966f55 | ||
|
|
47df93b8f3 | ||
|
|
0a8e4e4d8d | ||
|
|
f2d846d057 | ||
|
|
27d93b1f08 | ||
|
|
a13ca8271e | ||
|
|
d2098f638f | ||
|
|
d72fa83245 | ||
|
|
7eb4eba381 | ||
|
|
630b99334c | ||
|
|
fd23cd4aed | ||
|
|
26ad896676 | ||
|
|
a117ed9cb0 | ||
|
|
15870a9582 | ||
|
|
bc77dfb492 | ||
|
|
5a2af49e58 | ||
|
|
8a6a94db0a | ||
|
|
6aaa863432 | ||
|
|
ab02f47a29 | ||
|
|
7115a37f23 | ||
|
|
a748265b50 | ||
|
|
7c96935552 | ||
|
|
09aa3d6409 | ||
|
|
717be92385 | ||
|
|
a4cd3eb9ec | ||
|
|
a8798e999b | ||
|
|
1cb032a934 | ||
|
|
988f243286 | ||
|
|
db142b6e23 | ||
|
|
2736a19518 | ||
|
|
93ac7d8824 | ||
|
|
61a6ca82db | ||
|
|
ddcac5ae09 | ||
|
|
d2f5f5c564 | ||
|
|
66fc80e922 | ||
|
|
8b8d3b1477 | ||
|
|
5ba1325ef5 | ||
|
|
4c9141aac6 | ||
|
|
0d3962f1f0 | ||
|
|
b081019d5a | ||
|
|
c2240df616 | ||
|
|
7f8e4647f7 | ||
|
|
91e082671a | ||
|
|
ea50171a95 | ||
|
|
77ca1c8ce0 | ||
|
|
86c9d69086 | ||
|
|
983a76ecef | ||
|
|
af5e1e29f6 | ||
|
|
1955dcd47b | ||
|
|
c3eaebd1c5 | ||
|
|
8ab278998f | ||
|
|
42f9f37afc | ||
|
|
4a377a712d | ||
|
|
2e9f27769d | ||
|
|
5e1303ecd1 | ||
|
|
ac88af1f71 | ||
|
|
65115c75c8 | ||
|
|
4a66257e65 | ||
|
|
c94bfa8223 | ||
|
|
648e8f1438 | ||
|
|
4a942bc59a | ||
|
|
6ff4192069 | ||
|
|
acece1ee67 | ||
|
|
82ce7176f7 | ||
|
|
5f8a497f0c | ||
|
|
bcf25dc67e | ||
|
|
7cd19206cc | ||
|
|
63a7914830 | ||
|
|
89ede8cd28 | ||
|
|
232aea721c | ||
|
|
d2c9ffac23 | ||
|
|
5faa0879ec | ||
|
|
cc90414b29 | ||
|
|
c76183a3f0 | ||
|
|
aff52c552e | ||
|
|
1763373f29 | ||
|
|
75dd0b22c4 | ||
|
|
fa1480a3e1 | ||
|
|
78c1ed384a | ||
|
|
a46bfdc2e0 | ||
|
|
badd237fe6 | ||
|
|
b06f26cba1 | ||
|
|
cb8aaf521e | ||
|
|
7995027c8c | ||
|
|
056bbf84bd | ||
|
|
a830af5097 | ||
|
|
d28d9fb195 | ||
|
|
2057ffdb50 | ||
|
|
99ec965544 | ||
|
|
0a3a1d7c71 | ||
|
|
e04ff12768 | ||
|
|
686826c3b0 | ||
|
|
2f9370afe7 | ||
|
|
d98e5352c2 | ||
|
|
146998ee2b | ||
|
|
069700db50 | ||
|
|
dbe4a508c8 | ||
|
|
20d3008c38 | ||
|
|
1155be1c15 | ||
|
|
40c4d3c57a | ||
|
|
8f43cd72ad | ||
|
|
2f98fec1aa | ||
|
|
abbf826445 | ||
|
|
2fc9c76969 | ||
|
|
cb7e3eef04 | ||
|
|
1624979f13 | ||
|
|
ba02bd7567 | ||
|
|
c33d934a59 | ||
|
|
212abd64d7 | ||
|
|
90ca9c36ff | ||
|
|
fbcff969d1 | ||
|
|
ce71e18f4d | ||
|
|
59ec5dc69f | ||
|
|
0a20bdd5b4 | ||
|
|
02d7474a09 | ||
|
|
d069b4fce9 | ||
|
|
05b16a78db | ||
|
|
e58343012f | ||
|
|
c826b18437 | ||
|
|
22df8c29e4 | ||
|
|
48df7d401c | ||
|
|
820832a647 | ||
|
|
6610ad0a1b | ||
|
|
a6705159a5 | ||
|
|
d40a4e8af7 | ||
|
|
a1e24ac839 | ||
|
|
cf138d7479 | ||
|
|
c1fbee04ce | ||
|
|
3b2be8ae88 | ||
|
|
69be2b84d7 | ||
|
|
1d39f204ca | ||
|
|
745c40650b | ||
|
|
942f22989a | ||
|
|
7fd291f407 | ||
|
|
2b44dbd7e4 | ||
|
|
ac881909bf | ||
|
|
ef0656db3e | ||
|
|
e30971a76c | ||
|
|
f8b5fe53e7 | ||
|
|
632f689209 | ||
|
|
8a95d10be2 | ||
|
|
ab574cbec0 | ||
|
|
4932b87fc9 | ||
|
|
01d2966cb8 | ||
|
|
bf0709cd98 | ||
|
|
96c5ee9065 | ||
|
|
dad3bb043a | ||
|
|
e50d0c4072 | ||
|
|
0a1885deb0 | ||
|
|
cae69592be | ||
|
|
f0d7992765 | ||
|
|
ac5d67c11a | ||
|
|
8a9db93977 | ||
|
|
fb688a2077 | ||
|
|
2f84b170a6 | ||
|
|
1f2fe53c4b | ||
|
|
1c97f7224e | ||
|
|
5a94b8e90d | ||
|
|
d2de74a205 | ||
|
|
7e1de2012c | ||
|
|
ff56e32e8e | ||
|
|
f47685c861 | ||
|
|
0242d89877 | ||
|
|
06d38ce529 | ||
|
|
51bbed6f76 | ||
|
|
a72fc7ad09 | ||
|
|
2b5a3625bc | ||
|
|
dfb83160f0 | ||
|
|
38b2f73004 | ||
|
|
22ffd04926 | ||
|
|
9eeaf260eb | ||
|
|
e440dee245 | ||
|
|
89dee022e5 | ||
|
|
b697ebf16b | ||
|
|
5e74b6e011 | ||
|
|
02f3bdf5ff | ||
|
|
833186b7be | ||
|
|
e340b3371b | ||
|
|
65d8f175b4 | ||
|
|
26a983b467 | ||
|
|
f548ce72b2 | ||
|
|
f3989e64cf | ||
|
|
e8de8a2e8e | ||
|
|
12fc92828c | ||
|
|
360deb4568 | ||
|
|
de782144bd | ||
|
|
0ef46467ad | ||
|
|
9b13e9bda8 | ||
|
|
5fcb8553da | ||
|
|
e7fcb5fc7d | ||
|
|
cf2bd809fb | ||
|
|
00bf9b0346 | ||
|
|
36d712dc64 | ||
|
|
c2712cb0bb | ||
|
|
4ce9674365 | ||
|
|
35d3d79e92 | ||
|
|
d64dfc5d77 | ||
|
|
83a1a32f2a | ||
|
|
b11015c2e1 | ||
|
|
026c7d9a3d | ||
|
|
4ba42369b9 | ||
|
|
df3d88ed4e | ||
|
|
514182a05f | ||
|
|
8506b4ba33 | ||
|
|
a892febac3 | ||
|
|
9c28c7dfe2 | ||
|
|
9910c06bd2 | ||
|
|
2e6ab58f37 | ||
|
|
63f481c61a | ||
|
|
6cc0dce1b4 | ||
|
|
49b21c7e2f | ||
|
|
a67fb30bdf | ||
|
|
523f2003fa | ||
|
|
71046cd407 | ||
|
|
c35e56ae66 | ||
|
|
1fda8899b1 | ||
|
|
b3e657a00e | ||
|
|
391a408eee | ||
|
|
a34db10d65 | ||
|
|
e55c4263a8 | ||
|
|
e7b9b558e9 | ||
|
|
196d86fdcf | ||
|
|
b77fc5c860 | ||
|
|
52c15029d1 | ||
|
|
16386fbb70 | ||
|
|
478030c6ff | ||
|
|
47ab97a347 | ||
|
|
1f9085cef2 | ||
|
|
09b1b9b925 | ||
|
|
9d0c65ad86 | ||
|
|
451fad1ed2 | ||
|
|
e633b97957 | ||
|
|
1690c05075 | ||
|
|
fd3e6e84fb | ||
|
|
c667952861 | ||
|
|
0b0e03fa39 | ||
|
|
d22d6d181b | ||
|
|
2ee61db6af | ||
|
|
65cf5ea290 | ||
|
|
92f11c15aa | ||
|
|
15ac6d24a1 | ||
|
|
44bd80e100 | ||
|
|
b3af1a8740 | ||
|
|
700f129750 | ||
|
|
e4e78e0f1b | ||
|
|
bb9f206529 | ||
|
|
d46cba8a0b | ||
|
|
16e96c79e8 | ||
|
|
73e3b495e0 | ||
|
|
f0b0990612 | ||
|
|
8e9fee2e10 | ||
|
|
924b6192c1 | ||
|
|
a25e0a608e | ||
|
|
f58a34ed34 | ||
|
|
3138b239f6 | ||
|
|
cf2ecb83b8 | ||
|
|
14f83aec55 | ||
|
|
50058c1cab | ||
|
|
42ef3b86b6 | ||
|
|
6004eca8c6 | ||
|
|
0a1f83bbe5 | ||
|
|
82f7a5cba6 | ||
|
|
c89813d5d7 | ||
|
|
fefedea577 | ||
|
|
3284f365b2 | ||
|
|
ed90a4676f | ||
|
|
f79807ac11 | ||
|
|
e4fe04cbaf | ||
|
|
577f3cebbf | ||
|
|
1a8c914dd2 | ||
|
|
9554989110 | ||
|
|
1d78e63233 | ||
|
|
e9f5b2e75f | ||
|
|
0e7182533c | ||
|
|
6992c74bba | ||
|
|
284def7321 | ||
|
|
7fe567da94 | ||
|
|
b4ef24844f | ||
|
|
d1031e2c8f | ||
|
|
ce51a74045 | ||
|
|
b5df4f1cf0 | ||
|
|
d7c3f23610 | ||
|
|
335d787018 | ||
|
|
89ada2df28 | ||
|
|
e7c7c91d71 | ||
|
|
c5b9ec889e | ||
|
|
c648ed1bc5 | ||
|
|
08077cc9e1 | ||
|
|
1953348c90 | ||
|
|
2ec7a4dd72 | ||
|
|
60f61c8f0c | ||
|
|
aa68eb8540 | ||
|
|
1db154464e | ||
|
|
60f0a86c75 | ||
|
|
1691feb9bb | ||
|
|
73a53daf38 | ||
|
|
09c7acf9fc | ||
|
|
d14b612e13 | ||
|
|
45a96fde12 | ||
|
|
9a8d732a13 | ||
|
|
a66aae880c | ||
|
|
3b5a4b7362 | ||
|
|
ce4687fbf9 | ||
|
|
dc18888c83 | ||
|
|
43860d2469 | ||
|
|
5822ec3d44 | ||
|
|
6a588826c1 | ||
|
|
9fd6a9eaa9 | ||
|
|
3e60a5b819 | ||
|
|
1d85484c3a | ||
|
|
42098699db | ||
|
|
44bbdb2623 | ||
|
|
795f4f2fe7 | ||
|
|
8defcc6225 | ||
|
|
0fb2fa7393 | ||
|
|
04da777bed | ||
|
|
0e4436a070 | ||
|
|
ca10b1353d | ||
|
|
c722851bce | ||
|
|
bdfad7a2dd | ||
|
|
17ea28ccc6 | ||
|
|
4b7de22999 | ||
|
|
550145d49e | ||
|
|
f0b6861998 | ||
|
|
a5d3212751 | ||
|
|
c86d22226f | ||
|
|
6c2d7ebaa4 | ||
|
|
be47c1791d | ||
|
|
1685e9ca66 | ||
|
|
ecb249f424 | ||
|
|
660e4d5687 | ||
|
|
eb1230e841 | ||
|
|
f1a451faea | ||
|
|
604785be66 | ||
|
|
b18070b268 | ||
|
|
85a82af5f5 | ||
|
|
ce06f27a35 | ||
|
|
52fa476b21 | ||
|
|
ed30d9d329 | ||
|
|
abdfa8b2da | ||
|
|
448a1b222d | ||
|
|
e3e3020c00 | ||
|
|
a903b6d997 | ||
|
|
4fa5cef491 | ||
|
|
fb616011ef | ||
|
|
eef4559783 | ||
|
|
0c5bd57698 | ||
|
|
7409281e34 | ||
|
|
607e4c4c6c | ||
|
|
3c631c6e5c | ||
|
|
b3a5b17b7d | ||
|
|
7e6d2bf451 | ||
|
|
2f54303d98 | ||
|
|
3a787ecbfa | ||
|
|
54a84434fc | ||
|
|
64e28312dc | ||
|
|
6f06485dbd | ||
|
|
eb78e5e1f4 | ||
|
|
0d66719c5a | ||
|
|
bf82c863bc | ||
|
|
1d52d9d510 | ||
|
|
fb736ec3fb | ||
|
|
5e9aa90009 | ||
|
|
97a72783f5 | ||
|
|
c654bc14d9 | ||
|
|
6edba0dfa6 | ||
|
|
5b3658b122 | ||
|
|
54f369a734 | ||
|
|
e70b98252a | ||
|
|
daf90db115 | ||
|
|
194435acc1 | ||
|
|
1819c0f818 | ||
|
|
388920bc53 | ||
|
|
ea0d956a57 | ||
|
|
a0dee6c57f | ||
|
|
8cfe33fc4a | ||
|
|
9520866ab3 | ||
|
|
b10221fa07 | ||
|
|
475e526a48 | ||
|
|
831b00dc7a | ||
|
|
c3124815a1 | ||
|
|
b68354a9da | ||
|
|
4ed73b6f07 | ||
|
|
d6e5285e95 | ||
|
|
93f0406b7e | ||
|
|
7240af4333 | ||
|
|
63a1fa96cc | ||
|
|
e964cf0d35 | ||
|
|
5140f01d5c | ||
|
|
56b541d76b | ||
|
|
4a257edd0a | ||
|
|
17103bf8fe | ||
|
|
faf655c5db | ||
|
|
a62834808a | ||
|
|
4916c78ad5 | ||
|
|
71ad9f439f | ||
|
|
15a7581e30 | ||
|
|
9448787ff2 | ||
|
|
fdb4952e5f | ||
|
|
6919faea77 | ||
|
|
997d3daa65 | ||
|
|
b969ed4302 | ||
|
|
cad9a5d11b | ||
|
|
b811c2fbf8 | ||
|
|
3f4a052c85 | ||
|
|
70970e832a | ||
|
|
75ab2c8de3 | ||
|
|
e10d005f81 | ||
|
|
a4934e2232 | ||
|
|
b15be9de3e | ||
|
|
bf18ec5adc | ||
|
|
e0694a8f6e | ||
|
|
09fdf9af74 | ||
|
|
a03a1d3847 | ||
|
|
4a1b2d534a | ||
|
|
7c4569624d | ||
|
|
fa193dcd22 | ||
|
|
f8b61da4ae | ||
|
|
2f4ccc04ae | ||
|
|
5e17d0736e | ||
|
|
e9cfd1f82e | ||
|
|
b0748328d7 | ||
|
|
6e054e4a72 | ||
|
|
8dc7035fbc | ||
|
|
09dbdbc3d7 | ||
|
|
c8b2c614f9 | ||
|
|
57cb7ea3ae | ||
|
|
3a67f6a326 | ||
|
|
5259984e73 | ||
|
|
1ab0aa143b | ||
|
|
8bfa01cab1 | ||
|
|
5c8369e758 | ||
|
|
d909c841fa | ||
|
|
e007df7723 | ||
|
|
af53747181 | ||
|
|
4aa5e79cdf | ||
|
|
fd3b313e9f | ||
|
|
c6c7427e8d | ||
|
|
6de3bf2f6d | ||
|
|
bcb54a8a67 | ||
|
|
787ece6c01 | ||
|
|
bcb7c68911 | ||
|
|
1fa9d257c2 | ||
|
|
d08d088d4a | ||
|
|
757d341d96 | ||
|
|
b92e2fc457 | ||
|
|
a30eb425e3 | ||
|
|
bc8c3ff399 | ||
|
|
90ee7e01ca | ||
|
|
dde4e9adcc | ||
|
|
99488cbd5e | ||
|
|
fffdc76681 | ||
|
|
d2f2750a37 | ||
|
|
ddb002d57e | ||
|
|
270af08171 | ||
|
|
3d9a64d54e | ||
|
|
9f0c8f18fb | ||
|
|
e61424a7bf | ||
|
|
4680546c65 | ||
|
|
84ff99013a | ||
|
|
4ecb6d1a3d | ||
|
|
4ac03908fc | ||
|
|
722a7d2142 | ||
|
|
d3b099140f | ||
|
|
f8ad0dced3 | ||
|
|
ecbcc332cc | ||
|
|
e820fecf53 | ||
|
|
ff95117d9d | ||
|
|
70ce1cda1f | ||
|
|
274d7730ca | ||
|
|
2da1378f53 | ||
|
|
1bbf32f04c | ||
|
|
28b4477f48 | ||
|
|
5f8ee4fae3 | ||
|
|
3e91392c8a | ||
|
|
6afa56ba09 | ||
|
|
f8d43bd423 | ||
|
|
b7b4d08758 | ||
|
|
7d7958b0d7 | ||
|
|
98ffd0a3fe | ||
|
|
d090c02476 | ||
|
|
a746b9d0b2 | ||
|
|
56a9766529 | ||
|
|
1abc300112 | ||
|
|
ce8b94bd73 | ||
|
|
db1ccab0bc | ||
|
|
a6a026cb9e | ||
|
|
358b2781af | ||
|
|
ad743c1e41 | ||
|
|
b40e382e5a | ||
|
|
26587ef1e7 | ||
|
|
ac111ee8c6 | ||
|
|
7a613287ee | ||
|
|
af1246c78b | ||
|
|
7c6cc24b1d | ||
|
|
f869dfabdf | ||
|
|
6ab7ebcb31 | ||
|
|
606c8196a0 | ||
|
|
490754594e | ||
|
|
2a566d194d | ||
|
|
b9c4c480d2 | ||
|
|
08baf6b01b | ||
|
|
a8f0272ace | ||
|
|
ec9068fae8 | ||
|
|
4e2b0d5b83 | ||
|
|
319a1c65b1 | ||
|
|
4619035cd2 | ||
|
|
8df2fba997 | ||
|
|
9860222979 | ||
|
|
d3213f193c | ||
|
|
d2ddca583e | ||
|
|
7615024f27 | ||
|
|
b7fc58333b | ||
|
|
1c8dcecf82 | ||
|
|
48ddb827a7 | ||
|
|
13c1e97beb | ||
|
|
0689226ba6 | ||
|
|
9d61e1fd4b | ||
|
|
ea4d707d12 | ||
|
|
9c520c7a50 | ||
|
|
dab361f764 | ||
|
|
7bfb5527ff | ||
|
|
c6d2e0f7ff | ||
|
|
bce9e6601e | ||
|
|
6f6730c28d | ||
|
|
c48aea165d | ||
|
|
25457361c7 | ||
|
|
ac4bbe6bd6 | ||
|
|
cbe19e29c7 | ||
|
|
e2f10bc2ea | ||
|
|
2c3cc9185d | ||
|
|
f8edd2d8b4 | ||
|
|
5dd98ac658 | ||
|
|
8aca9455b2 | ||
|
|
04ea116e8e | ||
|
|
1bc68cc41d | ||
|
|
365df5b5be | ||
|
|
c04ffd3913 | ||
|
|
07bcd97961 | ||
|
|
80fc4a8b94 | ||
|
|
0668e42e8f | ||
|
|
d5253ec5f4 | ||
|
|
78bc90cd07 | ||
|
|
4923dd22a7 | ||
|
|
b8a694e7a3 | ||
|
|
28d955a3c8 | ||
|
|
2b781f537c | ||
|
|
1a9dc4e7e8 | ||
|
|
f5b9bdb93d | ||
|
|
ea1309bf73 | ||
|
|
4dd64f873e | ||
|
|
aa9e05430a | ||
|
|
c24cace1d1 | ||
|
|
32ce57a6f6 | ||
|
|
4670eb5194 | ||
|
|
f2312262c7 | ||
|
|
445aaca53e | ||
|
|
05cc60042e | ||
|
|
11cbe6cb5b | ||
|
|
c937858ec1 | ||
|
|
667b9d5d53 | ||
|
|
0094d2755b | ||
|
|
b095c7a84d | ||
|
|
45a021a18b | ||
|
|
aac5f60602 | ||
|
|
2857b4be36 | ||
|
|
2577811738 | ||
|
|
66012c4e8e | ||
|
|
c825db8d56 | ||
|
|
fc94a56f56 | ||
|
|
a328cefbf0 | ||
|
|
22bdb8123d | ||
|
|
c83c92a0d1 | ||
|
|
f68f30c7aa | ||
|
|
c165c83f55 | ||
|
|
5584d30eed | ||
|
|
551e7cf39f | ||
|
|
51e4ebb293 | ||
|
|
d06ddc50ab | ||
|
|
fcff398f31 | ||
|
|
9bdfa623ba | ||
|
|
4c24890f17 | ||
|
|
c9a772e36b | ||
|
|
f864ff281f | ||
|
|
1dd459c9ec | ||
|
|
42849c7d66 | ||
|
|
9a61faa716 | ||
|
|
4dbc4a637b | ||
|
|
ee892c109b | ||
|
|
fd65072f1f | ||
|
|
f9d0fcd1a2 | ||
|
|
298784d80e | ||
|
|
88e4aed397 | ||
|
|
1c2a42af9c | ||
|
|
f61c275395 | ||
|
|
23b44e67df | ||
|
|
f7d0ea8784 | ||
|
|
be9ce3ad26 | ||
|
|
e88c426966 | ||
|
|
bf7a671d87 |
No files matched your search
+23
@@ -0,0 +1,23 @@
|
|||||||
|
INSTALL
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
aclocal.m4
|
||||||
|
config.cache
|
||||||
|
config.guess
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
config.sub
|
||||||
|
configure
|
||||||
|
depcomp
|
||||||
|
install-sh
|
||||||
|
libtool
|
||||||
|
missing
|
||||||
|
stamp-h1
|
||||||
|
autom4te.cache
|
||||||
|
cscope.files
|
||||||
|
cscope.out
|
||||||
|
compile
|
||||||
|
*~
|
||||||
|
tags
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
language: C
|
||||||
|
dist: trusty
|
||||||
|
sudo: true
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install --assume-yes asciidoc valgrind
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./autogen.sh
|
||||||
|
- ./configure
|
||||||
|
- make
|
||||||
|
- make test
|
||||||
|
- ./configure --enable-debug --enable-transparent --enable-reverse
|
||||||
|
- make
|
||||||
|
- make test
|
||||||
|
- make valgrind-test
|
||||||
|
- make distcheck
|
||||||
@@ -1,9 +1,39 @@
|
|||||||
tinyproxy is a collaborative work between Steven Young
|
Andrew Stribblehill
|
||||||
<sdyoung@well.com> and Robert James Kaes <rjkaes@flarenet.com>.
|
bertliao
|
||||||
|
Bob Showalter
|
||||||
From versions 0-1.1, Steven Young was the primary maintainer.
|
Brian Cain
|
||||||
From 1.2 to 1.3.0, Robert James Kaes was the primary maintainer.
|
cvs2svn
|
||||||
As of 1.3.1, Steven Young will once again be the primary maintainer.
|
Daniel Egger
|
||||||
|
Daniel M. Drucker
|
||||||
Please see the ChangeLog for futher details as to who did what. :)
|
David Shanks
|
||||||
|
Dmitry Semyonov
|
||||||
|
dmz-uk
|
||||||
|
Drew G. Wallace
|
||||||
|
Frank Morgner
|
||||||
|
gary-wzl77
|
||||||
|
Gaudenz Steinlin
|
||||||
|
goba62000374
|
||||||
|
Gonzalo Tornaria
|
||||||
|
Greg
|
||||||
|
Jeremy Hinegardner
|
||||||
|
John Spencer
|
||||||
|
John van der Kamp
|
||||||
|
John Weldon
|
||||||
|
Jordi
|
||||||
|
Jordi Mallach
|
||||||
|
Julien Hartmann
|
||||||
|
kikuchan
|
||||||
|
Mathew Mrosko
|
||||||
|
Matthew Dempsky
|
||||||
|
Michael Adam
|
||||||
|
Mike Mead
|
||||||
|
Mukund Sivaraman
|
||||||
|
Pablo Panero
|
||||||
|
Peter H. Froehlich
|
||||||
|
Robert James Kaes
|
||||||
|
rofl0r
|
||||||
|
Stephan Leemburg
|
||||||
|
Steven Conaway
|
||||||
|
Steven Young
|
||||||
|
Valen Blanco
|
||||||
|
Vladimir Belov
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
|
|||||||
General Public License applies to most of the Free Software
|
General Public License applies to most of the Free Software
|
||||||
Foundation's software and to any other program whose authors commit to
|
Foundation's software and to any other program whose authors commit to
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
the GNU Library General Public License instead.) You can apply it to
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
your programs, too.
|
your programs, too.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
@@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all.
|
|||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
|
|||||||
License. (Exception: if the Program itself is interactive but
|
License. (Exception: if the Program itself is interactive but
|
||||||
does not normally print such an announcement, your work based on
|
does not normally print such an announcement, your work based on
|
||||||
the Program is not required to print an announcement.)
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
These requirements apply to the modified work as a whole. If
|
||||||
identifiable sections of that work are not derived from the Program,
|
identifiable sections of that work are not derived from the Program,
|
||||||
and can be reasonably considered independent and separate works in
|
and can be reasonably considered independent and separate works in
|
||||||
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
|
|||||||
access to copy the source code from the same place counts as
|
access to copy the source code from the same place counts as
|
||||||
distribution of the source code, even though third parties are not
|
distribution of the source code, even though third parties are not
|
||||||
compelled to copy the source along with the object code.
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
except as expressly provided under this License. Any attempt
|
except as expressly provided under this License. Any attempt
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
@@ -225,7 +225,7 @@ impose that choice.
|
|||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
This section is intended to make thoroughly clear what is believed to
|
||||||
be a consequence of the rest of this License.
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
original copyright holder who places the Program under this License
|
original copyright holder who places the Program under this License
|
||||||
@@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|||||||
POSSIBILITY OF SUCH DAMAGES.
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License along
|
||||||
along with this program; if not, write to the Free Software
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
If the program is interactive, make it output a short notice like this
|
||||||
when it starts in an interactive mode:
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) year name of author
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
|
|||||||
This General Public License does not permit incorporating your program into
|
This General Public License does not permit incorporating your program into
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
consider it more useful to permit linking proprietary applications with the
|
consider it more useful to permit linking proprietary applications with the
|
||||||
library. If this is what you want to do, use the GNU Library General
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
Public License instead of this License.
|
Public License instead of this License.
|
||||||
@@ -1,584 +1 @@
|
|||||||
2001-08-26 Robert James Kaes <rjkaes@flarenet.com>
|
The ChangeLog is maintained in the git history.
|
||||||
|
|
||||||
* src/utils.c (httperr): Split the headers from the actual message
|
|
||||||
and include more headers like Date, Server, Content-Length,
|
|
||||||
etc. Also set the type for the error message to const char*.
|
|
||||||
|
|
||||||
* src/reqs.c (process_method): Fixed a SEGV problem if an invalid
|
|
||||||
request was submitted.
|
|
||||||
|
|
||||||
* Makefile.am (EXTRA_DIST): Don't include ./reconf in the
|
|
||||||
tarball.
|
|
||||||
|
|
||||||
* src/log.c (log_message): Fixed a problem with the new LOG_CONN
|
|
||||||
log level.
|
|
||||||
|
|
||||||
* configure.in: The debugging code was being included even on
|
|
||||||
non-debugging builds.
|
|
||||||
|
|
||||||
* src/anonymous.c (anonymous_insert): Moved the creation of the
|
|
||||||
search tree into the anonymous_insert() function. Therefore, the
|
|
||||||
search tree is _not_ created until the first insertion. This
|
|
||||||
should also fix a bug in main() where I was inserting headers
|
|
||||||
before creating the search tree. Doh.
|
|
||||||
(is_anonymous_enabled): Removed the tests for config.anon and
|
|
||||||
replaced it with a function call which returns a BOOL.
|
|
||||||
|
|
||||||
* Spell checked the ChangeLog file! :)
|
|
||||||
|
|
||||||
2001-08-25 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* src/thread.c (thread_main): Thanks to Hans-Georg Bork for
|
|
||||||
fixing a problem where the status of the threads was not
|
|
||||||
going back to T_WAITING if MaxRequestsPerChild was 0. Also, fixed
|
|
||||||
a problem with the looping system where the Debian
|
|
||||||
start-stop-daemon script would not stop all the threads if new
|
|
||||||
threads had been created.
|
|
||||||
|
|
||||||
* src/log.h (LOG_CONN): Added the LOG_CONN log level. This is less
|
|
||||||
verbose than LOG_INFO.
|
|
||||||
|
|
||||||
* doc/tinyproxy.8: Added the -l option to the list of command line
|
|
||||||
options.
|
|
||||||
|
|
||||||
* src/anonymous.c (anon_insert): Fixed a bug where anonymous
|
|
||||||
filtering wasn't working even if it was specified in the
|
|
||||||
configuration file.
|
|
||||||
|
|
||||||
2001-07-02 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* src/tinyproxy.c (versiondisp): Added George Talusan to the
|
|
||||||
copyright message. Also now include the target system name to the
|
|
||||||
version message.
|
|
||||||
|
|
||||||
2001-06-06 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* configure.in: Total reorganization.
|
|
||||||
|
|
||||||
2001-06-04 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* configure.in: Remove the --with-* for port, logfile, and user
|
|
||||||
since the configuration file handles this now. Fixed a problem
|
|
||||||
where we were testing for the libraries correctly, but not
|
|
||||||
actually including them in the linking.
|
|
||||||
|
|
||||||
2001-06-02 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* doc/tinyproxy.conf: Clarified the LogLevel directive.
|
|
||||||
|
|
||||||
* configure.in: Fixed up the tests for libsocket, libnsl, and
|
|
||||||
libresolv. Also improved the test for the yacc program since I
|
|
||||||
used bison 1.25 to originally write it. Updated the list of
|
|
||||||
headers to look for when configuring. Bumped up the version.
|
|
||||||
|
|
||||||
2001-06-01 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* configure.in: Fixed a problem when using the --with-port= config
|
|
||||||
|
|
||||||
* src/tinyproxy.c (main): Change the logging level from LOG_EMERG
|
|
||||||
(which doesn't exist anymore) to LOG_CRIT.
|
|
||||||
|
|
||||||
* src/scanner.l: Added the strings in the data structure to handle
|
|
||||||
the LogLevel switch.
|
|
||||||
|
|
||||||
* src/log.c (set_log_level): Code for handling selective logging.
|
|
||||||
|
|
||||||
* src/grammar.y: Added the tokens and code for handling the
|
|
||||||
LogLevel switch in the configuration file.
|
|
||||||
|
|
||||||
* configure.in: Added a test for the resolv library for the
|
|
||||||
gethostby* functions. Also bumped up the pre-version.
|
|
||||||
|
|
||||||
2001-05-26 Robert James Kaes <rjkaes@flarenet.com>
|
|
||||||
|
|
||||||
* src/tinyproxy.c (main): Added code to stop the creation of core
|
|
||||||
files.
|
|
||||||
|
|
||||||
* src/reqs.c (process_method): Fixed a memory leak.
|
|
||||||
(relay_connection): Cleaned up the code to remove some unneeded
|
|
||||||
variables and removed redundant code.
|
|
||||||
|
|
||||||
* src/log.c (log_message): Renamed "log()" function to
|
|
||||||
log_message().
|
|
||||||
|
|
||||||
* src/dnscache.c (new_dnscache):
|
|
||||||
* src/anonymous.c (new_anonymous): Fixed the return type.
|
|
||||||
|
|
||||||
2001-01-15 12:13 rjkaes
|
|
||||||
|
|
||||||
* configure.in: Bumped up the pre version number
|
|
||||||
|
|
||||||
2001-01-15 12:11 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog, src/reqs.c, src/stats.c: Fixed more potential overflow
|
|
||||||
bugs.
|
|
||||||
|
|
||||||
2001-01-15 12:06 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog, src/utils.c: Fixed a potential security bug in
|
|
||||||
http_err. There was a possibility of a heap overflow exploit.
|
|
||||||
|
|
||||||
2001-01-02 14:30 rjkaes
|
|
||||||
|
|
||||||
* src/scanner.l: Fixed a bug where the ':' character was not being
|
|
||||||
properly detected.
|
|
||||||
|
|
||||||
2000-12-09 15:03 rjkaes
|
|
||||||
|
|
||||||
* configure.in: Rolling out the first pre to 1.4.0
|
|
||||||
|
|
||||||
2000-12-08 21:35 rjkaes
|
|
||||||
|
|
||||||
* src/thread.c: Implemented the MaxRequestsPerChild directive.
|
|
||||||
|
|
||||||
2000-12-07 22:35 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated changelog
|
|
||||||
|
|
||||||
2000-12-07 22:35 rjkaes
|
|
||||||
|
|
||||||
* src/: thread.c, tinyproxy.c: Fixed a problem with polling for the
|
|
||||||
number of active threads. No longer polls. :)
|
|
||||||
|
|
||||||
2000-11-22 23:49 rjkaes
|
|
||||||
|
|
||||||
* src/ternary.c: Fixed MACRO error.
|
|
||||||
|
|
||||||
2000-11-22 23:46 rjkaes
|
|
||||||
|
|
||||||
* src/tinyproxy.c: Fixed spelling mistake.
|
|
||||||
|
|
||||||
2000-11-22 23:46 rjkaes
|
|
||||||
|
|
||||||
* src/: filter.c, filter.h, reqs.c: Changed the filter_host command
|
|
||||||
to filter_url.
|
|
||||||
|
|
||||||
2000-10-23 17:47 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated Information.
|
|
||||||
|
|
||||||
2000-10-23 17:46 rjkaes
|
|
||||||
|
|
||||||
* src/ternary.c: In the Key Found code, don't display the string in
|
|
||||||
the debug code since it doesn't exist anymore when we display it.
|
|
||||||
Doh!
|
|
||||||
|
|
||||||
2000-10-23 17:44 rjkaes
|
|
||||||
|
|
||||||
* src/tinyproxy.c: Added the initialization section for the DNS and
|
|
||||||
Anonymous sub systems.
|
|
||||||
|
|
||||||
2000-10-23 17:43 rjkaes
|
|
||||||
|
|
||||||
* src/: anonymous.c, anonymous.h: Added the new_anonymous
|
|
||||||
initialize routine
|
|
||||||
|
|
||||||
2000-10-23 17:42 rjkaes
|
|
||||||
|
|
||||||
* src/: dnscache.c, dnscache.h: Added the new_dnscache routine to
|
|
||||||
initialize the Ternary tree. Also, removed the garbage collection
|
|
||||||
routine.
|
|
||||||
|
|
||||||
2000-09-26 01:00 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated documentation.
|
|
||||||
|
|
||||||
2000-09-26 00:59 rjkaes
|
|
||||||
|
|
||||||
* src/dnscache.c: Fixed the insert function to handle a failed
|
|
||||||
insert properly.
|
|
||||||
|
|
||||||
2000-09-26 00:59 rjkaes
|
|
||||||
|
|
||||||
* src/: ternary.c, ternary.h: Added the TE_EXISTS return code, and
|
|
||||||
cleaned up the ternary_destroy function.
|
|
||||||
|
|
||||||
2000-09-26 00:58 rjkaes
|
|
||||||
|
|
||||||
* src/: tinyproxy.h, utils.h: Moved the safefree() macro to the
|
|
||||||
tinyproxy.h header.
|
|
||||||
|
|
||||||
2000-09-26 00:57 rjkaes
|
|
||||||
|
|
||||||
* src/: acl.c, reqs.c: Updated the free() calls to the safefree()
|
|
||||||
calls.
|
|
||||||
|
|
||||||
2000-09-21 12:58 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated documentation.
|
|
||||||
|
|
||||||
2000-09-21 12:57 rjkaes
|
|
||||||
|
|
||||||
* src/tinyproxy.c: There is no LOG_EMERG level, so changed to
|
|
||||||
LOG_CRIT.
|
|
||||||
|
|
||||||
2000-09-21 12:53 rjkaes
|
|
||||||
|
|
||||||
* src/: log.c, log.h: Added the LOG_NOTICE level.
|
|
||||||
|
|
||||||
2000-09-15 16:58 rjkaes
|
|
||||||
|
|
||||||
* src/: grammar.c, grammar.h, scanner.c: These are generated by
|
|
||||||
grammar.y and scanner.l respectively, don't include them in the
|
|
||||||
CVS.
|
|
||||||
|
|
||||||
2000-09-15 16:57 rjkaes
|
|
||||||
|
|
||||||
* src/stamp-h.in: Automatically generated file.
|
|
||||||
|
|
||||||
2000-09-15 16:55 rjkaes
|
|
||||||
|
|
||||||
* src/Makefile.in, doc/Makefile.in: Don't include automatically
|
|
||||||
generated files.
|
|
||||||
|
|
||||||
2000-09-15 16:53 rjkaes
|
|
||||||
|
|
||||||
* install-sh, missing, mkinstalldirs: Don't included automatically
|
|
||||||
generated files.
|
|
||||||
|
|
||||||
2000-09-15 16:52 rjkaes
|
|
||||||
|
|
||||||
* Makefile.in, config.guess, config.sub, configure: Flipping again.
|
|
||||||
:) Don't include any of the automatically generated stuff.
|
|
||||||
|
|
||||||
2000-09-14 12:41 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog, configure.in, src/tinyproxy.h: Need to do a check for
|
|
||||||
the <stdint.h> header since it's not a standard header available on
|
|
||||||
all systems.
|
|
||||||
|
|
||||||
2000-09-12 14:10 rjkaes
|
|
||||||
|
|
||||||
* Makefile.in, doc/Makefile.in, src/Makefile.in: Again, needed for
|
|
||||||
configure script. Automatically built by ./reconf
|
|
||||||
|
|
||||||
2000-09-11 20:45 rjkaes
|
|
||||||
|
|
||||||
* config.guess, config.sub: Needed for running configure.
|
|
||||||
Automatically built with reconf
|
|
||||||
|
|
||||||
2000-09-11 20:43 rjkaes
|
|
||||||
|
|
||||||
* configure: Can be made from configure.in (and should be), but I
|
|
||||||
want to be able to check out the source and immediately configure
|
|
||||||
it.
|
|
||||||
|
|
||||||
2000-09-11 20:22 rjkaes
|
|
||||||
|
|
||||||
* doc/tinyproxy.conf: Example tinyproxy configuration file.
|
|
||||||
|
|
||||||
2000-09-11 20:21 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: We all know what this is. :)
|
|
||||||
|
|
||||||
2000-09-11 20:20 rjkaes
|
|
||||||
|
|
||||||
* acinclude.m4: A M4 macro for finding the various types on the
|
|
||||||
system (typedefs, etc.)
|
|
||||||
|
|
||||||
2000-09-11 20:18 rjkaes
|
|
||||||
|
|
||||||
* Makefile.am, acconfig.h, configure.in: New defaults, and better
|
|
||||||
checking for various features needed by tinyproxy. Looks like fun!
|
|
||||||
:)
|
|
||||||
|
|
||||||
2000-09-11 20:16 rjkaes
|
|
||||||
|
|
||||||
* AUTHORS, BUGS, INSTALL, README, THANKS: Just updating the
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
2000-09-11 20:12 rjkaes
|
|
||||||
|
|
||||||
* src/: grammar.c, grammar.h, grammar.y, scanner.c, scanner.l:
|
|
||||||
These all handle reading the tinyproxy configuration file.
|
|
||||||
|
|
||||||
2000-09-11 20:10 rjkaes
|
|
||||||
|
|
||||||
* src/: ternary.c, ternary.h: Generalized the ternary code which
|
|
||||||
was already being used in anonymous.* now it can be used (and is
|
|
||||||
used) in both anonymous and dnscache
|
|
||||||
|
|
||||||
2000-09-11 20:08 rjkaes
|
|
||||||
|
|
||||||
* src/: acl.c, acl.h: Improved access control semantics. Allows
|
|
||||||
for a finger control for allowing and denying hosts.
|
|
||||||
|
|
||||||
2000-09-11 20:07 rjkaes
|
|
||||||
|
|
||||||
* src/: thread.c, thread.h: tinyproxy now uses a pool of threads to
|
|
||||||
handle connections. All the work for creating new threads, deleting
|
|
||||||
old thread, and generally managing the pool is done here.
|
|
||||||
|
|
||||||
2000-09-11 20:06 rjkaes
|
|
||||||
|
|
||||||
* src/: stats.c, stats.h: This module handles the various stats
|
|
||||||
relating to tinyproxy's functionality.
|
|
||||||
|
|
||||||
2000-09-11 20:04 rjkaes
|
|
||||||
|
|
||||||
* src/: reqs.c, reqs.h: MAJOR RE-WRITE! Read the ChangeLog and look
|
|
||||||
at the source. It's shorter than re-documenting the changes here. :)
|
|
||||||
|
|
||||||
2000-09-11 20:03 rjkaes
|
|
||||||
|
|
||||||
* src/: tinyproxy.c, tinyproxy.h: Fixed the change user/group
|
|
||||||
ability. Log when tinyproxy is using default values rather than
|
|
||||||
specific ones. Cleaned up the command line arguments since
|
|
||||||
tinyproxy now uses a configuration file. Removed the USR1 signal
|
|
||||||
and added the thread creation code.
|
|
||||||
|
|
||||||
2000-09-11 20:01 rjkaes
|
|
||||||
|
|
||||||
* src/: utils.c, utils.h: Removed the xmalloc() and xstrdup()
|
|
||||||
functions. Added the pidfile_create() function. Added the OpenBSD
|
|
||||||
style strlcat() and strlcpy() functions.
|
|
||||||
|
|
||||||
2000-09-11 19:57 rjkaes
|
|
||||||
|
|
||||||
* src/: uri.c, uri.h: Switched to the new logging style and
|
|
||||||
replaced the xmalloc() with straight malloc().
|
|
||||||
|
|
||||||
2000-09-11 19:56 rjkaes
|
|
||||||
|
|
||||||
* src/: sock.c, sock.h: Needed locking in getpeer_string(). Added
|
|
||||||
mutex locking around the dnscache() call. Removed the global
|
|
||||||
sockaddr and setup_fd variables. Added the socket_blocking() and
|
|
||||||
socket_nonblocking() functions. Gutted the readline() function and
|
|
||||||
replaced it with something similar to the 1.0 version. :)
|
|
||||||
|
|
||||||
2000-09-11 19:50 rjkaes
|
|
||||||
|
|
||||||
* src/regexp.h: Moved back to the <config.h> for autoconf defines.
|
|
||||||
|
|
||||||
2000-09-11 19:47 rjkaes
|
|
||||||
|
|
||||||
* src/: log.c, log.h: Cleaned up the logging format, and also
|
|
||||||
included logging levels (which are similar to the syslogd format.)
|
|
||||||
|
|
||||||
2000-09-11 19:46 rjkaes
|
|
||||||
|
|
||||||
* src/gnuregex.c: Not using <defines.h> for autoconf anymore, so
|
|
||||||
move back to the <config.h> format.
|
|
||||||
|
|
||||||
2000-09-11 19:43 rjkaes
|
|
||||||
|
|
||||||
* src/: filter.c, filter.h: Just using standard malloc() since the
|
|
||||||
xmalloc() didn't really add anything useful to the command.
|
|
||||||
|
|
||||||
2000-09-11 19:42 rjkaes
|
|
||||||
|
|
||||||
* src/: dnscache.c, dnscache.h: Removed the custom hash routines.
|
|
||||||
Using the ternary module instead.
|
|
||||||
|
|
||||||
2000-09-11 19:41 rjkaes
|
|
||||||
|
|
||||||
* src/: buffer.c, buffer.h: Cleaned up the source so that the
|
|
||||||
internal structure is no exposed by the buffer.h header.
|
|
||||||
|
|
||||||
2000-09-11 19:38 rjkaes
|
|
||||||
|
|
||||||
* src/: anonymous.c, anonymous.h: Removed the ternary tree code
|
|
||||||
from these files and made it a separate module.
|
|
||||||
|
|
||||||
2000-09-11 19:37 rjkaes
|
|
||||||
|
|
||||||
* src/Makefile.am: Modified to include all the files needed to
|
|
||||||
build tinyproxy, plus the special targets for building the LEX and
|
|
||||||
YACC files. (Also included the GNU license.)
|
|
||||||
|
|
||||||
2000-09-11 19:33 rjkaes
|
|
||||||
|
|
||||||
* doc/tinyproxy.8: Since the tinyproxy program has changed, the
|
|
||||||
manual had to change as well. Documents all the command line
|
|
||||||
arguments, though I think I need to document the configuration file
|
|
||||||
as well.
|
|
||||||
|
|
||||||
2000-09-11 19:32 rjkaes
|
|
||||||
|
|
||||||
* doc/: Makefile.am, TODO: Updated to reflect the new reality of
|
|
||||||
the tinyproxy source code.
|
|
||||||
|
|
||||||
2000-09-11 19:31 rjkaes
|
|
||||||
|
|
||||||
* doc/CONFIG: This was the layout for the purposed config file.
|
|
||||||
This is no more.
|
|
||||||
|
|
||||||
2000-09-11 19:27 rjkaes
|
|
||||||
|
|
||||||
* INSTALL.configure: This was the generic INSTALL file, but the
|
|
||||||
INSTALL file itself is again the generic file. :)
|
|
||||||
|
|
||||||
2000-09-11 19:24 rjkaes
|
|
||||||
|
|
||||||
* src/: config.h, conns.c, conns.h: These files are no longer used
|
|
||||||
within tinyproxy.
|
|
||||||
|
|
||||||
2000-06-06 13:58 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Reflect changes made in source.
|
|
||||||
|
|
||||||
2000-06-06 13:56 rjkaes
|
|
||||||
|
|
||||||
* doc/tinyproxy.8: Fixed the links for finding tinyproxy. Thanks to
|
|
||||||
Simon Baker for pointing this out.
|
|
||||||
|
|
||||||
2000-04-26 12:31 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog, src/dnscache.c, src/uri.c: Reorganized (or added) the
|
|
||||||
#include <sys/types.h> line so tinyproxy would compile cleanly on
|
|
||||||
FreeBSD systems.
|
|
||||||
|
|
||||||
2000-03-31 17:55 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog, src/reqs.c: Fixed a bug with the path in clientreq. If
|
|
||||||
the path was empty it caused a malformed request to be sent.
|
|
||||||
|
|
||||||
2000-03-31 15:15 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: A whole whack of changes and bug fixes.
|
|
||||||
|
|
||||||
2000-03-31 15:14 rjkaes
|
|
||||||
|
|
||||||
* src/Makefile.am: Added a line for the anonymous.* files.
|
|
||||||
|
|
||||||
2000-03-31 15:14 rjkaes
|
|
||||||
|
|
||||||
* src/config.h: Changed the socket time out to 10 secs.
|
|
||||||
|
|
||||||
2000-03-31 15:13 rjkaes
|
|
||||||
|
|
||||||
* src/reqs.c: Updated the anonheader function to use the new
|
|
||||||
anonymous API. Removed the hack for the POST method in clientreq.
|
|
||||||
|
|
||||||
2000-03-31 15:10 rjkaes
|
|
||||||
|
|
||||||
* src/sock.c: Completely rewrote the readline function.
|
|
||||||
|
|
||||||
2000-03-31 15:09 rjkaes
|
|
||||||
|
|
||||||
* src/: buffer.c, buffer.h: Added the working_* fields as a scratch
|
|
||||||
pad for readline().
|
|
||||||
|
|
||||||
2000-03-31 15:08 rjkaes
|
|
||||||
|
|
||||||
* src/: tinyproxy.c, tinyproxy.h: Removed the allowedhdr_s
|
|
||||||
structure since it is now accessed through anonymous.*
|
|
||||||
|
|
||||||
2000-03-31 14:56 rjkaes
|
|
||||||
|
|
||||||
* src/: anonymous.c, anonymous.h: Moved the anonymous header code
|
|
||||||
into it's own file to make it easier to update.
|
|
||||||
|
|
||||||
2000-03-29 11:19 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated to list changes in src/reqs.c and
|
|
||||||
src/dnscache.c
|
|
||||||
|
|
||||||
2000-03-29 11:18 rjkaes
|
|
||||||
|
|
||||||
* src/dnscache.c: Included the <sys/types.h> header.
|
|
||||||
|
|
||||||
2000-03-29 11:17 rjkaes
|
|
||||||
|
|
||||||
* src/reqs.c: Fixed a bug with the clientreq function which was
|
|
||||||
incorrectly setting the clientheader flag and causing _all_ headers
|
|
||||||
to be sent even in anonymous mode.
|
|
||||||
|
|
||||||
2000-03-28 11:44 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated ChangeLog entry for new fix.
|
|
||||||
|
|
||||||
2000-03-28 11:41 rjkaes
|
|
||||||
|
|
||||||
* src/reqs.c: Fixed another NULL bug with the uri->authority. If an
|
|
||||||
badly formed request was made in the form of
|
|
||||||
http:\\www.somewhere.com/ tinyproxy would SEGV. This has been
|
|
||||||
corrected.
|
|
||||||
|
|
||||||
2000-03-28 11:21 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: Updated to reflect changes in src/reqs.c
|
|
||||||
|
|
||||||
2000-03-28 11:19 rjkaes
|
|
||||||
|
|
||||||
* src/reqs.c: Fixed a NULL pointer bug in clientreq. If the SCHEME
|
|
||||||
in the URL was NULL the program would SEGV. This was caused by the
|
|
||||||
error logging code.
|
|
||||||
|
|
||||||
2000-03-12 19:56 rjkaes
|
|
||||||
|
|
||||||
* src/config.h: Remove the defines for DEFAULT_* and UPSTREAM
|
|
||||||
(they've been moved into acconfig.h and configure).
|
|
||||||
|
|
||||||
2000-03-12 19:55 rjkaes
|
|
||||||
|
|
||||||
* ChangeLog: List all the changes which has occurred on the program.
|
|
||||||
|
|
||||||
2000-03-11 15:43 rjkaes
|
|
||||||
|
|
||||||
* acconfig.h: Added the support for the upstream proxy and also
|
|
||||||
made the defaults for the LOGFILE, USER, and PORT.
|
|
||||||
|
|
||||||
2000-03-11 15:37 rjkaes
|
|
||||||
|
|
||||||
* src/: dnscache.c, reqs.c, tinyproxy.c, tinyproxy.h: Included the
|
|
||||||
changes needed to re-add the upstream proxy option.
|
|
||||||
|
|
||||||
2000-03-11 15:36 rjkaes
|
|
||||||
|
|
||||||
* doc/tinyproxy.8: Updated the manual to reflect all the options,
|
|
||||||
plus provide additional information concerning the changes made to
|
|
||||||
some of the options.
|
|
||||||
|
|
||||||
2000-03-11 15:35 rjkaes
|
|
||||||
|
|
||||||
* configure.in: Re-ordered some of the arguments. Included the
|
|
||||||
support for the Upstream Proxy.
|
|
||||||
|
|
||||||
2000-03-11 15:34 rjkaes
|
|
||||||
|
|
||||||
* src/: Makefile.in, defines.h.in: Once again, these files are made
|
|
||||||
automatically, don't include them.
|
|
||||||
|
|
||||||
2000-03-11 15:33 rjkaes
|
|
||||||
|
|
||||||
* doc/Makefile.in: Again, the file is generated automatically, so
|
|
||||||
don't include it.
|
|
||||||
|
|
||||||
2000-03-11 15:32 rjkaes
|
|
||||||
|
|
||||||
* Makefile.in, aclocal.m4, configure: These files are generated by
|
|
||||||
reconf, so don't include them in the CVS.
|
|
||||||
|
|
||||||
2000-02-16 12:32 sdyoung
|
|
||||||
|
|
||||||
* AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am, Makefile.in,
|
|
||||||
NEWS, README, THANKS, aclocal.m4, BUGS, INSTALL.configure,
|
|
||||||
acconfig.h, configure, configure.in, install-sh, missing,
|
|
||||||
mkinstalldirs, reconf, src/Makefile.am, src/Makefile.in,
|
|
||||||
src/defines.h.in, src/stamp-h.in, src/filter.c, src/buffer.c,
|
|
||||||
src/buffer.h, src/config.h, src/conns.c, src/conns.h,
|
|
||||||
src/dnscache.c, src/dnscache.h, src/gnuregex.c, src/log.c,
|
|
||||||
src/log.h, src/reqs.c, src/reqs.h, src/sock.c, src/sock.h,
|
|
||||||
src/tinyproxy.c, src/tinyproxy.h, src/uri.c, doc/Makefile.am,
|
|
||||||
doc/Makefile.in, doc/TODO, src/filter.h, src/gnuregex.h,
|
|
||||||
src/regexp.h, src/uri.h, src/utils.c, src/utils.h, doc/CONFIG,
|
|
||||||
doc/HTTP_ERROR_CODES, doc/RFC_INFO, doc/report.sh, doc/tinyproxy.8:
|
|
||||||
Initial revision
|
|
||||||
|
|
||||||
2000-02-16 12:32 sdyoung
|
|
||||||
|
|
||||||
* AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am, Makefile.in,
|
|
||||||
NEWS, README, THANKS, aclocal.m4, BUGS, INSTALL.configure,
|
|
||||||
acconfig.h, configure, configure.in, install-sh, missing,
|
|
||||||
mkinstalldirs, reconf, src/Makefile.am, src/Makefile.in,
|
|
||||||
src/defines.h.in, src/stamp-h.in, src/filter.c, src/buffer.c,
|
|
||||||
src/buffer.h, src/config.h, src/conns.c, src/conns.h,
|
|
||||||
src/dnscache.c, src/dnscache.h, src/gnuregex.c, src/log.c,
|
|
||||||
src/log.h, src/reqs.c, src/reqs.h, src/sock.c, src/sock.h,
|
|
||||||
src/tinyproxy.c, src/tinyproxy.h, src/uri.c, doc/Makefile.am,
|
|
||||||
doc/Makefile.in, doc/TODO, src/filter.h, src/gnuregex.h,
|
|
||||||
src/regexp.h, src/uri.h, src/utils.c, src/utils.h, doc/CONFIG,
|
|
||||||
doc/HTTP_ERROR_CODES, doc/RFC_INFO, doc/report.sh, doc/tinyproxy.8:
|
|
||||||
Initial CVS checking of tinyproxy - version 1.3.2.
|
|
||||||
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
Basic Installation
|
|
||||||
==================
|
|
||||||
|
|
||||||
These are generic installation instructions.
|
|
||||||
|
|
||||||
The `configure' shell script attempts to guess correct values for
|
|
||||||
various system-dependent variables used during compilation. It uses
|
|
||||||
those values to create a `Makefile' in each directory of the package.
|
|
||||||
It may also create one or more `.h' files containing system-dependent
|
|
||||||
definitions. Finally, it creates a shell script `config.status' that
|
|
||||||
you can run in the future to recreate the current configuration, a file
|
|
||||||
`config.cache' that saves the results of its tests to speed up
|
|
||||||
reconfiguring, and a file `config.log' containing compiler output
|
|
||||||
(useful mainly for debugging `configure').
|
|
||||||
|
|
||||||
If you need to do unusual things to compile the package, please try
|
|
||||||
to figure out how `configure' could check whether to do them, and mail
|
|
||||||
diffs or instructions to the address given in the `README' so they can
|
|
||||||
be considered for the next release. If at some point `config.cache'
|
|
||||||
contains results you don't want to keep, you may remove or edit it.
|
|
||||||
|
|
||||||
The file `configure.in' is used to create `configure' by a program
|
|
||||||
called `autoconf'. You only need `configure.in' if you want to change
|
|
||||||
it or regenerate `configure' using a newer version of `autoconf'.
|
|
||||||
|
|
||||||
The simplest way to compile this package is:
|
|
||||||
|
|
||||||
1. `cd' to the directory containing the package's source code and type
|
|
||||||
`./configure' to configure the package for your system. If you're
|
|
||||||
using `csh' on an old version of System V, you might need to type
|
|
||||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
|
||||||
`configure' itself.
|
|
||||||
|
|
||||||
Running `configure' takes awhile. While running, it prints some
|
|
||||||
messages telling which features it is checking for.
|
|
||||||
|
|
||||||
2. Type `make' to compile the package.
|
|
||||||
|
|
||||||
3. Optionally, type `make check' to run any self-tests that come with
|
|
||||||
the package.
|
|
||||||
|
|
||||||
4. Type `make install' to install the programs and any data files and
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
5. You can remove the program binaries and object files from the
|
|
||||||
source code directory by typing `make clean'. To also remove the
|
|
||||||
files that `configure' created (so you can compile the package for
|
|
||||||
a different kind of computer), type `make distclean'. There is
|
|
||||||
also a `make maintainer-clean' target, but that is intended mainly
|
|
||||||
for the package's developers. If you use it, you may have to get
|
|
||||||
all sorts of other programs in order to regenerate files that came
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
Compilers and Options
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Some systems require unusual options for compilation or linking that
|
|
||||||
the `configure' script does not know about. You can give `configure'
|
|
||||||
initial values for variables by setting them in the environment. Using
|
|
||||||
a Bourne-compatible shell, you can do that on the command line like
|
|
||||||
this:
|
|
||||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
|
||||||
|
|
||||||
Or on systems that have the `env' program, you can do it like this:
|
|
||||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
|
||||||
|
|
||||||
Compiling For Multiple Architectures
|
|
||||||
====================================
|
|
||||||
|
|
||||||
You can compile the package for more than one kind of computer at the
|
|
||||||
same time, by placing the object files for each architecture in their
|
|
||||||
own directory. To do this, you must use a version of `make' that
|
|
||||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
|
||||||
directory where you want the object files and executables to go and run
|
|
||||||
the `configure' script. `configure' automatically checks for the
|
|
||||||
source code in the directory that `configure' is in and in `..'.
|
|
||||||
|
|
||||||
If you have to use a `make' that does not supports the `VPATH'
|
|
||||||
variable, you have to compile the package for one architecture at a time
|
|
||||||
in the source code directory. After you have installed the package for
|
|
||||||
one architecture, use `make distclean' before reconfiguring for another
|
|
||||||
architecture.
|
|
||||||
|
|
||||||
Installation Names
|
|
||||||
==================
|
|
||||||
|
|
||||||
By default, `make install' will install the package's files in
|
|
||||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
|
||||||
installation prefix other than `/usr/local' by giving `configure' the
|
|
||||||
option `--prefix=PATH'.
|
|
||||||
|
|
||||||
You can specify separate installation prefixes for
|
|
||||||
architecture-specific files and architecture-independent files. If you
|
|
||||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
|
||||||
PATH as the prefix for installing programs and libraries.
|
|
||||||
Documentation and other data files will still use the regular prefix.
|
|
||||||
|
|
||||||
In addition, if you use an unusual directory layout you can give
|
|
||||||
options like `--bindir=PATH' to specify different values for particular
|
|
||||||
kinds of files. Run `configure --help' for a list of the directories
|
|
||||||
you can set and what kinds of files go in them.
|
|
||||||
|
|
||||||
If the package supports it, you can cause programs to be installed
|
|
||||||
with an extra prefix or suffix on their names by giving `configure' the
|
|
||||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
|
||||||
|
|
||||||
Optional Features
|
|
||||||
=================
|
|
||||||
|
|
||||||
Some packages pay attention to `--enable-FEATURE' options to
|
|
||||||
`configure', where FEATURE indicates an optional part of the package.
|
|
||||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
|
||||||
is something like `gnu-as' or `x' (for the X Window System). The
|
|
||||||
`README' should mention any `--enable-' and `--with-' options that the
|
|
||||||
package recognizes.
|
|
||||||
|
|
||||||
For packages that use the X Window System, `configure' can usually
|
|
||||||
find the X include and library files automatically, but if it doesn't,
|
|
||||||
you can use the `configure' options `--x-includes=DIR' and
|
|
||||||
`--x-libraries=DIR' to specify their locations.
|
|
||||||
|
|
||||||
Specifying the System Type
|
|
||||||
==========================
|
|
||||||
|
|
||||||
There may be some features `configure' can not figure out
|
|
||||||
automatically, but needs to determine by the type of host the package
|
|
||||||
will run on. Usually `configure' can figure that out, but if it prints
|
|
||||||
a message saying it can not guess the host type, give it the
|
|
||||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
|
||||||
type, such as `sun4', or a canonical name with three fields:
|
|
||||||
CPU-COMPANY-SYSTEM
|
|
||||||
|
|
||||||
See the file `config.sub' for the possible values of each field. If
|
|
||||||
`config.sub' isn't included in this package, then this package doesn't
|
|
||||||
need to know the host type.
|
|
||||||
|
|
||||||
If you are building compiler tools for cross-compiling, you can also
|
|
||||||
use the `--target=TYPE' option to select the type of system they will
|
|
||||||
produce code for and the `--build=TYPE' option to select the type of
|
|
||||||
system on which you are compiling the package.
|
|
||||||
|
|
||||||
Sharing Defaults
|
|
||||||
================
|
|
||||||
|
|
||||||
If you want to set default values for `configure' scripts to share,
|
|
||||||
you can create a site shell script called `config.site' that gives
|
|
||||||
default values for variables like `CC', `cache_file', and `prefix'.
|
|
||||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
|
||||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
|
||||||
`CONFIG_SITE' environment variable to the location of the site script.
|
|
||||||
A warning: not all `configure' scripts look for a site script.
|
|
||||||
|
|
||||||
Operation Controls
|
|
||||||
==================
|
|
||||||
|
|
||||||
`configure' recognizes the following options to control how it
|
|
||||||
operates.
|
|
||||||
|
|
||||||
`--cache-file=FILE'
|
|
||||||
Use and save the results of the tests in FILE instead of
|
|
||||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
|
||||||
debugging `configure'.
|
|
||||||
|
|
||||||
`--help'
|
|
||||||
Print a summary of the options to `configure', and exit.
|
|
||||||
|
|
||||||
`--quiet'
|
|
||||||
`--silent'
|
|
||||||
`-q'
|
|
||||||
Do not print messages saying which checks are being made. To
|
|
||||||
suppress all normal output, redirect it to `/dev/null' (any error
|
|
||||||
messages will still be shown).
|
|
||||||
|
|
||||||
`--srcdir=DIR'
|
|
||||||
Look for the package's source code in directory DIR. Usually
|
|
||||||
`configure' can determine that directory automatically.
|
|
||||||
|
|
||||||
`--version'
|
|
||||||
Print the version of Autoconf used to generate the `configure'
|
|
||||||
script, and exit.
|
|
||||||
|
|
||||||
`configure' also accepts some other, not widely useful, options.
|
|
||||||
+37
-2
@@ -1,2 +1,37 @@
|
|||||||
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4
|
SUBDIRS = \
|
||||||
SUBDIRS = src doc
|
src \
|
||||||
|
data \
|
||||||
|
etc \
|
||||||
|
docs \
|
||||||
|
m4macros \
|
||||||
|
tests \
|
||||||
|
scripts
|
||||||
|
|
||||||
|
# tools want this on a single line
|
||||||
|
ACLOCAL_AMFLAGS = -I m4macros
|
||||||
|
|
||||||
|
all-local:
|
||||||
|
|
||||||
|
dist_doc_DATA = \
|
||||||
|
AUTHORS \
|
||||||
|
NEWS \
|
||||||
|
README \
|
||||||
|
README.md
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
autogen.sh \
|
||||||
|
tinyproxy-indent.sh \
|
||||||
|
TODO \
|
||||||
|
VERSION
|
||||||
|
|
||||||
|
test: all
|
||||||
|
./tests/scripts/run_tests.sh
|
||||||
|
|
||||||
|
test-wait:
|
||||||
|
TINYPROXY_TESTS_WAIT=yes $(MAKE) test
|
||||||
|
|
||||||
|
valgrind-test: all
|
||||||
|
./tests/scripts/run_tests_valgrind.sh
|
||||||
|
|
||||||
|
valgrind-test-wait:
|
||||||
|
TINYPROXY_TESTS_WAIT=yes $(MAKE) valgrind-test
|
||||||
@@ -1,25 +1 @@
|
|||||||
|
See git log for recent changes in Tinyproxy.
|
||||||
NEWS
|
|
||||||
====
|
|
||||||
|
|
||||||
Well so much for the 1.4.0 version being the best tinyproxy---there
|
|
||||||
were bugs. The most serious was a segmentation fault problem when an
|
|
||||||
invalid request was received. Also, anonymous filtering was not
|
|
||||||
actually working. Another bug fix is that on Debian systems (and maybe
|
|
||||||
others) child threads would not be closed if they had been created
|
|
||||||
after tinyproxy had been started. Finally, if MaxClientRequests was
|
|
||||||
set to 0, the status of the thread was not going back to T_WAITING.
|
|
||||||
|
|
||||||
Okay, now on to the new features. There is a new Connect log
|
|
||||||
level. This is basically "Info" without info's noise. Also, the error
|
|
||||||
reporting function sends back more HTTP headers, which should lead to
|
|
||||||
a more standards compliant proxy.
|
|
||||||
|
|
||||||
There are a couple of features which I'm working on for the next
|
|
||||||
release. There has been requests for logging on tunnelled
|
|
||||||
connections. Also, some people would like HTTP filtering on tunnelled
|
|
||||||
connections. Finally, I do have the information to include SSL
|
|
||||||
connections, so I will be including it in the next release.
|
|
||||||
|
|
||||||
So, the above bugs are fixed, hopefully there are no other ones. The
|
|
||||||
new features will be worked into the next few releases.
|
|
||||||
@@ -1,87 +1 @@
|
|||||||
|
see README.md
|
||||||
DESCRIPTION
|
|
||||||
-----------
|
|
||||||
|
|
||||||
tinyproxy is a small, efficient HTTP proxy daemon. tinyproxy is very
|
|
||||||
useful in a small network setting, where a larger proxy like Squid
|
|
||||||
would either be too resource intensive, or a security risk. One of
|
|
||||||
the key features of tinyproxy is the buffering connection concept.
|
|
||||||
In effect, tinyproxy will buffer a high speed response from a server,
|
|
||||||
and then relay it to a client at the highest speed the client will
|
|
||||||
accept. This feature greatly reduces the problems with sluggishness
|
|
||||||
on the Internet. If you are sharing an Internet connection with a
|
|
||||||
small network, and you only want to allow HTTP requests to be
|
|
||||||
allowed, then tinyproxy is a great tool for the network
|
|
||||||
administrator.
|
|
||||||
|
|
||||||
|
|
||||||
INSTALLATION
|
|
||||||
------------
|
|
||||||
|
|
||||||
To install this package under a Unix derivative, read the INSTALL
|
|
||||||
file. tinyproxy uses a standard GNU configure script. There are
|
|
||||||
additional command line arguments you can supply to configure. They
|
|
||||||
include:
|
|
||||||
|
|
||||||
--enable-debug If you would like to turn on full
|
|
||||||
debugging support
|
|
||||||
--enable-socks This turns on SOCKS support for using
|
|
||||||
tinyproxy across a fire wall.
|
|
||||||
--enable-xtinyproxy Compile in support for the XTinyproxy
|
|
||||||
header, which is sent to any web
|
|
||||||
server in your domain.
|
|
||||||
--enable-filter Allows tinyproxy to filter out certain
|
|
||||||
domains and URLs.
|
|
||||||
--enable-tunnel Provides the option of having
|
|
||||||
tinyproxy act as TCP tunnel, rather
|
|
||||||
than a HTTP proxy.
|
|
||||||
|
|
||||||
Options for file locations etc.
|
|
||||||
--with-stathost=HOST Set the default name of the stats host
|
|
||||||
--with-config=FILE Set the default location of the
|
|
||||||
configuration file
|
|
||||||
|
|
||||||
Once you have completed your installation, if you would like to
|
|
||||||
report your success please execute the report.sh script in the doc
|
|
||||||
directory. This will send an email to the authors reporting your
|
|
||||||
version, and a few bits of information concerning the memory usage of
|
|
||||||
tinyproxy. Alternatively, you could just send an email stating the
|
|
||||||
version. Which ever you prefer.
|
|
||||||
|
|
||||||
|
|
||||||
SUPPORT
|
|
||||||
-------
|
|
||||||
|
|
||||||
If you are having problems with tinyproxy, please report the problem
|
|
||||||
to:
|
|
||||||
|
|
||||||
Robert James Kaes <rjkaes@users.sourceforge.net>
|
|
||||||
Steven Young <sdyoung@users.sourceforge.net>
|
|
||||||
|
|
||||||
Please recompile tinyproxy with full debug support (--enable-debug)
|
|
||||||
and include a copy of the log file, and any assert errors reported by
|
|
||||||
tinyproxy. Also, if you feel up to it, try running tinyproxy under
|
|
||||||
your debugger and report the error your received and a context
|
|
||||||
listing of the location. Under gdb you would run tinyproxy like so:
|
|
||||||
|
|
||||||
gdb tinyproxy
|
|
||||||
|
|
||||||
(gdb) set args -c location_of_tinyproxy_conf -d
|
|
||||||
(gdb) run
|
|
||||||
|
|
||||||
Now access the port tinyproxy is on until you receive a break in the
|
|
||||||
gdb. You can now type:
|
|
||||||
|
|
||||||
(gbd) l
|
|
||||||
|
|
||||||
to produce a context listing of the location of the error. Send a
|
|
||||||
copy to the authors.
|
|
||||||
|
|
||||||
|
|
||||||
HOW TO CONTRIBUTE TO tinyproxy
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
If you would like to contribute a feature, or a bug fix to the
|
|
||||||
tinyproxy source, please send a diff (preferable a unified
|
|
||||||
diff. i.e. "diff -u") against the latest release of tinyproxy. Also,
|
|
||||||
if you could include a brief description of what your patch does.
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# Tinyproxy
|
||||||
|
|
||||||
|
Tinyproxy is a small, efficient HTTP/SSL proxy daemon released under the
|
||||||
|
GNU General Public License. Tinyproxy is very useful in a small network
|
||||||
|
setting, where a larger proxy would either be too resource intensive, or
|
||||||
|
a security risk. One of the key features of Tinyproxy is the buffering
|
||||||
|
connection concept. In effect, Tinyproxy will buffer a high speed
|
||||||
|
response from a server, and then relay it to a client at the highest
|
||||||
|
speed the client will accept. This feature greatly reduces the problems
|
||||||
|
with sluggishness on the Internet. If you are sharing an Internet
|
||||||
|
connection with a small network, and you only want to allow HTTP
|
||||||
|
requests to be allowed, then Tinyproxy is a great tool for the network
|
||||||
|
administrator.
|
||||||
|
|
||||||
|
For more info, please visit [the Tinyproxy web site](https://tinyproxy.github.io/).
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Tinyproxy uses a standard GNU `configure` script based on the automake
|
||||||
|
system. If compiling from a git checkout, you need to first run
|
||||||
|
|
||||||
|
```
|
||||||
|
./autogen.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
from the top level directory to generate the `configure` script.
|
||||||
|
The release tarball contains the pre-created `configure` script,
|
||||||
|
so when building from a release, you can skip this step.
|
||||||
|
Then basically all you need to do is
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
in the top level directory to compile and install Tinyproxy. There are
|
||||||
|
additional command line arguments you can supply to `configure`. They
|
||||||
|
include:
|
||||||
|
|
||||||
|
- `--enable-debug`:
|
||||||
|
If you would like to turn on full debugging support.
|
||||||
|
|
||||||
|
- `--enable-xtinyproxy`:
|
||||||
|
Compile in support for the XTinyproxy header, which is sent to any
|
||||||
|
web server in your domain.
|
||||||
|
|
||||||
|
- `--enable-filter`:
|
||||||
|
Allows Tinyproxy to filter out certain domains and URLs.
|
||||||
|
|
||||||
|
- `--enable-upstream`:
|
||||||
|
Enable support for proxying connections through another proxy server.
|
||||||
|
|
||||||
|
- `--enable-transparent`:
|
||||||
|
Allow Tinyproxy to be used as a transparent proxy daemon.
|
||||||
|
|
||||||
|
- `--enable-reverse`:
|
||||||
|
Enable reverse proxying.
|
||||||
|
|
||||||
|
- `--with-stathost=HOST`:
|
||||||
|
Set the default name of the stats host.
|
||||||
|
|
||||||
|
For more information about the build system, read the INSTALL file
|
||||||
|
that is generated by `autogen.sh` and comes with the release tar ball.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
|
||||||
|
If you are having problems with Tinyproxy, please raise an
|
||||||
|
[issue on github](https://github.com/tinyproxy/tinyproxy/issues).
|
||||||
|
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
If you would like to contribute a feature, or a bug fix to the Tinyproxy
|
||||||
|
source, please clone the
|
||||||
|
[git repository from github](https://github.com/tinyproxy/tinyproxy.git)
|
||||||
|
and create a [pull request](https://github.com/tinyproxy/tinyproxy/pulls).
|
||||||
|
|
||||||
|
|
||||||
|
## Community
|
||||||
|
|
||||||
|
You can meet developers and users to discuss development,
|
||||||
|
patches and deployment issues in the `#tinyproxy` IRC channel on
|
||||||
|
Freenode (`irc.freenode.net`).
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
Tinyproxy wouldn't be possible in its current form without the help of
|
|
||||||
the following people. Thanks a lot, guys (sorted in no particular
|
|
||||||
order). Note that in the case of entries listed under 'numerous others',
|
|
||||||
only the first person to report it is listed.
|
|
||||||
|
|
||||||
|
|
||||||
Steven Young - Wrote version 1.0 - 1.1
|
|
||||||
Robert James Kaes - Wrote versions from 1.2 to 1.3 and
|
|
||||||
autoconf enabled the source tree and
|
|
||||||
well just look at the ChangeLog for all
|
|
||||||
the rest. :)
|
|
||||||
Albert Ragnarsson - Made an RPM out of the 1.0d .tar.gz archive.
|
|
||||||
Alan W Black - Misc. bug reports and fixes.
|
|
||||||
Ed Boraas - Various suggestions, helped beta test 1.0d.
|
|
||||||
Abhijit Menon-Sen - Beta tested 1.1, numerous bugs fixed
|
|
||||||
and features improved. Also helped
|
|
||||||
establish world peace and eliminate
|
|
||||||
hunger and poverty. Generally
|
|
||||||
credited with the singlehanded
|
|
||||||
abolition of all crime and dishonesty.
|
|
||||||
Jay Kominek - Made the 1.1 DEB.
|
|
||||||
Eran Tromer - Provided webspace at attacca.com.
|
|
||||||
Bruno Viaris - Found and provided initial fix for
|
|
||||||
bug in the clientreq() routine when
|
|
||||||
dealing with broken requests from clients.
|
|
||||||
Alexander Loehr - Found and provided fix for a bug in
|
|
||||||
the listen_sock routine.
|
|
||||||
Bob Grabau - Added additional logging of URLs to
|
|
||||||
incoming connections.
|
|
||||||
Mitsuru Yoshida - Made the FreeBSD port
|
|
||||||
Ian Holsman - Suggested the selective listening option
|
|
||||||
Peter Meerwald - Portability suggests and improvements
|
|
||||||
Shaun Johnson - Fixed a problem with compiling with
|
|
||||||
syslog enabled on a SunOS box. Should
|
|
||||||
help other systems too.
|
|
||||||
Timothy E. Newsome - SOCKS firewall enabled tinyproxy
|
|
||||||
George Talusan - Bug testing
|
|
||||||
Chris Lightfoot - Provided patches to give tinyproxy adns
|
|
||||||
support.
|
|
||||||
Michael Pearson - Reported connptr bug with patch.
|
|
||||||
Raja Subramanian - Reported fd leak bug, with patch.
|
|
||||||
J.D. Bronson - Helped make version 1.4.0 release ready
|
|
||||||
Hans-Georg Bork - Fixed a problem with the thread_main()
|
|
||||||
function and added the LOG_CONN log level.
|
|
||||||
numerous others - Reported null requests bug.
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
TODO List
|
||||||
|
---------
|
||||||
|
|
||||||
|
The following are features that I would like to add to tinyproxy in the
|
||||||
|
future. Where possible, I've listed the person who suggested it. This
|
||||||
|
list is in no particular order. And hey, if you want to implement one of
|
||||||
|
these, or another idea you have, go right ahead. Just mail me the diff
|
||||||
|
against the current tree and I'll integrate it if possible.
|
||||||
|
|
||||||
|
[ Actually, the ordering has become kind of important as of
|
||||||
|
late. Basically, I'm adding new ideas to the bottom of the list
|
||||||
|
as I go. ]
|
||||||
|
|
||||||
|
* Include hooks so other types of proxies can be modularly added to
|
||||||
|
the source tree. Then people can simply choose which types of
|
||||||
|
proxies (ftp, www, etc) they'd like enabled in tinyproxy.h
|
||||||
|
Suggested: Tarun Tuli.
|
||||||
|
|
||||||
|
* Include a function to rewrite the incoming requests. Should not be
|
||||||
|
much of a problem. Just need to modify the process_method() code
|
||||||
|
to look up the URL and rewrite it. If we want to go really fancy
|
||||||
|
with RegEx mapping this could get ugly. :)
|
||||||
|
|
||||||
|
* Have the ability to send the data from the connections through an
|
||||||
|
external filtering program. I kind of like this idea, but I don't
|
||||||
|
really have a good way of doing it yet.
|
||||||
|
Suggested: Ed Avis
|
||||||
|
|
||||||
|
* Include the ability to rewrite both incoming and outgoing headers.
|
||||||
|
|
||||||
|
* Enable an option for chroot() jailing tinyproxy.
|
||||||
|
|
||||||
|
* Come up with a more consistent (and elegant) way of logging errors
|
||||||
|
for the administrators. Right now it's more a hodge-podge
|
||||||
|
collections of error messages without a _real_ standard. I would
|
||||||
|
prefer a more uniform look.
|
||||||
|
|
||||||
|
* Include user authentication for accessing tinyproxy itself.
|
||||||
|
Administrators should be allowed to selectively allow certain users
|
||||||
|
access to tinyproxy via a user name/password pair. Check the
|
||||||
|
HTTP/1.1 RFC for more information.
|
||||||
|
|
||||||
|
==> https://www.banu.com/bugzilla/show_bug.cgi?id=13
|
||||||
|
|
||||||
|
* Remove common.h and fix order of headers
|
||||||
|
|
||||||
|
* Remove memory debugging functions (Valgrind is good enough)
|
||||||
|
|
||||||
|
* Make all functions return from one place (the end of the function)
|
||||||
|
|
||||||
|
* Move TODO items to Banu Bugzilla
|
||||||
|
|
||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Define if you want to have the peer's IP address to be included in a
|
|
||||||
* XTinyproxy header sent to the server.
|
|
||||||
*/
|
|
||||||
#undef XTINYPROXY_ENABLE
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the default location of the configuration file
|
|
||||||
*/
|
|
||||||
#define DEFAULT_CONF_FILE "/etc/tinyproxy/tinyproxy.conf"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define if you would like to include filtering code.
|
|
||||||
*/
|
|
||||||
#undef FILTER_ENABLE
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define if you want to use the included GNU regex routine
|
|
||||||
*/
|
|
||||||
#undef USE_GNU_REGEX
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define if you want to include upstream proxy support
|
|
||||||
*/
|
|
||||||
#undef TUNNEL_SUPPORT
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: for DEFAULT_STATHOST: this controls remote proxy stats display.
|
|
||||||
* for example, the default DEFAULT_STATHOST of "tinyproxy.stats" will
|
|
||||||
* mean that when you use the proxy to access http://tinyproxy.stats/",
|
|
||||||
* you will be shown the proxy stats. Set this to something obscure
|
|
||||||
* if you don't want random people to be able to see them, or set it to
|
|
||||||
* "" to disable. In the future, I figure maybe some sort of auth
|
|
||||||
* might be desirable, but that would involve a major simplicity
|
|
||||||
* sacrifice.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* The "hostname" for getting tinyproxy stats. "" = disabled by default
|
|
||||||
*/
|
|
||||||
#define DEFAULT_STATHOST "tinyproxy.stats"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define the following for the appropriate datatype, if necessary
|
|
||||||
*/
|
|
||||||
#undef uint8_t
|
|
||||||
#undef int16_t
|
|
||||||
#undef uint16_t
|
|
||||||
#undef int32_t
|
|
||||||
#undef uint32_t
|
|
||||||
#undef in_addr_t
|
|
||||||
#undef size_t
|
|
||||||
#undef ssize_t
|
|
||||||
#undef socklen_t
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A string containing the name of the system tinyproxy was built towards.
|
|
||||||
*/
|
|
||||||
#undef TARGET_SYSTEM
|
|
||||||
-102
@@ -1,102 +0,0 @@
|
|||||||
dnl Taken from Unix Network Programming, W. Richard Stevens
|
|
||||||
|
|
||||||
dnl ##################################################################
|
|
||||||
dnl We cannot use the AC_CHECK_TYPE macros becasue AC_CHECK_TYPE
|
|
||||||
dnl #includes only <sys/types.h>, <stdlib.h>, and <stddef.h>.
|
|
||||||
dnl Unfortunately, many implementations today hide typedefs in wierd
|
|
||||||
dnl locations: Solaris 2.5.1 has uint8_t and uint32_t in <pthread.h>.
|
|
||||||
dnl SunOS 4.1.x has int8_t in <sys/bittypes.h>.
|
|
||||||
dnl So we define our own macro AC_UNP_CHECK_TYPE that does the same
|
|
||||||
dnl #includes as "unp.h", and then looks for the typedef.
|
|
||||||
dnl
|
|
||||||
dnl This macro should be invoked after all the header checks have been
|
|
||||||
dnl performed, since we #include "confdefs.h" below, and then use the
|
|
||||||
dnl HAVE_foo_H values that is can #define.
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_UNP_CHECK_TYPE,
|
|
||||||
[AC_MSG_CHECKING(if $1 defined)
|
|
||||||
AC_CACHE_VAL(ac_cv_type_$1,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[
|
|
||||||
#include "confdefs.h" /* the header built by configure so far */
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
# include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
# include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ERRNO_H
|
|
||||||
# include <errno.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_FCNTL_H
|
|
||||||
# include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETDB_H
|
|
||||||
# include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SIGNAL_H
|
|
||||||
# include <signal.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDIO_H
|
|
||||||
# include <stdio.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
# include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
# include <string.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
# include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UIO_H
|
|
||||||
# include <sys/uio.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_WAIT_H
|
|
||||||
# include <sys/wait.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
|
||||||
# include <sys/un.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SELECT_H
|
|
||||||
# include <sys/select.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRINGS_H
|
|
||||||
# include <strings.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
|
||||||
# include <sys/ioctl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_FILIO_H
|
|
||||||
# include <sys/filio.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_SOCKIO_H
|
|
||||||
# include <sys/sockio.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
# include <pthread.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
# include <stdint.h>
|
|
||||||
#endif
|
|
||||||
],
|
|
||||||
[ $1 foo ],
|
|
||||||
ac_cv_type_$1=yes,
|
|
||||||
ac_cv_type_$1=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_type_$1)
|
|
||||||
if test $ac_cv_type_$1 = no ; then
|
|
||||||
AC_DEFINE($1, $2)
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
srcdir=`dirname $0`
|
||||||
|
test -z "$srcdir" && srcdir=.
|
||||||
|
ORIGDIR=`pwd`
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
cd $srcdir
|
||||||
|
|
||||||
|
aclocal -I m4macros \
|
||||||
|
&& autoheader \
|
||||||
|
&& automake --gnu --add-missing \
|
||||||
|
&& autoconf
|
||||||
|
|
||||||
|
cd $ORIGDIR
|
||||||
|
|
||||||
|
set -
|
||||||
|
|
||||||
|
echo $srcdir/configure "$@"
|
||||||
|
$srcdir/configure "$@"
|
||||||
|
RC=$?
|
||||||
|
if test $RC -ne 0; then
|
||||||
|
echo
|
||||||
|
echo "Configure failed or did not finish!"
|
||||||
|
exit $RC
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Now type 'make' to compile Tinyproxy."
|
||||||
+233
@@ -0,0 +1,233 @@
|
|||||||
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
# Portions of this file were adapted from GIMP.
|
||||||
|
|
||||||
|
AC_PREREQ(2.54)
|
||||||
|
|
||||||
|
m4_define([tinyproxy_version], esyscmd(sh scripts/version.sh | tr -d '\n'))
|
||||||
|
|
||||||
|
AC_INIT([Tinyproxy], [tinyproxy_version],
|
||||||
|
[https://tinyproxy.github.io/],
|
||||||
|
[tinyproxy])
|
||||||
|
|
||||||
|
AC_CANONICAL_TARGET
|
||||||
|
AM_INIT_AUTOMAKE([dist-bzip2 dist-xz])
|
||||||
|
AC_CONFIG_HEADERS(config.h)
|
||||||
|
AC_CONFIG_MACRO_DIR([m4macros])
|
||||||
|
|
||||||
|
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||||
|
|
||||||
|
dnl Temporarily defined here until we get tinyproxy-version.h
|
||||||
|
AC_DEFINE(TINYPROXY_VERSION, "tinyproxy_version", [Tinyproxy version number])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Check if we're compiling on a weird platform :)
|
||||||
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
|
dnl Set the domain name for find the statistics of tinyproxy
|
||||||
|
AH_TEMPLATE([TINYPROXY_STATHOST],
|
||||||
|
[This controls remote proxy stats display.])
|
||||||
|
AC_ARG_WITH(stathost,
|
||||||
|
[AC_HELP_STRING([--with-stathost=HOST], [Default status host])],
|
||||||
|
[AC_DEFINE_UNQUOTED(TINYPROXY_STATHOST, "$withval")
|
||||||
|
TINYPROXY_STATHOST="$withval"],
|
||||||
|
[AC_DEFINE_UNQUOTED(TINYPROXY_STATHOST, "tinyproxy.stats")
|
||||||
|
TINYPROXY_STATHOST="tinyproxy.stats"])
|
||||||
|
|
||||||
|
AC_SUBST(TINYPROXY_STATHOST)
|
||||||
|
|
||||||
|
dnl Add compiler-specific optimization flags
|
||||||
|
TP_ARG_ENABLE(debug,
|
||||||
|
[Enable debugging support code and methods (default is NO)],
|
||||||
|
no)
|
||||||
|
|
||||||
|
dnl Check to see if the XTinyproxy header is to be included
|
||||||
|
AH_TEMPLATE([XTINYPROXY_ENABLE],
|
||||||
|
[Define if you want to have the peer's IP address included in a XTinyproxy header sent to the server.])
|
||||||
|
TP_ARG_ENABLE(xtinyproxy,
|
||||||
|
[Include the X-Tinyproxy header (default is YES)],
|
||||||
|
yes)
|
||||||
|
|
||||||
|
if test x"$xtinyproxy_enabled" = x"yes"; then
|
||||||
|
AC_DEFINE(XTINYPROXY_ENABLE)
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Include filtering for domain/URLs
|
||||||
|
AH_TEMPLATE([FILTER_ENABLE],
|
||||||
|
[Defined if you would like filtering code included.])
|
||||||
|
TP_ARG_ENABLE(filter,
|
||||||
|
[Enable filtering of domains/URLS (default is YES)],
|
||||||
|
yes)
|
||||||
|
|
||||||
|
if test x"$filter_enabled" = x"yes"; then
|
||||||
|
ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS filter.o"
|
||||||
|
AC_DEFINE(FILTER_ENABLE)
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Include support for upstream proxies?
|
||||||
|
AH_TEMPLATE([UPSTREAM_SUPPORT],
|
||||||
|
[Include support for connecting to an upstream proxy.])
|
||||||
|
TP_ARG_ENABLE(upstream,
|
||||||
|
[Enable upstream proxying (default is YES)],
|
||||||
|
yes)
|
||||||
|
if test x"$upstream_enabled" = x"yes"; then
|
||||||
|
AC_DEFINE(UPSTREAM_SUPPORT)
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Include support for reverse proxy?
|
||||||
|
AH_TEMPLATE([REVERSE_SUPPORT],
|
||||||
|
[Include support for reverse proxy.])
|
||||||
|
TP_ARG_ENABLE(reverse,
|
||||||
|
[Enable reverse proxying (default is YES)],
|
||||||
|
yes)
|
||||||
|
if test x"$reverse_enabled" = x"yes"; then
|
||||||
|
ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS reverse-proxy.o"
|
||||||
|
AC_DEFINE(REVERSE_SUPPORT)
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Include the transparent proxy support
|
||||||
|
AH_TEMPLATE([TRANSPARENT_PROXY],
|
||||||
|
[Include support for using tinyproxy as a transparent proxy.])
|
||||||
|
TP_ARG_ENABLE(transparent,
|
||||||
|
[Enable transparent proxying code (default is YES)],
|
||||||
|
yes)
|
||||||
|
if test x"$transparent_enabled" = x"yes"; then
|
||||||
|
ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS transparent-proxy.o"
|
||||||
|
AC_DEFINE(TRANSPARENT_PROXY)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This is required to build test programs below
|
||||||
|
AC_PROG_CC
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for libraries
|
||||||
|
dnl
|
||||||
|
AC_CHECK_LIB(socket, socket, , [AC_CHECK_LIB(socket, htonl)])
|
||||||
|
|
||||||
|
dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to
|
||||||
|
dnl avoid -lnsl checks, if we already have the functions which are
|
||||||
|
dnl usually in libnsl
|
||||||
|
|
||||||
|
unset ac_cv_func_yp_get_default_domain
|
||||||
|
AC_CHECK_FUNC(yp_get_default_domain,
|
||||||
|
tinyproxy_no_nsl_checks=yes,
|
||||||
|
tinyproxy_no_nsl_checks=no)
|
||||||
|
unset ac_cv_func_yp_get_default_domain
|
||||||
|
|
||||||
|
if test x"$tinyproxy_no_nsl_checks" != x"yes"; then
|
||||||
|
AC_CHECK_LIB(nsl, gethostname, , [AC_CHECK_LIB(nsl, gethostbyaddr)])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_LIB(resolv, inet_aton)
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Checks for headers
|
||||||
|
dnl
|
||||||
|
AC_HEADER_STDC
|
||||||
|
AC_HEADER_TIME
|
||||||
|
AC_HEADER_SYS_WAIT
|
||||||
|
AC_CHECK_HEADERS([sys/ioctl.h alloca.h memory.h malloc.h sysexits.h \
|
||||||
|
values.h])
|
||||||
|
|
||||||
|
dnl Checks for libary functions
|
||||||
|
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||||
|
AC_FUNC_MALLOC
|
||||||
|
AC_FUNC_REALLOC
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS([inet_ntoa strdup])
|
||||||
|
AC_CHECK_FUNCS([strlcpy strlcat setgroups])
|
||||||
|
|
||||||
|
dnl Enable extra warnings
|
||||||
|
DESIRED_FLAGS="-fdiagnostics-show-option -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wfloat-equal -Wundef -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Waggregate-return -Winit-self -Wpacked --std=c89 -ansi -Wno-overlength-strings -Wno-long-long -Wno-overlength-strings -Wdeclaration-after-statement -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-qual -Wcast-align -Wwrite-strings -Wp,-D_FORTIFY_SOURCE=2 -fno-common"
|
||||||
|
|
||||||
|
if test -n "${MAINTAINER_MODE_FALSE}"; then
|
||||||
|
DESIRED_FLAGS="-Werror $DESIRED_FLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for flag in $DESIRED_FLAGS; do
|
||||||
|
AS_COMPILER_FLAG([$flag], [CFLAGS="$CFLAGS $flag"])
|
||||||
|
done
|
||||||
|
|
||||||
|
dnl Disable debugging if it's not specified
|
||||||
|
if test x"$debug_enabled" != x"yes" ; then
|
||||||
|
CFLAGS="-DNDEBUG $CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AS_ECHO_N(["checking to see if linker understands -z,defs... "])
|
||||||
|
LDFLAGS_OLD="-Wl $LDFLAGS"
|
||||||
|
LDFLAGS="-Wl,-z,defs $LDFLAGS"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
|
||||||
|
AS_ECHO("yes"),
|
||||||
|
AS_ECHO("no"); LDFLAGS="$LDFLAGS_OLD")
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Make sure we can actually handle the "--with-*" and "--enable-*" stuff.
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Substitute the variables into the various Makefiles
|
||||||
|
dnl
|
||||||
|
AC_SUBST(CFLAGS)
|
||||||
|
AC_SUBST(LDFLAGS)
|
||||||
|
AC_SUBST(CPPFLAGS)
|
||||||
|
AC_SUBST(LIBS)
|
||||||
|
AC_SUBST(ADDITIONAL_OBJECTS)
|
||||||
|
|
||||||
|
# Check for xml tools
|
||||||
|
AC_PATH_PROG(XSLTPROC, xsltproc, no)
|
||||||
|
AM_CONDITIONAL(HAVE_XSLTPROC, test "x$XSLTPROC" != "xno")
|
||||||
|
|
||||||
|
# Check for asciidoc
|
||||||
|
AC_PATH_PROG(A2X, a2x, no)
|
||||||
|
AM_CONDITIONAL(HAVE_A2X, test "x$A2X" != "xno")
|
||||||
|
|
||||||
|
# checking xmllint
|
||||||
|
AC_PATH_PROG(XMLLINT, xmllint, no)
|
||||||
|
if test "x$XMLLINT" != "xno"; then
|
||||||
|
AS_ECHO_N("testing xmllint... ")
|
||||||
|
echo "TEST" > conftest.txt
|
||||||
|
if $A2X -f docbook conftest.txt 2>/dev/null; then
|
||||||
|
AS_ECHO("ok")
|
||||||
|
else
|
||||||
|
AS_ECHO("failed")
|
||||||
|
XMLLINT="no"
|
||||||
|
fi
|
||||||
|
rm -f conftest.txt conftest.xml
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(HAVE_XMLLINT, test "x$XMLLINT" != "xno")
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([
|
||||||
|
Makefile
|
||||||
|
src/Makefile
|
||||||
|
data/Makefile
|
||||||
|
data/templates/Makefile
|
||||||
|
etc/Makefile
|
||||||
|
docs/Makefile
|
||||||
|
docs/man5/Makefile
|
||||||
|
docs/man5/tinyproxy.conf.txt
|
||||||
|
docs/man8/Makefile
|
||||||
|
docs/man8/tinyproxy.txt
|
||||||
|
m4macros/Makefile
|
||||||
|
tests/Makefile
|
||||||
|
tests/scripts/Makefile
|
||||||
|
scripts/Makefile
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_OUTPUT
|
||||||
|
|
||||||
|
# the manpages are shipped in the release tarball and we don't want them to
|
||||||
|
# get regenerated if a2x is not available. the intermediate files from
|
||||||
|
# AC_CONFIG_FILES are created with config.status, which is created at configure
|
||||||
|
# runtime, so we need to touch them after config.status terminated to prevent
|
||||||
|
# make from rebuild them.
|
||||||
|
|
||||||
|
if test "x$A2X" = "xno"; then
|
||||||
|
touch docs/man5/tinyproxy.conf.txt
|
||||||
|
touch docs/man8/tinyproxy.txt
|
||||||
|
if test -e docs/man5/tinyproxy.conf.5 ; then
|
||||||
|
touch docs/man5/tinyproxy.conf.5
|
||||||
|
fi
|
||||||
|
if test -e docs/man8/tinyproxy.8 ; then
|
||||||
|
touch docs/man8/tinyproxy.8
|
||||||
|
fi
|
||||||
|
fi
|
||||||
-300
@@ -1,300 +0,0 @@
|
|||||||
dnl $Id: configure.in,v 1.18 2001-08-27 03:47:47 rjkaes Exp $
|
|
||||||
|
|
||||||
dnl Devlopers, please strive to achieve this order:
|
|
||||||
dnl
|
|
||||||
dnl 0. Initialization and options processing
|
|
||||||
dnl 1. Programs
|
|
||||||
dnl 2. Libraries
|
|
||||||
dnl 3. Header files
|
|
||||||
dnl 4. Types
|
|
||||||
dnl 5. Structures
|
|
||||||
dnl 6. Compiler characteristics
|
|
||||||
dnl 7. Functions, global variables
|
|
||||||
dnl 8. System services
|
|
||||||
dnl
|
|
||||||
dnl Read the Autoconf manual for details.
|
|
||||||
|
|
||||||
AC_INIT()
|
|
||||||
|
|
||||||
AC_CANONICAL_SYSTEM
|
|
||||||
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.1.3)
|
|
||||||
AM_CONFIG_HEADER(config.h)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Command line options
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl Set the URL name for find the statistics of tinyproxy
|
|
||||||
AC_ARG_WITH(stathost, [ --with-stathost=HOST Default status host],
|
|
||||||
AC_DEFINE_UNQUOTED(DEFAULT_STATHOST, "$withval"))
|
|
||||||
|
|
||||||
dnl Set the default configuration file location
|
|
||||||
AC_ARG_WITH(config,
|
|
||||||
[ --with-config=FILE Set the default location of the config file],
|
|
||||||
AC_DEFINE_UNQUOTED(DEFAULT_CONF_FILE, "$withval"))
|
|
||||||
|
|
||||||
dnl Add compiler-specific optimization flags
|
|
||||||
AC_ARG_ENABLE(debug,
|
|
||||||
[ --enable-debug Disable aggressive optimizations [default=no]],
|
|
||||||
debug_enabled=yes, debug_enabled=no)
|
|
||||||
|
|
||||||
dnl Include SOCKS support
|
|
||||||
AC_ARG_ENABLE(socks,
|
|
||||||
[ --enable-socks Enable SOCKS support [default=no]],
|
|
||||||
socks_enabled=yes, socks_enabled=no)
|
|
||||||
|
|
||||||
dnl Check to see if the XTinyproxy header is to be included
|
|
||||||
AC_ARG_ENABLE(xtinyproxy,
|
|
||||||
[ --enable-xtinyproxy Include X-Tinyproxy header [default=yes]],
|
|
||||||
xtinyproxy_enabled=yes, xtinyproxy_enabled=yes)
|
|
||||||
if test "$xtinyproxy_enabled" = "yes"; then
|
|
||||||
AC_DEFINE(XTINYPROXY_ENABLE)
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl Include filtering for domain/URLs
|
|
||||||
AC_ARG_ENABLE(filter,
|
|
||||||
[ --enable-filter Enable filtering of domains/URLs [default=yes]],
|
|
||||||
filter_enabled=yes, filter_enabled=yes)
|
|
||||||
if test "$filter_enabled" = "yes"; then
|
|
||||||
LIBOBJS="$LIBOBJS filter.o"
|
|
||||||
AC_DEFINE(FILTER_ENABLE)
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl Include support for upstream proxies? (TCP tunneling)
|
|
||||||
AC_ARG_ENABLE(tunnel,
|
|
||||||
[ --enable-tunnel Enable support for TCP tunneling [default=yes]],
|
|
||||||
tunnel_enabled=yes, tunnel_enabled=yes)
|
|
||||||
if test "$tunnel_enabled" = "yes" ; then
|
|
||||||
AC_DEFINE(TUNNEL_SUPPORT)
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks for programs
|
|
||||||
dnl
|
|
||||||
AC_PROG_AWK
|
|
||||||
AC_PROG_MAKE_SET
|
|
||||||
AC_PROG_CC
|
|
||||||
AC_PROG_INSTALL
|
|
||||||
AC_PROG_LN_S
|
|
||||||
AM_PROG_LEX
|
|
||||||
AC_PROG_YACC
|
|
||||||
|
|
||||||
dnl Make sure YACC is actually bison
|
|
||||||
if test "$YACC" != "bison -y"; then
|
|
||||||
AC_MSG_WARN(You will need bison if you want to regenerate the parser.)
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING(bison version)
|
|
||||||
oldIFS=$IFS; IFS=.
|
|
||||||
set `bison -V | sed -e 's/^GNU Bison version //'`
|
|
||||||
IFS=$oldIFS
|
|
||||||
if test "$1" = "1" -a "$2" -lt "25"; then
|
|
||||||
AC_MSG_WARN(Bison 1.25 or newer needed to regenerate parsers (found $1.$2).)
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($1.$2 (ok))
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks for libraries
|
|
||||||
dnl
|
|
||||||
AC_CHECK_LIB(pthread, pthread_create)
|
|
||||||
if test "$ac_cv_lib_pthread_pthread_create" = "yes"; then
|
|
||||||
CFLAGS="-D_REENTRANT $CFLAGS"
|
|
||||||
else
|
|
||||||
AC_CHECK_LIB(pthreads, pthread_create)
|
|
||||||
if test "$ac_cv_lib_pthreads_pthread_create" = "yes"; then
|
|
||||||
CFLAGS="-D_REENTRANT $CFLAGS"
|
|
||||||
else
|
|
||||||
AC_MSG_ERROR(You must have a POSIX compliant threading library installed)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CHECK_LIB(socket, socket, , AC_CHECK_LIB(socket, htonl))
|
|
||||||
|
|
||||||
dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to
|
|
||||||
dnl avoid -lnsl checks, if we already have the functions which are
|
|
||||||
dnl usually in libnsl
|
|
||||||
|
|
||||||
unset ac_cv_func_yp_get_default_domain
|
|
||||||
AC_CHECK_FUNC(yp_get_default_domain, [ tinyproxy_no_nsl_checks=yes ], [ ])
|
|
||||||
unset ac_cv_func_yp_get_default_domain
|
|
||||||
|
|
||||||
if test "$tinyproxy_no_nsl_checks" != "yes"; then
|
|
||||||
AC_CHECK_LIB(nsl, gethostname, , AC_CHECK_LIB(nsl, gethostbyaddr))
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CHECK_LIB(resolv, inet_aton)
|
|
||||||
AC_CHECK_LIB(socks, main, socks_library=yes, socks_library=no)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks for headers
|
|
||||||
dnl
|
|
||||||
AC_HEADER_STDC
|
|
||||||
AC_CHECK_HEADERS(\
|
|
||||||
sys/types.h \
|
|
||||||
sys/ioctl.h \
|
|
||||||
sys/resource.h \
|
|
||||||
sys/select.h \
|
|
||||||
sys/socket.h \
|
|
||||||
sys/stat.h \
|
|
||||||
sys/sysctl.h \
|
|
||||||
sys/time.h \
|
|
||||||
sys/uio.h \
|
|
||||||
sys/un.h \
|
|
||||||
sys/wait.h \
|
|
||||||
arpa/inet.h \
|
|
||||||
netinet/in.h \
|
|
||||||
alloca.h \
|
|
||||||
assert.h \
|
|
||||||
ctype.h \
|
|
||||||
errno.h \
|
|
||||||
fcntl.h \
|
|
||||||
grp.h \
|
|
||||||
io.h \
|
|
||||||
libintl.h \
|
|
||||||
malloc.h \
|
|
||||||
memory.h \
|
|
||||||
netdb.h \
|
|
||||||
pthread.h \
|
|
||||||
pwd.h \
|
|
||||||
regex.h \
|
|
||||||
signal.h \
|
|
||||||
stdarg.h \
|
|
||||||
stddef.h \
|
|
||||||
stdint.h \
|
|
||||||
stdio.h \
|
|
||||||
stdlib.h \
|
|
||||||
string.h \
|
|
||||||
strings.h \
|
|
||||||
sysexits.h \
|
|
||||||
syslog.h \
|
|
||||||
time.h \
|
|
||||||
unistd.h \
|
|
||||||
wchar.h \
|
|
||||||
wctype.h \
|
|
||||||
)
|
|
||||||
AC_HEADER_TIME
|
|
||||||
AC_CHECK_HEADER(socks.h, socks_header=yes, socks_header=no)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks for types
|
|
||||||
dnl
|
|
||||||
AM_C_PROTOTYPES
|
|
||||||
AC_C_CONST
|
|
||||||
AC_C_INLINE
|
|
||||||
AC_UNP_CHECK_TYPE(uint8_t, unsigned char)
|
|
||||||
AC_UNP_CHECK_TYPE(int16_t, short)
|
|
||||||
AC_UNP_CHECK_TYPE(uint16_t, unsigned short)
|
|
||||||
AC_UNP_CHECK_TYPE(int32_t, int)
|
|
||||||
AC_UNP_CHECK_TYPE(uint32_t, unsigned int)
|
|
||||||
AC_UNP_CHECK_TYPE(size_t, unsigned int)
|
|
||||||
AC_UNP_CHECK_TYPE(ssize_t, int)
|
|
||||||
AC_UNP_CHECK_TYPE(socklen_t, unsigned int)
|
|
||||||
AC_UNP_CHECK_TYPE(in_addr_t, uint32_t)
|
|
||||||
AC_TYPE_PID_T
|
|
||||||
AC_TYPE_SIGNAL
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Compiler characteristics
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl Enable the debugging flags (by checking for the GCC compiler)
|
|
||||||
CFLAGS="-Wall $CFLAGS"
|
|
||||||
if test "$enable_debug" = "yes" ; then
|
|
||||||
dnl Add the warnings if we have the GCC compiler
|
|
||||||
if test x$ac_cv_prog_gcc = xyes ; then
|
|
||||||
CFLAGS="-Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes $CFLAGS"
|
|
||||||
CFLAGS="-Wmissing-prototypes -Wmissing-declarations $CFLAGS"
|
|
||||||
CFLAGS="-Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"
|
|
||||||
fi
|
|
||||||
CFLAGS="-DYYDEBUG $CFLAGS"
|
|
||||||
YFLAGS="-v -d"
|
|
||||||
else
|
|
||||||
dnl No debugging information, include the optimizations
|
|
||||||
CFLAGS="-DNDEBUG $CFLAGS"
|
|
||||||
YFLAGS="-d"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks for functions
|
|
||||||
dnl
|
|
||||||
AC_FUNC_ALLOCA
|
|
||||||
dnl AC_FUNC_MEMCMP
|
|
||||||
AC_FUNC_STRFTIME
|
|
||||||
AC_FUNC_VPRINTF
|
|
||||||
AC_CHECK_FUNCS(\
|
|
||||||
ftruncate \
|
|
||||||
regexec \
|
|
||||||
select \
|
|
||||||
setrlimit \
|
|
||||||
socket \
|
|
||||||
strdup \
|
|
||||||
strerror \
|
|
||||||
strtol \
|
|
||||||
vsnprintf \
|
|
||||||
vsyslog \
|
|
||||||
)
|
|
||||||
AC_CHECK_FUNCS(strlcpy strlcat)
|
|
||||||
|
|
||||||
if test "$ac_cv_func_vprintf" != "yes"; then
|
|
||||||
AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT))
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Make sure we can actually handle the "--with-*" and "--enable-*" stuff.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl Handle the SOCKS support
|
|
||||||
if test "$socks_enabled" = "yes"; then
|
|
||||||
if test "$socks_header" = "yes" -a "$socks_library" = "yes"; then
|
|
||||||
CFLAGS="-I/usr/include/sock.h -DSOCKS $CFLAGS"
|
|
||||||
LIBS="-lsocks $LIBS"
|
|
||||||
else
|
|
||||||
AC_MSG_ERROR([Could not include the SOCKS library or header])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl Handle the REGEX library
|
|
||||||
if test "$ac_cv_func_regex" != "yes"; then
|
|
||||||
dnl We don't have a functioning REGEX so include our copy
|
|
||||||
tinyproxy_use_our_regex=yes
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING([whether the system's regex library is broken])
|
|
||||||
AC_CACHE_VAL(tinyproxy_cv_regex_broken,
|
|
||||||
AC_TRY_RUN([
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <regex.h>
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
regex_t blah;
|
|
||||||
return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec(&blah, "foobar", 0, NULL, 0);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
tinyproxy_cv_regex_broken=no,
|
|
||||||
tinyproxy_cv_regex_broken=yes,
|
|
||||||
tinyproxy_cv_regex_broken=yes))
|
|
||||||
|
|
||||||
AC_MSG_RESULT($tinyproxy_cv_regex_broken)
|
|
||||||
|
|
||||||
if test "$tinyproxy_cv_regex_broken" = "yes" ; then
|
|
||||||
echo "Using the included GNU regex instead." >&AC_FD_MSG
|
|
||||||
tinyproxy_use_our_regex=yes
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$tinyproxy_use_our_regex" = "yes" ; then
|
|
||||||
AC_DEFINE(USE_GNU_REGEX)
|
|
||||||
LIBOBJS="gnuregex.o $LIBOBJS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Substitute the variables into the various Makefiles
|
|
||||||
dnl
|
|
||||||
AC_SUBST(CFLAGS)
|
|
||||||
AC_SUBST(YFLAGS)
|
|
||||||
AC_SUBST(CPPFLAGS)
|
|
||||||
AC_SUBST(LIBS)
|
|
||||||
AC_SUBST(LIBOBJS)
|
|
||||||
|
|
||||||
AC_OUTPUT(Makefile src/Makefile doc/Makefile)
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
SUBDIRS = \
|
||||||
|
templates
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
templatesdir = $(pkgdatadir)
|
||||||
|
|
||||||
|
TEMPLATES = \
|
||||||
|
debug.html \
|
||||||
|
default.html \
|
||||||
|
stats.html
|
||||||
|
|
||||||
|
templates_DATA = \
|
||||||
|
$(TEMPLATES)
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
$(TEMPLATES)
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>{errno} {cause}</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>{cause}</h1>
|
||||||
|
|
||||||
|
<p>{detail}</p>
|
||||||
|
|
||||||
|
<p>Here are the error variables:</p>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
|
||||||
|
<dt>request</dt>
|
||||||
|
<dd>{request}</dd>
|
||||||
|
|
||||||
|
<dt>cause</dt>
|
||||||
|
<dd>{cause}</dd>
|
||||||
|
|
||||||
|
<dt>clientip</dt>
|
||||||
|
<dd>{clientip}</dd>
|
||||||
|
|
||||||
|
<dt>clienthost</dt>
|
||||||
|
<dd>{clienthost}</dd>
|
||||||
|
|
||||||
|
<dt>version</dt>
|
||||||
|
<dd>{version}</dd>
|
||||||
|
|
||||||
|
<dt>package</dt>
|
||||||
|
<dd>{package}</dd>
|
||||||
|
|
||||||
|
<dt>date</dt>
|
||||||
|
<dd>{date}</dd>
|
||||||
|
|
||||||
|
<dt>detail</dt>
|
||||||
|
<dd>{detail}</dd>
|
||||||
|
|
||||||
|
<dt>url</dt>
|
||||||
|
<dd>{url}</dd>
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<p><em>Generated by <a href="{website}">{package}</a> version {version}.</em></p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>{errno} {cause}</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>{cause}</h1>
|
||||||
|
|
||||||
|
<p>{detail}</p>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<p><em>Generated by <a href="{website}">{package}</a> version {version}.</em></p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>{package} version {version} run-time statistics</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
<!--/*--><![CDATA[<!--*/
|
||||||
|
|
||||||
|
th, td
|
||||||
|
{
|
||||||
|
text-align: left;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*]]>*/-->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>{package} version {version} run-time statistics</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Number of open connections</td>
|
||||||
|
<td>{opens}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Number of requests</td>
|
||||||
|
<td>{reqs}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Number of bad connections</td>
|
||||||
|
<td>{badconns}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Number of denied connections</td>
|
||||||
|
<td>{deniedconns}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Number of refused connections due to high load</td>
|
||||||
|
<td>{refusedconns}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<p><em>Generated by <a href="{website}">{package}</a> version {version}.</em></p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
EXTRA_DIST = tinyproxy.8 tinyproxy.conf HTTP_ERROR_CODES RFC_INFO TODO report.sh
|
|
||||||
man_MANS = tinyproxy.8
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
The following are some features that I'd like to add to tinyproxy in the
|
|
||||||
future. Where possible, I've listed the person who suggested it. This
|
|
||||||
list is in no particular order. And hey, if you want to implement one of
|
|
||||||
these, or another idea you have, go right ahead. Just mail me the diff
|
|
||||||
against the current tree and I'll integrate it if possible.
|
|
||||||
|
|
||||||
- Include hooks so other types of proxies can be modularly added to
|
|
||||||
the source tree. Then people can simply choose which types of
|
|
||||||
proxies (ftp, www, etc) they'd like enabled in tinyproxy.h
|
|
||||||
Suggested: Tarun Tuli.
|
|
||||||
- Find a more elegant solution to embedding HTML documents in the
|
|
||||||
source than the current method. (see httperr() and showstats() for
|
|
||||||
examples of how it's done right now).
|
|
||||||
- Include a function to rewrite the incoming requests. Should not be
|
|
||||||
much of a problem. Just need to modify the process_method() code
|
|
||||||
to look up the URL and rewrite it. If we want to go really fancy
|
|
||||||
with RegEx mapping this could get ugly. :)
|
|
||||||
- Have the ability to send the data from the connections through an
|
|
||||||
external filtering program. I kind of like this idea, but I don't
|
|
||||||
really have a good way of doing it yet.
|
|
||||||
Suggested: Ed Avis
|
|
||||||
- Handle Secure Socket Layer (SSL) connections (usually port 443).
|
|
||||||
- Include the ability to rewrite both incoming and outgoing headers.
|
|
||||||
- Log requests for tunnelled connections
|
|
||||||
- Allow HTTP header filtering through tunnelled connections
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
(echo "date: "
|
|
||||||
date
|
|
||||||
echo "uname: "
|
|
||||||
uname -a
|
|
||||||
echo "ps: "
|
|
||||||
ps -auxw | grep [t]inyproxy -
|
|
||||||
echo "ver: "
|
|
||||||
if [ -x /usr/local/bin/tinyproxy ]; then
|
|
||||||
/usr/local/bin/tinyproxy -v
|
|
||||||
else
|
|
||||||
echo no ver available.
|
|
||||||
fi;) 2>&1 | mail -s 'tinyproxy install report' rjkaes@users.sourceforge.net
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
.\" -*- nroff -*-
|
|
||||||
.\"
|
|
||||||
.\" tinyproxy.1
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1998-2000 Steven Young and Robert James Kaes.
|
|
||||||
.\" Copyright (c) 2001 Robert James Kaes
|
|
||||||
.\"
|
|
||||||
.\" This program is distributed under the terms of the GNU General Public
|
|
||||||
.\" License. See COPYING for additional information.
|
|
||||||
.\"
|
|
||||||
.TH tinyproxy 1 .\" "tinyproxy Manual" "August 25, 2001"
|
|
||||||
.SH NAME
|
|
||||||
tinyproxy - A small HTTP proxy server
|
|
||||||
.SH SYNTAX
|
|
||||||
\fBtinyproxy\fR [ \fBoptions\fR ]
|
|
||||||
.SH VERSION
|
|
||||||
This man page documents tinyproxy
|
|
||||||
.SH DESCRIPTION
|
|
||||||
\fBtinyproxy\fR is an HTTP proxy server designed to consume a minimum of
|
|
||||||
system resources. It listens on a given TCP port and handles HTTP proxy
|
|
||||||
requests.
|
|
||||||
.SH OPTIONS
|
|
||||||
.IP "-c config_file"
|
|
||||||
Use an alternate configuration file.
|
|
||||||
.IP -d
|
|
||||||
Don't daemonize; stay in the foreground. Useful for debugging purposes.
|
|
||||||
.IP -h
|
|
||||||
Display a short help screen of command line arguments and exit.
|
|
||||||
.IP -l
|
|
||||||
Displays the licensing agreement.
|
|
||||||
.IP -v
|
|
||||||
Display version information and exit.
|
|
||||||
.SH SIGNALS
|
|
||||||
In addition to these command line options, there are also several signals
|
|
||||||
that can be sent to tinyproxy while it is running to generate debugging
|
|
||||||
information and to force certain events.
|
|
||||||
.TP 5
|
|
||||||
.B SIGHUP
|
|
||||||
Force \fBtinyproxy\fR to do a garbage collection on the current connections
|
|
||||||
linked list. This is usually done automatically after a certain number of
|
|
||||||
connections have been handled.
|
|
||||||
.SH FILES
|
|
||||||
.nf
|
|
||||||
/etc/tinyproxy/tinyproxy.conf
|
|
||||||
/var/run/tinyproxy.pid
|
|
||||||
/var/log/tinyproxy.log
|
|
||||||
.fi
|
|
||||||
.SH AUTHORS
|
|
||||||
.nf
|
|
||||||
Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
Steven Young (sdyoung@users.sourceforge.net)
|
|
||||||
.fi
|
|
||||||
.SH COPYRIGHT
|
|
||||||
\fBtinyproxy\fR is distributed under the GNU Public License (GPL). For more
|
|
||||||
information on the GPL, please see the file COPYING which should have been
|
|
||||||
included in the archive with \fBtinyproxy\fR. Failing that,
|
|
||||||
http://www.fsf.org/ will doubtless have a copy up for you to peruse. Please
|
|
||||||
don't use this software if you don't agree to the terms specified therein.
|
|
||||||
.SH AVAILABILITY
|
|
||||||
The latest version of \fBtinyproxy\fR can be acquired from: http://tinyproxy.sourceforge.net/
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
##
|
|
||||||
## tinyproxy.conf -- tinyproxy daemon configuration file
|
|
||||||
##
|
|
||||||
|
|
||||||
#
|
|
||||||
# Name of the user the tinyproxy daemon should switch to after the port
|
|
||||||
# has been bound.
|
|
||||||
#
|
|
||||||
User nobody
|
|
||||||
Group nogroup
|
|
||||||
|
|
||||||
#
|
|
||||||
# Port to listen on.
|
|
||||||
#
|
|
||||||
Port 8888
|
|
||||||
|
|
||||||
#
|
|
||||||
# If you have multiple interfaces this allows you to bind to only one. If
|
|
||||||
# this is commented out, tinyproxy will bind to all interfaces present.
|
|
||||||
#
|
|
||||||
#Listen 192.168.0.1
|
|
||||||
|
|
||||||
#
|
|
||||||
# Timeout: The number of seconds of inactivity a connection is allowed to
|
|
||||||
# have before it closed by tinyproxy.
|
|
||||||
#
|
|
||||||
Timeout 600
|
|
||||||
|
|
||||||
#
|
|
||||||
# Where to log the information. Either LogFile or Syslog should be set,
|
|
||||||
# but not both.
|
|
||||||
#
|
|
||||||
Logfile "/var/log/tinyproxy.log"
|
|
||||||
# Syslog On
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set the logging level. Allowed settings are:
|
|
||||||
# Critical (least verbose)
|
|
||||||
# Error
|
|
||||||
# Warning
|
|
||||||
# Notice
|
|
||||||
# Connect (to log connections without Info's noise)
|
|
||||||
# Info (most verbose)
|
|
||||||
# The LogLevel logs from the set level and above. For example, if the LogLevel
|
|
||||||
# was set to Warning, than all log messages from Warning to Critical would be
|
|
||||||
# output, but Notice and below would be suppressed.
|
|
||||||
#
|
|
||||||
LogLevel Info
|
|
||||||
|
|
||||||
#
|
|
||||||
# PidFile: Write the PID of the main tinyproxy thread to this file so it
|
|
||||||
# can be used for signalling purposes.
|
|
||||||
#
|
|
||||||
PidFile "/var/run/tinyproxy.pid"
|
|
||||||
|
|
||||||
#
|
|
||||||
# Include the X-Tinyproxy header, which has the client's IP address when
|
|
||||||
# connecting to the sites listed.
|
|
||||||
#
|
|
||||||
#XTinyproxy mydomain.com
|
|
||||||
|
|
||||||
#
|
|
||||||
# Turns tinyproxy into a TCP tunnel which connects the local computer on
|
|
||||||
# 'Port' to the remote computer's port. The form is remote_machine port
|
|
||||||
#
|
|
||||||
#Tunnel some.remote.computer:port
|
|
||||||
|
|
||||||
#
|
|
||||||
# This is the absolute highest number of threads which will be created. In
|
|
||||||
# other words, only MaxClients number of clients can be connected at the
|
|
||||||
# same time.
|
|
||||||
#
|
|
||||||
MaxClients 100
|
|
||||||
|
|
||||||
#
|
|
||||||
# These settings set the upper and lower limit for the number of
|
|
||||||
# spare servers which should be available. If the number of spare servers
|
|
||||||
# falls below MinSpareServers then new ones will be created. If the number
|
|
||||||
# of servers exceeds MaxSpareServers then the extras will be killed off.
|
|
||||||
#
|
|
||||||
MinSpareServers 5
|
|
||||||
MaxSpareServers 20
|
|
||||||
|
|
||||||
#
|
|
||||||
# Number of servers to start initially.
|
|
||||||
#
|
|
||||||
StartServers 10
|
|
||||||
|
|
||||||
#
|
|
||||||
# MaxRequestsPerChild is the number of connections a thread will handle
|
|
||||||
# before it is killed. In practice this should be set to 0, which disables
|
|
||||||
# thread reaping. If you do notice problems with memory leakage, then set
|
|
||||||
# this to something like 10000
|
|
||||||
#
|
|
||||||
MaxRequestsPerChild 0
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following is the authorization controls. If there are any access
|
|
||||||
# control keywords then the default action is to DENY. Otherwise, the
|
|
||||||
# default action is ALLOW.
|
|
||||||
#
|
|
||||||
# Also the order of the controls are important. The incoming connections
|
|
||||||
# are tested against the controls based on order.
|
|
||||||
#
|
|
||||||
Allow 127.0.0.1
|
|
||||||
Allow 192.168.1.0/25
|
|
||||||
|
|
||||||
#
|
|
||||||
# The location of the filter file.
|
|
||||||
#
|
|
||||||
#Filter "/etc/tinyproxy/filter"
|
|
||||||
|
|
||||||
#
|
|
||||||
# If an Anonymous keyword is present, then anonymous proxying is enabled.
|
|
||||||
# The headers listed are allowed through, while all others are denied. If
|
|
||||||
# no Anonymous keyword is present, then all header are allowed through.
|
|
||||||
#
|
|
||||||
#Anonymous Host
|
|
||||||
#Anonymous Authorization
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
report.sh
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
SUBDIRS = \
|
||||||
|
man5 \
|
||||||
|
man8
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
http-error-codes.txt \
|
||||||
|
http-rfcs.txt \
|
||||||
|
filter-howto.txt
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
Using tinyproxy with Your Home/Small Business Network
|
||||||
|
|
||||||
|
Written: Patrick L. McGillan
|
||||||
|
Edited: Robert James Kaes (2002-06-04)
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
Being as this will be the most common usage and there were no clear
|
||||||
|
basic instructions for this scenario, I thought I would write up what
|
||||||
|
I did for my home system.
|
||||||
|
|
||||||
|
First the layout of the network. A cable modem is connected through a
|
||||||
|
Linksys Router to a small hub. The computers hanging off the hub and
|
||||||
|
have a clear shot to the Internet.
|
||||||
|
|
||||||
|
So, the connection from the Internet to the hub looks like this:
|
||||||
|
|
||||||
|
Internet->Cable TV Line->Cable Modem->Linksys Router->Hub/Switch
|
||||||
|
|
||||||
|
Restricting Internet web access on some of those computers (connected
|
||||||
|
to the hub) is what using tinyproxy is all about. Using the web
|
||||||
|
interface to the Linksys router, turn off all Internet access to those
|
||||||
|
computers that shouldn't have direct access to the Internet. This is
|
||||||
|
done by clicking on the advanced tab and entering the IP number in the
|
||||||
|
filter range. Now those computers have to go through a proxy, for
|
||||||
|
their access, as they have no direct access.
|
||||||
|
|
||||||
|
On one of the Linux computers which still has Internet access (I use
|
||||||
|
an old 486) load up tinyproxy. Now have the users configure their
|
||||||
|
Internet Explorer/Netscape Navigator programs to use the proxy on the
|
||||||
|
tinyproxy computer box, along with the port number declared in the
|
||||||
|
tinyproxy configuration file. By default, there is no blocking of web
|
||||||
|
sites with this program, so I created a file, called "filter", to
|
||||||
|
start blocking some sites.
|
||||||
|
|
||||||
|
Example "filter" file entries:
|
||||||
|
|
||||||
|
bannerads.zwire.com
|
||||||
|
ad.doubleclick.net
|
||||||
|
ads.fortunecity.com
|
||||||
|
|
||||||
|
This filter file usually goes into the same folder, as your
|
||||||
|
configuration file. Be sure and uncomment the 'Filter' line in your
|
||||||
|
configuration file and make sure it points at your newly created
|
||||||
|
filter file.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2002 Patrick L. McGillan <pmcgillan@dwx.com>
|
||||||
|
|
||||||
|
This document is released under the same copyright license as
|
||||||
|
tinyproxy. You should have found a COPYING file in the top level
|
||||||
|
directory of this distribution which contains the current license.
|
||||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
|
|||||||
|
*.5
|
||||||
|
*.xml
|
||||||
|
*.txt
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
MAN5_FILES = \
|
||||||
|
tinyproxy.conf.txt
|
||||||
|
|
||||||
|
if HAVE_XMLLINT
|
||||||
|
A2X_ARGS = -d manpage -f manpage
|
||||||
|
else
|
||||||
|
A2X_ARGS = -d manpage -f manpage -L
|
||||||
|
endif
|
||||||
|
|
||||||
|
man_MANS = \
|
||||||
|
$(MAN5_FILES:.txt=.5)
|
||||||
|
|
||||||
|
.txt.5:
|
||||||
|
if HAVE_A2X
|
||||||
|
$(AM_V_GEN) $(A2X) $(A2X_ARGS) $<
|
||||||
|
else
|
||||||
|
@echo "*** a2x (asciidoc) is required to regenerate $(@) ***"; exit 1;
|
||||||
|
endif
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(MAN5_FILES:.txt=.5) \
|
||||||
|
$(MAN5_FILES:.txt=.xml)
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
$(MAN5_FILES:.txt=.5)
|
||||||
@@ -0,0 +1,371 @@
|
|||||||
|
TINYPROXY.CONF(5)
|
||||||
|
=================
|
||||||
|
:man source: Version @VERSION@
|
||||||
|
:man manual: Tinyproxy manual
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
|
||||||
|
tinyproxy.conf - Tinyproxy HTTP proxy daemon configuration file
|
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
|
||||||
|
*tinyproxy.conf*
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
|
||||||
|
`tinyproxy(8)` reads its configuration file, typically stored in
|
||||||
|
`/etc/tinyproxy/tinyproxy.conf` (or passed to Tinyproxy with -c on the
|
||||||
|
command line). This manpage describes the syntax and contents of the
|
||||||
|
configuration file.
|
||||||
|
|
||||||
|
The Tinyproxy configuration file contains key-value pairs, one per
|
||||||
|
line. Lines starting with `#` and empty lines are comments and are
|
||||||
|
ignored. Keywords are case-insensitive, whereas values are
|
||||||
|
case-sensitive. Values may be enclosed in double-quotes (") if they
|
||||||
|
contain spaces.
|
||||||
|
|
||||||
|
The possible keywords and their descriptions are as follows:
|
||||||
|
|
||||||
|
*User*::
|
||||||
|
|
||||||
|
The user which the Tinyproxy process should run as, after the
|
||||||
|
initial port-binding has been done as the `root` user. Either the
|
||||||
|
user name or the UID may be specified.
|
||||||
|
|
||||||
|
*Group*::
|
||||||
|
|
||||||
|
The group which the Tinyproxy process should run as, after the
|
||||||
|
initial port-binding has been done as the `root` user. Either the
|
||||||
|
group name or the GID may be specified.
|
||||||
|
|
||||||
|
*Port*::
|
||||||
|
|
||||||
|
The port which the Tinyproxy service will listen on. If the port is
|
||||||
|
less than 1024, you will need to start the Tinyproxy process as the
|
||||||
|
`root` user.
|
||||||
|
|
||||||
|
*Listen*::
|
||||||
|
|
||||||
|
By default, Tinyproxy listens for connections on all available
|
||||||
|
interfaces (i.e. it listens on the wildcard address `0.0.0.0`).
|
||||||
|
With this configuration parameter, Tinyproxy can be told to listen
|
||||||
|
only on one specific address.
|
||||||
|
|
||||||
|
*Bind*::
|
||||||
|
|
||||||
|
This allows you to specify which address Tinyproxy will bind
|
||||||
|
to for outgoing connections to web servers or upstream proxies.
|
||||||
|
|
||||||
|
*BindSame*::
|
||||||
|
|
||||||
|
If this boolean parameter is set to `yes`, then Tinyproxy will
|
||||||
|
bind the outgoing connection to the IP address of the incoming
|
||||||
|
connection that triggered the outgoing request.
|
||||||
|
|
||||||
|
*Timeout*::
|
||||||
|
|
||||||
|
The maximum number of seconds of inactivity a connection is
|
||||||
|
allowed to have before it is closed by Tinyproxy.
|
||||||
|
|
||||||
|
*ErrorFile*::
|
||||||
|
|
||||||
|
This parameter controls which HTML file Tinyproxy returns when a
|
||||||
|
given HTTP error occurs. It takes two arguments, the error number
|
||||||
|
and the location of the HTML error file.
|
||||||
|
|
||||||
|
*DefaultErrorFile*::
|
||||||
|
|
||||||
|
This parameter controls the HTML template file returned when an
|
||||||
|
error occurs for which no specific error file has been set.
|
||||||
|
|
||||||
|
*StatHost*::
|
||||||
|
|
||||||
|
This configures the host name or IP address that is treated
|
||||||
|
as the `stat host`: Whenever a request for this host is received,
|
||||||
|
Tinyproxy will return an internal statistics page instead of
|
||||||
|
forwarding the request to that host. The template for this
|
||||||
|
page can be configured with the `StatFile` configuration option.
|
||||||
|
The default value of `StatHost` is `@TINYPROXY_STATHOST@`.
|
||||||
|
|
||||||
|
*StatFile*::
|
||||||
|
|
||||||
|
This configures the HTML file that Tinyproxy sends when
|
||||||
|
a request for the stathost is received. If this parameter is
|
||||||
|
not set, Tinyproxy returns a hard-coded basic statistics page.
|
||||||
|
See the STATHOST section in the `tinyproxy(8)` manual page
|
||||||
|
for details.
|
||||||
|
+
|
||||||
|
Note that the StatFile and the error files configured with ErrorFile
|
||||||
|
and DefaultErrorFile are template files that can contain a few
|
||||||
|
template variables that Tinyproxy expands prior to delivery.
|
||||||
|
Examples are "\{cause}" for an abbreviated error description and
|
||||||
|
"\{detail}" for a detailed error message. The `tinyproxy(8)`
|
||||||
|
manual page contains a description of all template variables.
|
||||||
|
|
||||||
|
*LogFile*::
|
||||||
|
|
||||||
|
This controls the location of the file to which Tinyproxy
|
||||||
|
writes its debug output. Alternatively, Tinyproxy can log
|
||||||
|
to syslog -- see the Syslog option.
|
||||||
|
|
||||||
|
*Syslog*::
|
||||||
|
|
||||||
|
When set to `On`, this option tells Tinyproxy to write its
|
||||||
|
debug messages to syslog instead of to a log file configured
|
||||||
|
with `LogFile`. These two options are mutually exclusive.
|
||||||
|
|
||||||
|
*LogLevel*::
|
||||||
|
|
||||||
|
Sets the log level. Messages from the set level and above are
|
||||||
|
logged. For example, if the LogLevel was set to Warning, then all
|
||||||
|
log messages from Warning to Critical would be output, but Notice
|
||||||
|
and below would be suppressed. Allowed values are:
|
||||||
|
|
||||||
|
* Critical (least verbose)
|
||||||
|
* Error
|
||||||
|
* Warning
|
||||||
|
* Notice
|
||||||
|
* Connect (log connections without Info's noise)
|
||||||
|
* Info (most verbose)
|
||||||
|
|
||||||
|
*PidFile*::
|
||||||
|
|
||||||
|
This option controls the location of the file where the main
|
||||||
|
Tinyproxy process stores its process ID for signaling purposes.
|
||||||
|
|
||||||
|
*XTinyproxy*::
|
||||||
|
|
||||||
|
Setting this option to `Yes` tells Tinyproxy to add a header
|
||||||
|
`X-Tinyproxy` containing the client's IP address to the request.
|
||||||
|
|
||||||
|
*Upstream*::
|
||||||
|
|
||||||
|
This option allows you to set up a set of rules for deciding
|
||||||
|
whether an upstream proxy server is to be used, based on the
|
||||||
|
host or domain of the site being accessed. The rules are stored
|
||||||
|
in the order encountered in the configuration file and the
|
||||||
|
LAST matching rule wins. The following forms for specifying upstream
|
||||||
|
rules exist:
|
||||||
|
|
||||||
|
* 'upstream type host:port' turns proxy upstream support on generally.
|
||||||
|
|
||||||
|
* 'upstream type user:pass@host:port' does the same, but uses the
|
||||||
|
supplied credentials for authentication.
|
||||||
|
|
||||||
|
* 'upstream type host:port "site_spec"' turns on the upstream proxy
|
||||||
|
for the sites matching `site_spec`.
|
||||||
|
|
||||||
|
`type` can be one of `http`, `socks4`, `socks5`, `none`.
|
||||||
|
|
||||||
|
* 'upstream none "site_spec"' turns off upstream support for sites
|
||||||
|
matching `site_spec`.
|
||||||
|
|
||||||
|
The site can be specified in various forms as a hostname, domain
|
||||||
|
name or as an IP range:
|
||||||
|
|
||||||
|
* 'name' matches host exactly
|
||||||
|
* '.name' matches any host in domain "name"
|
||||||
|
* '.' matches any host with no domain (in 'empty' domain)
|
||||||
|
* 'IP/bits' matches network/mask
|
||||||
|
* 'IP/mask' matches network/mask
|
||||||
|
|
||||||
|
*MaxClients*::
|
||||||
|
|
||||||
|
Tinyproxy creates one child process for each connected client.
|
||||||
|
This options specifies the absolute highest number processes that
|
||||||
|
will be created. With other words, only MaxClients clients can be
|
||||||
|
connected to Tinyproxy simultaneously.
|
||||||
|
|
||||||
|
*MinSpareServers*::
|
||||||
|
*MaxSpareServers*::
|
||||||
|
|
||||||
|
Tinyproxy always keeps a certain number of idle child processes
|
||||||
|
so that it can handle new incoming client requests quickly.
|
||||||
|
`MinSpareServer` and `MaxSpareServers` control the lower and upper
|
||||||
|
limits for the number of spare processes. I.e. when the number of
|
||||||
|
spare servers drops below `MinSpareServers` then Tinyproxy will
|
||||||
|
start forking new spare processes in the background and when the
|
||||||
|
number of spare processes exceeds `MaxSpareServers` then Tinyproxy
|
||||||
|
will kill off extra processes.
|
||||||
|
|
||||||
|
*StartServers*::
|
||||||
|
|
||||||
|
The number of servers to start initially. This should usually be
|
||||||
|
set to a value between MinSpareServers and MaxSpareServers.
|
||||||
|
|
||||||
|
*MaxRequestsPerChild*::
|
||||||
|
|
||||||
|
This limits the number of connections that a child process
|
||||||
|
will handle before it is killed. The default value is `0`
|
||||||
|
which disables this feature. This option is meant as an
|
||||||
|
emergency measure in the case of problems with memory leakage.
|
||||||
|
In that case, setting `MaxRequestsPerChild` to a value of e.g.
|
||||||
|
1000, or 10000 can be useful.
|
||||||
|
|
||||||
|
*Allow*::
|
||||||
|
*Deny*::
|
||||||
|
|
||||||
|
The `Allow` and `Deny` options provide a means to customize
|
||||||
|
which clients are allowed to access Tinyproxy. `Allow` and `Deny`
|
||||||
|
lines can be specified multiple times to build the access control
|
||||||
|
list for Tinyproxy. The order in the config file is important.
|
||||||
|
If there are no `Allow` or `Deny` lines, then all clients are
|
||||||
|
allowed. Otherwise, the default action is to deny access.
|
||||||
|
The argument to `Allow` or `Deny` can be a single IP address
|
||||||
|
of a client host, like `127.0.0.1`, an IP address range, like
|
||||||
|
`192.168.0.1/24` or a string that will be matched against the
|
||||||
|
end of the client host name, i.e, this can be a full host name
|
||||||
|
like `host.example.com` or a domain name like `.example.com` or
|
||||||
|
even a top level domain name like `.com`.
|
||||||
|
|
||||||
|
*AddHeader*::
|
||||||
|
|
||||||
|
Configure one or more HTTP request headers to be added to outgoing
|
||||||
|
HTTP requests that Tinyproxy makes. Note that this option will not
|
||||||
|
work for HTTPS traffic, as Tinyproxy has no control over what
|
||||||
|
headers are exchanged.
|
||||||
|
+
|
||||||
|
----
|
||||||
|
AddHeader "X-My-Header" "Powered by Tinyproxy"
|
||||||
|
----
|
||||||
|
|
||||||
|
*ViaProxyName*::
|
||||||
|
|
||||||
|
RFC 2616 requires proxies to add a `Via` header to the HTTP
|
||||||
|
requests, but using the real host name can be a security
|
||||||
|
concern. If the `ViaProxyname` option is present, then its
|
||||||
|
string value will be used as the host name in the Via header.
|
||||||
|
Otherwise, the server's host name will be used.
|
||||||
|
|
||||||
|
*DisableViaHeader*::
|
||||||
|
|
||||||
|
When this is set to yes, Tinyproxy does NOT add the `Via` header
|
||||||
|
to the requests. This virtually puts Tinyproxy into stealth mode.
|
||||||
|
Note that RFC 2616 requires proxies to set the `Via` header, so by
|
||||||
|
enabling this option, you break compliance.
|
||||||
|
Don't disable the `Via` header unless you know what you are doing...
|
||||||
|
|
||||||
|
*Filter*::
|
||||||
|
|
||||||
|
Tinyproxy supports filtering of web sites based on URLs or
|
||||||
|
domains. This option specifies the location of the file
|
||||||
|
containing the filter rules, one rule per line.
|
||||||
|
|
||||||
|
*FilterURLs*::
|
||||||
|
|
||||||
|
If this boolean option is set to `Yes` or `On`, filtering is
|
||||||
|
performed for URLs rather than for domains. The default is to
|
||||||
|
filter based on domains.
|
||||||
|
|
||||||
|
*FilterExtended*::
|
||||||
|
|
||||||
|
If this boolean option is set to `Yes`, then extended POSIX
|
||||||
|
regular expressions are used for matching the filter rules.
|
||||||
|
The default is to use basic POSIX regular expressions.
|
||||||
|
|
||||||
|
*FilterCaseSensitive*::
|
||||||
|
|
||||||
|
If this boolean option is set to `Yes`, then the filter rules
|
||||||
|
are matched in a case sensitive manner. The default is to
|
||||||
|
match case-insensitively.
|
||||||
|
|
||||||
|
*FilterDefaultDeny*::
|
||||||
|
|
||||||
|
The default filtering policy is to allow everything that is
|
||||||
|
not matched by a filtering rule. Setting `FilterDefaultDeny`
|
||||||
|
to `Yes` changes the policy do deny everything but the domains
|
||||||
|
or URLs matched by the filtering rules.
|
||||||
|
|
||||||
|
*Anonymous*::
|
||||||
|
|
||||||
|
If an `Anonymous` keyword is present, then anonymous proxying
|
||||||
|
is enabled. The headers listed with `Anonymous` are allowed
|
||||||
|
through, while all others are denied. If no Anonymous keyword
|
||||||
|
is present, then all headers are allowed through. You must
|
||||||
|
include quotes around the headers.
|
||||||
|
+
|
||||||
|
Most sites require cookies to be enabled for them to work correctly, so
|
||||||
|
you will need to allow cookies through if you access those sites.
|
||||||
|
+
|
||||||
|
Example:
|
||||||
|
+
|
||||||
|
----
|
||||||
|
Anonymous "Host"
|
||||||
|
Anonymous "Authorization"
|
||||||
|
Anonymous "Cookie"
|
||||||
|
----
|
||||||
|
|
||||||
|
*ConnectPort*::
|
||||||
|
|
||||||
|
This option can be used to specify the ports allowed for the
|
||||||
|
CONNECT method. If no `ConnectPort` line is found, then all
|
||||||
|
ports are allowed. To disable CONNECT altogether, include a
|
||||||
|
single ConnectPort line with a value of `0`.
|
||||||
|
|
||||||
|
*ReversePath*::
|
||||||
|
|
||||||
|
Configure one or more ReversePath directives to enable reverse proxy
|
||||||
|
support. With reverse proxying it's possible to make a number of
|
||||||
|
sites appear as if they were part of a single site.
|
||||||
|
+
|
||||||
|
If you uncomment the following two directives and run Tinyproxy
|
||||||
|
on your own computer at port 8888, you can access example.com,
|
||||||
|
using http://localhost:8888/example/.
|
||||||
|
+
|
||||||
|
----
|
||||||
|
ReversePath "/example/" "http://www.example.com/"
|
||||||
|
----
|
||||||
|
|
||||||
|
*ReverseOnly*::
|
||||||
|
|
||||||
|
When using Tinyproxy as a reverse proxy, it is STRONGLY
|
||||||
|
recommended that the normal proxy is turned off by setting
|
||||||
|
this boolean option to `Yes`.
|
||||||
|
|
||||||
|
*ReverseMagic*::
|
||||||
|
|
||||||
|
Setting this option to `Yes`, makes Tinyproxy use a cookie to
|
||||||
|
track reverse proxy mappings. If you need to reverse proxy
|
||||||
|
sites which have absolute links you must use this option.
|
||||||
|
|
||||||
|
*ReverseBaseURL*::
|
||||||
|
|
||||||
|
The URL that is used to access this reverse proxy. The URL is
|
||||||
|
used to rewrite HTTP redirects so that they won't escape the
|
||||||
|
proxy. If you have a chain of reverse proxies, you'll need to
|
||||||
|
put the outermost URL here (the address which the end user
|
||||||
|
types into his/her browser). If this option is not set then
|
||||||
|
no rewriting of redirects occurs.
|
||||||
|
|
||||||
|
|
||||||
|
BUGS
|
||||||
|
----
|
||||||
|
|
||||||
|
To report bugs in Tinyproxy, please visit
|
||||||
|
<https://tinyproxy.github.io/[https://tinyproxy.github.io/]>.
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
tinyproxy(8)
|
||||||
|
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
|
||||||
|
This manpage was written by the Tinyproxy project team.
|
||||||
|
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
|
||||||
|
Copyright (c) 1998-2018 the Tinyproxy authors.
|
||||||
|
|
||||||
|
This program is distributed under the terms of the GNU General Public
|
||||||
|
License version 2 or above. See the COPYING file for additional
|
||||||
|
information.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
*.8
|
||||||
|
*.xml
|
||||||
|
*.txt
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
MAN8_FILES = \
|
||||||
|
tinyproxy.txt
|
||||||
|
|
||||||
|
if HAVE_XMLLINT
|
||||||
|
A2X_ARGS = -d manpage -f manpage
|
||||||
|
else
|
||||||
|
A2X_ARGS = -d manpage -f manpage -L
|
||||||
|
endif
|
||||||
|
|
||||||
|
man_MANS = \
|
||||||
|
$(MAN8_FILES:.txt=.8)
|
||||||
|
|
||||||
|
.txt.8:
|
||||||
|
if HAVE_A2X
|
||||||
|
$(AM_V_GEN) $(A2X) $(A2X_ARGS) $<
|
||||||
|
else
|
||||||
|
@echo "*** a2x (asciidoc) is required to regenerate $(@) ***"; exit 1;
|
||||||
|
endif
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(MAN8_FILES:.txt=.8) \
|
||||||
|
$(MAN8_FILES:.txt=.xml)
|
||||||
|
|
||||||
|
EXTRA_DIST= \
|
||||||
|
$(MAN8_FILES:.txt=.8)
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
TINYPROXY(8)
|
||||||
|
============
|
||||||
|
:man source: Version @VERSION@
|
||||||
|
:man manual: Tinyproxy manual
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
|
||||||
|
tinyproxy - A light-weight HTTP proxy daemon
|
||||||
|
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
|
||||||
|
*tinyproxy* [-vdch]
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
|
||||||
|
*tinyproxy* is a light-weight HTTP proxy daemon designed to consume a
|
||||||
|
minimum amount of system resources. It listens on a given TCP port and
|
||||||
|
handles HTTP proxy requests. Designed from the ground up to be fast and
|
||||||
|
yet small, it is an ideal solution for use cases such as embedded
|
||||||
|
deployments where a full featured HTTP proxy is required, but the system
|
||||||
|
resources for a larger proxy are unavailable.
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
|
||||||
|
*tinyproxy* accepts the following options:
|
||||||
|
|
||||||
|
*-c <config-file>*::
|
||||||
|
Use an alternate configuration file.
|
||||||
|
|
||||||
|
*-d*::
|
||||||
|
Don't daemonize and stay in the foreground. Useful for debugging purposes.
|
||||||
|
|
||||||
|
*-h*::
|
||||||
|
Display a short help screen of command line arguments and exit.
|
||||||
|
|
||||||
|
*-v*::
|
||||||
|
Display version information and exit.
|
||||||
|
|
||||||
|
|
||||||
|
SIGNALS
|
||||||
|
-------
|
||||||
|
|
||||||
|
In addition to command-line options, there are also several signals that
|
||||||
|
can be sent to *tinyproxy* while it is running to generate debugging
|
||||||
|
information and to force certain events.
|
||||||
|
|
||||||
|
*SIGHUP*::
|
||||||
|
Force Tinyproxy to do a garbage collection on the current
|
||||||
|
connections linked list. This is usually done automatically after a
|
||||||
|
certain number of connections have been handled.
|
||||||
|
|
||||||
|
|
||||||
|
TEMPLATE FILES
|
||||||
|
--------------
|
||||||
|
|
||||||
|
There are two occasions when Tinyproxy delivers HTML pages to
|
||||||
|
the client on it's own right:
|
||||||
|
|
||||||
|
. When an error occurred, a corresponding error page is returned.
|
||||||
|
. When a request for the stathost is made, a page summarizing the
|
||||||
|
connection statistics is returned. (See STATHOST below.)
|
||||||
|
|
||||||
|
The layout of both error pages and the statistics page can be
|
||||||
|
controlled via configurable HTML template files that are plain
|
||||||
|
HTML files that additionally understand a few template
|
||||||
|
variables.
|
||||||
|
|
||||||
|
|
||||||
|
TEMPLATE VARIABLES
|
||||||
|
------------------
|
||||||
|
|
||||||
|
There are several standard HTML variables that are available in every
|
||||||
|
template file:
|
||||||
|
|
||||||
|
*request*::
|
||||||
|
The full HTTP request line.
|
||||||
|
|
||||||
|
*cause*::
|
||||||
|
The abbreviated cause of the error condition.
|
||||||
|
|
||||||
|
*clientip*::
|
||||||
|
The IP address of the client making the request.
|
||||||
|
|
||||||
|
*clienthost*::
|
||||||
|
The hostname of the client making the request.
|
||||||
|
|
||||||
|
*version*::
|
||||||
|
The version of Tinyproxy.
|
||||||
|
|
||||||
|
*package*::
|
||||||
|
The package name. Presently, resolves to 'tinyproxy'.
|
||||||
|
|
||||||
|
*date*::
|
||||||
|
The current date/time in HTTP format.
|
||||||
|
|
||||||
|
In addition, almost all templates support:
|
||||||
|
|
||||||
|
*detail*::
|
||||||
|
A detailed, plain English explanation of the error and possible
|
||||||
|
causes.
|
||||||
|
|
||||||
|
When Tinyproxy finds a variable name enclosed in braces, e.g.
|
||||||
|
"\{request}", then this is replaced by the value of the corresponding
|
||||||
|
variable before delivery of the page.
|
||||||
|
|
||||||
|
|
||||||
|
STATHOST
|
||||||
|
--------
|
||||||
|
|
||||||
|
Tinyproxy returns a HTML page with connection statistics when it
|
||||||
|
receives a HTTP request for a certain host -- the stathost. The
|
||||||
|
stathost name defaults to `@TINYPROXY_STATHOST@` and can be changed at
|
||||||
|
runtime to any name or IP address with the configuration variable
|
||||||
|
`StatHost`.
|
||||||
|
|
||||||
|
The stat file template can be changed at runtime through the
|
||||||
|
configuration variable `StatFile`.
|
||||||
|
|
||||||
|
|
||||||
|
FILES
|
||||||
|
-----
|
||||||
|
|
||||||
|
`/etc/tinyproxy/tinyproxy.conf`, `/var/run/tinyproxy/tinyproxy.pid`, `/var/log/tinyproxy/tinyproxy.log`
|
||||||
|
|
||||||
|
BUGS
|
||||||
|
----
|
||||||
|
|
||||||
|
To report bugs in Tinyproxy, please visit
|
||||||
|
<https://tinyproxy.github.io/[https://tinyproxy.github.io/]>.
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
tinyproxy.conf(5)
|
||||||
|
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
|
||||||
|
This manpage was written by the Tinyproxy project team.
|
||||||
|
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
|
||||||
|
Copyright (c) 1998-2018 the Tinyproxy authors.
|
||||||
|
|
||||||
|
This program is distributed under the terms of the GNU General Public
|
||||||
|
License version 2 or above. See the COPYING file for additional
|
||||||
|
information.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
tinyproxy.conf
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
pkgsysconfdir = $(sysconfdir)/$(PACKAGE)
|
||||||
|
|
||||||
|
pkgsysconf_DATA = \
|
||||||
|
tinyproxy.conf
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
tinyproxy.conf.in
|
||||||
|
|
||||||
|
edit = sed \
|
||||||
|
-e 's|@bindir[@]|$(bindir)|g' \
|
||||||
|
-e 's|@datadir[@]|$(datadir)|g' \
|
||||||
|
-e 's|@datarootdir[@]|$(datarootdir)|g' \
|
||||||
|
-e 's|@pkgsysconfdir[@]|$(pkgsysconfdir)|g' \
|
||||||
|
-e 's|@localstatedir[@]|$(localstatedir)|g' \
|
||||||
|
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
|
||||||
|
-e 's|@prefix[@]|$(prefix)|g' \
|
||||||
|
-e 's|@TINYPROXY_STATHOST[@]|$(TINYPROXY_STATHOST)|g'
|
||||||
|
|
||||||
|
tinyproxy.conf: $(top_srcdir)/etc/tinyproxy.conf.in Makefile
|
||||||
|
@rm -f $@ $@.tmp
|
||||||
|
$(AM_V_GEN) $(edit) $(top_srcdir)/etc/$@.in > $@.tmp
|
||||||
|
@mv $@.tmp $@
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
tinyproxy.conf
|
||||||
@@ -0,0 +1,350 @@
|
|||||||
|
##
|
||||||
|
## tinyproxy.conf -- tinyproxy daemon configuration file
|
||||||
|
##
|
||||||
|
## This example tinyproxy.conf file contains example settings
|
||||||
|
## with explanations in comments. For decriptions of all
|
||||||
|
## parameters, see the tinproxy.conf(5) manual page.
|
||||||
|
##
|
||||||
|
|
||||||
|
#
|
||||||
|
# User/Group: This allows you to set the user and group that will be
|
||||||
|
# used for tinyproxy after the initial binding to the port has been done
|
||||||
|
# as the root user. Either the user or group name or the UID or GID
|
||||||
|
# number may be used.
|
||||||
|
#
|
||||||
|
User nobody
|
||||||
|
Group nobody
|
||||||
|
|
||||||
|
#
|
||||||
|
# Port: Specify the port which tinyproxy will listen on. Please note
|
||||||
|
# that should you choose to run on a port lower than 1024 you will need
|
||||||
|
# to start tinyproxy using root.
|
||||||
|
#
|
||||||
|
Port 8888
|
||||||
|
|
||||||
|
#
|
||||||
|
# Listen: If you have multiple interfaces this allows you to bind to
|
||||||
|
# only one. If this is commented out, tinyproxy will bind to all
|
||||||
|
# interfaces present.
|
||||||
|
#
|
||||||
|
#Listen 192.168.0.1
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bind: This allows you to specify which interface will be used for
|
||||||
|
# outgoing connections. This is useful for multi-home'd machines where
|
||||||
|
# you want all traffic to appear outgoing from one particular interface.
|
||||||
|
#
|
||||||
|
#Bind 192.168.0.1
|
||||||
|
|
||||||
|
#
|
||||||
|
# BindSame: If enabled, tinyproxy will bind the outgoing connection to the
|
||||||
|
# ip address of the incoming connection.
|
||||||
|
#
|
||||||
|
#BindSame yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# Timeout: The maximum number of seconds of inactivity a connection is
|
||||||
|
# allowed to have before it is closed by tinyproxy.
|
||||||
|
#
|
||||||
|
Timeout 600
|
||||||
|
|
||||||
|
#
|
||||||
|
# ErrorFile: Defines the HTML file to send when a given HTTP error
|
||||||
|
# occurs. You will probably need to customize the location to your
|
||||||
|
# particular install. The usual locations to check are:
|
||||||
|
# /usr/local/share/tinyproxy
|
||||||
|
# /usr/share/tinyproxy
|
||||||
|
# /etc/tinyproxy
|
||||||
|
#
|
||||||
|
#ErrorFile 404 "@pkgdatadir@/404.html"
|
||||||
|
#ErrorFile 400 "@pkgdatadir@/400.html"
|
||||||
|
#ErrorFile 503 "@pkgdatadir@/503.html"
|
||||||
|
#ErrorFile 403 "@pkgdatadir@/403.html"
|
||||||
|
#ErrorFile 408 "@pkgdatadir@/408.html"
|
||||||
|
|
||||||
|
#
|
||||||
|
# DefaultErrorFile: The HTML file that gets sent if there is no
|
||||||
|
# HTML file defined with an ErrorFile keyword for the HTTP error
|
||||||
|
# that has occured.
|
||||||
|
#
|
||||||
|
DefaultErrorFile "@pkgdatadir@/default.html"
|
||||||
|
|
||||||
|
#
|
||||||
|
# StatHost: This configures the host name or IP address that is treated
|
||||||
|
# as the stat host: Whenever a request for this host is received,
|
||||||
|
# Tinyproxy will return an internal statistics page instead of
|
||||||
|
# forwarding the request to that host. The default value of StatHost is
|
||||||
|
# @TINYPROXY_STATHOST@.
|
||||||
|
#
|
||||||
|
#StatHost "@TINYPROXY_STATHOST@"
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# StatFile: The HTML file that gets sent when a request is made
|
||||||
|
# for the stathost. If this file doesn't exist a basic page is
|
||||||
|
# hardcoded in tinyproxy.
|
||||||
|
#
|
||||||
|
StatFile "@pkgdatadir@/stats.html"
|
||||||
|
|
||||||
|
#
|
||||||
|
# LogFile: Allows you to specify the location where information should
|
||||||
|
# be logged to. If you would prefer to log to syslog, then disable this
|
||||||
|
# and enable the Syslog directive. These directives are mutually
|
||||||
|
# exclusive. If neither Syslog nor LogFile are specified, output goes
|
||||||
|
# to stdout.
|
||||||
|
#
|
||||||
|
#LogFile "@localstatedir@/log/tinyproxy/tinyproxy.log"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Syslog: Tell tinyproxy to use syslog instead of a logfile. This
|
||||||
|
# option must not be enabled if the Logfile directive is being used.
|
||||||
|
# These two directives are mutually exclusive.
|
||||||
|
#
|
||||||
|
#Syslog On
|
||||||
|
|
||||||
|
#
|
||||||
|
# LogLevel: Warning
|
||||||
|
#
|
||||||
|
# Set the logging level. Allowed settings are:
|
||||||
|
# Critical (least verbose)
|
||||||
|
# Error
|
||||||
|
# Warning
|
||||||
|
# Notice
|
||||||
|
# Connect (to log connections without Info's noise)
|
||||||
|
# Info (most verbose)
|
||||||
|
#
|
||||||
|
# The LogLevel logs from the set level and above. For example, if the
|
||||||
|
# LogLevel was set to Warning, then all log messages from Warning to
|
||||||
|
# Critical would be output, but Notice and below would be suppressed.
|
||||||
|
#
|
||||||
|
LogLevel Info
|
||||||
|
|
||||||
|
#
|
||||||
|
# PidFile: Write the PID of the main tinyproxy thread to this file so it
|
||||||
|
# can be used for signalling purposes.
|
||||||
|
# If not specified, no pidfile will be written.
|
||||||
|
#
|
||||||
|
#PidFile "@localstatedir@/run/tinyproxy/tinyproxy.pid"
|
||||||
|
|
||||||
|
#
|
||||||
|
# XTinyproxy: Tell Tinyproxy to include the X-Tinyproxy header, which
|
||||||
|
# contains the client's IP address.
|
||||||
|
#
|
||||||
|
#XTinyproxy Yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# Upstream:
|
||||||
|
#
|
||||||
|
# Turns on upstream proxy support.
|
||||||
|
#
|
||||||
|
# The upstream rules allow you to selectively route upstream connections
|
||||||
|
# based on the host/domain of the site being accessed.
|
||||||
|
#
|
||||||
|
# Syntax: upstream type (user:pass@)ip:port ("domain")
|
||||||
|
# Or: upstream none "domain"
|
||||||
|
# The parts in parens are optional.
|
||||||
|
# Possible types are http, socks4, socks5, none
|
||||||
|
#
|
||||||
|
# For example:
|
||||||
|
# # connection to test domain goes through testproxy
|
||||||
|
# upstream http testproxy:8008 ".test.domain.invalid"
|
||||||
|
# upstream http testproxy:8008 ".our_testbed.example.com"
|
||||||
|
# upstream http testproxy:8008 "192.168.128.0/255.255.254.0"
|
||||||
|
#
|
||||||
|
# # upstream proxy using basic authentication
|
||||||
|
# upstream http user:pass@testproxy:8008 ".test.domain.invalid"
|
||||||
|
#
|
||||||
|
# # no upstream proxy for internal websites and unqualified hosts
|
||||||
|
# upstream none ".internal.example.com"
|
||||||
|
# upstream none "www.example.com"
|
||||||
|
# upstream none "10.0.0.0/8"
|
||||||
|
# upstream none "192.168.0.0/255.255.254.0"
|
||||||
|
# upstream none "."
|
||||||
|
#
|
||||||
|
# # connection to these boxes go through their DMZ firewalls
|
||||||
|
# upstream http cust1_firewall:8008 "testbed_for_cust1"
|
||||||
|
# upstream http cust2_firewall:8008 "testbed_for_cust2"
|
||||||
|
#
|
||||||
|
# # default upstream is internet firewall
|
||||||
|
# upstream http firewall.internal.example.com:80
|
||||||
|
#
|
||||||
|
# You may also use SOCKS4/SOCKS5 upstream proxies:
|
||||||
|
# upstream socks4 127.0.0.1:9050
|
||||||
|
# upstream socks5 socksproxy:1080
|
||||||
|
#
|
||||||
|
# The LAST matching rule wins the route decision. As you can see, you
|
||||||
|
# can use a host, or a domain:
|
||||||
|
# name matches host exactly
|
||||||
|
# .name matches any host in domain "name"
|
||||||
|
# . matches any host with no domain (in 'empty' domain)
|
||||||
|
# IP/bits matches network/mask
|
||||||
|
# IP/mask matches network/mask
|
||||||
|
#
|
||||||
|
#Upstream http some.remote.proxy:port
|
||||||
|
|
||||||
|
#
|
||||||
|
# MaxClients: This is the absolute highest number of threads which will
|
||||||
|
# be created. In other words, only MaxClients number of clients can be
|
||||||
|
# connected at the same time.
|
||||||
|
#
|
||||||
|
MaxClients 100
|
||||||
|
|
||||||
|
#
|
||||||
|
# MinSpareServers/MaxSpareServers: These settings set the upper and
|
||||||
|
# lower limit for the number of spare servers which should be available.
|
||||||
|
#
|
||||||
|
# If the number of spare servers falls below MinSpareServers then new
|
||||||
|
# server processes will be spawned. If the number of servers exceeds
|
||||||
|
# MaxSpareServers then the extras will be killed off.
|
||||||
|
#
|
||||||
|
MinSpareServers 5
|
||||||
|
MaxSpareServers 20
|
||||||
|
|
||||||
|
#
|
||||||
|
# StartServers: The number of servers to start initially.
|
||||||
|
#
|
||||||
|
StartServers 10
|
||||||
|
|
||||||
|
#
|
||||||
|
# MaxRequestsPerChild: The number of connections a thread will handle
|
||||||
|
# before it is killed. In practise this should be set to 0, which
|
||||||
|
# disables thread reaping. If you do notice problems with memory
|
||||||
|
# leakage, then set this to something like 10000.
|
||||||
|
#
|
||||||
|
MaxRequestsPerChild 0
|
||||||
|
|
||||||
|
#
|
||||||
|
# Allow: Customization of authorization controls. If there are any
|
||||||
|
# access control keywords then the default action is to DENY. Otherwise,
|
||||||
|
# the default action is ALLOW.
|
||||||
|
#
|
||||||
|
# The order of the controls are important. All incoming connections are
|
||||||
|
# tested against the controls based on order.
|
||||||
|
#
|
||||||
|
Allow 127.0.0.1
|
||||||
|
Allow ::1
|
||||||
|
|
||||||
|
# BasicAuth: HTTP "Basic Authentication" for accessing the proxy.
|
||||||
|
# If there are any entries specified, access is only granted for authenticated
|
||||||
|
# users.
|
||||||
|
#BasicAuth user password
|
||||||
|
|
||||||
|
#
|
||||||
|
# AddHeader: Adds the specified headers to outgoing HTTP requests that
|
||||||
|
# Tinyproxy makes. Note that this option will not work for HTTPS
|
||||||
|
# traffic, as Tinyproxy has no control over what headers are exchanged.
|
||||||
|
#
|
||||||
|
#AddHeader "X-My-Header" "Powered by Tinyproxy"
|
||||||
|
|
||||||
|
#
|
||||||
|
# ViaProxyName: The "Via" header is required by the HTTP RFC, but using
|
||||||
|
# the real host name is a security concern. If the following directive
|
||||||
|
# is enabled, the string supplied will be used as the host name in the
|
||||||
|
# Via header; otherwise, the server's host name will be used.
|
||||||
|
#
|
||||||
|
ViaProxyName "tinyproxy"
|
||||||
|
|
||||||
|
#
|
||||||
|
# DisableViaHeader: When this is set to yes, Tinyproxy does NOT add
|
||||||
|
# the Via header to the requests. This virtually puts Tinyproxy into
|
||||||
|
# stealth mode. Note that RFC 2616 requires proxies to set the Via
|
||||||
|
# header, so by enabling this option, you break compliance.
|
||||||
|
# Don't disable the Via header unless you know what you are doing...
|
||||||
|
#
|
||||||
|
#DisableViaHeader Yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# Filter: This allows you to specify the location of the filter file.
|
||||||
|
#
|
||||||
|
#Filter "@pkgsysconfdir@/filter"
|
||||||
|
|
||||||
|
#
|
||||||
|
# FilterURLs: Filter based on URLs rather than domains.
|
||||||
|
#
|
||||||
|
#FilterURLs On
|
||||||
|
|
||||||
|
#
|
||||||
|
# FilterExtended: Use POSIX Extended regular expressions rather than
|
||||||
|
# basic.
|
||||||
|
#
|
||||||
|
#FilterExtended On
|
||||||
|
|
||||||
|
#
|
||||||
|
# FilterCaseSensitive: Use case sensitive regular expressions.
|
||||||
|
#
|
||||||
|
#FilterCaseSensitive On
|
||||||
|
|
||||||
|
#
|
||||||
|
# FilterDefaultDeny: Change the default policy of the filtering system.
|
||||||
|
# If this directive is commented out, or is set to "No" then the default
|
||||||
|
# policy is to allow everything which is not specifically denied by the
|
||||||
|
# filter file.
|
||||||
|
#
|
||||||
|
# However, by setting this directive to "Yes" the default policy becomes
|
||||||
|
# to deny everything which is _not_ specifically allowed by the filter
|
||||||
|
# file.
|
||||||
|
#
|
||||||
|
#FilterDefaultDeny Yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# Anonymous: If an Anonymous keyword is present, then anonymous proxying
|
||||||
|
# is enabled. The headers listed are allowed through, while all others
|
||||||
|
# are denied. If no Anonymous keyword is present, then all headers are
|
||||||
|
# allowed through. You must include quotes around the headers.
|
||||||
|
#
|
||||||
|
# Most sites require cookies to be enabled for them to work correctly, so
|
||||||
|
# you will need to allow Cookies through if you access those sites.
|
||||||
|
#
|
||||||
|
#Anonymous "Host"
|
||||||
|
#Anonymous "Authorization"
|
||||||
|
#Anonymous "Cookie"
|
||||||
|
|
||||||
|
#
|
||||||
|
# ConnectPort: This is a list of ports allowed by tinyproxy when the
|
||||||
|
# CONNECT method is used. To disable the CONNECT method altogether, set
|
||||||
|
# the value to 0. If no ConnectPort line is found, all ports are
|
||||||
|
# allowed.
|
||||||
|
#
|
||||||
|
# The following two ports are used by SSL.
|
||||||
|
#
|
||||||
|
#ConnectPort 443
|
||||||
|
#ConnectPort 563
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure one or more ReversePath directives to enable reverse proxy
|
||||||
|
# support. With reverse proxying it's possible to make a number of
|
||||||
|
# sites appear as if they were part of a single site.
|
||||||
|
#
|
||||||
|
# If you uncomment the following two directives and run tinyproxy
|
||||||
|
# on your own computer at port 8888, you can access Google using
|
||||||
|
# http://localhost:8888/google/ and Wired News using
|
||||||
|
# http://localhost:8888/wired/news/. Neither will actually work
|
||||||
|
# until you uncomment ReverseMagic as they use absolute linking.
|
||||||
|
#
|
||||||
|
#ReversePath "/google/" "http://www.google.com/"
|
||||||
|
#ReversePath "/wired/" "http://www.wired.com/"
|
||||||
|
|
||||||
|
#
|
||||||
|
# When using tinyproxy as a reverse proxy, it is STRONGLY recommended
|
||||||
|
# that the normal proxy is turned off by uncommenting the next directive.
|
||||||
|
#
|
||||||
|
#ReverseOnly Yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# Use a cookie to track reverse proxy mappings. If you need to reverse
|
||||||
|
# proxy sites which have absolute links you must uncomment this.
|
||||||
|
#
|
||||||
|
#ReverseMagic Yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# The URL that's used to access this reverse proxy. The URL is used to
|
||||||
|
# rewrite HTTP redirects so that they won't escape the proxy. If you
|
||||||
|
# have a chain of reverse proxies, you'll need to put the outermost
|
||||||
|
# URL here (the address which the end user types into his/her browser).
|
||||||
|
#
|
||||||
|
# If not set then no rewriting occurs.
|
||||||
|
#
|
||||||
|
#ReverseBaseURL "http://localhost:8888/"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
EXTRA_DIST = \
|
||||||
|
as-compiler-flag.m4 \
|
||||||
|
argenable.m4
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
dnl $Id: argenable.m4,v 1.1 2004-08-24 18:40:21 rjkaes Exp $
|
||||||
|
dnl
|
||||||
|
dnl Define a new AC_ARG_ENABLE like macro which handles invalid inputs
|
||||||
|
dnl correctly. The macro takes three arguments:
|
||||||
|
dnl 1) the option name (used like --enable-option)
|
||||||
|
dnl 2) the help string
|
||||||
|
dnl 3) the default value (either yes or no)
|
||||||
|
dnl
|
||||||
|
dnl This macro also defines on variable in the form "option_enabled"
|
||||||
|
dnl set to either "yes" or "no".
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([TP_ARG_ENABLE],
|
||||||
|
[AC_ARG_ENABLE([$1],
|
||||||
|
AS_HELP_STRING([--enable-$1], [$2]),
|
||||||
|
[case "${enableval}" in
|
||||||
|
yes) $1_enabled=yes ;;
|
||||||
|
no) $1_enabled=no ;;
|
||||||
|
*) AC_MSG_ERROR([bad value ${enableval} for --enable-$1]) ;;
|
||||||
|
esac],[$1_enabled=$3])])
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
dnl as-compiler-flag.m4 0.1.0
|
||||||
|
|
||||||
|
dnl autostars m4 macro for detection of compiler flags
|
||||||
|
|
||||||
|
dnl David Schleef <ds@schleef.org>
|
||||||
|
dnl Tim-Philipp Müller <tim centricular net>
|
||||||
|
|
||||||
|
dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
|
||||||
|
dnl Tries to compile with the given CFLAGS.
|
||||||
|
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
|
||||||
|
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
|
||||||
|
|
||||||
|
AC_DEFUN([AS_COMPILER_FLAG],
|
||||||
|
[
|
||||||
|
AC_MSG_CHECKING([to see if compiler understands $1])
|
||||||
|
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS $1"
|
||||||
|
|
||||||
|
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
|
||||||
|
if test "X$flag_ok" = Xyes ; then
|
||||||
|
$2
|
||||||
|
true
|
||||||
|
else
|
||||||
|
$3
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT([$flag_ok])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
|
||||||
|
dnl Tries to compile with the given CPPFLAGS.
|
||||||
|
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
|
||||||
|
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
|
||||||
|
|
||||||
|
AC_DEFUN([AS_CXX_COMPILER_FLAG],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([AC_PROG_CXX])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([to see if c++ compiler understands $1])
|
||||||
|
|
||||||
|
save_CPPFLAGS="$CPPFLAGS"
|
||||||
|
CPPFLAGS="$CPPFLAGS $1"
|
||||||
|
|
||||||
|
AC_LANG_PUSH(C++)
|
||||||
|
|
||||||
|
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
|
||||||
|
CPPFLAGS="$save_CPPFLAGS"
|
||||||
|
|
||||||
|
if test "X$flag_ok" = Xyes ; then
|
||||||
|
$2
|
||||||
|
true
|
||||||
|
else
|
||||||
|
$3
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_LANG_POP(C++)
|
||||||
|
|
||||||
|
AC_MSG_RESULT([$flag_ok])
|
||||||
|
])
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
rm -f config.cache
|
|
||||||
echo "- aclocal."
|
|
||||||
aclocal
|
|
||||||
echo "- autoconf."
|
|
||||||
autoconf
|
|
||||||
echo "- autoheader."
|
|
||||||
autoheader
|
|
||||||
echo "- automake."
|
|
||||||
automake -a
|
|
||||||
exit
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
EXTRA_DIST = \
|
||||||
|
version.sh
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
|
||||||
|
BASE_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||||
|
AUTHORS_FILE="${BASE_DIR}/AUTHORS"
|
||||||
|
|
||||||
|
type git > /dev/null || exit
|
||||||
|
test -d "${BASE_DIR}/.git" || exit
|
||||||
|
|
||||||
|
git log --all --format='%aN' | sort -u > "${AUTHORS_FILE}"
|
||||||
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
|
||||||
|
GIT_DIR="${SCRIPT_DIR}/../.git"
|
||||||
|
|
||||||
|
if test -d "${GIT_DIR}" ; then
|
||||||
|
if type git >/dev/null 2>&1 ; then
|
||||||
|
git describe --match '[0-9]*.[0-9]*.[0-9]*' 2>/dev/null \
|
||||||
|
| sed -e 's/-/-git-/'
|
||||||
|
else
|
||||||
|
sed 's/$/-git/' < VERSION
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cat VERSION
|
||||||
|
fi
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.deps
|
||||||
|
.libs
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
tinyproxy
|
||||||
|
*.o
|
||||||
|
*.pcno
|
||||||
+43
-33
@@ -1,47 +1,57 @@
|
|||||||
# $Id: Makefile.am,v 1.3 2000-09-11 23:37:01 rjkaes Exp $
|
# tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
# Copyright (C) 2000 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
#
|
#
|
||||||
#
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
# This program is distributed in the hope that it will be useful,
|
||||||
#
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# under the terms of the GNU General Public License as published by the
|
# GNU General Public License for more details.
|
||||||
# Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
# later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but
|
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# General Public License for more details.
|
|
||||||
#
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
YFLAGS = @YFLAGS@
|
pkgsysconfdir = $(sysconfdir)/$(PACKAGE)
|
||||||
|
|
||||||
bin_PROGRAMS = tinyproxy
|
bin_PROGRAMS = tinyproxy
|
||||||
|
|
||||||
|
AM_CPPFLAGS = \
|
||||||
|
-DSYSCONFDIR=\"${pkgsysconfdir}\" \
|
||||||
|
-DLOCALSTATEDIR=\"${localstatedir}\"
|
||||||
|
|
||||||
tinyproxy_SOURCES = \
|
tinyproxy_SOURCES = \
|
||||||
|
acl.c acl.h \
|
||||||
|
anonymous.c anonymous.h \
|
||||||
buffer.c buffer.h \
|
buffer.c buffer.h \
|
||||||
dnscache.c dnscache.h \
|
child.c child.h \
|
||||||
|
common.h \
|
||||||
|
conf.c conf.h \
|
||||||
|
conns.c conns.h \
|
||||||
|
daemon.c daemon.h \
|
||||||
|
hashmap.c hashmap.h \
|
||||||
|
heap.c heap.h \
|
||||||
|
html-error.c html-error.h \
|
||||||
|
http-message.c http-message.h \
|
||||||
log.c log.h \
|
log.c log.h \
|
||||||
|
network.c network.h \
|
||||||
reqs.c reqs.h \
|
reqs.c reqs.h \
|
||||||
sock.c sock.h \
|
sock.c sock.h \
|
||||||
tinyproxy.c tinyproxy.h \
|
|
||||||
uri.c uri.h \
|
|
||||||
utils.c utils.h \
|
|
||||||
anonymous.c anonymous.h \
|
|
||||||
stats.c stats.h \
|
stats.c stats.h \
|
||||||
thread.c thread.h \
|
text.c text.h \
|
||||||
grammar.y scanner.l \
|
main.c main.h \
|
||||||
acl.c acl.h \
|
utils.c utils.h \
|
||||||
ternary.c ternary.h \
|
vector.c vector.h \
|
||||||
regexp.h
|
upstream.c upstream.h \
|
||||||
|
basicauth.c basicauth.h \
|
||||||
|
base64.c base64.h \
|
||||||
|
connect-ports.c connect-ports.h
|
||||||
|
|
||||||
tinyproxy_LDADD = @LIBOBJS@
|
EXTRA_tinyproxy_SOURCES = filter.c filter.h \
|
||||||
|
reverse-proxy.c reverse-proxy.h \
|
||||||
EXTRA_DIST = gnuregex.c gnuregex.h \
|
transparent-proxy.c transparent-proxy.h
|
||||||
filter.c filter.h
|
tinyproxy_DEPENDENCIES = @ADDITIONAL_OBJECTS@
|
||||||
|
tinyproxy_LDADD = @ADDITIONAL_OBJECTS@
|
||||||
EXTRA_tinyproxy_SOURCES = grammar.h
|
|
||||||
|
|
||||||
scanner.c: scanner.l grammar.h
|
|
||||||
$(LEX) $(AM_LFLAGS) $(LFLAGS) -i $< && mv $(LEX_OUTPUT_ROOT).c $@
|
|
||||||
@@ -1,61 +1,128 @@
|
|||||||
/* $Id: acl.c,v 1.4 2001-05-27 02:20:54 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2000, 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This system handles Access Control for use of this daemon. A list of
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This system handles Access Control for use of this daemon. A list of
|
||||||
* domains, or IP addresses (including IP blocks) are stored in a list
|
* domains, or IP addresses (including IP blocks) are stored in a list
|
||||||
* which is then used to compare incoming connections.
|
* which is then used to compare incoming connections.
|
||||||
*
|
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "acl.h"
|
#include "acl.h"
|
||||||
|
#include "heap.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "network.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
struct acl_s {
|
#include <limits.h>
|
||||||
acl_access_t acl_access;
|
|
||||||
enum { ACL_STRING, ACL_NUMERIC } type;
|
/* Define how long an IPv6 address is in bytes (128 bits, 16 bytes) */
|
||||||
char *location;
|
#define IPV6_LEN 16
|
||||||
int netmask;
|
|
||||||
struct acl_s *next;
|
enum acl_type {
|
||||||
|
ACL_STRING,
|
||||||
|
ACL_NUMERIC
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct acl_s *access_list = NULL;
|
/*
|
||||||
|
* Hold the information about a particular access control. We store
|
||||||
|
* whether it's an ALLOW or DENY entry, and also whether it's a string
|
||||||
|
* entry (like a domain name) or an IP entry.
|
||||||
|
*/
|
||||||
|
struct acl_s {
|
||||||
|
acl_access_t access;
|
||||||
|
enum acl_type type;
|
||||||
|
union {
|
||||||
|
char *string;
|
||||||
|
struct {
|
||||||
|
unsigned char network[IPV6_LEN];
|
||||||
|
unsigned char mask[IPV6_LEN];
|
||||||
|
} ip;
|
||||||
|
} address;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take a netmask number (between 0 and 32) and returns a network ordered
|
* Fills in the netmask array given a numeric value.
|
||||||
* value for comparison. Somebody please clean this up. :)
|
*
|
||||||
|
* Returns:
|
||||||
|
* 0 on success
|
||||||
|
* -1 on failure (invalid mask value)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
static in_addr_t make_netmask(int netmask_num)
|
static int
|
||||||
|
fill_netmask_array (char *bitmask_string, int v6,
|
||||||
|
unsigned char array[], size_t len)
|
||||||
{
|
{
|
||||||
static in_addr_t netmasks[] = {
|
unsigned int i;
|
||||||
0x00000000, 0x80000000, 0xc0000000, 0xe0000000,
|
unsigned long int mask;
|
||||||
0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
|
char *endptr;
|
||||||
0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
|
|
||||||
0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000,
|
|
||||||
0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000,
|
|
||||||
0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
|
|
||||||
0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
|
|
||||||
0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe,
|
|
||||||
0xffffffff
|
|
||||||
};
|
|
||||||
|
|
||||||
assert(netmask_num >= 0 && netmask_num <= 32);
|
errno = 0; /* to distinguish success/failure after call */
|
||||||
|
mask = strtoul (bitmask_string, &endptr, 10);
|
||||||
|
|
||||||
return htonl(netmasks[netmask_num]);
|
/* check for various conversion errors */
|
||||||
|
if ((errno == ERANGE && mask == ULONG_MAX)
|
||||||
|
|| (errno != 0 && mask == 0) || (endptr == bitmask_string))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (v6 == 0) {
|
||||||
|
/* The mask comparison is done as an IPv6 address, so
|
||||||
|
* convert to a longer mask in the case of IPv4
|
||||||
|
* addresses. */
|
||||||
|
mask += 12 * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check valid range for a bit mask */
|
||||||
|
if (mask > (8 * len))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* we have a valid range to fill in the array */
|
||||||
|
for (i = 0; i != len; ++i) {
|
||||||
|
if (mask >= 8) {
|
||||||
|
array[i] = 0xff;
|
||||||
|
mask -= 8;
|
||||||
|
} else if (mask > 0) {
|
||||||
|
array[i] = (unsigned char) (0xff << (8 - mask));
|
||||||
|
mask = 0;
|
||||||
|
} else {
|
||||||
|
array[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the access list has not been set up, create it.
|
||||||
|
*/
|
||||||
|
static int init_access_list(vector_t *access_list)
|
||||||
|
{
|
||||||
|
if (!*access_list) {
|
||||||
|
*access_list = vector_create ();
|
||||||
|
if (!*access_list) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Unable to allocate memory for access list");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -67,154 +134,268 @@ static in_addr_t make_netmask(int netmask_num)
|
|||||||
* -1 on failure
|
* -1 on failure
|
||||||
* 0 otherwise.
|
* 0 otherwise.
|
||||||
*/
|
*/
|
||||||
int insert_acl(char *location, acl_access_t access_type)
|
int
|
||||||
|
insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
|
||||||
{
|
{
|
||||||
size_t i;
|
struct acl_s acl;
|
||||||
struct acl_s **rev_acl_ptr, *acl_ptr, *new_acl_ptr;
|
int ret;
|
||||||
char *nptr;
|
char *p, ip_dst[IPV6_LEN];
|
||||||
|
|
||||||
assert(location != NULL);
|
assert (location != NULL);
|
||||||
|
|
||||||
/*
|
ret = init_access_list(access_list);
|
||||||
* First check to see if the location is a string or numeric.
|
if (ret != 0) {
|
||||||
*/
|
return -1;
|
||||||
for (i = 0; i < strlen((char *)location); i++) {
|
}
|
||||||
if (isdigit((unsigned char)location[i]) != 0 && location[i] != '.') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a new ACL to the list.
|
* Start populating the access control structure.
|
||||||
*/
|
*/
|
||||||
rev_acl_ptr = &access_list;
|
memset (&acl, 0, sizeof (struct acl_s));
|
||||||
acl_ptr = access_list;
|
acl.access = access_type;
|
||||||
while (acl_ptr) {
|
|
||||||
rev_acl_ptr = &acl_ptr->next;
|
|
||||||
acl_ptr = acl_ptr->next;
|
|
||||||
}
|
|
||||||
new_acl_ptr = malloc(sizeof(struct acl_s));
|
|
||||||
if (!new_acl_ptr) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_acl_ptr->acl_access = access_type;
|
|
||||||
|
|
||||||
if (i != strlen(location)) {
|
|
||||||
/* We did break early, so this a numeric location.
|
|
||||||
* Check for a netmask.
|
|
||||||
*/
|
|
||||||
new_acl_ptr->type = ACL_NUMERIC;
|
|
||||||
nptr = strchr(location, '/');
|
|
||||||
if (nptr) {
|
|
||||||
*nptr++ = '\0';
|
|
||||||
|
|
||||||
new_acl_ptr->netmask = atoi(nptr);
|
/*
|
||||||
if (new_acl_ptr->netmask < 0 || new_acl_ptr->netmask > 32) {
|
* Check for a valid IP address (the simplest case) first.
|
||||||
safefree(new_acl_ptr);
|
*/
|
||||||
return -1;
|
if (full_inet_pton (location, ip_dst) > 0) {
|
||||||
}
|
acl.type = ACL_NUMERIC;
|
||||||
} else {
|
memcpy (acl.address.ip.network, ip_dst, IPV6_LEN);
|
||||||
new_acl_ptr->netmask = 32;
|
memset (acl.address.ip.mask, 0xff, IPV6_LEN);
|
||||||
}
|
} else {
|
||||||
} else {
|
int i;
|
||||||
new_acl_ptr->type = ACL_STRING;
|
|
||||||
new_acl_ptr->netmask = 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_acl_ptr->location = strdup(location);
|
/*
|
||||||
if (!new_acl_ptr->location) {
|
* At this point we're either a hostname or an
|
||||||
safefree(new_acl_ptr);
|
* IP address with a slash.
|
||||||
return -1;
|
*/
|
||||||
}
|
p = strchr (location, '/');
|
||||||
|
if (p != NULL) {
|
||||||
|
char dst[sizeof(struct in6_addr)];
|
||||||
|
int v6;
|
||||||
|
|
||||||
*rev_acl_ptr = new_acl_ptr;
|
/*
|
||||||
new_acl_ptr->next = acl_ptr;
|
* We have a slash, so it's intended to be an
|
||||||
|
* IP address with mask
|
||||||
return 0;
|
*/
|
||||||
|
*p = '\0';
|
||||||
|
if (full_inet_pton (location, ip_dst) <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
acl.type = ACL_NUMERIC;
|
||||||
|
|
||||||
|
/* Check if the IP address before the netmask is
|
||||||
|
* an IPv6 address */
|
||||||
|
if (inet_pton(AF_INET6, location, dst) > 0)
|
||||||
|
v6 = 1;
|
||||||
|
else
|
||||||
|
v6 = 0;
|
||||||
|
|
||||||
|
if (fill_netmask_array
|
||||||
|
(p + 1, v6, &(acl.address.ip.mask[0]), IPV6_LEN)
|
||||||
|
< 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < IPV6_LEN; i++)
|
||||||
|
acl.address.ip.network[i] = ip_dst[i] &
|
||||||
|
acl.address.ip.mask[i];
|
||||||
|
} else {
|
||||||
|
/* In all likelihood a string */
|
||||||
|
acl.type = ACL_STRING;
|
||||||
|
acl.address.string = safestrdup (location);
|
||||||
|
if (!acl.address.string)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = vector_append (*access_list, &acl, sizeof (struct acl_s));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks where file descriptor is allowed.
|
* This function is called whenever a "string" access control is found in
|
||||||
|
* the ACL. From here we do both a text based string comparison, along with
|
||||||
|
* a reverse name lookup comparison of the IP addresses.
|
||||||
|
*
|
||||||
|
* Return: 0 if host is denied
|
||||||
|
* 1 if host is allowed
|
||||||
|
* -1 if no tests match, so skip
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
acl_string_processing (struct acl_s *acl,
|
||||||
|
const char *ip_address, const char *string_address)
|
||||||
|
{
|
||||||
|
int match;
|
||||||
|
struct addrinfo hints, *res, *ressave;
|
||||||
|
size_t test_length, match_length;
|
||||||
|
char ipbuf[512];
|
||||||
|
|
||||||
|
assert (acl && acl->type == ACL_STRING);
|
||||||
|
assert (ip_address && strlen (ip_address) > 0);
|
||||||
|
assert (string_address && strlen (string_address) > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the first character of the ACL string is a period, we need to
|
||||||
|
* do a string based test only; otherwise, we can do a reverse
|
||||||
|
* lookup test as well.
|
||||||
|
*/
|
||||||
|
if (acl->address.string[0] != '.') {
|
||||||
|
memset (&hints, 0, sizeof (struct addrinfo));
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
if (getaddrinfo (acl->address.string, NULL, &hints, &res) != 0)
|
||||||
|
goto STRING_TEST;
|
||||||
|
|
||||||
|
ressave = res;
|
||||||
|
|
||||||
|
match = FALSE;
|
||||||
|
do {
|
||||||
|
get_ip_string (res->ai_addr, ipbuf, sizeof (ipbuf));
|
||||||
|
if (strcmp (ip_address, ipbuf) == 0) {
|
||||||
|
match = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while ((res = res->ai_next) != NULL);
|
||||||
|
|
||||||
|
freeaddrinfo (ressave);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
if (acl->access == ACL_DENY)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STRING_TEST:
|
||||||
|
test_length = strlen (string_address);
|
||||||
|
match_length = strlen (acl->address.string);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the string length is shorter than AC string, return a -1 so
|
||||||
|
* that the "driver" will skip onto the next control in the list.
|
||||||
|
*/
|
||||||
|
if (test_length < match_length)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (strcasecmp
|
||||||
|
(string_address + (test_length - match_length),
|
||||||
|
acl->address.string) == 0) {
|
||||||
|
if (acl->access == ACL_DENY)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Indicate that no tests succeeded, so skip to next control. */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare the supplied numeric IP address with the supplied ACL structure.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* 1 IP address is allowed
|
||||||
|
* 0 IP address is denied
|
||||||
|
* -1 neither allowed nor denied.
|
||||||
|
*/
|
||||||
|
static int check_numeric_acl (const struct acl_s *acl, const char *ip)
|
||||||
|
{
|
||||||
|
uint8_t addr[IPV6_LEN], x, y;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
assert (acl && acl->type == ACL_NUMERIC);
|
||||||
|
assert (ip && strlen (ip) > 0);
|
||||||
|
|
||||||
|
if (full_inet_pton (ip, &addr) <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i != IPV6_LEN; ++i) {
|
||||||
|
x = addr[i] & acl->address.ip.mask[i];
|
||||||
|
y = acl->address.ip.network[i];
|
||||||
|
|
||||||
|
/* If x and y don't match, the IP addresses don't match */
|
||||||
|
if (x != y)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The addresses match, return the permission */
|
||||||
|
return (acl->access == ACL_ALLOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks whether a connection is allowed.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* 1 if allowed
|
* 1 if allowed
|
||||||
* 0 if denied
|
* 0 if denied
|
||||||
* -1 if error
|
|
||||||
*/
|
*/
|
||||||
int check_acl(int fd)
|
int check_acl (const char *ip, const char *host, vector_t access_list)
|
||||||
{
|
{
|
||||||
struct acl_s *aclptr;
|
struct acl_s *acl;
|
||||||
char ip_address[PEER_IP_LENGTH];
|
int perm = 0;
|
||||||
char string_address[PEER_STRING_LENGTH];
|
size_t i;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert (ip != NULL);
|
||||||
|
assert (host != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is no access list allow everything.
|
* If there is no access list allow everything.
|
||||||
*/
|
*/
|
||||||
aclptr = access_list;
|
if (!access_list)
|
||||||
if (!aclptr)
|
return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
/*
|
for (i = 0; i != (size_t) vector_length (access_list); ++i) {
|
||||||
* Get the IP address and the string domain.
|
acl = (struct acl_s *) vector_getentry (access_list, i, NULL);
|
||||||
*/
|
switch (acl->type) {
|
||||||
getpeer_ip(fd, ip_address);
|
case ACL_STRING:
|
||||||
getpeer_string(fd, string_address);
|
perm = acl_string_processing (acl, ip, host);
|
||||||
|
break;
|
||||||
|
|
||||||
while (aclptr) {
|
case ACL_NUMERIC:
|
||||||
if (aclptr->type == ACL_STRING) {
|
if (ip[0] == '\0')
|
||||||
size_t test_length = strlen(string_address);
|
continue;
|
||||||
size_t match_length = strlen(aclptr->location);
|
perm = check_numeric_acl (acl, ip);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (test_length < match_length) {
|
/*
|
||||||
aclptr = aclptr->next;
|
* Check the return value too see if the IP address is
|
||||||
continue;
|
* allowed or denied.
|
||||||
}
|
*/
|
||||||
|
if (perm == 0)
|
||||||
|
break;
|
||||||
|
else if (perm == 1)
|
||||||
|
return perm;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcasecmp(string_address + (test_length - match_length), aclptr->location) == 0) {
|
/*
|
||||||
if (aclptr->acl_access == ACL_DENY) {
|
* Deny all connections by default.
|
||||||
log_message(LOG_NOTICE, "Unauthorized access from %s", string_address);
|
*/
|
||||||
return 0;
|
log_message (LOG_NOTICE, "Unauthorized connection from \"%s\" [%s].",
|
||||||
} else {
|
host, ip);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
void flush_access_list (vector_t access_list)
|
||||||
struct in_addr test_addr, match_addr;
|
{
|
||||||
in_addr_t netmask_addr;
|
struct acl_s *acl;
|
||||||
|
size_t i;
|
||||||
if (ip_address[0] == 0) {
|
|
||||||
aclptr = aclptr->next;
|
if (!access_list) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inet_aton(ip_address, &test_addr);
|
/*
|
||||||
inet_aton(aclptr->location, &match_addr);
|
* We need to free allocated data hanging off the acl entries
|
||||||
|
* before we can free the acl entries themselves.
|
||||||
netmask_addr = make_netmask(aclptr->netmask);
|
* A hierarchical memory system would be great...
|
||||||
|
*/
|
||||||
if ((test_addr.s_addr & netmask_addr) == (match_addr.s_addr & netmask_addr)) {
|
for (i = 0; i != (size_t) vector_length (access_list); ++i) {
|
||||||
if (aclptr->acl_access == ACL_DENY) {
|
acl = (struct acl_s *) vector_getentry (access_list, i, NULL);
|
||||||
log_message(LOG_NOTICE, "Unauthorized access from %s", ip_address);
|
if (acl->type == ACL_STRING) {
|
||||||
return 0;
|
safefree (acl->address.string);
|
||||||
} else {
|
}
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
}
|
vector_delete (access_list);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Dropped through... go on to the next one.
|
|
||||||
*/
|
|
||||||
aclptr = aclptr->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deny all connections by default.
|
|
||||||
*/
|
|
||||||
log_message(LOG_NOTICE, "Unauthorized connection from %s [%s]", string_address, ip_address);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,34 @@
|
|||||||
/* $Id: acl.h,v 1.2 2001-06-02 02:07:34 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2000 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* See 'acl.c' for detailed information.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* See 'acl.c' for detailed information. */
|
||||||
|
|
||||||
#ifndef TINYPROXY_ACL_H
|
#ifndef TINYPROXY_ACL_H
|
||||||
#define TINYPROXY_ACL_H
|
#define TINYPROXY_ACL_H
|
||||||
|
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
typedef enum { ACL_ALLOW, ACL_DENY } acl_access_t;
|
typedef enum { ACL_ALLOW, ACL_DENY } acl_access_t;
|
||||||
|
|
||||||
extern int insert_acl(char *location, acl_access_t access_type);
|
extern int insert_acl (char *location, acl_access_t access_type,
|
||||||
extern int check_acl(int fd);
|
vector_t *access_list);
|
||||||
|
extern int check_acl (const char *ip_address, const char *string_address,
|
||||||
|
vector_t access_list);
|
||||||
|
extern void flush_access_list (vector_t access_list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+55
-58
@@ -1,76 +1,73 @@
|
|||||||
/* $Id: anonymous.c,v 1.6 2001-08-26 21:07:27 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2000 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* Handles insertion and searches for headers which should be let through when
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* the anonymous feature is turned on. The headers are stored in a Ternary
|
* it under the terms of the GNU General Public License as published by
|
||||||
* Search Tree. The initial code came from Dr. Dobb's Journal, April 1998
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* "Ternary Search Trees", Jon Bentley and Bob Sedgewick, pg 20-25.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
/* Handles insertion and searches for headers which should be let through
|
||||||
# include <config.h>
|
* when the anonymous feature is turned on.
|
||||||
#endif
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include "main.h"
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "anonymous.h"
|
#include "anonymous.h"
|
||||||
|
#include "hashmap.h"
|
||||||
|
#include "heap.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "ternary.h"
|
#include "conf.h"
|
||||||
#include "tinyproxy.h"
|
|
||||||
|
short int is_anonymous_enabled (void)
|
||||||
|
{
|
||||||
|
return (config.anonymous_map != NULL) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
static TERNARY anonymous_tree = 0;
|
|
||||||
/*
|
/*
|
||||||
* Keep track of whether the Anonymous filtering is enabled. Off by
|
* Search for the header. This function returns a positive value greater than
|
||||||
* default.
|
* zero if the string was found, zero if it wasn't and negative upon error.
|
||||||
*/
|
*/
|
||||||
static short int anonymous_is_enabled = 0;
|
int anonymous_search (const char *s)
|
||||||
|
|
||||||
short int is_anonymous_enabled(void)
|
|
||||||
{
|
{
|
||||||
return anonymous_is_enabled;
|
assert (s != NULL);
|
||||||
|
assert (config.anonymous_map != NULL);
|
||||||
|
|
||||||
|
return hashmap_search (config.anonymous_map, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int anonymous_search(char *s)
|
/*
|
||||||
|
* Insert a new header.
|
||||||
|
*
|
||||||
|
* Return -1 if there is an error, otherwise a 0 is returned if the insert was
|
||||||
|
* successful.
|
||||||
|
*/
|
||||||
|
int anonymous_insert (const char *s)
|
||||||
{
|
{
|
||||||
assert(s != NULL);
|
char data = 1;
|
||||||
assert(anonymous_is_enabled == 1);
|
|
||||||
assert(anonymous_tree > 0);
|
|
||||||
|
|
||||||
return ternary_search(anonymous_tree, s, NULL);
|
assert (s != NULL);
|
||||||
}
|
|
||||||
|
if (!config.anonymous_map) {
|
||||||
int anonymous_insert(char *s)
|
config.anonymous_map = hashmap_create (32);
|
||||||
{
|
if (!config.anonymous_map)
|
||||||
assert(s != NULL);
|
return -1;
|
||||||
|
}
|
||||||
/*
|
|
||||||
* If this is the first time we're inserting a word, create the
|
if (hashmap_search (config.anonymous_map, s) > 0) {
|
||||||
* search tree.
|
/* The key was already found, so return a positive number. */
|
||||||
*/
|
return 0;
|
||||||
if (!anonymous_is_enabled) {
|
}
|
||||||
anonymous_tree = ternary_new();
|
|
||||||
if (anonymous_tree < 0)
|
/* Insert the new key */
|
||||||
return -1;
|
return hashmap_insert (config.anonymous_map, s, &data, sizeof (data));
|
||||||
|
|
||||||
anonymous_is_enabled = 1;
|
|
||||||
|
|
||||||
DEBUG1("Starting the Anonymous header subsytem.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ternary_insert(anonymous_tree, s, NULL);
|
|
||||||
}
|
}
|
||||||
+18
-17
@@ -1,27 +1,28 @@
|
|||||||
/* $Id: anonymous.h,v 1.5 2001-08-26 21:07:27 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2000 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* See 'anonymous.c' for a detailed description.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* See 'anonymous.c' for detailed information. */
|
||||||
|
|
||||||
#ifndef _TINYPROXY_ANONYMOUS_H_
|
#ifndef _TINYPROXY_ANONYMOUS_H_
|
||||||
#define _TINYPROXY_ANONYMOUS_H_
|
#define _TINYPROXY_ANONYMOUS_H_
|
||||||
|
|
||||||
#include "ternary.h"
|
extern short int is_anonymous_enabled (void);
|
||||||
|
extern int anonymous_search (const char *s);
|
||||||
extern short int is_anonymous_enabled(void);
|
extern int anonymous_insert (const char *s);
|
||||||
extern int anonymous_search(char *s);
|
|
||||||
extern int anonymous_insert(char *s);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* this file Copyright (C) 2016-2018 rofl0r
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "base64.h"
|
||||||
|
|
||||||
|
static const char base64_tbl[64] =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
/*
|
||||||
|
rofl0r's base64 impl (taken from libulz)
|
||||||
|
takes count bytes from src, writing base64 encoded string into dst.
|
||||||
|
dst needs to be at least BASE64ENC_BYTES(count) + 1 bytes in size.
|
||||||
|
the string in dst will be zero-terminated.
|
||||||
|
*/
|
||||||
|
void base64enc(char *dst, const void* src, size_t count)
|
||||||
|
{
|
||||||
|
unsigned const char *s = src;
|
||||||
|
char* d = dst;
|
||||||
|
while(count) {
|
||||||
|
int i = 0, n = *s << 16;
|
||||||
|
s++;
|
||||||
|
count--;
|
||||||
|
if(count) {
|
||||||
|
n |= *s << 8;
|
||||||
|
s++;
|
||||||
|
count--;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if(count) {
|
||||||
|
n |= *s;
|
||||||
|
s++;
|
||||||
|
count--;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
*d++ = base64_tbl[(n >> 18) & 0x3f];
|
||||||
|
*d++ = base64_tbl[(n >> 12) & 0x3f];
|
||||||
|
*d++ = i ? base64_tbl[(n >> 6) & 0x3f] : '=';
|
||||||
|
*d++ = i == 2 ? base64_tbl[n & 0x3f] : '=';
|
||||||
|
}
|
||||||
|
*d = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* this file Copyright (C) 2016-2018 rofl0r
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_BASE64_H
|
||||||
|
#define TINYPROXY_BASE64_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* calculates number of bytes base64-encoded stream of N bytes will take. */
|
||||||
|
#define BASE64ENC_BYTES(N) (((N+2)/3)*4)
|
||||||
|
void base64enc(char *dst, const void* src, size_t count);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* This file: Copyright (C) 2016-2017 rofl0r
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "basicauth.h"
|
||||||
|
|
||||||
|
#include "conns.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "html-error.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "conf.h"
|
||||||
|
#include "base64.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create basic-auth token in buf.
|
||||||
|
* Returns strlen of token on success,
|
||||||
|
* -1 if user/pass missing
|
||||||
|
* 0 if user/pass too long
|
||||||
|
*/
|
||||||
|
ssize_t basicauth_string(const char *user, const char *pass,
|
||||||
|
char *buf, size_t bufsize)
|
||||||
|
{
|
||||||
|
char tmp[256+2];
|
||||||
|
int l;
|
||||||
|
if (!user || !pass) return -1;
|
||||||
|
l = snprintf(tmp, sizeof tmp, "%s:%s", user, pass);
|
||||||
|
if (l < 0 || l >= (ssize_t) sizeof tmp) return 0;
|
||||||
|
if (bufsize < (BASE64ENC_BYTES((unsigned)l) + 1)) return 0;
|
||||||
|
base64enc(buf, tmp, l);
|
||||||
|
return BASE64ENC_BYTES(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add entry to the basicauth list
|
||||||
|
*/
|
||||||
|
void basicauth_add (vector_t authlist,
|
||||||
|
const char *user, const char *pass)
|
||||||
|
{
|
||||||
|
char b[BASE64ENC_BYTES((256+2)-1) + 1];
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
|
ret = basicauth_string(user, pass, b, sizeof b);
|
||||||
|
if (ret == -1) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Illegal basicauth rule: missing user or pass");
|
||||||
|
return;
|
||||||
|
} else if (ret == 0) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"User / pass in basicauth rule too long");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vector_append(authlist, b, ret + 1) == -ENOMEM) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Unable to allocate memory in basicauth_add()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message (LOG_INFO,
|
||||||
|
"Added basic auth user : %s", user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if a user/password combination (encoded as base64)
|
||||||
|
* is in the basicauth list.
|
||||||
|
* return 1 on success, 0 on failure.
|
||||||
|
*/
|
||||||
|
int basicauth_check (vector_t authlist, const char *authstring)
|
||||||
|
{
|
||||||
|
ssize_t vl, i;
|
||||||
|
size_t el;
|
||||||
|
const char* entry;
|
||||||
|
|
||||||
|
vl = vector_length (authlist);
|
||||||
|
if (vl == -EINVAL) return 0;
|
||||||
|
|
||||||
|
for (i = 0; i < vl; i++) {
|
||||||
|
entry = vector_getentry (authlist, i, &el);
|
||||||
|
if (strcmp (authstring, entry) == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2005 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'basicauth.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_BASICAUTH_H
|
||||||
|
#define TINYPROXY_BASICAUTH_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
extern ssize_t basicauth_string(const char *user, const char *pass,
|
||||||
|
char *buf, size_t bufsize);
|
||||||
|
|
||||||
|
extern void basicauth_add (vector_t authlist,
|
||||||
|
const char *user, const char *pass);
|
||||||
|
|
||||||
|
extern int basicauth_check (vector_t authlist, const char *authstring);
|
||||||
|
|
||||||
|
#endif
|
||||||
+216
-173
@@ -1,278 +1,321 @@
|
|||||||
/* $Id: buffer.c,v 1.5 2001-05-27 02:23:08 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1999, 2001 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* The buffer used in each connection is a linked list of lines. As the lines
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The buffer used in each connection is a linked list of lines. As the lines
|
||||||
* are read in and written out the buffer expands and contracts. Basically,
|
* are read in and written out the buffer expands and contracts. Basically,
|
||||||
* by using this method we can increase the buffer size dynamicly. However,
|
* by using this method we can increase the buffer size dynamically. However,
|
||||||
* we have a hard limit of 64 KB for the size of the buffer. The buffer can be
|
* we have a hard limit of 64 KB for the size of the buffer. The buffer can be
|
||||||
* thought of as a queue were we act on both the head and tail. The various
|
* thought of as a queue were we act on both the head and tail. The various
|
||||||
* functions act on each end (the names are taken from what Perl uses to act on
|
* functions act on each end (the names are taken from what Perl uses to act on
|
||||||
* the ends of an array. :)
|
* the ends of an array. :)
|
||||||
*
|
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "heap.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#define BUFFER_HEAD(x) (((struct buffer_s *)(x))->head)
|
#define BUFFER_HEAD(x) (x)->head
|
||||||
#define BUFFER_TAIL(x) (((struct buffer_s *)(x))->tail)
|
#define BUFFER_TAIL(x) (x)->tail
|
||||||
|
|
||||||
struct bufline_s {
|
struct bufline_s {
|
||||||
unsigned char *string; /* the actual string of data */
|
unsigned char *string; /* the actual string of data */
|
||||||
struct bufline_s *next; /* pointer to next in linked list */
|
struct bufline_s *next; /* pointer to next in linked list */
|
||||||
size_t length; /* length of the string of data */
|
size_t length; /* length of the string of data */
|
||||||
size_t pos; /* start sending from this offset */
|
size_t pos; /* start sending from this offset */
|
||||||
};
|
|
||||||
|
|
||||||
struct buffer_s {
|
|
||||||
struct bufline_s *head; /* top of the buffer */
|
|
||||||
struct bufline_s *tail; /* bottom of the buffer */
|
|
||||||
size_t size; /* total size of the buffer */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the size of the supplied buffer.
|
* The buffer structure points to the beginning and end of the buffer list
|
||||||
|
* (and includes the total size)
|
||||||
*/
|
*/
|
||||||
size_t buffer_size(struct buffer_s *buffptr)
|
struct buffer_s {
|
||||||
{
|
struct bufline_s *head; /* top of the buffer */
|
||||||
assert(buffptr != NULL);
|
struct bufline_s *tail; /* bottom of the buffer */
|
||||||
|
size_t size; /* total size of the buffer */
|
||||||
return buffptr->size;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take a string of data and a length and make a new line which can be added
|
* Take a string of data and a length and make a new line which can be added
|
||||||
* to the buffer
|
* to the buffer. The data IS copied, so make sure if you allocated your
|
||||||
|
* data buffer on the heap, delete it because you now have TWO copies.
|
||||||
*/
|
*/
|
||||||
static struct bufline_s *makenewline(unsigned char *data, size_t length)
|
static struct bufline_s *makenewline (unsigned char *data, size_t length)
|
||||||
{
|
{
|
||||||
struct bufline_s *newline;
|
struct bufline_s *newline;
|
||||||
|
|
||||||
assert(data != NULL);
|
assert (data != NULL);
|
||||||
|
assert (length > 0);
|
||||||
|
|
||||||
if (!(newline = malloc(sizeof(struct bufline_s))))
|
newline = (struct bufline_s *) safemalloc (sizeof (struct bufline_s));
|
||||||
return NULL;
|
if (!newline)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
newline->string = data;
|
newline->string = (unsigned char *) safemalloc (length);
|
||||||
newline->next = NULL;
|
if (!newline->string) {
|
||||||
newline->length = length;
|
safefree (newline);
|
||||||
newline->pos = 0;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return newline;
|
memcpy (newline->string, data, length);
|
||||||
|
|
||||||
|
newline->next = NULL;
|
||||||
|
newline->length = length;
|
||||||
|
|
||||||
|
/* Position our "read" pointer at the beginning of the data */
|
||||||
|
newline->pos = 0;
|
||||||
|
|
||||||
|
return newline;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the allocated buffer line
|
* Free the allocated buffer line
|
||||||
*/
|
*/
|
||||||
static void free_line(struct bufline_s *line)
|
static void free_line (struct bufline_s *line)
|
||||||
{
|
{
|
||||||
assert(line != NULL);
|
assert (line != NULL);
|
||||||
|
|
||||||
if (!line)
|
if (!line)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (line->string) {
|
if (line->string)
|
||||||
safefree(line->string);
|
safefree (line->string);
|
||||||
}
|
|
||||||
|
|
||||||
safefree(line);
|
safefree (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new buffer
|
* Create a new buffer
|
||||||
*/
|
*/
|
||||||
struct buffer_s *new_buffer(void)
|
struct buffer_s *new_buffer (void)
|
||||||
{
|
{
|
||||||
struct buffer_s *buffptr;
|
struct buffer_s *buffptr;
|
||||||
|
|
||||||
if (!(buffptr = malloc(sizeof(struct buffer_s))))
|
buffptr = (struct buffer_s *) safemalloc (sizeof (struct buffer_s));
|
||||||
return NULL;
|
if (!buffptr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
buffptr->head = buffptr->tail = NULL;
|
/*
|
||||||
buffptr->size = 0;
|
* Since the buffer is initially empty, set the HEAD and TAIL
|
||||||
|
* pointers to NULL since they can't possibly point anywhere at the
|
||||||
|
* moment.
|
||||||
|
*/
|
||||||
|
BUFFER_HEAD (buffptr) = BUFFER_TAIL (buffptr) = NULL;
|
||||||
|
buffptr->size = 0;
|
||||||
|
|
||||||
return buffptr;
|
return buffptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete all the lines in the buffer and the buffer itself
|
* Delete all the lines in the buffer and the buffer itself
|
||||||
*/
|
*/
|
||||||
void delete_buffer(struct buffer_s *buffptr)
|
void delete_buffer (struct buffer_s *buffptr)
|
||||||
{
|
{
|
||||||
struct bufline_s *next;
|
struct bufline_s *next;
|
||||||
|
|
||||||
assert(buffptr != NULL);
|
assert (buffptr != NULL);
|
||||||
|
|
||||||
while (BUFFER_HEAD(buffptr)) {
|
while (BUFFER_HEAD (buffptr)) {
|
||||||
next = BUFFER_HEAD(buffptr)->next;
|
next = BUFFER_HEAD (buffptr)->next;
|
||||||
free_line(BUFFER_HEAD(buffptr));
|
free_line (BUFFER_HEAD (buffptr));
|
||||||
BUFFER_HEAD(buffptr) = next;
|
BUFFER_HEAD (buffptr) = next;
|
||||||
}
|
}
|
||||||
BUFFER_HEAD(buffptr) = NULL;
|
|
||||||
BUFFER_TAIL(buffptr) = NULL;
|
|
||||||
|
|
||||||
safefree(buffptr);
|
safefree (buffptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Push a new line on to the end of the buffer
|
* Return the current size of the buffer.
|
||||||
*/
|
*/
|
||||||
static int add_to_buffer(struct buffer_s *buffptr, unsigned char *data,
|
size_t buffer_size (struct buffer_s *buffptr)
|
||||||
size_t length)
|
|
||||||
{
|
{
|
||||||
struct bufline_s *newline;
|
return buffptr->size;
|
||||||
|
|
||||||
assert(buffptr != NULL);
|
|
||||||
assert(data != NULL);
|
|
||||||
|
|
||||||
if (!(newline = makenewline(data, length)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr))
|
|
||||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = newline;
|
|
||||||
else
|
|
||||||
BUFFER_TAIL(buffptr) = (BUFFER_TAIL(buffptr)->next = newline);
|
|
||||||
|
|
||||||
buffptr->size += length;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shift a line off the top of the buffer (remove the line from the top of
|
* Push a new line on to the end of the buffer.
|
||||||
* the buffer)
|
|
||||||
*/
|
*/
|
||||||
static struct bufline_s *remove_from_buffer(struct buffer_s *buffptr)
|
int add_to_buffer (struct buffer_s *buffptr, unsigned char *data, size_t length)
|
||||||
{
|
{
|
||||||
struct bufline_s *line;
|
struct bufline_s *newline;
|
||||||
|
|
||||||
assert(buffptr != NULL);
|
assert (buffptr != NULL);
|
||||||
|
assert (data != NULL);
|
||||||
|
assert (length > 0);
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr) && !BUFFER_TAIL(buffptr)) {
|
/*
|
||||||
line = BUFFER_HEAD(buffptr);
|
* Sanity check here. A buffer with a non-NULL head pointer must
|
||||||
BUFFER_HEAD(buffptr) = BUFFER_TAIL(buffptr) = NULL;
|
* have a size greater than zero, and vice-versa.
|
||||||
buffptr->size = 0;
|
*/
|
||||||
return line;
|
if (BUFFER_HEAD (buffptr) == NULL)
|
||||||
}
|
assert (buffptr->size == 0);
|
||||||
|
else
|
||||||
|
assert (buffptr->size > 0);
|
||||||
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
/*
|
||||||
BUFFER_HEAD(buffptr) = line->next;
|
* Make a new line so we can add it to the buffer.
|
||||||
|
*/
|
||||||
|
if (!(newline = makenewline (data, length)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!BUFFER_HEAD(buffptr))
|
if (buffptr->size == 0)
|
||||||
BUFFER_TAIL(buffptr) = NULL;
|
BUFFER_HEAD (buffptr) = BUFFER_TAIL (buffptr) = newline;
|
||||||
|
else {
|
||||||
|
BUFFER_TAIL (buffptr)->next = newline;
|
||||||
|
BUFFER_TAIL (buffptr) = newline;
|
||||||
|
}
|
||||||
|
|
||||||
buffptr->size -= line->length;
|
buffptr->size += length;
|
||||||
|
|
||||||
return line;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove the first line from the top of the buffer
|
||||||
|
*/
|
||||||
|
static struct bufline_s *remove_from_buffer (struct buffer_s *buffptr)
|
||||||
|
{
|
||||||
|
struct bufline_s *line;
|
||||||
|
|
||||||
|
assert (buffptr != NULL);
|
||||||
|
assert (BUFFER_HEAD (buffptr) != NULL);
|
||||||
|
|
||||||
|
line = BUFFER_HEAD (buffptr);
|
||||||
|
BUFFER_HEAD (buffptr) = line->next;
|
||||||
|
|
||||||
|
buffptr->size -= line->length;
|
||||||
|
|
||||||
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads the bytes from the socket, and adds them to the buffer.
|
* Reads the bytes from the socket, and adds them to the buffer.
|
||||||
* Takes a connection and returns the number of bytes read.
|
* Takes a connection and returns the number of bytes read.
|
||||||
*/
|
*/
|
||||||
ssize_t readbuff(int fd, struct buffer_s *buffptr)
|
#define READ_BUFFER_SIZE (1024 * 2)
|
||||||
|
ssize_t read_buffer (int fd, struct buffer_s * buffptr)
|
||||||
{
|
{
|
||||||
ssize_t bytesin;
|
ssize_t bytesin;
|
||||||
unsigned char inbuf[MAXBUFFSIZE];
|
unsigned char *buffer;
|
||||||
unsigned char *buffer;
|
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert (fd >= 0);
|
||||||
assert(buffptr != NULL);
|
assert (buffptr != NULL);
|
||||||
|
|
||||||
if (buffer_size(buffptr) >= MAXBUFFSIZE)
|
/*
|
||||||
return 0;
|
* Don't allow the buffer to grow larger than MAXBUFFSIZE
|
||||||
|
*/
|
||||||
|
if (buffptr->size >= MAXBUFFSIZE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
bytesin = read(fd, inbuf, MAXBUFFSIZE - buffer_size(buffptr));
|
buffer = (unsigned char *) safemalloc (READ_BUFFER_SIZE);
|
||||||
|
if (!buffer) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
if (bytesin > 0) {
|
bytesin = read (fd, buffer, READ_BUFFER_SIZE);
|
||||||
if (!(buffer = malloc(bytesin))) {
|
|
||||||
log_message(LOG_CRIT, "Could not allocate memory in readbuff() [%s:%d]", __FILE__, __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(buffer, inbuf, bytesin);
|
if (bytesin > 0) {
|
||||||
if (add_to_buffer(buffptr, buffer, bytesin) < 0) {
|
if (add_to_buffer (buffptr, buffer, bytesin) < 0) {
|
||||||
return -1;
|
log_message (LOG_ERR,
|
||||||
}
|
"readbuff: add_to_buffer() error.");
|
||||||
|
bytesin = -1;
|
||||||
return bytesin;
|
}
|
||||||
} else if (bytesin == 0) {
|
} else if (bytesin == 0) {
|
||||||
/* connection was closed by client */
|
/* connection was closed by client */
|
||||||
return -1;
|
bytesin = -1;
|
||||||
} else {
|
} else {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
#ifdef EWOULDBLOCK
|
#ifdef EWOULDBLOCK
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#else
|
#else
|
||||||
# ifdef EAGAIN
|
# ifdef EAGAIN
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
case EINTR:
|
case EINTR:
|
||||||
return 0;
|
bytesin = 0;
|
||||||
default:
|
break;
|
||||||
log_message(LOG_ERR, "readbuff: recv (%s)", strerror(errno));
|
default:
|
||||||
return -1;
|
log_message (LOG_ERR,
|
||||||
}
|
"read_buffer: read() failed on fd %d: %s",
|
||||||
}
|
fd, strerror(errno));
|
||||||
|
bytesin = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
safefree (buffer);
|
||||||
|
return bytesin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write the bytes in the buffer to the socket.
|
* Write the bytes in the buffer to the socket.
|
||||||
* Takes a connection and returns the number of bytes written.
|
* Takes a connection and returns the number of bytes written.
|
||||||
*/
|
*/
|
||||||
ssize_t writebuff(int fd, struct buffer_s *buffptr)
|
ssize_t write_buffer (int fd, struct buffer_s * buffptr)
|
||||||
{
|
{
|
||||||
ssize_t bytessent;
|
ssize_t bytessent;
|
||||||
struct bufline_s *line;
|
struct bufline_s *line;
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert (fd >= 0);
|
||||||
assert(buffptr != NULL);
|
assert (buffptr != NULL);
|
||||||
|
|
||||||
line = BUFFER_HEAD(buffptr);
|
if (buffptr->size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (buffer_size(buffptr) <= 0)
|
/* Sanity check. It would be bad to be using a NULL pointer! */
|
||||||
return 0;
|
assert (BUFFER_HEAD (buffptr) != NULL);
|
||||||
|
line = BUFFER_HEAD (buffptr);
|
||||||
|
|
||||||
bytessent = write(fd, line->string + line->pos, line->length - line->pos);
|
bytessent =
|
||||||
|
send (fd, line->string + line->pos, line->length - line->pos,
|
||||||
|
MSG_NOSIGNAL);
|
||||||
|
|
||||||
if (bytessent >= 0) {
|
if (bytessent >= 0) {
|
||||||
/* bytes sent, adjust buffer */
|
/* bytes sent, adjust buffer */
|
||||||
line->pos += bytessent;
|
line->pos += bytessent;
|
||||||
if (line->pos == line->length)
|
if (line->pos == line->length)
|
||||||
free_line(remove_from_buffer(buffptr));
|
free_line (remove_from_buffer (buffptr));
|
||||||
return bytessent;
|
return bytessent;
|
||||||
} else {
|
} else {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
#ifdef EWOULDBLOCK
|
#ifdef EWOULDBLOCK
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#else
|
#else
|
||||||
# ifdef EAGAIN
|
# ifdef EAGAIN
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
case EINTR:
|
case EINTR:
|
||||||
return 0;
|
return 0;
|
||||||
case ENOBUFS:
|
case ENOBUFS:
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
log_message(LOG_ERR, "writebuff: send [NOBUFS/NOMEM] %s", strerror(errno));
|
log_message (LOG_ERR,
|
||||||
return 0;
|
"writebuff: write() error [NOBUFS/NOMEM] \"%s\" on "
|
||||||
default:
|
"file descriptor %d", strerror (errno),
|
||||||
log_message(LOG_ERR, "writebuff: send (%s)", strerror(errno));
|
fd);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
default:
|
||||||
}
|
log_message (LOG_ERR,
|
||||||
|
"writebuff: write() error \"%s\" on file descriptor %d",
|
||||||
|
strerror (errno), fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+30
-18
@@ -1,28 +1,40 @@
|
|||||||
/* $Id: buffer.h,v 1.4 2001-05-27 02:23:08 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1999 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* See 'buffer.c' for a detailed description.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* See 'buffer.c' for detailed information. */
|
||||||
|
|
||||||
#ifndef _TINYPROXY_BUFFER_H_
|
#ifndef _TINYPROXY_BUFFER_H_
|
||||||
#define _TINYPROXY_BUFFER_H_
|
#define _TINYPROXY_BUFFER_H_
|
||||||
|
|
||||||
extern struct buffer_s *new_buffer(void);
|
/* Forward declaration */
|
||||||
extern void delete_buffer(struct buffer_s *buffptr);
|
struct buffer_s;
|
||||||
extern size_t buffer_size(struct buffer_s *buffptr);
|
|
||||||
|
|
||||||
extern ssize_t readbuff(int fd, struct buffer_s *buffptr);
|
extern struct buffer_s *new_buffer (void);
|
||||||
extern ssize_t writebuff(int fd, struct buffer_s *buffptr);
|
extern void delete_buffer (struct buffer_s *buffptr);
|
||||||
|
extern size_t buffer_size (struct buffer_s *buffptr);
|
||||||
|
|
||||||
#endif /* __BUFFER_H_ */
|
/*
|
||||||
|
* Add a new line to the given buffer. The data IS copied into the structure.
|
||||||
|
*/
|
||||||
|
extern int add_to_buffer (struct buffer_s *buffptr, unsigned char *data,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
|
extern ssize_t read_buffer (int fd, struct buffer_s *buffptr);
|
||||||
|
extern ssize_t write_buffer (int fd, struct buffer_s *buffptr);
|
||||||
|
|
||||||
|
#endif /* __BUFFER_H_ */
|
||||||
+604
@@ -0,0 +1,604 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2000 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Handles the creation/destruction of the various children required for
|
||||||
|
* processing incoming connections.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "child.h"
|
||||||
|
#include "daemon.h"
|
||||||
|
#include "filter.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "reqs.h"
|
||||||
|
#include "sock.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
|
static vector_t listen_fds;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stores the internal data needed for each child (connection)
|
||||||
|
*/
|
||||||
|
enum child_status_t { T_EMPTY, T_WAITING, T_CONNECTED };
|
||||||
|
struct child_s {
|
||||||
|
pid_t tid;
|
||||||
|
unsigned int connects;
|
||||||
|
enum child_status_t status;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A pointer to an array of children. A certain number of children are
|
||||||
|
* created when the program is started.
|
||||||
|
*/
|
||||||
|
static struct child_s *child_ptr;
|
||||||
|
|
||||||
|
static struct child_config_s {
|
||||||
|
unsigned int maxclients, maxrequestsperchild;
|
||||||
|
unsigned int maxspareservers, minspareservers, startservers;
|
||||||
|
} child_config;
|
||||||
|
|
||||||
|
static unsigned int *servers_waiting; /* servers waiting for a connection */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock/Unlock the "servers_waiting" variable so that two children cannot
|
||||||
|
* modify it at the same time.
|
||||||
|
*/
|
||||||
|
#define SERVER_COUNT_LOCK() _child_lock_wait()
|
||||||
|
#define SERVER_COUNT_UNLOCK() _child_lock_release()
|
||||||
|
|
||||||
|
/* START OF LOCKING SECTION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These variables are required for the locking mechanism. Also included
|
||||||
|
* are the "private" functions for locking/unlocking.
|
||||||
|
*/
|
||||||
|
static struct flock lock_it, unlock_it;
|
||||||
|
static int lock_fd = -1;
|
||||||
|
|
||||||
|
static void _child_lock_init (void)
|
||||||
|
{
|
||||||
|
char lock_file[] = "/tmp/tinyproxy.servers.lock.XXXXXX";
|
||||||
|
|
||||||
|
/* Only allow u+rw bits. This may be required for some versions
|
||||||
|
* of glibc so that mkstemp() doesn't make us vulnerable.
|
||||||
|
*/
|
||||||
|
umask (0177);
|
||||||
|
|
||||||
|
lock_fd = mkstemp (lock_file);
|
||||||
|
unlink (lock_file);
|
||||||
|
|
||||||
|
lock_it.l_type = F_WRLCK;
|
||||||
|
lock_it.l_whence = SEEK_SET;
|
||||||
|
lock_it.l_start = 0;
|
||||||
|
lock_it.l_len = 0;
|
||||||
|
|
||||||
|
unlock_it.l_type = F_UNLCK;
|
||||||
|
unlock_it.l_whence = SEEK_SET;
|
||||||
|
unlock_it.l_start = 0;
|
||||||
|
unlock_it.l_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _child_lock_wait (void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
while ((rc = fcntl (lock_fd, F_SETLKW, &lock_it)) < 0) {
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _child_lock_release (void)
|
||||||
|
{
|
||||||
|
if (fcntl (lock_fd, F_SETLKW, &unlock_it) < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* END OF LOCKING SECTION */
|
||||||
|
|
||||||
|
#define SERVER_INC() do { \
|
||||||
|
SERVER_COUNT_LOCK(); \
|
||||||
|
++(*servers_waiting); \
|
||||||
|
DEBUG2("INC: servers_waiting: %d", *servers_waiting); \
|
||||||
|
SERVER_COUNT_UNLOCK(); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define SERVER_DEC() do { \
|
||||||
|
SERVER_COUNT_LOCK(); \
|
||||||
|
assert(*servers_waiting > 0); \
|
||||||
|
--(*servers_waiting); \
|
||||||
|
DEBUG2("DEC: servers_waiting: %d", *servers_waiting); \
|
||||||
|
SERVER_COUNT_UNLOCK(); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the configuration values for the various child related settings.
|
||||||
|
*/
|
||||||
|
short int child_configure (child_config_t type, unsigned int val)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case CHILD_MAXCLIENTS:
|
||||||
|
child_config.maxclients = val;
|
||||||
|
break;
|
||||||
|
case CHILD_MAXSPARESERVERS:
|
||||||
|
child_config.maxspareservers = val;
|
||||||
|
break;
|
||||||
|
case CHILD_MINSPARESERVERS:
|
||||||
|
child_config.minspareservers = val;
|
||||||
|
break;
|
||||||
|
case CHILD_STARTSERVERS:
|
||||||
|
child_config.startservers = val;
|
||||||
|
break;
|
||||||
|
case CHILD_MAXREQUESTSPERCHILD:
|
||||||
|
child_config.maxrequestsperchild = val;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DEBUG2 ("Invalid type (%d)", type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* child signal handler for sighup
|
||||||
|
*/
|
||||||
|
static void child_sighup_handler (int sig)
|
||||||
|
{
|
||||||
|
if (sig == SIGHUP) {
|
||||||
|
/*
|
||||||
|
* Ignore the return value of reload_config for now.
|
||||||
|
* This should actually be handled somehow...
|
||||||
|
*/
|
||||||
|
reload_config ();
|
||||||
|
|
||||||
|
#ifdef FILTER_ENABLE
|
||||||
|
filter_reload ();
|
||||||
|
#endif /* FILTER_ENABLE */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the main (per child) loop.
|
||||||
|
*/
|
||||||
|
static void child_main (struct child_s *ptr)
|
||||||
|
{
|
||||||
|
int connfd;
|
||||||
|
struct sockaddr *cliaddr;
|
||||||
|
socklen_t clilen;
|
||||||
|
fd_set rfds;
|
||||||
|
int maxfd = 0;
|
||||||
|
ssize_t i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
cliaddr = (struct sockaddr *)
|
||||||
|
safemalloc (sizeof(struct sockaddr_storage));
|
||||||
|
if (!cliaddr) {
|
||||||
|
log_message (LOG_CRIT,
|
||||||
|
"Could not allocate memory for child address.");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->connects = 0;
|
||||||
|
srand(time(NULL));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have to wait for connections on multiple fds,
|
||||||
|
* so use select.
|
||||||
|
*/
|
||||||
|
while (!config.quit) {
|
||||||
|
|
||||||
|
int listenfd = -1;
|
||||||
|
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
|
||||||
|
for (i = 0; i < vector_length(listen_fds); i++) {
|
||||||
|
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
|
||||||
|
|
||||||
|
ret = socket_nonblocking(*fd);
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR, "Failed to set the listening "
|
||||||
|
"socket %d to non-blocking: %s",
|
||||||
|
fd, strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
FD_SET(*fd, &rfds);
|
||||||
|
maxfd = max(maxfd, *fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->status = T_WAITING;
|
||||||
|
|
||||||
|
clilen = sizeof(struct sockaddr_storage);
|
||||||
|
|
||||||
|
ret = select(maxfd + 1, &rfds, NULL, NULL, NULL);
|
||||||
|
if (ret == -1) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
log_message (LOG_ERR, "error calling select: %s",
|
||||||
|
strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
} else if (ret == 0) {
|
||||||
|
log_message (LOG_WARNING, "Strange: select returned 0 "
|
||||||
|
"but we did not specify a timeout...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < vector_length(listen_fds); i++) {
|
||||||
|
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
|
||||||
|
|
||||||
|
if (FD_ISSET(*fd, &rfds)) {
|
||||||
|
/*
|
||||||
|
* only accept the connection on the first
|
||||||
|
* fd that we find readable. - fair?
|
||||||
|
*/
|
||||||
|
listenfd = *fd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listenfd == -1) {
|
||||||
|
log_message(LOG_WARNING, "Strange: None of our listen "
|
||||||
|
"fds was readable after select");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = socket_blocking(listenfd);
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR, "Failed to set listening "
|
||||||
|
"socket %d to blocking for accept: %s",
|
||||||
|
listenfd, strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have a socket that is readable.
|
||||||
|
* Continue handling this connection.
|
||||||
|
*/
|
||||||
|
|
||||||
|
connfd = accept (listenfd, cliaddr, &clilen);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
/*
|
||||||
|
* Enable the TINYPROXY_DEBUG environment variable if you
|
||||||
|
* want to use the GDB debugger.
|
||||||
|
*/
|
||||||
|
if (getenv ("TINYPROXY_DEBUG")) {
|
||||||
|
/* Pause for 10 seconds to allow us to connect debugger */
|
||||||
|
fprintf (stderr,
|
||||||
|
"Process has accepted connection: %ld\n",
|
||||||
|
(long int) ptr->tid);
|
||||||
|
sleep (10);
|
||||||
|
fprintf (stderr, "Continuing process: %ld\n",
|
||||||
|
(long int) ptr->tid);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure no error occurred...
|
||||||
|
*/
|
||||||
|
if (connfd < 0) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Accept returned an error (%s) ... retrying.",
|
||||||
|
strerror (errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->status = T_CONNECTED;
|
||||||
|
|
||||||
|
SERVER_DEC ();
|
||||||
|
|
||||||
|
handle_connection (connfd);
|
||||||
|
ptr->connects++;
|
||||||
|
|
||||||
|
if (child_config.maxrequestsperchild != 0) {
|
||||||
|
DEBUG2 ("%u connections so far...", ptr->connects);
|
||||||
|
|
||||||
|
if (ptr->connects == child_config.maxrequestsperchild) {
|
||||||
|
log_message (LOG_NOTICE,
|
||||||
|
"Child has reached MaxRequestsPerChild (%u). "
|
||||||
|
"Killing child.", ptr->connects);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVER_COUNT_LOCK ();
|
||||||
|
if (*servers_waiting > child_config.maxspareservers) {
|
||||||
|
/*
|
||||||
|
* There are too many spare children, kill ourself
|
||||||
|
* off.
|
||||||
|
*/
|
||||||
|
log_message (LOG_NOTICE,
|
||||||
|
"Waiting servers (%d) exceeds MaxSpareServers (%d). "
|
||||||
|
"Killing child.",
|
||||||
|
*servers_waiting,
|
||||||
|
child_config.maxspareservers);
|
||||||
|
SERVER_COUNT_UNLOCK ();
|
||||||
|
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
SERVER_COUNT_UNLOCK ();
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVER_INC ();
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->status = T_EMPTY;
|
||||||
|
|
||||||
|
safefree (cliaddr);
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fork a child "child" (or in our case a process) and then start up the
|
||||||
|
* child_main() function.
|
||||||
|
*/
|
||||||
|
static pid_t child_make (struct child_s *ptr)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
if ((pid = fork ()) > 0)
|
||||||
|
return pid; /* parent */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset the SIGNALS so that the child can be reaped.
|
||||||
|
*/
|
||||||
|
set_signal_handler (SIGCHLD, SIG_DFL);
|
||||||
|
set_signal_handler (SIGTERM, SIG_DFL);
|
||||||
|
set_signal_handler (SIGHUP, child_sighup_handler);
|
||||||
|
|
||||||
|
child_main (ptr); /* never returns */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a pool of children to handle incoming connections
|
||||||
|
*/
|
||||||
|
short int child_pool_create (void)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the number of MaxClients is not zero, since this
|
||||||
|
* variable determines the size of the array created for children
|
||||||
|
* later on.
|
||||||
|
*/
|
||||||
|
if (child_config.maxclients == 0) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"child_pool_create: \"MaxClients\" must be "
|
||||||
|
"greater than zero.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (child_config.startservers == 0) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"child_pool_create: \"StartServers\" must be "
|
||||||
|
"greater than zero.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
child_ptr =
|
||||||
|
(struct child_s *) calloc_shared_memory (child_config.maxclients,
|
||||||
|
sizeof (struct child_s));
|
||||||
|
if (!child_ptr) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Could not allocate memory for children.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
servers_waiting =
|
||||||
|
(unsigned int *) malloc_shared_memory (sizeof (unsigned int));
|
||||||
|
if (servers_waiting == MAP_FAILED) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Could not allocate memory for child counting.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*servers_waiting = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a "locking" file for use around the servers_waiting
|
||||||
|
* variable.
|
||||||
|
*/
|
||||||
|
_child_lock_init ();
|
||||||
|
|
||||||
|
if (child_config.startservers > child_config.maxclients) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Can not start more than \"MaxClients\" servers. "
|
||||||
|
"Starting %u servers instead.",
|
||||||
|
child_config.maxclients);
|
||||||
|
child_config.startservers = child_config.maxclients;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i != child_config.maxclients; i++) {
|
||||||
|
child_ptr[i].status = T_EMPTY;
|
||||||
|
child_ptr[i].connects = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i != child_config.startservers; i++) {
|
||||||
|
DEBUG2 ("Trying to create child %d of %d", i + 1,
|
||||||
|
child_config.startservers);
|
||||||
|
child_ptr[i].status = T_WAITING;
|
||||||
|
child_ptr[i].tid = child_make (&child_ptr[i]);
|
||||||
|
|
||||||
|
if (child_ptr[i].tid < 0) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Could not create child number %d of %d",
|
||||||
|
i, child_config.startservers);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
log_message (LOG_INFO,
|
||||||
|
"Creating child number %d of %d ...",
|
||||||
|
i + 1, child_config.startservers);
|
||||||
|
|
||||||
|
SERVER_INC ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message (LOG_INFO, "Finished creating all children.");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the proper number of servers running. This is the birth of the
|
||||||
|
* servers. It monitors this at least once a second.
|
||||||
|
*/
|
||||||
|
void child_main_loop (void)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if (config.quit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* If there are not enough spare servers, create more */
|
||||||
|
SERVER_COUNT_LOCK ();
|
||||||
|
if (*servers_waiting < child_config.minspareservers) {
|
||||||
|
log_message (LOG_NOTICE,
|
||||||
|
"Waiting servers (%d) is less than MinSpareServers (%d). "
|
||||||
|
"Creating new child.",
|
||||||
|
*servers_waiting,
|
||||||
|
child_config.minspareservers);
|
||||||
|
|
||||||
|
SERVER_COUNT_UNLOCK ();
|
||||||
|
|
||||||
|
for (i = 0; i != child_config.maxclients; i++) {
|
||||||
|
if (child_ptr[i].status == T_EMPTY) {
|
||||||
|
child_ptr[i].status = T_WAITING;
|
||||||
|
child_ptr[i].tid =
|
||||||
|
child_make (&child_ptr[i]);
|
||||||
|
if (child_ptr[i].tid < 0) {
|
||||||
|
log_message (LOG_NOTICE,
|
||||||
|
"Could not create child");
|
||||||
|
|
||||||
|
child_ptr[i].status = T_EMPTY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVER_INC ();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SERVER_COUNT_UNLOCK ();
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep (5);
|
||||||
|
|
||||||
|
/* Handle log rotation if it was requested */
|
||||||
|
if (received_sighup) {
|
||||||
|
/*
|
||||||
|
* Ignore the return value of reload_config for now.
|
||||||
|
* This should actually be handled somehow...
|
||||||
|
*/
|
||||||
|
reload_config ();
|
||||||
|
|
||||||
|
#ifdef FILTER_ENABLE
|
||||||
|
filter_reload ();
|
||||||
|
#endif /* FILTER_ENABLE */
|
||||||
|
|
||||||
|
/* propagate filter reload to all children */
|
||||||
|
child_kill_children (SIGHUP);
|
||||||
|
|
||||||
|
received_sighup = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Go through all the non-empty children and cancel them.
|
||||||
|
*/
|
||||||
|
void child_kill_children (int sig)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i != child_config.maxclients; i++) {
|
||||||
|
if (child_ptr[i].status != T_EMPTY)
|
||||||
|
kill (child_ptr[i].tid, sig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listen on the various configured interfaces
|
||||||
|
*/
|
||||||
|
int child_listening_sockets(vector_t listen_addrs, uint16_t port)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
ssize_t i;
|
||||||
|
|
||||||
|
assert (port > 0);
|
||||||
|
|
||||||
|
if (listen_fds == NULL) {
|
||||||
|
listen_fds = vector_create();
|
||||||
|
if (listen_fds == NULL) {
|
||||||
|
log_message (LOG_ERR, "Could not create the list "
|
||||||
|
"of listening fds");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((listen_addrs == NULL) ||
|
||||||
|
(vector_length(listen_addrs) == 0))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* no Listen directive:
|
||||||
|
* listen on the wildcard address(es)
|
||||||
|
*/
|
||||||
|
ret = listen_sock(NULL, port, listen_fds);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < vector_length(listen_addrs); i++) {
|
||||||
|
const char *addr;
|
||||||
|
|
||||||
|
addr = (char *)vector_getentry(listen_addrs, i, NULL);
|
||||||
|
if (addr == NULL) {
|
||||||
|
log_message(LOG_WARNING,
|
||||||
|
"got NULL from listen_addrs - skipping");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = listen_sock(addr, port, listen_fds);
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void child_close_sock (void)
|
||||||
|
{
|
||||||
|
ssize_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < vector_length(listen_fds); i++) {
|
||||||
|
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
|
||||||
|
close (*fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector_delete(listen_fds);
|
||||||
|
|
||||||
|
listen_fds = NULL;
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'child.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_CHILD_H
|
||||||
|
#define TINYPROXY_CHILD_H
|
||||||
|
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CHILD_MAXCLIENTS,
|
||||||
|
CHILD_MAXSPARESERVERS,
|
||||||
|
CHILD_MINSPARESERVERS,
|
||||||
|
CHILD_STARTSERVERS,
|
||||||
|
CHILD_MAXREQUESTSPERCHILD
|
||||||
|
} child_config_t;
|
||||||
|
|
||||||
|
extern short int child_pool_create (void);
|
||||||
|
extern int child_listening_sockets (vector_t listen_addrs, uint16_t port);
|
||||||
|
extern void child_close_sock (void);
|
||||||
|
extern void child_main_loop (void);
|
||||||
|
extern void child_kill_children (int sig);
|
||||||
|
|
||||||
|
extern short int child_configure (child_config_t type, unsigned int val);
|
||||||
|
|
||||||
|
#endif
|
||||||
+133
@@ -0,0 +1,133 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file groups all the headers required throughout the tinyproxy
|
||||||
|
* system. All this information use to be in the "main.h" header,
|
||||||
|
* but various other "libraries" in the program need the same information,
|
||||||
|
* without the tinyproxy specific defines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_HEADER_H
|
||||||
|
#define COMMON_HEADER_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include standard headers which are used through-out tinyproxy
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* standard C headers - we can safely assume they exist. */
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
/* standard POSIX headers - they need to be there as well. */
|
||||||
|
# include <errno.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <netdb.h>
|
||||||
|
# include <signal.h>
|
||||||
|
# include <stdarg.h>
|
||||||
|
# include <strings.h>
|
||||||
|
# include <syslog.h>
|
||||||
|
# include <wchar.h>
|
||||||
|
# include <wctype.h>
|
||||||
|
# include <sys/mman.h>
|
||||||
|
# include <sys/select.h>
|
||||||
|
# include <sys/socket.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/wait.h>
|
||||||
|
# include <sys/uio.h>
|
||||||
|
# include <sys/un.h>
|
||||||
|
# include <sys/time.h>
|
||||||
|
# include <time.h>
|
||||||
|
# include <inttypes.h>
|
||||||
|
# include <sys/resource.h>
|
||||||
|
# include <netinet/in.h>
|
||||||
|
# include <assert.h>
|
||||||
|
# include <arpa/inet.h>
|
||||||
|
# include <grp.h>
|
||||||
|
# include <pwd.h>
|
||||||
|
# include <regex.h>
|
||||||
|
|
||||||
|
/* rest - some oddball headers */
|
||||||
|
#ifdef HAVE_VALUES_H
|
||||||
|
# include <values.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ALLOCA_H
|
||||||
|
# include <alloca.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MEMORY_H
|
||||||
|
# include <memory.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MALLOC_H
|
||||||
|
# include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSEXITS_H
|
||||||
|
# include <sysexits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If MSG_NOSIGNAL is not defined, define it to be zero so that it doesn't
|
||||||
|
* cause any problems.
|
||||||
|
*/
|
||||||
|
#ifndef MSG_NOSIGNAL
|
||||||
|
# define MSG_NOSIGNAL (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SHUT_RD /* these three Posix.1g names are quite new */
|
||||||
|
# define SHUT_RD 0 /* shutdown for reading */
|
||||||
|
# define SHUT_WR 1 /* shutdown for writing */
|
||||||
|
# define SHUT_RDWR 2 /* shutdown for reading and writing */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAXLISTEN 1024 /* Max number of connections */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SunOS doesn't have INADDR_NONE defined.
|
||||||
|
*/
|
||||||
|
#ifndef INADDR_NONE
|
||||||
|
# define INADDR_NONE -1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define boolean values */
|
||||||
|
#ifndef FALSE
|
||||||
|
# define FALSE 0
|
||||||
|
# define TRUE (!FALSE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Useful function macros */
|
||||||
|
#if !defined(min) || !defined(max)
|
||||||
|
# define min(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
# define max(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
+1161
File diff suppressed because it is too large.
Load diff
+121
@@ -0,0 +1,121 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2004 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2009 Michael Adam <obnox@samba.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'conf.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_CONF_H
|
||||||
|
#define TINYPROXY_CONF_H
|
||||||
|
|
||||||
|
#include "hashmap.h"
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stores a HTTP header created using the AddHeader directive.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
char *value;
|
||||||
|
} http_header_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hold all the configuration time information.
|
||||||
|
*/
|
||||||
|
struct config_s {
|
||||||
|
vector_t basicauth_list;
|
||||||
|
char *logf_name;
|
||||||
|
char *config_file;
|
||||||
|
unsigned int syslog; /* boolean */
|
||||||
|
unsigned int port;
|
||||||
|
char *stathost;
|
||||||
|
unsigned int godaemon; /* boolean */
|
||||||
|
unsigned int quit; /* boolean */
|
||||||
|
char *user;
|
||||||
|
char *group;
|
||||||
|
vector_t listen_addrs;
|
||||||
|
#ifdef FILTER_ENABLE
|
||||||
|
char *filter;
|
||||||
|
unsigned int filter_url; /* boolean */
|
||||||
|
unsigned int filter_extended; /* boolean */
|
||||||
|
unsigned int filter_casesensitive; /* boolean */
|
||||||
|
#endif /* FILTER_ENABLE */
|
||||||
|
#ifdef XTINYPROXY_ENABLE
|
||||||
|
unsigned int add_xtinyproxy; /* boolean */
|
||||||
|
#endif
|
||||||
|
#ifdef REVERSE_SUPPORT
|
||||||
|
struct reversepath *reversepath_list;
|
||||||
|
unsigned int reverseonly; /* boolean */
|
||||||
|
unsigned int reversemagic; /* boolean */
|
||||||
|
char *reversebaseurl;
|
||||||
|
#endif
|
||||||
|
#ifdef UPSTREAM_SUPPORT
|
||||||
|
struct upstream *upstream_list;
|
||||||
|
#endif /* UPSTREAM_SUPPORT */
|
||||||
|
char *pidpath;
|
||||||
|
unsigned int idletimeout;
|
||||||
|
char *bind_address;
|
||||||
|
unsigned int bindsame;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The configured name to use in the HTTP "Via" header field.
|
||||||
|
*/
|
||||||
|
char *via_proxy_name;
|
||||||
|
|
||||||
|
unsigned int disable_viaheader; /* boolean */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Error page support. Map error numbers to file paths.
|
||||||
|
*/
|
||||||
|
hashmap_t errorpages;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Error page to be displayed if appropriate page cannot be located
|
||||||
|
* in the errorpages structure.
|
||||||
|
*/
|
||||||
|
char *errorpage_undef;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The HTML statistics page.
|
||||||
|
*/
|
||||||
|
char *statpage;
|
||||||
|
|
||||||
|
vector_t access_list;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the list of port allowed by CONNECT.
|
||||||
|
*/
|
||||||
|
vector_t connect_ports;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map of headers which should be let through when the
|
||||||
|
* anonymous feature is turned on.
|
||||||
|
*/
|
||||||
|
hashmap_t anonymous_map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extra headers to be added to outgoing HTTP requests.
|
||||||
|
*/
|
||||||
|
vector_t add_headers;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int reload_config_file (const char *config_fname, struct config_s *conf,
|
||||||
|
struct config_s *defaults);
|
||||||
|
|
||||||
|
int config_compile_regex (void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999-2005 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2009 Michael Adam <obnox@samba.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "connect-ports.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now, this routine adds a "port" to the list. It also creates the list if
|
||||||
|
* it hasn't already by done.
|
||||||
|
*/
|
||||||
|
void add_connect_port_allowed (int port, vector_t *connect_ports)
|
||||||
|
{
|
||||||
|
if (!*connect_ports) {
|
||||||
|
*connect_ports = vector_create ();
|
||||||
|
if (!*connect_ports) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Could not create a list of allowed CONNECT ports");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message (LOG_INFO,
|
||||||
|
"Adding Port [%d] to the list allowed by CONNECT", port);
|
||||||
|
vector_append (*connect_ports, &port, sizeof (port));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This routine checks to see if a port is allowed in the CONNECT method.
|
||||||
|
*
|
||||||
|
* Returns: 1 if allowed
|
||||||
|
* 0 if denied
|
||||||
|
*/
|
||||||
|
int check_allowed_connect_ports (int port, vector_t connect_ports)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
int *data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The absence of ConnectPort options in the config file
|
||||||
|
* meanas that all ports are allowed for CONNECT.
|
||||||
|
*/
|
||||||
|
if (!connect_ports)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (i = 0; i != (size_t) vector_length (connect_ports); ++i) {
|
||||||
|
data = (int *) vector_getentry (connect_ports, i, NULL);
|
||||||
|
if (data && *data == port)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a connect_ports list.
|
||||||
|
*/
|
||||||
|
void free_connect_ports_list (vector_t connect_ports)
|
||||||
|
{
|
||||||
|
vector_delete (connect_ports);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2009 Michael Adam <obnox@samba.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TINYPROXY_CONNECT_PORTS_H_
|
||||||
|
#define _TINYPROXY_CONNECT_PORTS_H_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
extern void add_connect_port_allowed (int port, vector_t *connect_ports);
|
||||||
|
int check_allowed_connect_ports (int port, vector_t connect_ports);
|
||||||
|
void free_connect_ports_list (vector_t connect_ports);
|
||||||
|
|
||||||
|
#endif /* _TINYPROXY_CONNECT_PORTS_ */
|
||||||
+148
@@ -0,0 +1,148 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2001 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Create and free the connection structure. One day there could be
|
||||||
|
* other connection related tasks put here, but for now the header
|
||||||
|
* file and this file are only used for create/free functions and the
|
||||||
|
* connection structure definition.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "conns.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "stats.h"
|
||||||
|
|
||||||
|
struct conn_s *initialize_conn (int client_fd, const char *ipaddr,
|
||||||
|
const char *string_addr,
|
||||||
|
const char *sock_ipaddr)
|
||||||
|
{
|
||||||
|
struct conn_s *connptr;
|
||||||
|
struct buffer_s *cbuffer, *sbuffer;
|
||||||
|
|
||||||
|
assert (client_fd >= 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate the memory for all the internal components
|
||||||
|
*/
|
||||||
|
cbuffer = new_buffer ();
|
||||||
|
sbuffer = new_buffer ();
|
||||||
|
|
||||||
|
if (!cbuffer || !sbuffer)
|
||||||
|
goto error_exit;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate the space for the conn_s structure itself.
|
||||||
|
*/
|
||||||
|
connptr = (struct conn_s *) safemalloc (sizeof (struct conn_s));
|
||||||
|
if (!connptr)
|
||||||
|
goto error_exit;
|
||||||
|
|
||||||
|
connptr->client_fd = client_fd;
|
||||||
|
connptr->server_fd = -1;
|
||||||
|
|
||||||
|
connptr->cbuffer = cbuffer;
|
||||||
|
connptr->sbuffer = sbuffer;
|
||||||
|
|
||||||
|
connptr->request_line = NULL;
|
||||||
|
|
||||||
|
/* These store any error strings */
|
||||||
|
connptr->error_variables = NULL;
|
||||||
|
connptr->error_string = NULL;
|
||||||
|
connptr->error_number = -1;
|
||||||
|
|
||||||
|
connptr->connect_method = FALSE;
|
||||||
|
connptr->show_stats = FALSE;
|
||||||
|
|
||||||
|
connptr->protocol.major = connptr->protocol.minor = 0;
|
||||||
|
|
||||||
|
/* There is _no_ content length initially */
|
||||||
|
connptr->content_length.server = connptr->content_length.client = -1;
|
||||||
|
|
||||||
|
connptr->server_ip_addr = (sock_ipaddr ?
|
||||||
|
safestrdup (sock_ipaddr) : NULL);
|
||||||
|
connptr->client_ip_addr = safestrdup (ipaddr);
|
||||||
|
connptr->client_string_addr = safestrdup (string_addr);
|
||||||
|
|
||||||
|
connptr->upstream_proxy = NULL;
|
||||||
|
|
||||||
|
update_stats (STAT_OPEN);
|
||||||
|
|
||||||
|
#ifdef REVERSE_SUPPORT
|
||||||
|
connptr->reversepath = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return connptr;
|
||||||
|
|
||||||
|
error_exit:
|
||||||
|
/*
|
||||||
|
* If we got here, there was a problem allocating memory
|
||||||
|
*/
|
||||||
|
if (cbuffer)
|
||||||
|
delete_buffer (cbuffer);
|
||||||
|
if (sbuffer)
|
||||||
|
delete_buffer (sbuffer);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_conn (struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
assert (connptr != NULL);
|
||||||
|
|
||||||
|
if (connptr->client_fd != -1)
|
||||||
|
if (close (connptr->client_fd) < 0)
|
||||||
|
log_message (LOG_INFO, "Client (%d) close message: %s",
|
||||||
|
connptr->client_fd, strerror (errno));
|
||||||
|
if (connptr->server_fd != -1)
|
||||||
|
if (close (connptr->server_fd) < 0)
|
||||||
|
log_message (LOG_INFO, "Server (%d) close message: %s",
|
||||||
|
connptr->server_fd, strerror (errno));
|
||||||
|
|
||||||
|
if (connptr->cbuffer)
|
||||||
|
delete_buffer (connptr->cbuffer);
|
||||||
|
if (connptr->sbuffer)
|
||||||
|
delete_buffer (connptr->sbuffer);
|
||||||
|
|
||||||
|
if (connptr->request_line)
|
||||||
|
safefree (connptr->request_line);
|
||||||
|
|
||||||
|
if (connptr->error_variables)
|
||||||
|
hashmap_delete (connptr->error_variables);
|
||||||
|
|
||||||
|
if (connptr->error_string)
|
||||||
|
safefree (connptr->error_string);
|
||||||
|
|
||||||
|
if (connptr->server_ip_addr)
|
||||||
|
safefree (connptr->server_ip_addr);
|
||||||
|
if (connptr->client_ip_addr)
|
||||||
|
safefree (connptr->client_ip_addr);
|
||||||
|
if (connptr->client_string_addr)
|
||||||
|
safefree (connptr->client_string_addr);
|
||||||
|
|
||||||
|
#ifdef REVERSE_SUPPORT
|
||||||
|
if (connptr->reversepath)
|
||||||
|
safefree (connptr->reversepath);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
safefree (connptr);
|
||||||
|
|
||||||
|
update_stats (STAT_CLOSE);
|
||||||
|
}
|
||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2001 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'conns.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_CONNS_H
|
||||||
|
#define TINYPROXY_CONNS_H
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "hashmap.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Connection Definition
|
||||||
|
*/
|
||||||
|
struct conn_s {
|
||||||
|
int client_fd;
|
||||||
|
int server_fd;
|
||||||
|
|
||||||
|
struct buffer_s *cbuffer;
|
||||||
|
struct buffer_s *sbuffer;
|
||||||
|
|
||||||
|
/* The request line (first line) from the client */
|
||||||
|
char *request_line;
|
||||||
|
|
||||||
|
/* Booleans */
|
||||||
|
unsigned int connect_method;
|
||||||
|
unsigned int show_stats;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure stores key -> value mappings for substitution
|
||||||
|
* in the error HTML files.
|
||||||
|
*/
|
||||||
|
hashmap_t error_variables;
|
||||||
|
|
||||||
|
int error_number;
|
||||||
|
char *error_string;
|
||||||
|
|
||||||
|
/* A Content-Length value from the remote server */
|
||||||
|
struct {
|
||||||
|
long int server;
|
||||||
|
long int client;
|
||||||
|
} content_length;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the server's IP (for BindSame)
|
||||||
|
*/
|
||||||
|
char *server_ip_addr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the client's IP and hostname information
|
||||||
|
*/
|
||||||
|
char *client_ip_addr;
|
||||||
|
char *client_string_addr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the incoming request's HTTP protocol.
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
unsigned int major;
|
||||||
|
unsigned int minor;
|
||||||
|
} protocol;
|
||||||
|
|
||||||
|
#ifdef REVERSE_SUPPORT
|
||||||
|
/*
|
||||||
|
* Place to store the current per-connection reverse proxy path
|
||||||
|
*/
|
||||||
|
char *reversepath;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pointer to upstream proxy.
|
||||||
|
*/
|
||||||
|
struct upstream *upstream_proxy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions for the creation and destruction of a connection structure.
|
||||||
|
*/
|
||||||
|
extern struct conn_s *initialize_conn (int client_fd, const char *ipaddr,
|
||||||
|
const char *string_addr,
|
||||||
|
const char *sock_ipaddr);
|
||||||
|
extern void destroy_conn (struct conn_s *connptr);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file contains functions which are useful when writing a
|
||||||
|
* daemon process. The functions include a "makedaemon" function and
|
||||||
|
* a function to portably set a signal handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "daemon.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fork a child process and then kill the parent so make the calling
|
||||||
|
* program a daemon process.
|
||||||
|
*/
|
||||||
|
void makedaemon (void)
|
||||||
|
{
|
||||||
|
if (fork () != 0)
|
||||||
|
exit (0);
|
||||||
|
|
||||||
|
setsid ();
|
||||||
|
set_signal_handler (SIGHUP, SIG_IGN);
|
||||||
|
|
||||||
|
if (fork () != 0)
|
||||||
|
exit (0);
|
||||||
|
|
||||||
|
if (chdir ("/") != 0) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Could not change directory to /");
|
||||||
|
}
|
||||||
|
|
||||||
|
umask (0177);
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
/*
|
||||||
|
* When not in debugging mode, close the standard file
|
||||||
|
* descriptors.
|
||||||
|
*/
|
||||||
|
close (0);
|
||||||
|
close (1);
|
||||||
|
close (2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass a signal number and a signal handling function into this function
|
||||||
|
* to handle signals sent to the process.
|
||||||
|
*/
|
||||||
|
signal_func *set_signal_handler (int signo, signal_func * func)
|
||||||
|
{
|
||||||
|
struct sigaction act, oact;
|
||||||
|
|
||||||
|
act.sa_handler = func;
|
||||||
|
sigemptyset (&act.sa_mask);
|
||||||
|
act.sa_flags = 0;
|
||||||
|
if (signo == SIGALRM) {
|
||||||
|
#ifdef SA_INTERRUPT
|
||||||
|
act.sa_flags |= SA_INTERRUPT; /* SunOS 4.x */
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#ifdef SA_RESTART
|
||||||
|
act.sa_flags |= SA_RESTART; /* SVR4, 4.4BSD */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sigaction (signo, &act, &oact) < 0)
|
||||||
|
return SIG_ERR;
|
||||||
|
|
||||||
|
return oact.sa_handler;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'daemon.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_DAEMON_H
|
||||||
|
#define TINYPROXY_DAEMON_H
|
||||||
|
|
||||||
|
typedef void signal_func (int);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass a singal integer and a function to handle the signal.
|
||||||
|
*/
|
||||||
|
extern signal_func *set_signal_handler (int signo, signal_func * func);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a program a daemon process
|
||||||
|
*/
|
||||||
|
extern void makedaemon (void);
|
||||||
|
|
||||||
|
#endif
|
||||||
-113
@@ -1,113 +0,0 @@
|
|||||||
/* $Id: dnscache.c,v 1.9 2001-05-27 02:24:00 rjkaes Exp $
|
|
||||||
*
|
|
||||||
* This is a caching DNS system. When a host name is needed we look it up here
|
|
||||||
* and see if there is already an answer for it. The domains are placed in a
|
|
||||||
* hashed linked list. If the name is not here, then we need to look it up and
|
|
||||||
* add it to the system. This really speeds up the connection to servers since
|
|
||||||
* the DNS name does not need to be looked up each time. It's kind of cool. :)
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
* Copyright (C) 2000 Chris Lightfoot (chris@ex-parrot.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "dnscache.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "ternary.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#define DNSEXPIRE (5 * 60)
|
|
||||||
|
|
||||||
struct dnscache_s {
|
|
||||||
struct in_addr ipaddr;
|
|
||||||
time_t expire;
|
|
||||||
};
|
|
||||||
|
|
||||||
static TERNARY dns_tree;
|
|
||||||
|
|
||||||
TERNARY new_dnscache(void)
|
|
||||||
{
|
|
||||||
dns_tree = ternary_new();
|
|
||||||
|
|
||||||
return dns_tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dns_lookup(struct in_addr *addr, char *domain)
|
|
||||||
{
|
|
||||||
struct dnscache_s *ptr;
|
|
||||||
|
|
||||||
assert(addr != NULL);
|
|
||||||
assert(domain != NULL);
|
|
||||||
|
|
||||||
if (TE_ISERROR(ternary_search(dns_tree, domain, (void *)&ptr)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (difftime(time(NULL), ptr->expire) > (double)DNSEXPIRE) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*addr = ptr->ipaddr;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dns_insert(struct in_addr *addr, char *domain)
|
|
||||||
{
|
|
||||||
struct dnscache_s *newptr;
|
|
||||||
|
|
||||||
assert(addr != NULL);
|
|
||||||
assert(domain != NULL);
|
|
||||||
|
|
||||||
if (!(newptr = malloc(sizeof(struct dnscache_s)))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
newptr->ipaddr = *addr;
|
|
||||||
newptr->expire = time(NULL);
|
|
||||||
|
|
||||||
if (TE_ISERROR(ternary_insert(dns_tree, domain, newptr)))
|
|
||||||
safefree(newptr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dnscache(struct in_addr *addr, char *domain)
|
|
||||||
{
|
|
||||||
struct hostent *resolv;
|
|
||||||
|
|
||||||
assert(addr != NULL);
|
|
||||||
assert(domain != NULL);
|
|
||||||
|
|
||||||
if (inet_aton(domain, (struct in_addr *) addr) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Well, we're not dotted-decimal so we need to look it up */
|
|
||||||
if (dns_lookup(addr, domain) == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Okay, so not in the list... need to actually look it up. */
|
|
||||||
if (!(resolv = gethostbyname(domain)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
memcpy(addr, resolv->h_addr_list[0], (size_t)resolv->h_length);
|
|
||||||
dns_insert(addr, domain);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/* $Id: dnscache.h,v 1.4 2001-05-27 02:24:00 rjkaes Exp $
|
|
||||||
*
|
|
||||||
* See 'dnscache.c' for a detailed description.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TINYPROXY_DNSCACHE_H_
|
|
||||||
#define _TINYPROXY_DNSCACHE_H_
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include "ternary.h"
|
|
||||||
|
|
||||||
extern TERNARY new_dnscache(void);
|
|
||||||
extern int dnscache(struct in_addr *addr, char *domain);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+198
-101
@@ -1,132 +1,229 @@
|
|||||||
/* $Id: filter.c,v 1.4 2001-05-27 02:24:40 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1999 George Talusan <gstalusan@uwaterloo.ca>
|
||||||
|
* Copyright (C) 2002 James E. Flemer <jflemer@acm.jhu.edu>
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* A substring of the domain to be filtered goes into the file
|
* This program is distributed in the hope that it will be useful,
|
||||||
* pointed at by DEFAULT_FILTER.
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
/* A substring of the domain to be filtered goes into the file
|
||||||
|
* pointed at by DEFAULT_FILTER.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include "main.h"
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "regexp.h"
|
#include "heap.h"
|
||||||
#include "utils.h"
|
#include "log.h"
|
||||||
|
#include "reqs.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
|
#define FILTER_BUFFER_LEN (512)
|
||||||
|
|
||||||
static int err;
|
static int err;
|
||||||
|
|
||||||
struct filter_list {
|
struct filter_list {
|
||||||
struct filter_list *next;
|
struct filter_list *next;
|
||||||
char *pat;
|
char *pat;
|
||||||
regex_t *cpat;
|
regex_t *cpat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static struct filter_list *fl = NULL;
|
static struct filter_list *fl = NULL;
|
||||||
static int already_init = 0;
|
static int already_init = 0;
|
||||||
|
static filter_policy_t default_policy = FILTER_DEFAULT_ALLOW;
|
||||||
|
|
||||||
/* initializes a linked list of strings containing hosts to be filtered */
|
/*
|
||||||
void filter_init(void)
|
* Initializes a linked list of strings containing hosts/urls to be filtered
|
||||||
|
*/
|
||||||
|
void filter_init (void)
|
||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
struct filter_list *p;
|
struct filter_list *p;
|
||||||
char buf[255];
|
char buf[FILTER_BUFFER_LEN];
|
||||||
char *s;
|
char *s, *start;
|
||||||
|
int cflags;
|
||||||
|
|
||||||
if (!fl && !already_init) {
|
if (fl || already_init) {
|
||||||
fd = fopen(config.filter, "r");
|
return;
|
||||||
if (fd) {
|
}
|
||||||
p = NULL;
|
|
||||||
|
|
||||||
while (fgets(buf, 255, fd)) {
|
fd = fopen (config.filter, "r");
|
||||||
s = buf;
|
if (!fd) {
|
||||||
if (!p) /* head of list */
|
return;
|
||||||
fl = p = (struct filter_list *)
|
}
|
||||||
malloc(sizeof
|
|
||||||
(struct filter_list));
|
|
||||||
else { /* next entry */
|
|
||||||
p->next = (struct filter_list *)
|
|
||||||
malloc(sizeof
|
|
||||||
(struct filter_list));
|
|
||||||
p = p->next;
|
|
||||||
}
|
|
||||||
/* initialize space to zero */
|
|
||||||
memset(p, 0, sizeof(struct filter_list));
|
|
||||||
|
|
||||||
/* replace first whitespace with \0 */
|
p = NULL;
|
||||||
while (*s++)
|
|
||||||
if (isspace((unsigned char)*s))
|
|
||||||
*s = '\0';
|
|
||||||
|
|
||||||
p->pat = strdup(buf);
|
cflags = REG_NEWLINE | REG_NOSUB;
|
||||||
p->cpat = malloc(sizeof(regex_t));
|
if (config.filter_extended)
|
||||||
if ((err = regcomp(p->cpat, p->pat, REG_NEWLINE | REG_NOSUB)) != 0) {
|
cflags |= REG_EXTENDED;
|
||||||
fprintf(stderr,
|
if (!config.filter_casesensitive)
|
||||||
"Bad regex in %s: %s\n",
|
cflags |= REG_ICASE;
|
||||||
config.filter, p->pat);
|
|
||||||
exit(EX_DATAERR);
|
while (fgets (buf, FILTER_BUFFER_LEN, fd)) {
|
||||||
}
|
/* skip leading whitespace */
|
||||||
}
|
s = buf;
|
||||||
already_init = 1;
|
while (*s && isspace ((unsigned char) *s))
|
||||||
fclose(fd);
|
s++;
|
||||||
}
|
start = s;
|
||||||
}
|
|
||||||
|
/*
|
||||||
|
* Remove any trailing white space and
|
||||||
|
* comments.
|
||||||
|
*/
|
||||||
|
while (*s) {
|
||||||
|
if (isspace ((unsigned char) *s))
|
||||||
|
break;
|
||||||
|
if (*s == '#') {
|
||||||
|
/*
|
||||||
|
* If the '#' char is preceeded by
|
||||||
|
* an escape, it's not a comment
|
||||||
|
* string.
|
||||||
|
*/
|
||||||
|
if (s == buf || *(s - 1) != '\\')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++s;
|
||||||
|
}
|
||||||
|
*s = '\0';
|
||||||
|
s = start;
|
||||||
|
|
||||||
|
/* skip blank lines and comments */
|
||||||
|
if (*s == '\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!p) /* head of list */
|
||||||
|
fl = p =
|
||||||
|
(struct filter_list *)
|
||||||
|
safecalloc (1, sizeof (struct filter_list));
|
||||||
|
else { /* next entry */
|
||||||
|
p->next =
|
||||||
|
(struct filter_list *)
|
||||||
|
safecalloc (1, sizeof (struct filter_list));
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->pat = safestrdup (s);
|
||||||
|
p->cpat = (regex_t *) safemalloc (sizeof (regex_t));
|
||||||
|
err = regcomp (p->cpat, p->pat, cflags);
|
||||||
|
if (err != 0) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"Bad regex in %s: %s\n",
|
||||||
|
config.filter, p->pat);
|
||||||
|
exit (EX_DATAERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ferror (fd)) {
|
||||||
|
perror ("fgets");
|
||||||
|
exit (EX_DATAERR);
|
||||||
|
}
|
||||||
|
fclose (fd);
|
||||||
|
|
||||||
|
already_init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unlink the list */
|
/* unlink the list */
|
||||||
void filter_destroy(void)
|
void filter_destroy (void)
|
||||||
{
|
{
|
||||||
struct filter_list *p, *q;
|
struct filter_list *p, *q;
|
||||||
|
|
||||||
if (already_init) {
|
if (already_init) {
|
||||||
for (p = q = fl; p; p = q) {
|
for (p = q = fl; p; p = q) {
|
||||||
regfree(p->cpat);
|
regfree (p->cpat);
|
||||||
safefree(p->cpat);
|
safefree (p->cpat);
|
||||||
safefree(p->pat);
|
safefree (p->pat);
|
||||||
q = p->next;
|
q = p->next;
|
||||||
safefree(p);
|
safefree (p);
|
||||||
}
|
}
|
||||||
fl = NULL;
|
fl = NULL;
|
||||||
already_init = 0;
|
already_init = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns 0 if host is not an element of filter list, non-zero otherwise */
|
/**
|
||||||
int filter_url(char *host)
|
* reload the filter file if filtering is enabled
|
||||||
|
*/
|
||||||
|
void filter_reload (void)
|
||||||
{
|
{
|
||||||
struct filter_list *p;
|
if (config.filter) {
|
||||||
char *s, *port;
|
log_message (LOG_NOTICE, "Re-reading filter file.");
|
||||||
int result;
|
filter_destroy ();
|
||||||
|
filter_init ();
|
||||||
if (!fl || !already_init)
|
}
|
||||||
return (0);
|
}
|
||||||
|
|
||||||
/* strip off the port number */
|
/* Return 0 to allow, non-zero to block */
|
||||||
s = strdup(host);
|
int filter_domain (const char *host)
|
||||||
port = strchr(s, ':');
|
{
|
||||||
if (port)
|
struct filter_list *p;
|
||||||
*port = '\0';
|
int result;
|
||||||
|
|
||||||
result = 0;
|
if (!fl || !already_init)
|
||||||
|
goto COMMON_EXIT;
|
||||||
for (p = fl; p; p = p->next) {
|
|
||||||
result = !regexec(p->cpat, s, (size_t) 0, (regmatch_t *) 0, 0);
|
for (p = fl; p; p = p->next) {
|
||||||
|
result =
|
||||||
if (result)
|
regexec (p->cpat, host, (size_t) 0, (regmatch_t *) 0, 0);
|
||||||
break;
|
|
||||||
}
|
if (result == 0) {
|
||||||
safefree(s);
|
if (default_policy == FILTER_DEFAULT_ALLOW)
|
||||||
return (result);
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
COMMON_EXIT:
|
||||||
|
if (default_policy == FILTER_DEFAULT_ALLOW)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns 0 to allow, non-zero to block */
|
||||||
|
int filter_url (const char *url)
|
||||||
|
{
|
||||||
|
struct filter_list *p;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (!fl || !already_init)
|
||||||
|
goto COMMON_EXIT;
|
||||||
|
|
||||||
|
for (p = fl; p; p = p->next) {
|
||||||
|
result =
|
||||||
|
regexec (p->cpat, url, (size_t) 0, (regmatch_t *) 0, 0);
|
||||||
|
|
||||||
|
if (result == 0) {
|
||||||
|
if (default_policy == FILTER_DEFAULT_ALLOW)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
COMMON_EXIT:
|
||||||
|
if (default_policy == FILTER_DEFAULT_ALLOW)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the default filtering policy
|
||||||
|
*/
|
||||||
|
void filter_set_default_policy (filter_policy_t policy)
|
||||||
|
{
|
||||||
|
default_policy = policy;
|
||||||
}
|
}
|
||||||
+27
-15
@@ -1,25 +1,37 @@
|
|||||||
/* $Id: filter.h,v 1.3 2000-11-23 04:46:25 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1999 George Talusan <gstalusan@uwaterloo.ca>
|
||||||
*
|
*
|
||||||
* See 'filter.c' for a detailed description.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* See 'filter.c' for detailed information. */
|
||||||
|
|
||||||
#ifndef _TINYPROXY_FILTER_H_
|
#ifndef _TINYPROXY_FILTER_H_
|
||||||
#define _TINYPROXY_FILTER_H_
|
#define _TINYPROXY_FILTER_H_
|
||||||
|
|
||||||
extern void filter_init(void);
|
typedef enum {
|
||||||
extern void filter_destroy(void);
|
FILTER_DEFAULT_ALLOW,
|
||||||
extern int filter_url(char *host);
|
FILTER_DEFAULT_DENY
|
||||||
|
} filter_policy_t;
|
||||||
|
|
||||||
|
extern void filter_init (void);
|
||||||
|
extern void filter_destroy (void);
|
||||||
|
extern void filter_reload (void);
|
||||||
|
extern int filter_domain (const char *host);
|
||||||
|
extern int filter_url (const char *url);
|
||||||
|
|
||||||
|
extern void filter_set_default_policy (filter_policy_t policy);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
-5880
File diff suppressed because it is too large.
Load diff
-542
@@ -1,542 +0,0 @@
|
|||||||
/* Definitions for data structures and routines for the regular
|
|
||||||
expression library, version 0.12.
|
|
||||||
Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of the GNU C Library. Its master source is NOT part of
|
|
||||||
the C library, however. The master source lives in /gd/gnu/lib.
|
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public License as
|
|
||||||
published by the Free Software Foundation; either version 2 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
The GNU C Library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
|
||||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
||||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
Boston, MA 02111-1307, USA. */
|
|
||||||
|
|
||||||
#ifndef _REGEX_H
|
|
||||||
#define _REGEX_H 1
|
|
||||||
|
|
||||||
/* Allow the use in C++ code. */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* POSIX says that <sys/types.h> must be included (by the caller) before
|
|
||||||
<regex.h>. */
|
|
||||||
|
|
||||||
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
|
|
||||||
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
|
|
||||||
should be there. */
|
|
||||||
# include <stddef.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The following two types have to be signed and unsigned integer type
|
|
||||||
wide enough to hold a value of a pointer. For most ANSI compilers
|
|
||||||
ptrdiff_t and size_t should be likely OK. Still size of these two
|
|
||||||
types is 2 for Microsoft C. Ugh... */
|
|
||||||
typedef long int s_reg_t;
|
|
||||||
typedef unsigned long int active_reg_t;
|
|
||||||
|
|
||||||
/* The following bits are used to determine the regexp syntax we
|
|
||||||
recognize. The set/not-set meanings are chosen so that Emacs syntax
|
|
||||||
remains the value 0. The bits are given in alphabetical order, and
|
|
||||||
the definitions shifted by one from the previous bit; thus, when we
|
|
||||||
add or remove a bit, only one other definition need change. */
|
|
||||||
typedef unsigned long int reg_syntax_t;
|
|
||||||
|
|
||||||
/* If this bit is not set, then \ inside a bracket expression is literal.
|
|
||||||
If set, then such a \ quotes the following character. */
|
|
||||||
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
|
|
||||||
|
|
||||||
/* If this bit is not set, then + and ? are operators, and \+ and \? are
|
|
||||||
literals.
|
|
||||||
If set, then \+ and \? are operators and + and ? are literals. */
|
|
||||||
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then character classes are supported. They are:
|
|
||||||
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
|
|
||||||
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
|
|
||||||
If not set, then character classes are not supported. */
|
|
||||||
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then ^ and $ are always anchors (outside bracket
|
|
||||||
expressions, of course).
|
|
||||||
If this bit is not set, then it depends:
|
|
||||||
^ is an anchor if it is at the beginning of a regular
|
|
||||||
expression or after an open-group or an alternation operator;
|
|
||||||
$ is an anchor if it is at the end of a regular expression, or
|
|
||||||
before a close-group or an alternation operator.
|
|
||||||
|
|
||||||
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
|
|
||||||
POSIX draft 11.2 says that * etc. in leading positions is undefined.
|
|
||||||
We already implemented a previous draft which made those constructs
|
|
||||||
invalid, though, so we haven't changed the code back. */
|
|
||||||
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then special characters are always special
|
|
||||||
regardless of where they are in the pattern.
|
|
||||||
If this bit is not set, then special characters are special only in
|
|
||||||
some contexts; otherwise they are ordinary. Specifically,
|
|
||||||
* + ? and intervals are only special when not after the beginning,
|
|
||||||
open-group, or alternation operator. */
|
|
||||||
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
|
|
||||||
immediately after an alternation or begin-group operator. */
|
|
||||||
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then . matches newline.
|
|
||||||
If not set, then it doesn't. */
|
|
||||||
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then . doesn't match NUL.
|
|
||||||
If not set, then it does. */
|
|
||||||
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, nonmatching lists [^...] do not match newline.
|
|
||||||
If not set, they do. */
|
|
||||||
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, either \{...\} or {...} defines an
|
|
||||||
interval, depending on RE_NO_BK_BRACES.
|
|
||||||
If not set, \{, \}, {, and } are literals. */
|
|
||||||
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, +, ? and | aren't recognized as operators.
|
|
||||||
If not set, they are. */
|
|
||||||
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, newline is an alternation operator.
|
|
||||||
If not set, newline is literal. */
|
|
||||||
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
|
|
||||||
are literals.
|
|
||||||
If not set, then `\{...\}' defines an interval. */
|
|
||||||
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, (...) defines a group, and \( and \) are literals.
|
|
||||||
If not set, \(...\) defines a group, and ( and ) are literals. */
|
|
||||||
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then \<digit> matches <digit>.
|
|
||||||
If not set, then \<digit> is a back-reference. */
|
|
||||||
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then | is an alternation operator, and \| is literal.
|
|
||||||
If not set, then \| is an alternation operator, and | is literal. */
|
|
||||||
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then an ending range point collating higher
|
|
||||||
than the starting range point, as in [z-a], is invalid.
|
|
||||||
If not set, then when ending range point collates higher than the
|
|
||||||
starting range point, the range is ignored. */
|
|
||||||
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then an unmatched ) is ordinary.
|
|
||||||
If not set, then an unmatched ) is invalid. */
|
|
||||||
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, succeed as soon as we match the whole pattern,
|
|
||||||
without further backtracking. */
|
|
||||||
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, do not process the GNU regex operators.
|
|
||||||
If not set, then the GNU regex operators are recognized. */
|
|
||||||
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, turn on internal regex debugging.
|
|
||||||
If not set, and debugging was on, turn it off.
|
|
||||||
This only works if regex.c is compiled -DDEBUG.
|
|
||||||
We define this bit always, so that all that's needed to turn on
|
|
||||||
debugging is to recompile regex.c; the calling code can always have
|
|
||||||
this bit set, and it won't affect anything in the normal case. */
|
|
||||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
|
||||||
|
|
||||||
/* This global variable defines the particular regexp syntax to use (for
|
|
||||||
some interfaces). When a regexp is compiled, the syntax used is
|
|
||||||
stored in the pattern buffer, so changing this does not affect
|
|
||||||
already-compiled regexps. */
|
|
||||||
extern reg_syntax_t re_syntax_options;
|
|
||||||
|
|
||||||
/* Define combinations of the above bits for the standard possibilities.
|
|
||||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
|
||||||
don't delete them!) */
|
|
||||||
/* [[[begin syntaxes]]] */
|
|
||||||
#define RE_SYNTAX_EMACS 0
|
|
||||||
|
|
||||||
#define RE_SYNTAX_AWK \
|
|
||||||
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
|
|
||||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
|
||||||
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
|
|
||||||
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
|
|
||||||
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
|
|
||||||
|
|
||||||
#define RE_SYNTAX_GNU_AWK \
|
|
||||||
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
|
|
||||||
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
|
|
||||||
|
|
||||||
#define RE_SYNTAX_POSIX_AWK \
|
|
||||||
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
|
|
||||||
| RE_INTERVALS | RE_NO_GNU_OPS)
|
|
||||||
|
|
||||||
#define RE_SYNTAX_GREP \
|
|
||||||
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
|
|
||||||
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
|
|
||||||
| RE_NEWLINE_ALT)
|
|
||||||
|
|
||||||
#define RE_SYNTAX_EGREP \
|
|
||||||
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
|
|
||||||
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
|
|
||||||
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
|
|
||||||
| RE_NO_BK_VBAR)
|
|
||||||
|
|
||||||
#define RE_SYNTAX_POSIX_EGREP \
|
|
||||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
|
|
||||||
|
|
||||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
|
||||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
|
||||||
|
|
||||||
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
|
|
||||||
|
|
||||||
/* Syntax bits common to both basic and extended POSIX regex syntax. */
|
|
||||||
#define _RE_SYNTAX_POSIX_COMMON \
|
|
||||||
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
|
|
||||||
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
|
|
||||||
|
|
||||||
#define RE_SYNTAX_POSIX_BASIC \
|
|
||||||
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
|
|
||||||
|
|
||||||
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
|
|
||||||
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
|
|
||||||
isn't minimal, since other operators, such as \`, aren't disabled. */
|
|
||||||
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
|
|
||||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
|
||||||
|
|
||||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
|
||||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
|
||||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
|
||||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
|
||||||
| RE_UNMATCHED_RIGHT_PAREN_ORD)
|
|
||||||
|
|
||||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
|
|
||||||
replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
|
|
||||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
|
||||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
|
||||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
|
||||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
|
||||||
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
|
||||||
/* [[[end syntaxes]]] */
|
|
||||||
|
|
||||||
/* Maximum number of duplicates an interval can allow. Some systems
|
|
||||||
(erroneously) define this in other header files, but we want our
|
|
||||||
value, so remove any previous define. */
|
|
||||||
#ifdef RE_DUP_MAX
|
|
||||||
# undef RE_DUP_MAX
|
|
||||||
#endif
|
|
||||||
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
|
|
||||||
#define RE_DUP_MAX (0x7fff)
|
|
||||||
|
|
||||||
|
|
||||||
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
|
|
||||||
|
|
||||||
/* If this bit is set, then use extended regular expression syntax.
|
|
||||||
If not set, then use basic regular expression syntax. */
|
|
||||||
#define REG_EXTENDED 1
|
|
||||||
|
|
||||||
/* If this bit is set, then ignore case when matching.
|
|
||||||
If not set, then case is significant. */
|
|
||||||
#define REG_ICASE (REG_EXTENDED << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then anchors do not match at newline
|
|
||||||
characters in the string.
|
|
||||||
If not set, then anchors do match at newlines. */
|
|
||||||
#define REG_NEWLINE (REG_ICASE << 1)
|
|
||||||
|
|
||||||
/* If this bit is set, then report only success or fail in regexec.
|
|
||||||
If not set, then returns differ between not matching and errors. */
|
|
||||||
#define REG_NOSUB (REG_NEWLINE << 1)
|
|
||||||
|
|
||||||
|
|
||||||
/* POSIX `eflags' bits (i.e., information for regexec). */
|
|
||||||
|
|
||||||
/* If this bit is set, then the beginning-of-line operator doesn't match
|
|
||||||
the beginning of the string (presumably because it's not the
|
|
||||||
beginning of a line).
|
|
||||||
If not set, then the beginning-of-line operator does match the
|
|
||||||
beginning of the string. */
|
|
||||||
#define REG_NOTBOL 1
|
|
||||||
|
|
||||||
/* Like REG_NOTBOL, except for the end-of-line. */
|
|
||||||
#define REG_NOTEOL (1 << 1)
|
|
||||||
|
|
||||||
|
|
||||||
/* If any error codes are removed, changed, or added, update the
|
|
||||||
`re_error_msg' table in regex.c. */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
#ifdef _XOPEN_SOURCE
|
|
||||||
REG_ENOSYS = -1, /* This will never happen for this implementation. */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
REG_NOERROR = 0, /* Success. */
|
|
||||||
REG_NOMATCH, /* Didn't find a match (for regexec). */
|
|
||||||
|
|
||||||
/* POSIX regcomp return error codes. (In the order listed in the
|
|
||||||
standard.) */
|
|
||||||
REG_BADPAT, /* Invalid pattern. */
|
|
||||||
REG_ECOLLATE, /* Not implemented. */
|
|
||||||
REG_ECTYPE, /* Invalid character class name. */
|
|
||||||
REG_EESCAPE, /* Trailing backslash. */
|
|
||||||
REG_ESUBREG, /* Invalid back reference. */
|
|
||||||
REG_EBRACK, /* Unmatched left bracket. */
|
|
||||||
REG_EPAREN, /* Parenthesis imbalance. */
|
|
||||||
REG_EBRACE, /* Unmatched \{. */
|
|
||||||
REG_BADBR, /* Invalid contents of \{\}. */
|
|
||||||
REG_ERANGE, /* Invalid range end. */
|
|
||||||
REG_ESPACE, /* Ran out of memory. */
|
|
||||||
REG_BADRPT, /* No preceding re for repetition op. */
|
|
||||||
|
|
||||||
/* Error codes we've added. */
|
|
||||||
REG_EEND, /* Premature end. */
|
|
||||||
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
|
|
||||||
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
|
|
||||||
} reg_errcode_t;
|
|
||||||
|
|
||||||
/* This data structure represents a compiled pattern. Before calling
|
|
||||||
the pattern compiler, the fields `buffer', `allocated', `fastmap',
|
|
||||||
`translate', and `no_sub' can be set. After the pattern has been
|
|
||||||
compiled, the `re_nsub' field is available. All other fields are
|
|
||||||
private to the regex routines. */
|
|
||||||
|
|
||||||
#ifndef RE_TRANSLATE_TYPE
|
|
||||||
# define RE_TRANSLATE_TYPE char *
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct re_pattern_buffer
|
|
||||||
{
|
|
||||||
/* [[[begin pattern_buffer]]] */
|
|
||||||
/* Space that holds the compiled pattern. It is declared as
|
|
||||||
`unsigned char *' because its elements are
|
|
||||||
sometimes used as array indexes. */
|
|
||||||
unsigned char *buffer;
|
|
||||||
|
|
||||||
/* Number of bytes to which `buffer' points. */
|
|
||||||
unsigned long int allocated;
|
|
||||||
|
|
||||||
/* Number of bytes actually used in `buffer'. */
|
|
||||||
unsigned long int used;
|
|
||||||
|
|
||||||
/* Syntax setting with which the pattern was compiled. */
|
|
||||||
reg_syntax_t syntax;
|
|
||||||
|
|
||||||
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
|
|
||||||
the fastmap, if there is one, to skip over impossible
|
|
||||||
starting points for matches. */
|
|
||||||
char *fastmap;
|
|
||||||
|
|
||||||
/* Either a translate table to apply to all characters before
|
|
||||||
comparing them, or zero for no translation. The translation
|
|
||||||
is applied to a pattern when it is compiled and to a string
|
|
||||||
when it is matched. */
|
|
||||||
RE_TRANSLATE_TYPE translate;
|
|
||||||
|
|
||||||
/* Number of subexpressions found by the compiler. */
|
|
||||||
size_t re_nsub;
|
|
||||||
|
|
||||||
/* Zero if this pattern cannot match the empty string, one else.
|
|
||||||
Well, in truth it's used only in `re_search_2', to see
|
|
||||||
whether or not we should use the fastmap, so we don't set
|
|
||||||
this absolutely perfectly; see `re_compile_fastmap' (the
|
|
||||||
`duplicate' case). */
|
|
||||||
unsigned can_be_null : 1;
|
|
||||||
|
|
||||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
|
||||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
|
||||||
If REGS_REALLOCATE, reallocate space if necessary.
|
|
||||||
If REGS_FIXED, use what's there. */
|
|
||||||
#define REGS_UNALLOCATED 0
|
|
||||||
#define REGS_REALLOCATE 1
|
|
||||||
#define REGS_FIXED 2
|
|
||||||
unsigned regs_allocated : 2;
|
|
||||||
|
|
||||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
|
||||||
by `re_compile_fastmap' if it updates the fastmap. */
|
|
||||||
unsigned fastmap_accurate : 1;
|
|
||||||
|
|
||||||
/* If set, `re_match_2' does not return information about
|
|
||||||
subexpressions. */
|
|
||||||
unsigned no_sub : 1;
|
|
||||||
|
|
||||||
/* If set, a beginning-of-line anchor doesn't match at the
|
|
||||||
beginning of the string. */
|
|
||||||
unsigned not_bol : 1;
|
|
||||||
|
|
||||||
/* Similarly for an end-of-line anchor. */
|
|
||||||
unsigned not_eol : 1;
|
|
||||||
|
|
||||||
/* If true, an anchor at a newline matches. */
|
|
||||||
unsigned newline_anchor : 1;
|
|
||||||
|
|
||||||
/* [[[end pattern_buffer]]] */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct re_pattern_buffer regex_t;
|
|
||||||
|
|
||||||
/* Type for byte offsets within the string. POSIX mandates this. */
|
|
||||||
typedef int regoff_t;
|
|
||||||
|
|
||||||
|
|
||||||
/* This is the structure we store register match data in. See
|
|
||||||
regex.texinfo for a full description of what registers match. */
|
|
||||||
struct re_registers
|
|
||||||
{
|
|
||||||
unsigned num_regs;
|
|
||||||
regoff_t *start;
|
|
||||||
regoff_t *end;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
|
|
||||||
`re_match_2' returns information about at least this many registers
|
|
||||||
the first time a `regs' structure is passed. */
|
|
||||||
#ifndef RE_NREGS
|
|
||||||
# define RE_NREGS 30
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* POSIX specification for registers. Aside from the different names than
|
|
||||||
`re_registers', POSIX uses an array of structures, instead of a
|
|
||||||
structure of arrays. */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
|
|
||||||
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
|
|
||||||
} regmatch_t;
|
|
||||||
|
|
||||||
/* Declarations for routines. */
|
|
||||||
|
|
||||||
/* To avoid duplicating every routine declaration -- once with a
|
|
||||||
prototype (if we are ANSI), and once without (if we aren't) -- we
|
|
||||||
use the following macro to declare argument types. This
|
|
||||||
unfortunately clutters up the declarations a bit, but I think it's
|
|
||||||
worth it. */
|
|
||||||
|
|
||||||
#if __STDC__
|
|
||||||
|
|
||||||
# define _RE_ARGS(args) args
|
|
||||||
|
|
||||||
#else /* not __STDC__ */
|
|
||||||
|
|
||||||
# define _RE_ARGS(args) ()
|
|
||||||
|
|
||||||
#endif /* not __STDC__ */
|
|
||||||
|
|
||||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
|
||||||
You can also simply assign to the `re_syntax_options' variable. */
|
|
||||||
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
|
||||||
|
|
||||||
/* Compile the regular expression PATTERN, with length LENGTH
|
|
||||||
and syntax given by the global `re_syntax_options', into the buffer
|
|
||||||
BUFFER. Return NULL if successful, and an error string if not. */
|
|
||||||
extern const char *re_compile_pattern
|
|
||||||
_RE_ARGS ((const char *pattern, size_t length,
|
|
||||||
struct re_pattern_buffer *buffer));
|
|
||||||
|
|
||||||
|
|
||||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
|
||||||
accelerate searches. Return 0 if successful and -2 if was an
|
|
||||||
internal error. */
|
|
||||||
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
|
||||||
|
|
||||||
|
|
||||||
/* Search in the string STRING (with length LENGTH) for the pattern
|
|
||||||
compiled into BUFFER. Start searching at position START, for RANGE
|
|
||||||
characters. Return the starting position of the match, -1 for no
|
|
||||||
match, or -2 for an internal error. Also return register
|
|
||||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
|
||||||
extern int re_search
|
|
||||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
|
||||||
int length, int start, int range, struct re_registers *regs));
|
|
||||||
|
|
||||||
|
|
||||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
|
||||||
STRING2. Also, stop searching at index START + STOP. */
|
|
||||||
extern int re_search_2
|
|
||||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
|
||||||
int length1, const char *string2, int length2,
|
|
||||||
int start, int range, struct re_registers *regs, int stop));
|
|
||||||
|
|
||||||
|
|
||||||
/* Like `re_search', but return how many characters in STRING the regexp
|
|
||||||
in BUFFER matched, starting at position START. */
|
|
||||||
extern int re_match
|
|
||||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
|
||||||
int length, int start, struct re_registers *regs));
|
|
||||||
|
|
||||||
|
|
||||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
|
||||||
extern int re_match_2
|
|
||||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
|
||||||
int length1, const char *string2, int length2,
|
|
||||||
int start, struct re_registers *regs, int stop));
|
|
||||||
|
|
||||||
|
|
||||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
|
||||||
ENDS. Subsequent matches using BUFFER and REGS will use this memory
|
|
||||||
for recording register information. STARTS and ENDS must be
|
|
||||||
allocated with malloc, and must each be at least `NUM_REGS * sizeof
|
|
||||||
(regoff_t)' bytes long.
|
|
||||||
|
|
||||||
If NUM_REGS == 0, then subsequent matches should allocate their own
|
|
||||||
register data.
|
|
||||||
|
|
||||||
Unless this function is called, the first search or match using
|
|
||||||
PATTERN_BUFFER will allocate its own register data, without
|
|
||||||
freeing the old data. */
|
|
||||||
extern void re_set_registers
|
|
||||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
|
||||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
|
||||||
|
|
||||||
#if defined _REGEX_RE_COMP || defined _LIBC
|
|
||||||
# ifndef _CRAY
|
|
||||||
/* 4.2 bsd compatibility. */
|
|
||||||
extern char *re_comp _RE_ARGS ((const char *));
|
|
||||||
extern int re_exec _RE_ARGS ((const char *));
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* POSIX compatibility. */
|
|
||||||
extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern,
|
|
||||||
int __cflags));
|
|
||||||
|
|
||||||
extern int regexec _RE_ARGS ((const regex_t *__preg,
|
|
||||||
const char *__string, size_t __nmatch,
|
|
||||||
regmatch_t __pmatch[], int __eflags));
|
|
||||||
|
|
||||||
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
|
||||||
char *__errbuf, size_t __errbuf_size));
|
|
||||||
|
|
||||||
extern void regfree _RE_ARGS ((regex_t *__preg));
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* C++ */
|
|
||||||
|
|
||||||
#endif /* regex.h */
|
|
||||||
|
|
||||||
/*
|
|
||||||
Local variables:
|
|
||||||
make-backup-files: t
|
|
||||||
version-control: t
|
|
||||||
trim-versions-without-asking: nil
|
|
||||||
End:
|
|
||||||
*/
|
|
||||||
-170
@@ -1,170 +0,0 @@
|
|||||||
/* $Id: grammar.y,v 1.4 2001-08-26 21:08:36 rjkaes Exp $
|
|
||||||
*
|
|
||||||
* This is the grammar for tinyproxy's configuration file. It needs to be
|
|
||||||
* in sync with scanner.l. If you know more about yacc and lex than I do
|
|
||||||
* please update these files.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
%{
|
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
|
||||||
|
|
||||||
#include "acl.h"
|
|
||||||
#include "anonymous.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "thread.h"
|
|
||||||
|
|
||||||
void yyerror(char *s);
|
|
||||||
int yylex(void);
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
%union {
|
|
||||||
unsigned int num;
|
|
||||||
char *cptr;
|
|
||||||
void *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* statements */
|
|
||||||
%token KW_PORT KW_LISTEN
|
|
||||||
%token KW_LOGFILE KW_PIDFILE KW_SYSLOG
|
|
||||||
%token KW_MAXCLIENTS KW_MAXSPARESERVERS KW_MINSPARESERVERS KW_STARTSERVERS
|
|
||||||
%token KW_MAXREQUESTSPERCHILD
|
|
||||||
%token KW_TIMEOUT
|
|
||||||
%token KW_USER KW_GROUP
|
|
||||||
%token KW_ANONYMOUS KW_FILTER KW_XTINYPROXY KW_TUNNEL
|
|
||||||
%token KW_ALLOW KW_DENY
|
|
||||||
|
|
||||||
/* yes/no switches */
|
|
||||||
%token KW_YES KW_NO
|
|
||||||
|
|
||||||
/* settings for loglevel */
|
|
||||||
%token KW_LOGLEVEL
|
|
||||||
%token KW_LOG_CRITICAL KW_LOG_ERROR KW_LOG_WARNING KW_LOG_NOTICE KW_LOG_CONNECT KW_LOG_INFO
|
|
||||||
|
|
||||||
%token <cptr> IDENTIFIER
|
|
||||||
%token <num> NUMBER
|
|
||||||
%token <cptr> STRING
|
|
||||||
%token <cptr> NUMERIC_ADDRESS
|
|
||||||
%token <cptr> STRING_ADDRESS
|
|
||||||
%token <cptr> NETMASK_ADDRESS
|
|
||||||
|
|
||||||
%type <num> yesno
|
|
||||||
%type <cptr> string
|
|
||||||
%type <cptr> network_address
|
|
||||||
%type <cptr> unique_address
|
|
||||||
%type <num> loglevels
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
start
|
|
||||||
: /* empty */
|
|
||||||
| start line
|
|
||||||
;
|
|
||||||
|
|
||||||
line
|
|
||||||
: '\n'
|
|
||||||
| statement '\n'
|
|
||||||
;
|
|
||||||
|
|
||||||
statement
|
|
||||||
: KW_PORT NUMBER { config.port = $2; }
|
|
||||||
| KW_TIMEOUT NUMBER { config.idletimeout = $2; }
|
|
||||||
| KW_SYSLOG yesno
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
|
||||||
config.syslog = $2;
|
|
||||||
#else
|
|
||||||
log_message(LOG_WARNING, "Syslog support was not compiled in.");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
| KW_MAXCLIENTS NUMBER { thread_configure(THREAD_MAXCLIENTS, $2); }
|
|
||||||
| KW_MAXSPARESERVERS NUMBER { thread_configure(THREAD_MAXSPARESERVERS, $2); }
|
|
||||||
| KW_MINSPARESERVERS NUMBER { thread_configure(THREAD_MINSPARESERVERS, $2); }
|
|
||||||
| KW_STARTSERVERS NUMBER { thread_configure(THREAD_STARTSERVERS, $2); }
|
|
||||||
| KW_MAXREQUESTSPERCHILD NUMBER { thread_configure(THREAD_MAXREQUESTSPERCHILD, $2); }
|
|
||||||
| KW_LOGFILE string
|
|
||||||
{
|
|
||||||
config.logf_name = $2;
|
|
||||||
if (!config.logf_name) {
|
|
||||||
fprintf(stderr, "bad log file\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
| KW_PIDFILE string { config.pidpath = $2; }
|
|
||||||
| KW_USER string { config.username = $2; }
|
|
||||||
| KW_GROUP string { config.group = $2; }
|
|
||||||
| KW_ANONYMOUS string { anonymous_insert($2); }
|
|
||||||
| KW_FILTER string
|
|
||||||
{
|
|
||||||
#ifdef FILTER_ENABLE
|
|
||||||
config.filter = $2;
|
|
||||||
#else
|
|
||||||
log_message(LOG_WARNING, "Filter support was not compiled in.");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
| KW_XTINYPROXY network_address { config.my_domain = $2; }
|
|
||||||
| KW_TUNNEL unique_address ':' NUMBER
|
|
||||||
{
|
|
||||||
#ifdef TUNNEL_SUPPORT
|
|
||||||
config.tunnel_name = $2;
|
|
||||||
config.tunnel_port = $4;
|
|
||||||
#else
|
|
||||||
log_message(LOG_WARNING, "Tunnel support was not compiled in.");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
| KW_LISTEN NUMERIC_ADDRESS { config.ipAddr = $2; }
|
|
||||||
| KW_ALLOW network_address { insert_acl($2, ACL_ALLOW); }
|
|
||||||
| KW_DENY network_address { insert_acl($2, ACL_DENY); }
|
|
||||||
| KW_LOGLEVEL loglevels { set_log_level($2); }
|
|
||||||
;
|
|
||||||
|
|
||||||
loglevels
|
|
||||||
: KW_LOG_CRITICAL { $$ = LOG_CRIT; }
|
|
||||||
| KW_LOG_ERROR { $$ = LOG_ERR; }
|
|
||||||
| KW_LOG_WARNING { $$ = LOG_WARNING; }
|
|
||||||
| KW_LOG_NOTICE { $$ = LOG_NOTICE; }
|
|
||||||
| KW_LOG_CONNECT { $$ = LOG_CONN; }
|
|
||||||
| KW_LOG_INFO { $$ = LOG_INFO; }
|
|
||||||
;
|
|
||||||
|
|
||||||
network_address
|
|
||||||
: unique_address
|
|
||||||
| NETMASK_ADDRESS
|
|
||||||
;
|
|
||||||
|
|
||||||
unique_address
|
|
||||||
: STRING_ADDRESS
|
|
||||||
| NUMERIC_ADDRESS
|
|
||||||
;
|
|
||||||
|
|
||||||
yesno
|
|
||||||
: KW_YES { $$ = 1; }
|
|
||||||
| KW_NO { $$ = 0; }
|
|
||||||
| NUMBER { $$ = $1; }
|
|
||||||
;
|
|
||||||
|
|
||||||
string
|
|
||||||
: IDENTIFIER
|
|
||||||
| STRING
|
|
||||||
;
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
extern unsigned int yylineno;
|
|
||||||
|
|
||||||
void yyerror(char *s)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Line %d: %s\n", yylineno, s);
|
|
||||||
}
|
|
||||||
+516
@@ -0,0 +1,516 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* A hashmap implementation. The keys are case-insensitive NULL terminated
|
||||||
|
* strings, and the data is arbitrary lumps of data. Copies of both the
|
||||||
|
* key and the data in the hashmap itself, so you must free the original
|
||||||
|
* key and data to avoid a memory leak. The hashmap returns a pointer
|
||||||
|
* to the data when a key is searched for, so take care in modifying the
|
||||||
|
* data as it's modifying the data stored in the hashmap. (In other words,
|
||||||
|
* don't try to free the data, or realloc the memory. :)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "hashmap.h"
|
||||||
|
#include "heap.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These structures are the storage for the hashmap. Entries are stored in
|
||||||
|
* struct hashentry_s (the key, data, and length), and all the "buckets" are
|
||||||
|
* grouped together in hashmap_s. The hashmap_s.size member is for
|
||||||
|
* internal use. It stores the number of buckets the hashmap was created
|
||||||
|
* with.
|
||||||
|
*/
|
||||||
|
struct hashentry_s {
|
||||||
|
char *key;
|
||||||
|
void *data;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
struct hashentry_s *prev, *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hashbucket_s {
|
||||||
|
struct hashentry_s *head, *tail;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hashmap_s {
|
||||||
|
uint32_t seed;
|
||||||
|
unsigned int size;
|
||||||
|
hashmap_iter end_iterator;
|
||||||
|
|
||||||
|
struct hashbucket_s *buckets;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A NULL terminated string is passed to this function and a "hash" value
|
||||||
|
* is produced within the range of [0 .. size) (In other words, 0 to one
|
||||||
|
* less than size.)
|
||||||
|
* The contents of the key are converted to lowercase, so this function
|
||||||
|
* is not case-sensitive.
|
||||||
|
*
|
||||||
|
* This is Dan Bernstein's hash function as described, for example, here:
|
||||||
|
* http://www.cse.yorku.ca/~oz/hash.html
|
||||||
|
*
|
||||||
|
* If any of the arguments are invalid a negative number is returned.
|
||||||
|
*/
|
||||||
|
static int hashfunc (const char *key, unsigned int size, uint32_t seed)
|
||||||
|
{
|
||||||
|
uint32_t hash;
|
||||||
|
|
||||||
|
if (key == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
if (size == 0)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
for (hash = seed; *key != '\0'; key++) {
|
||||||
|
hash = ((hash << 5) + hash) ^ tolower (*key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Keep the hash within the table limits */
|
||||||
|
return hash % size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a hashmap with the requested number of buckets. If "nbuckets" is
|
||||||
|
* not greater than zero a NULL is returned; otherwise, a _token_ to the
|
||||||
|
* hashmap is returned.
|
||||||
|
*
|
||||||
|
* NULLs are also returned if memory could not be allocated for hashmap.
|
||||||
|
*/
|
||||||
|
hashmap_t hashmap_create (unsigned int nbuckets)
|
||||||
|
{
|
||||||
|
struct hashmap_s *ptr;
|
||||||
|
|
||||||
|
if (nbuckets == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ptr = (struct hashmap_s *) safecalloc (1, sizeof (struct hashmap_s));
|
||||||
|
if (!ptr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ptr->seed = (uint32_t)rand();
|
||||||
|
ptr->size = nbuckets;
|
||||||
|
ptr->buckets = (struct hashbucket_s *) safecalloc (nbuckets,
|
||||||
|
sizeof (struct
|
||||||
|
hashbucket_s));
|
||||||
|
if (!ptr->buckets) {
|
||||||
|
safefree (ptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This points to "one" past the end of the hashmap. */
|
||||||
|
ptr->end_iterator = 0;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Follow the chain of hashentries and delete them (including the data and
|
||||||
|
* the key.)
|
||||||
|
*
|
||||||
|
* Returns: 0 if the function completed successfully
|
||||||
|
* negative number is returned if "entry" was NULL
|
||||||
|
*/
|
||||||
|
static int delete_hashbucket (struct hashbucket_s *bucket)
|
||||||
|
{
|
||||||
|
struct hashentry_s *nextptr;
|
||||||
|
struct hashentry_s *ptr;
|
||||||
|
|
||||||
|
if (bucket == NULL || bucket->head == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
ptr = bucket->head;
|
||||||
|
while (ptr) {
|
||||||
|
nextptr = ptr->next;
|
||||||
|
|
||||||
|
safefree (ptr->key);
|
||||||
|
safefree (ptr->data);
|
||||||
|
safefree (ptr);
|
||||||
|
|
||||||
|
ptr = nextptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deletes a hashmap. All the key/data pairs are also deleted.
|
||||||
|
*
|
||||||
|
* Returns: 0 on success
|
||||||
|
* negative if a NULL "map" was supplied
|
||||||
|
*/
|
||||||
|
int hashmap_delete (hashmap_t map)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
if (map == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
for (i = 0; i != map->size; i++) {
|
||||||
|
if (map->buckets[i].head != NULL) {
|
||||||
|
delete_hashbucket (&map->buckets[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
safefree (map->buckets);
|
||||||
|
safefree (map);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inserts a NULL terminated string (as the key), plus any arbitrary "data"
|
||||||
|
* of "len" bytes. Both the key and the data are copied, so the original
|
||||||
|
* key/data must be freed to avoid a memory leak.
|
||||||
|
* The "data" must be non-NULL and "len" must be greater than zero. You
|
||||||
|
* cannot insert NULL data in association with the key.
|
||||||
|
*
|
||||||
|
* Returns: 0 on success
|
||||||
|
* negative number if there are errors
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
hashmap_insert (hashmap_t map, const char *key, const void *data, size_t len)
|
||||||
|
{
|
||||||
|
struct hashentry_s *ptr;
|
||||||
|
int hash;
|
||||||
|
char *key_copy;
|
||||||
|
void *data_copy;
|
||||||
|
|
||||||
|
assert (map != NULL);
|
||||||
|
assert (key != NULL);
|
||||||
|
assert (data != NULL);
|
||||||
|
assert (len > 0);
|
||||||
|
|
||||||
|
if (map == NULL || key == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
if (!data || len < 1)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
hash = hashfunc (key, map->size, map->seed);
|
||||||
|
if (hash < 0)
|
||||||
|
return hash;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First make copies of the key and data in case there is a memory
|
||||||
|
* problem later.
|
||||||
|
*/
|
||||||
|
key_copy = safestrdup (key);
|
||||||
|
if (!key_copy)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
data_copy = safemalloc (len);
|
||||||
|
if (!data_copy) {
|
||||||
|
safefree (key_copy);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
memcpy (data_copy, data, len);
|
||||||
|
|
||||||
|
ptr = (struct hashentry_s *) safemalloc (sizeof (struct hashentry_s));
|
||||||
|
if (!ptr) {
|
||||||
|
safefree (key_copy);
|
||||||
|
safefree (data_copy);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr->key = key_copy;
|
||||||
|
ptr->data = data_copy;
|
||||||
|
ptr->len = len;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now add the entry to the end of the bucket chain.
|
||||||
|
*/
|
||||||
|
ptr->next = NULL;
|
||||||
|
ptr->prev = map->buckets[hash].tail;
|
||||||
|
if (map->buckets[hash].tail)
|
||||||
|
map->buckets[hash].tail->next = ptr;
|
||||||
|
|
||||||
|
map->buckets[hash].tail = ptr;
|
||||||
|
if (!map->buckets[hash].head)
|
||||||
|
map->buckets[hash].head = ptr;
|
||||||
|
|
||||||
|
map->end_iterator++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get an iterator to the first entry.
|
||||||
|
*
|
||||||
|
* Returns: an negative value upon error.
|
||||||
|
*/
|
||||||
|
hashmap_iter hashmap_first (hashmap_t map)
|
||||||
|
{
|
||||||
|
assert (map != NULL);
|
||||||
|
|
||||||
|
if (!map)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (map->end_iterator == 0)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks to see if the iterator is pointing at the "end" of the entries.
|
||||||
|
*
|
||||||
|
* Returns: 1 if it is the end
|
||||||
|
* 0 otherwise
|
||||||
|
*/
|
||||||
|
int hashmap_is_end (hashmap_t map, hashmap_iter iter)
|
||||||
|
{
|
||||||
|
assert (map != NULL);
|
||||||
|
assert (iter >= 0);
|
||||||
|
|
||||||
|
if (!map || iter < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (iter == map->end_iterator)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a "pointer" to the first instance of the particular key. It can
|
||||||
|
* be tested against hashmap_is_end() to see if the key was not found.
|
||||||
|
*
|
||||||
|
* Returns: negative upon an error
|
||||||
|
* an "iterator" pointing at the first key
|
||||||
|
* an "end-iterator" if the key wasn't found
|
||||||
|
*/
|
||||||
|
hashmap_iter hashmap_find (hashmap_t map, const char *key)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
hashmap_iter iter = 0;
|
||||||
|
struct hashentry_s *ptr;
|
||||||
|
|
||||||
|
assert (map != NULL);
|
||||||
|
assert (key != NULL);
|
||||||
|
|
||||||
|
if (!map || !key)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Loop through all the keys and look for the first occurrence
|
||||||
|
* of a particular key.
|
||||||
|
*/
|
||||||
|
for (i = 0; i != map->size; i++) {
|
||||||
|
ptr = map->buckets[i].head;
|
||||||
|
|
||||||
|
while (ptr) {
|
||||||
|
if (strcasecmp (ptr->key, key) == 0) {
|
||||||
|
/* Found it, so return the current count */
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
iter++;
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve the data associated with a particular iterator.
|
||||||
|
*
|
||||||
|
* Returns: the length of the data block upon success
|
||||||
|
* negative upon error
|
||||||
|
*/
|
||||||
|
ssize_t
|
||||||
|
hashmap_return_entry (hashmap_t map, hashmap_iter iter, char **key, void **data)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
struct hashentry_s *ptr;
|
||||||
|
hashmap_iter count = 0;
|
||||||
|
|
||||||
|
assert (map != NULL);
|
||||||
|
assert (iter >= 0);
|
||||||
|
assert (iter != map->end_iterator);
|
||||||
|
assert (key != NULL);
|
||||||
|
assert (data != NULL);
|
||||||
|
|
||||||
|
if (!map || iter < 0 || !key || !data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
for (i = 0; i != map->size; i++) {
|
||||||
|
ptr = map->buckets[i].head;
|
||||||
|
while (ptr) {
|
||||||
|
if (count == iter) {
|
||||||
|
/* This is the data so return it */
|
||||||
|
*key = ptr->key;
|
||||||
|
*data = ptr->data;
|
||||||
|
return ptr->len;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = ptr->next;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Searches for _any_ occurrences of "key" within the hashmap.
|
||||||
|
*
|
||||||
|
* Returns: negative upon an error
|
||||||
|
* zero if no key is found
|
||||||
|
* count found
|
||||||
|
*/
|
||||||
|
ssize_t hashmap_search (hashmap_t map, const char *key)
|
||||||
|
{
|
||||||
|
int hash;
|
||||||
|
struct hashentry_s *ptr;
|
||||||
|
ssize_t count = 0;
|
||||||
|
|
||||||
|
if (map == NULL || key == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
hash = hashfunc (key, map->size, map->seed);
|
||||||
|
if (hash < 0)
|
||||||
|
return hash;
|
||||||
|
|
||||||
|
ptr = map->buckets[hash].head;
|
||||||
|
|
||||||
|
/* All right, there is an entry here, now see if it's the one we want */
|
||||||
|
while (ptr) {
|
||||||
|
if (strcasecmp (ptr->key, key) == 0)
|
||||||
|
++count;
|
||||||
|
|
||||||
|
/* This entry didn't contain the key; move to the next one */
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the first entry (assuming there is more than one) for a particular
|
||||||
|
* key. The data MUST be non-NULL.
|
||||||
|
*
|
||||||
|
* Returns: negative upon error
|
||||||
|
* zero if no entry is found
|
||||||
|
* length of data for the entry
|
||||||
|
*/
|
||||||
|
ssize_t hashmap_entry_by_key (hashmap_t map, const char *key, void **data)
|
||||||
|
{
|
||||||
|
int hash;
|
||||||
|
struct hashentry_s *ptr;
|
||||||
|
|
||||||
|
if (!map || !key || !data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
hash = hashfunc (key, map->size, map->seed);
|
||||||
|
if (hash < 0)
|
||||||
|
return hash;
|
||||||
|
|
||||||
|
ptr = map->buckets[hash].head;
|
||||||
|
|
||||||
|
while (ptr) {
|
||||||
|
if (strcasecmp (ptr->key, key) == 0) {
|
||||||
|
*data = ptr->data;
|
||||||
|
return ptr->len;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Go through the hashmap and remove the particular key.
|
||||||
|
* NOTE: This will invalidate any iterators which have been created.
|
||||||
|
*
|
||||||
|
* Remove: negative upon error
|
||||||
|
* 0 if the key was not found
|
||||||
|
* positive count of entries deleted
|
||||||
|
*/
|
||||||
|
ssize_t hashmap_remove (hashmap_t map, const char *key)
|
||||||
|
{
|
||||||
|
int hash;
|
||||||
|
struct hashentry_s *ptr, *next;
|
||||||
|
short int deleted = 0;
|
||||||
|
|
||||||
|
if (map == NULL || key == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
hash = hashfunc (key, map->size, map->seed);
|
||||||
|
if (hash < 0)
|
||||||
|
return hash;
|
||||||
|
|
||||||
|
ptr = map->buckets[hash].head;
|
||||||
|
while (ptr) {
|
||||||
|
if (strcasecmp (ptr->key, key) == 0) {
|
||||||
|
/*
|
||||||
|
* Found the data, now need to remove everything
|
||||||
|
* and update the hashmap.
|
||||||
|
*/
|
||||||
|
next = ptr->next;
|
||||||
|
|
||||||
|
if (ptr->prev)
|
||||||
|
ptr->prev->next = ptr->next;
|
||||||
|
if (ptr->next)
|
||||||
|
ptr->next->prev = ptr->prev;
|
||||||
|
|
||||||
|
if (map->buckets[hash].head == ptr)
|
||||||
|
map->buckets[hash].head = ptr->next;
|
||||||
|
if (map->buckets[hash].tail == ptr)
|
||||||
|
map->buckets[hash].tail = ptr->prev;
|
||||||
|
|
||||||
|
safefree (ptr->key);
|
||||||
|
safefree (ptr->data);
|
||||||
|
safefree (ptr);
|
||||||
|
|
||||||
|
++deleted;
|
||||||
|
--map->end_iterator;
|
||||||
|
|
||||||
|
ptr = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This entry didn't contain the key; move to the next one */
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The key was not found, so return 0 */
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look up the value for a variable.
|
||||||
|
*/
|
||||||
|
char *lookup_variable (hashmap_t map, const char *varname)
|
||||||
|
{
|
||||||
|
hashmap_iter result_iter;
|
||||||
|
char *key;
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
result_iter = hashmap_find (map, varname);
|
||||||
|
|
||||||
|
if (hashmap_is_end (map, result_iter))
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (hashmap_return_entry (map, result_iter,
|
||||||
|
&key, (void **) &data) < 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
return (data);
|
||||||
|
}
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'hashmap.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef _HASHMAP_H
|
||||||
|
#define _HASHMAP_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We're using a typedef here to "hide" the implementation details of the
|
||||||
|
* hash map. Sure, it's a pointer, but the struct is hidden in the C file.
|
||||||
|
* So, just use the hashmap_t like it's a cookie. :)
|
||||||
|
*/
|
||||||
|
typedef struct hashmap_s *hashmap_t;
|
||||||
|
typedef int hashmap_iter;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* hashmap_create() takes one argument, which is the number of buckets to
|
||||||
|
* use internally. hashmap_delete() is self explanatory.
|
||||||
|
*/
|
||||||
|
extern hashmap_t hashmap_create (unsigned int nbuckets);
|
||||||
|
extern int hashmap_delete (hashmap_t map);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When the you insert a key/data pair into the hashmap it will the key
|
||||||
|
* and data are duplicated, so you must free your copy if it was created
|
||||||
|
* on the heap. The key must be a NULL terminated string. "data" must be
|
||||||
|
* non-NULL and length must be greater than zero.
|
||||||
|
*
|
||||||
|
* Returns: negative on error
|
||||||
|
* 0 upon successful insert
|
||||||
|
*/
|
||||||
|
extern int hashmap_insert (hashmap_t map, const char *key,
|
||||||
|
const void *data, size_t len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get an iterator to the first entry.
|
||||||
|
*
|
||||||
|
* Returns: an negative value upon error.
|
||||||
|
*/
|
||||||
|
extern hashmap_iter hashmap_first (hashmap_t map);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks to see if the iterator is pointing at the "end" of the entries.
|
||||||
|
*
|
||||||
|
* Returns: 1 if it is the end
|
||||||
|
* 0 otherwise
|
||||||
|
*/
|
||||||
|
extern int hashmap_is_end (hashmap_t map, hashmap_iter iter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a "pointer" to the first instance of the particular key. It can
|
||||||
|
* be tested against hashmap_is_end() to see if the key was not found.
|
||||||
|
*
|
||||||
|
* Returns: negative upon an error
|
||||||
|
* an "iterator" pointing at the first key
|
||||||
|
* an "end-iterator" if the key wasn't found
|
||||||
|
*/
|
||||||
|
extern hashmap_iter hashmap_find (hashmap_t map, const char *key);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve the key/data associated with a particular iterator.
|
||||||
|
* NOTE: These are pointers to the actual data, so don't mess around with them
|
||||||
|
* too much.
|
||||||
|
*
|
||||||
|
* Returns: the length of the data block upon success
|
||||||
|
* negative upon error
|
||||||
|
*/
|
||||||
|
extern ssize_t hashmap_return_entry (hashmap_t map, hashmap_iter iter,
|
||||||
|
char **key, void **data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the first entry (assuming there is more than one) for a particular
|
||||||
|
* key. The data MUST be non-NULL.
|
||||||
|
*
|
||||||
|
* Returns: negative upon error
|
||||||
|
* zero if no entry is found
|
||||||
|
* length of data for the entry
|
||||||
|
*/
|
||||||
|
extern ssize_t hashmap_entry_by_key (hashmap_t map, const char *key,
|
||||||
|
void **data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Searches for _any_ occurrances of "key" within the hashmap and returns the
|
||||||
|
* number of matching entries.
|
||||||
|
*
|
||||||
|
* Returns: negative upon an error
|
||||||
|
* zero if no key is found
|
||||||
|
* count found (positive value)
|
||||||
|
*/
|
||||||
|
extern ssize_t hashmap_search (hashmap_t map, const char *key);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Go through the hashmap and remove the particular key.
|
||||||
|
* NOTE: This will invalidate any iterators which have been created.
|
||||||
|
*
|
||||||
|
* Remove: negative upon error
|
||||||
|
* 0 if the key was not found
|
||||||
|
* positive count of entries deleted
|
||||||
|
*/
|
||||||
|
extern ssize_t hashmap_remove (hashmap_t map, const char *key);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look up the value for a variable.
|
||||||
|
*/
|
||||||
|
extern char *lookup_variable (hashmap_t map, const char *varname);
|
||||||
|
|
||||||
|
#endif /* _HASHMAP_H */
|
||||||
+157
@@ -0,0 +1,157 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Debugging versions of various heap related functions are combined
|
||||||
|
* here. The debugging versions include assertions and also print
|
||||||
|
* (to standard error) the function called along with the amount
|
||||||
|
* of memory allocated, and where the memory is pointing. The
|
||||||
|
* format of the log message is standardized.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "text.h"
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
|
||||||
|
void *debugging_calloc (size_t nmemb, size_t size, const char *file,
|
||||||
|
unsigned long line)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
assert (nmemb > 0);
|
||||||
|
assert (size > 0);
|
||||||
|
|
||||||
|
ptr = calloc (nmemb, size);
|
||||||
|
fprintf (stderr, "{calloc: %p:%lu x %lu} %s:%lu\n", ptr,
|
||||||
|
(unsigned long) nmemb, (unsigned long) size, file, line);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *debugging_malloc (size_t size, const char *file, unsigned long line)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
assert (size > 0);
|
||||||
|
|
||||||
|
ptr = malloc (size);
|
||||||
|
fprintf (stderr, "{malloc: %p:%lu} %s:%lu\n", ptr,
|
||||||
|
(unsigned long) size, file, line);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *debugging_realloc (void *ptr, size_t size, const char *file,
|
||||||
|
unsigned long line)
|
||||||
|
{
|
||||||
|
void *newptr;
|
||||||
|
|
||||||
|
assert (size > 0);
|
||||||
|
|
||||||
|
newptr = realloc (ptr, size);
|
||||||
|
fprintf (stderr, "{realloc: %p -> %p:%lu} %s:%lu\n", ptr, newptr,
|
||||||
|
(unsigned long) size, file, line);
|
||||||
|
return newptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void debugging_free (void *ptr, const char *file, unsigned long line)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "{free: %p} %s:%lu\n", ptr, file, line);
|
||||||
|
|
||||||
|
if (ptr != NULL)
|
||||||
|
free (ptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *debugging_strdup (const char *s, const char *file, unsigned long line)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
assert (s != NULL);
|
||||||
|
|
||||||
|
len = strlen (s) + 1;
|
||||||
|
ptr = (char *) malloc (len);
|
||||||
|
if (!ptr)
|
||||||
|
return NULL;
|
||||||
|
memcpy (ptr, s, len);
|
||||||
|
|
||||||
|
fprintf (stderr, "{strdup: %p:%lu} %s:%lu\n", ptr,
|
||||||
|
(unsigned long) len, file, line);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !NDEBUG */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a block of memory in the "shared" memory region.
|
||||||
|
*
|
||||||
|
* FIXME: This uses the most basic (and slowest) means of creating a
|
||||||
|
* shared memory location. It requires the use of a temporary file. We might
|
||||||
|
* want to look into something like MM (Shared Memory Library) for a better
|
||||||
|
* solution.
|
||||||
|
*/
|
||||||
|
void *malloc_shared_memory (size_t size)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
void *ptr;
|
||||||
|
char buffer[32];
|
||||||
|
|
||||||
|
static const char *shared_file = "/tmp/tinyproxy.shared.XXXXXX";
|
||||||
|
|
||||||
|
assert (size > 0);
|
||||||
|
|
||||||
|
strlcpy (buffer, shared_file, sizeof (buffer));
|
||||||
|
|
||||||
|
/* Only allow u+rw bits. This may be required for some versions
|
||||||
|
* of glibc so that mkstemp() doesn't make us vulnerable.
|
||||||
|
*/
|
||||||
|
umask (0177);
|
||||||
|
|
||||||
|
if ((fd = mkstemp (buffer)) == -1)
|
||||||
|
return MAP_FAILED;
|
||||||
|
unlink (buffer);
|
||||||
|
|
||||||
|
if (ftruncate (fd, size) == -1)
|
||||||
|
return MAP_FAILED;
|
||||||
|
ptr = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a block of memory from the "shared" region an initialize it to
|
||||||
|
* zero.
|
||||||
|
*/
|
||||||
|
void *calloc_shared_memory (size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
long length;
|
||||||
|
|
||||||
|
assert (nmemb > 0);
|
||||||
|
assert (size > 0);
|
||||||
|
|
||||||
|
length = nmemb * size;
|
||||||
|
|
||||||
|
ptr = malloc_shared_memory (length);
|
||||||
|
if (ptr == MAP_FAILED)
|
||||||
|
return ptr;
|
||||||
|
|
||||||
|
memset (ptr, 0, length);
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'heap.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_HEAP_H
|
||||||
|
#define TINYPROXY_HEAP_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following is to allow for better memory checking.
|
||||||
|
*/
|
||||||
|
#ifndef NDEBUG
|
||||||
|
|
||||||
|
extern void *debugging_calloc (size_t nmemb, size_t size, const char *file,
|
||||||
|
unsigned long line);
|
||||||
|
extern void *debugging_malloc (size_t size, const char *file,
|
||||||
|
unsigned long line);
|
||||||
|
extern void debugging_free (void *ptr, const char *file, unsigned long line);
|
||||||
|
extern void *debugging_realloc (void *ptr, size_t size, const char *file,
|
||||||
|
unsigned long line);
|
||||||
|
extern char *debugging_strdup (const char *s, const char *file,
|
||||||
|
unsigned long line);
|
||||||
|
|
||||||
|
# define safecalloc(x, y) debugging_calloc(x, y, __FILE__, __LINE__)
|
||||||
|
# define safemalloc(x) debugging_malloc(x, __FILE__, __LINE__)
|
||||||
|
# define saferealloc(x, y) debugging_realloc(x, y, __FILE__, __LINE__)
|
||||||
|
# define safestrdup(x) debugging_strdup(x, __FILE__, __LINE__)
|
||||||
|
# define safefree(x) (debugging_free(x, __FILE__, __LINE__), *(&(x)) = NULL)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define safecalloc(x, y) calloc(x, y)
|
||||||
|
# define safemalloc(x) malloc(x)
|
||||||
|
# define saferealloc(x, y) realloc(x, y)
|
||||||
|
# define safefree(x) (free (x), *(&(x)) = NULL)
|
||||||
|
# define safestrdup(x) strdup(x)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate memory from the "shared" region of memory.
|
||||||
|
*/
|
||||||
|
extern void *malloc_shared_memory (size_t size);
|
||||||
|
extern void *calloc_shared_memory (size_t nmemb, size_t size);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,312 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2003 Steven Young <sdyoung@miranda.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file contains source code for the handling and display of
|
||||||
|
* HTML error pages with variable substitution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "conns.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "html-error.h"
|
||||||
|
#include "network.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add an error number -> filename mapping to the errorpages list.
|
||||||
|
*/
|
||||||
|
#define ERRORNUM_BUFSIZE 8 /* this is more than required */
|
||||||
|
#define ERRPAGES_BUCKETCOUNT 16
|
||||||
|
|
||||||
|
int add_new_errorpage (char *filepath, unsigned int errornum)
|
||||||
|
{
|
||||||
|
char errornbuf[ERRORNUM_BUFSIZE];
|
||||||
|
|
||||||
|
config.errorpages = hashmap_create (ERRPAGES_BUCKETCOUNT);
|
||||||
|
if (!config.errorpages)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
snprintf (errornbuf, ERRORNUM_BUFSIZE, "%u", errornum);
|
||||||
|
|
||||||
|
if (hashmap_insert (config.errorpages, errornbuf,
|
||||||
|
filepath, strlen (filepath) + 1) < 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the file appropriate for a given error.
|
||||||
|
*/
|
||||||
|
static char *get_html_file (unsigned int errornum)
|
||||||
|
{
|
||||||
|
hashmap_iter result_iter;
|
||||||
|
char errornbuf[ERRORNUM_BUFSIZE];
|
||||||
|
char *key;
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
assert (errornum >= 100 && errornum < 1000);
|
||||||
|
|
||||||
|
if (!config.errorpages)
|
||||||
|
return (config.errorpage_undef);
|
||||||
|
|
||||||
|
snprintf (errornbuf, ERRORNUM_BUFSIZE, "%u", errornum);
|
||||||
|
|
||||||
|
result_iter = hashmap_find (config.errorpages, errornbuf);
|
||||||
|
|
||||||
|
if (hashmap_is_end (config.errorpages, result_iter))
|
||||||
|
return (config.errorpage_undef);
|
||||||
|
|
||||||
|
if (hashmap_return_entry (config.errorpages, result_iter,
|
||||||
|
&key, (void **) &val) < 0)
|
||||||
|
return (config.errorpage_undef);
|
||||||
|
|
||||||
|
return (val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send an already-opened file to the client with variable substitution.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
send_html_file (FILE *infile, struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
char *inbuf;
|
||||||
|
char *varstart = NULL;
|
||||||
|
char *p;
|
||||||
|
const char *varval;
|
||||||
|
int in_variable = 0;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
|
inbuf = (char *) safemalloc (4096);
|
||||||
|
|
||||||
|
while (fgets (inbuf, 4096, infile) != NULL) {
|
||||||
|
for (p = inbuf; *p; p++) {
|
||||||
|
switch (*p) {
|
||||||
|
case '}':
|
||||||
|
if (in_variable) {
|
||||||
|
*p = '\0';
|
||||||
|
varval = (const char *)
|
||||||
|
lookup_variable (connptr->error_variables,
|
||||||
|
varstart);
|
||||||
|
if (!varval)
|
||||||
|
varval = "(unknown)";
|
||||||
|
r = write_message (connptr->client_fd,
|
||||||
|
"%s", varval);
|
||||||
|
in_variable = 0;
|
||||||
|
} else {
|
||||||
|
r = write_message (connptr->client_fd,
|
||||||
|
"%c", *p);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '{':
|
||||||
|
/* a {{ will print a single {. If we are NOT
|
||||||
|
* already in a { variable, then proceed with
|
||||||
|
* setup. If we ARE already in a { variable,
|
||||||
|
* this code will fallthrough to the code that
|
||||||
|
* just dumps a character to the client fd.
|
||||||
|
*/
|
||||||
|
if (!in_variable) {
|
||||||
|
varstart = p + 1;
|
||||||
|
in_variable++;
|
||||||
|
} else
|
||||||
|
in_variable = 0;
|
||||||
|
|
||||||
|
/* FALL THROUGH */
|
||||||
|
default:
|
||||||
|
if (!in_variable) {
|
||||||
|
r = write_message (connptr->client_fd,
|
||||||
|
"%c", *p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r)
|
||||||
|
break;
|
||||||
|
|
||||||
|
in_variable = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
safefree (inbuf);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int send_http_headers (struct conn_s *connptr, int code, const char *message)
|
||||||
|
{
|
||||||
|
const char headers[] =
|
||||||
|
"HTTP/1.0 %d %s\r\n"
|
||||||
|
"Server: %s/%s\r\n"
|
||||||
|
"Content-Type: text/html\r\n"
|
||||||
|
"%s"
|
||||||
|
"Connection: close\r\n" "\r\n";
|
||||||
|
|
||||||
|
const char p_auth_str[] =
|
||||||
|
"Proxy-Authenticate: Basic realm=\""
|
||||||
|
PACKAGE_NAME "\"\r\n";
|
||||||
|
|
||||||
|
const char w_auth_str[] =
|
||||||
|
"WWW-Authenticate: Basic realm=\""
|
||||||
|
PACKAGE_NAME "\"\r\n";
|
||||||
|
|
||||||
|
/* according to rfc7235, the 407 error must be accompanied by
|
||||||
|
a Proxy-Authenticate header field. */
|
||||||
|
const char *add = code == 407 ? p_auth_str : (code == 401 ? w_auth_str : "");
|
||||||
|
|
||||||
|
return (write_message (connptr->client_fd, headers,
|
||||||
|
code, message, PACKAGE, VERSION,
|
||||||
|
add));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display an error to the client.
|
||||||
|
*/
|
||||||
|
int send_http_error_message (struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
char *error_file;
|
||||||
|
FILE *infile;
|
||||||
|
int ret;
|
||||||
|
const char *fallback_error =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
|
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" "
|
||||||
|
"\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
|
||||||
|
"<html>\n"
|
||||||
|
"<head><title>%d %s</title></head>\n"
|
||||||
|
"<body>\n"
|
||||||
|
"<h1>%s</h1>\n"
|
||||||
|
"<p>%s</p>\n"
|
||||||
|
"<hr />\n"
|
||||||
|
"<p><em>Generated by %s version %s.</em></p>\n" "</body>\n"
|
||||||
|
"</html>\n";
|
||||||
|
|
||||||
|
send_http_headers (connptr, connptr->error_number,
|
||||||
|
connptr->error_string);
|
||||||
|
|
||||||
|
error_file = get_html_file (connptr->error_number);
|
||||||
|
if (!(infile = fopen (error_file, "r"))) {
|
||||||
|
char *detail = lookup_variable (connptr->error_variables, "detail");
|
||||||
|
return (write_message (connptr->client_fd, fallback_error,
|
||||||
|
connptr->error_number,
|
||||||
|
connptr->error_string,
|
||||||
|
connptr->error_string,
|
||||||
|
detail, PACKAGE, VERSION));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = send_html_file (infile, connptr);
|
||||||
|
fclose (infile);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a key -> value mapping for HTML file substitution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ERRVAR_BUCKETCOUNT 16
|
||||||
|
|
||||||
|
int
|
||||||
|
add_error_variable (struct conn_s *connptr, const char *key, const char *val)
|
||||||
|
{
|
||||||
|
if (!connptr->error_variables)
|
||||||
|
if (!
|
||||||
|
(connptr->error_variables =
|
||||||
|
hashmap_create (ERRVAR_BUCKETCOUNT)))
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
return hashmap_insert (connptr->error_variables, key, val,
|
||||||
|
strlen (val) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ADD_VAR_RET(x, y) \
|
||||||
|
do { \
|
||||||
|
if (y == NULL) \
|
||||||
|
break; \
|
||||||
|
if (add_error_variable(connptr, x, y) < 0) \
|
||||||
|
return -1; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set some standard variables used by all HTML pages
|
||||||
|
*/
|
||||||
|
int add_standard_vars (struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
char errnobuf[16];
|
||||||
|
char timebuf[30];
|
||||||
|
time_t global_time;
|
||||||
|
|
||||||
|
snprintf (errnobuf, sizeof errnobuf, "%d", connptr->error_number);
|
||||||
|
ADD_VAR_RET ("errno", errnobuf);
|
||||||
|
|
||||||
|
ADD_VAR_RET ("cause", connptr->error_string);
|
||||||
|
ADD_VAR_RET ("request", connptr->request_line);
|
||||||
|
ADD_VAR_RET ("clientip", connptr->client_ip_addr);
|
||||||
|
ADD_VAR_RET ("clienthost", connptr->client_string_addr);
|
||||||
|
|
||||||
|
/* The following value parts are all non-NULL and will
|
||||||
|
* trigger warnings in ADD_VAR_RET(), so we use
|
||||||
|
* add_error_variable() directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
global_time = time (NULL);
|
||||||
|
strftime (timebuf, sizeof (timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
||||||
|
gmtime (&global_time));
|
||||||
|
add_error_variable (connptr, "date", timebuf);
|
||||||
|
|
||||||
|
add_error_variable (connptr, "website",
|
||||||
|
"https://tinyproxy.github.io/");
|
||||||
|
add_error_variable (connptr, "version", VERSION);
|
||||||
|
add_error_variable (connptr, "package", PACKAGE);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add the error information to the conn structure.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
indicate_http_error (struct conn_s *connptr, int number,
|
||||||
|
const char *message, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char *key, *val;
|
||||||
|
|
||||||
|
va_start (ap, message);
|
||||||
|
|
||||||
|
while ((key = va_arg (ap, char *))) {
|
||||||
|
val = va_arg (ap, char *);
|
||||||
|
|
||||||
|
if (add_error_variable (connptr, key, val) == -1) {
|
||||||
|
va_end (ap);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connptr->error_number = number;
|
||||||
|
connptr->error_string = safestrdup (message);
|
||||||
|
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return (add_standard_vars (connptr));
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2003 Steven Young <sdyoung@miranda.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'html-error.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_HTML_ERROR_H
|
||||||
|
#define TINYPROXY_HTML_ERROR_H
|
||||||
|
|
||||||
|
/* Forward declaration */
|
||||||
|
struct conn_s;
|
||||||
|
|
||||||
|
extern int add_new_errorpage (char *filepath, unsigned int errornum);
|
||||||
|
extern int send_http_error_message (struct conn_s *connptr);
|
||||||
|
extern int indicate_http_error (struct conn_s *connptr, int number,
|
||||||
|
const char *message, ...);
|
||||||
|
extern int add_error_variable (struct conn_s *connptr, const char *key,
|
||||||
|
const char *val);
|
||||||
|
extern int send_html_file (FILE * infile, struct conn_s *connptr);
|
||||||
|
extern int send_http_headers (struct conn_s *connptr, int code,
|
||||||
|
const char *message);
|
||||||
|
extern int add_standard_vars (struct conn_s *connptr);
|
||||||
|
|
||||||
|
#endif /* !TINYPROXY_HTML_ERROR_H */
|
||||||
@@ -0,0 +1,271 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2003 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'http-message.h' for detailed information. */
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "http-message.h"
|
||||||
|
#include "network.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Package up an HTTP message into a nice little structure. As you can
|
||||||
|
* see this structure doesn't actually store any allocated strings;
|
||||||
|
* therefore, the caller must free any memory referenced by this struct.
|
||||||
|
* Also, the caller MUST NOT free the memory while the structure is
|
||||||
|
* still in use---bad things would happen.
|
||||||
|
*/
|
||||||
|
struct http_message_s {
|
||||||
|
/* Response string and code supplied on the HTTP status line */
|
||||||
|
struct {
|
||||||
|
const char *string;
|
||||||
|
int code;
|
||||||
|
} response;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A group of headers to be sent with this message. Right now
|
||||||
|
* the strings are referenced through pointers in an array.
|
||||||
|
* I might change this to a vector in the future.
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
const char **strings;
|
||||||
|
unsigned int total;
|
||||||
|
unsigned int used;
|
||||||
|
} headers;
|
||||||
|
|
||||||
|
/* Body of the message (most likely an HTML message) */
|
||||||
|
struct {
|
||||||
|
const char *text;
|
||||||
|
size_t length;
|
||||||
|
} body;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the HTTP message is validly formed. This is the one odd-ball
|
||||||
|
* function. It returns 0 if the message is invalid; otherwise, a positive
|
||||||
|
* number is returned. Useful for if() tests and assert() tests.
|
||||||
|
*/
|
||||||
|
static int is_http_message_valid (http_message_t msg)
|
||||||
|
{
|
||||||
|
if (msg == NULL)
|
||||||
|
return 0;
|
||||||
|
if (msg->headers.strings == NULL)
|
||||||
|
return 0;
|
||||||
|
if (msg->response.string == NULL)
|
||||||
|
return 0;
|
||||||
|
if (msg->response.code < 1 || msg->response.code > 999)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initially allocate space for 128 headers */
|
||||||
|
#define NUMBER_OF_HEADERS 128
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a new http_message structure on the heap.
|
||||||
|
* If memory could not be allocated, return a NULL.
|
||||||
|
*/
|
||||||
|
http_message_t
|
||||||
|
http_message_create (int response_code, const char *response_string)
|
||||||
|
{
|
||||||
|
http_message_t msg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
msg =
|
||||||
|
(struct http_message_s *) safecalloc (1,
|
||||||
|
sizeof (struct
|
||||||
|
http_message_s));
|
||||||
|
if (msg == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
msg->headers.strings = (const char **) safecalloc (NUMBER_OF_HEADERS,
|
||||||
|
sizeof (char *));
|
||||||
|
if (msg->headers.strings == NULL) {
|
||||||
|
safefree (msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg->headers.total = NUMBER_OF_HEADERS;
|
||||||
|
|
||||||
|
/* Store the HTTP response information in the structure */
|
||||||
|
ret = http_message_set_response (msg, response_code, response_string);
|
||||||
|
if (IS_HTTP_MSG_ERROR (ret)) {
|
||||||
|
safefree (msg->headers.strings);
|
||||||
|
safefree (msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free up the space associated with this HTTP message structure.
|
||||||
|
* This DOES NOT free the pointers stored in this structure. That memory
|
||||||
|
* is the responsibility of the caller.
|
||||||
|
*/
|
||||||
|
int http_message_destroy (http_message_t msg)
|
||||||
|
{
|
||||||
|
assert (msg != NULL);
|
||||||
|
assert (msg->headers.strings != NULL);
|
||||||
|
|
||||||
|
/* Check for valid arguments */
|
||||||
|
if (msg == NULL)
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
if (msg->headers.strings != NULL)
|
||||||
|
safefree (msg->headers.strings);
|
||||||
|
safefree (msg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the HTTP response information for this structure. The response_string
|
||||||
|
* must be a NUL ('\0') terminated C string.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
http_message_set_response (http_message_t msg,
|
||||||
|
int response_code, const char *response_string)
|
||||||
|
{
|
||||||
|
/* Check for valid arguments */
|
||||||
|
if (msg == NULL)
|
||||||
|
return -EFAULT;
|
||||||
|
if (response_code < 1 || response_code > 999)
|
||||||
|
return -EINVAL;
|
||||||
|
if (response_string == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
if (strlen (response_string) == 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
msg->response.code = response_code;
|
||||||
|
msg->response.string = response_string;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the HTTP message body.
|
||||||
|
*/
|
||||||
|
int http_message_set_body (http_message_t msg, const char *body, size_t len)
|
||||||
|
{
|
||||||
|
/* Check for valid arguments */
|
||||||
|
if (msg == NULL)
|
||||||
|
return -EFAULT;
|
||||||
|
if (body == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
if (len == 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
msg->body.text = body;
|
||||||
|
msg->body.length = len;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add headers to the structure.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
http_message_add_headers (http_message_t msg, const char **headers,
|
||||||
|
unsigned int num_headers)
|
||||||
|
{
|
||||||
|
const char **new_headers;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/* Check for valid arguments */
|
||||||
|
if (msg == NULL)
|
||||||
|
return -EFAULT;
|
||||||
|
if (headers == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the number of headers to add is greater than the space
|
||||||
|
* available, reallocate the memory.
|
||||||
|
*/
|
||||||
|
if (msg->headers.used + num_headers > msg->headers.total) {
|
||||||
|
new_headers =
|
||||||
|
(const char **) safecalloc (msg->headers.total * 2,
|
||||||
|
sizeof (char *));
|
||||||
|
if (new_headers == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
/* Copy the array */
|
||||||
|
for (i = 0; i != msg->headers.used; ++i)
|
||||||
|
new_headers[i] = msg->headers.strings[i];
|
||||||
|
|
||||||
|
/* Remove the old array and replace it with the new array */
|
||||||
|
safefree (msg->headers.strings);
|
||||||
|
msg->headers.strings = new_headers;
|
||||||
|
msg->headers.total *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add the new headers to the structure
|
||||||
|
*/
|
||||||
|
for (i = 0; i != num_headers; ++i)
|
||||||
|
msg->headers.strings[i + msg->headers.used] = headers[i];
|
||||||
|
msg->headers.used += num_headers;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send the completed HTTP message via the supplied file descriptor.
|
||||||
|
*/
|
||||||
|
int http_message_send (http_message_t msg, int fd)
|
||||||
|
{
|
||||||
|
char timebuf[30];
|
||||||
|
time_t global_time;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
assert (is_http_message_valid (msg));
|
||||||
|
|
||||||
|
/* Check for valid arguments */
|
||||||
|
if (msg == NULL)
|
||||||
|
return -EFAULT;
|
||||||
|
if (fd < 1)
|
||||||
|
return -EBADF;
|
||||||
|
if (!is_http_message_valid (msg))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Write the response line */
|
||||||
|
write_message (fd, "HTTP/1.0 %d %s\r\n",
|
||||||
|
msg->response.code, msg->response.string);
|
||||||
|
|
||||||
|
/* Go through all the headers */
|
||||||
|
for (i = 0; i != msg->headers.used; ++i)
|
||||||
|
write_message (fd, "%s\r\n", msg->headers.strings[i]);
|
||||||
|
|
||||||
|
/* Output the date */
|
||||||
|
global_time = time (NULL);
|
||||||
|
strftime (timebuf, sizeof (timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
||||||
|
gmtime (&global_time));
|
||||||
|
write_message (fd, "Date: %s\r\n", timebuf);
|
||||||
|
|
||||||
|
/* Output the content-length */
|
||||||
|
write_message (fd, "Content-length: %u\r\n", msg->body.length);
|
||||||
|
|
||||||
|
/* Write the separator between the headers and body */
|
||||||
|
safe_write (fd, "\r\n", 2);
|
||||||
|
|
||||||
|
/* If there's a body, send it! */
|
||||||
|
if (msg->body.length > 0)
|
||||||
|
safe_write (fd, msg->body.text, msg->body.length);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2003 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* HTTP Message API
|
||||||
|
* ----------------
|
||||||
|
* The idea behind this application programming interface (API) is to
|
||||||
|
* represent an HTTP response message as a concrete entity. The API
|
||||||
|
* functions allow the message to be built up systematically before
|
||||||
|
* transmission to a connected socket.
|
||||||
|
*
|
||||||
|
* The order of the functions in your program would look something like
|
||||||
|
* this:
|
||||||
|
* http_message_create()
|
||||||
|
* http_message_set_response()
|
||||||
|
* http_message_set_body() [optional if no body is required]
|
||||||
|
* http_message_add_headers() [optional if no additional headers are used]
|
||||||
|
* http_message_send()
|
||||||
|
* http_message_destroy()
|
||||||
|
*
|
||||||
|
* NOTE: No user data is stored in the http_message_t type; therefore,
|
||||||
|
* do not delete strings referenced by the http_message_t object
|
||||||
|
* before you call http_message_destroy(). By not copying data, the
|
||||||
|
* API functions are faster, but you must take greater care.
|
||||||
|
*
|
||||||
|
* (Side note: be _very_ careful when using stack allocated memory with
|
||||||
|
* this API. Bad things will happen if you try to pass the
|
||||||
|
* http_message_t out of the calling function since the stack
|
||||||
|
* allocated memory referenced by the http_message_t will no long
|
||||||
|
* exist.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TINYPROXY_HTTP_MESSAGE_H_
|
||||||
|
#define _TINYPROXY_HTTP_MESSAGE_H_
|
||||||
|
|
||||||
|
/* Use the "http_message_t" as a cookie or handle to the structure. */
|
||||||
|
typedef struct http_message_s *http_message_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macro to test if an error occurred with the API. All the HTTP message
|
||||||
|
* functions will return 0 if no error occurred, or a negative number if
|
||||||
|
* there was a problem.
|
||||||
|
*/
|
||||||
|
#define IS_HTTP_MSG_ERROR(x) (x < 0)
|
||||||
|
|
||||||
|
/* Initialize the internal structure of the HTTP message */
|
||||||
|
extern http_message_t http_message_create (int response_code,
|
||||||
|
const char *response_string);
|
||||||
|
|
||||||
|
/* Free up an _internal_ resources */
|
||||||
|
extern int http_message_destroy (http_message_t msg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send an HTTP message via the supplied file descriptor. This function
|
||||||
|
* will add the "Date" header before it's sent.
|
||||||
|
*/
|
||||||
|
extern int http_message_send (http_message_t msg, int fd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change the internal state of the HTTP message. Either set the
|
||||||
|
* body of the message, update the response information, or
|
||||||
|
* add a new set of headers.
|
||||||
|
*/
|
||||||
|
extern int http_message_set_body (http_message_t msg,
|
||||||
|
const char *body, size_t len);
|
||||||
|
extern int http_message_set_response (http_message_t msg,
|
||||||
|
int response_code,
|
||||||
|
const char *response_string);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the headers for this HTTP message. Each string must be NUL ('\0')
|
||||||
|
* terminated, but DO NOT include any carriage returns (CR) or
|
||||||
|
* line-feeds (LF) since they will be included when the http_message is
|
||||||
|
* sent.
|
||||||
|
*/
|
||||||
|
extern int http_message_add_headers (http_message_t msg,
|
||||||
|
const char **headers,
|
||||||
|
unsigned int num_headers);
|
||||||
|
|
||||||
|
#endif /* _TINYPROXY_HTTP_MESSAGE_H_ */
|
||||||
@@ -1,120 +1,312 @@
|
|||||||
/* $Id: log.c,v 1.10 2001-08-26 23:37:26 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2009 Michael Adam <obnox@samba.org>
|
||||||
*
|
*
|
||||||
* Logs the various messages which tinyproxy produces to either a log file or
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* the syslog daemon. Not much to it...
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 Steven Young
|
* This program is distributed in the hope that it will be useful,
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
/* Logs the various messages which tinyproxy produces to either a log file
|
||||||
|
* or the syslog daemon. Not much to it...
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "heap.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "vector.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
static char *syslog_level[] = {
|
static const char *syslog_level[] = {
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
"CRITICAL",
|
"CRITICAL",
|
||||||
"ERROR",
|
"ERROR",
|
||||||
"WARNING",
|
"WARNING",
|
||||||
"NOTICE",
|
"NOTICE",
|
||||||
"INFO",
|
"INFO",
|
||||||
"DEBUG",
|
"DEBUG",
|
||||||
"CONNECT"
|
"CONNECT"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TIME_LENGTH 16
|
#define TIME_LENGTH 16
|
||||||
#define STRING_LENGTH 800
|
#define STRING_LENGTH 800
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global file descriptor for the log file
|
||||||
|
*/
|
||||||
|
int log_file_fd = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store the log level setting.
|
* Store the log level setting.
|
||||||
*/
|
*/
|
||||||
static short int log_level = LOG_ERR;
|
static int log_level = LOG_INFO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hold a listing of log messages which need to be sent once the log
|
||||||
|
* file has been established.
|
||||||
|
* The key is the actual messages (already filled in full), and the value
|
||||||
|
* is the log level.
|
||||||
|
*/
|
||||||
|
static vector_t log_message_storage;
|
||||||
|
|
||||||
|
static unsigned int logging_initialized = FALSE; /* boolean */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open the log file and store the file descriptor in a global location.
|
||||||
|
*/
|
||||||
|
int open_log_file (const char *log_file_name)
|
||||||
|
{
|
||||||
|
if (log_file_name == NULL) {
|
||||||
|
if(config.godaemon == FALSE)
|
||||||
|
log_file_fd = fileno(stdout);
|
||||||
|
else
|
||||||
|
log_file_fd = -1;
|
||||||
|
} else {
|
||||||
|
log_file_fd = create_file_safely (log_file_name, FALSE);
|
||||||
|
}
|
||||||
|
return log_file_fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the log file
|
||||||
|
*/
|
||||||
|
void close_log_file (void)
|
||||||
|
{
|
||||||
|
if (log_file_fd < 0 || log_file_fd == fileno(stdout)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
close (log_file_fd);
|
||||||
|
log_file_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the log level for writing to the log file.
|
* Set the log level for writing to the log file.
|
||||||
*/
|
*/
|
||||||
void set_log_level(short int level)
|
void set_log_level (int level)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
log_level = level;
|
||||||
/*
|
|
||||||
* If we're running with debugging enabled, then set the log level
|
|
||||||
* to DEBUG regardless of what's in the configuration file.
|
|
||||||
*/
|
|
||||||
log_level = LOG_DEBUG;
|
|
||||||
#else
|
|
||||||
log_level = level;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine logs messages to either the log file or the syslog function.
|
* This routine logs messages to either the log file or the syslog function.
|
||||||
*/
|
*/
|
||||||
void log_message(short int level, char *fmt, ...)
|
void log_message (int level, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
time_t nowtime;
|
time_t nowtime;
|
||||||
FILE *cf;
|
|
||||||
|
|
||||||
char time_string[TIME_LENGTH];
|
char time_string[TIME_LENGTH];
|
||||||
#if defined(HAVE_SYSLOG_H) && !defined(HAVE_VSYSLOG_H)
|
char str[STRING_LENGTH];
|
||||||
char str[STRING_LENGTH];
|
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
/*
|
||||||
|
* Figure out if we should write the message or not.
|
||||||
|
*/
|
||||||
|
if (log_level == LOG_CONN) {
|
||||||
|
if (level == LOG_INFO)
|
||||||
|
return;
|
||||||
|
} else if (log_level == LOG_INFO) {
|
||||||
|
if (level > LOG_INFO && level != LOG_CONN)
|
||||||
|
return;
|
||||||
|
} else if (level > log_level)
|
||||||
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
if (config.syslog && level == LOG_CONN)
|
||||||
* Figure out if we should write the message or not.
|
level = LOG_INFO;
|
||||||
*/
|
|
||||||
if (level == LOG_INFO && log_level == LOG_CONN)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (level > log_level)
|
va_start (args, fmt);
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
/*
|
||||||
if (config.syslog && level == LOG_CONN)
|
* If the config file hasn't been processed, then we need to store
|
||||||
level = LOG_INFO;
|
* the messages for later processing.
|
||||||
|
*/
|
||||||
|
if (!logging_initialized) {
|
||||||
|
char *entry_buffer;
|
||||||
|
|
||||||
|
if (!log_message_storage) {
|
||||||
|
log_message_storage = vector_create ();
|
||||||
|
if (!log_message_storage)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
vsnprintf (str, STRING_LENGTH, fmt, args);
|
||||||
|
|
||||||
|
entry_buffer = (char *) safemalloc (strlen (str) + 6);
|
||||||
|
if (!entry_buffer)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
sprintf (entry_buffer, "%d %s", level, str);
|
||||||
|
vector_append (log_message_storage, entry_buffer,
|
||||||
|
strlen (entry_buffer) + 1);
|
||||||
|
|
||||||
|
safefree (entry_buffer);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!config.syslog && log_file_fd == -1)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (config.syslog) {
|
||||||
|
#ifdef HAVE_VSYSLOG_H
|
||||||
|
vsyslog (level, fmt, args);
|
||||||
|
#else
|
||||||
|
vsnprintf (str, STRING_LENGTH, fmt, args);
|
||||||
|
syslog (level, "%s", str);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
char *p;
|
||||||
|
|
||||||
va_start(args, fmt);
|
nowtime = time (NULL);
|
||||||
|
/* Format is month day hour:minute:second (24 time) */
|
||||||
|
strftime (time_string, TIME_LENGTH, "%b %d %H:%M:%S",
|
||||||
|
localtime (&nowtime));
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
snprintf (str, STRING_LENGTH, "%-9s %s [%ld]: ",
|
||||||
if (config.syslog) {
|
syslog_level[level], time_string,
|
||||||
# ifdef HAVE_VSYSLOG_H
|
(long int) getpid ());
|
||||||
vsyslog(level, fmt, args);
|
|
||||||
# else
|
|
||||||
vsnprintf(str, STRING_LENGTH, fmt, args);
|
|
||||||
syslog(level, str);
|
|
||||||
# endif
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
nowtime = time(NULL);
|
|
||||||
/* Format is month day hour:minute:second (24 time) */
|
|
||||||
strftime(time_string, TIME_LENGTH, "%b %d %H:%M:%S",
|
|
||||||
localtime(&nowtime));
|
|
||||||
|
|
||||||
if (!(cf = config.logf))
|
/*
|
||||||
cf = stderr;
|
* Overwrite the '\0' and leave room for a trailing '\n'
|
||||||
|
* be added next.
|
||||||
|
*/
|
||||||
|
p = str + strlen(str);
|
||||||
|
vsnprintf (p, STRING_LENGTH - strlen(str) - 1, fmt, args);
|
||||||
|
|
||||||
fprintf(cf, "%-9s %s [%ld]: ", syslog_level[level],
|
p = str + strlen(str);
|
||||||
time_string, (long int)getpid());
|
*p = '\n';
|
||||||
vfprintf(cf, fmt, args);
|
*(p+1) = '\0';
|
||||||
fprintf(cf, "\n");
|
|
||||||
fflush(cf);
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
va_end(args);
|
assert (log_file_fd >= 0);
|
||||||
|
|
||||||
|
ret = write (log_file_fd, str, strlen (str));
|
||||||
|
if (ret == -1) {
|
||||||
|
config.syslog = TRUE;
|
||||||
|
|
||||||
|
log_message(LOG_CRIT, "ERROR: Could not write to log "
|
||||||
|
"file %s: %s.",
|
||||||
|
config.logf_name, strerror(errno));
|
||||||
|
log_message(LOG_CRIT,
|
||||||
|
"Falling back to syslog logging");
|
||||||
|
}
|
||||||
|
|
||||||
|
fsync (log_file_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This needs to send any stored log messages.
|
||||||
|
*/
|
||||||
|
static void send_stored_logs (void)
|
||||||
|
{
|
||||||
|
char *string;
|
||||||
|
char *ptr;
|
||||||
|
int level;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (log_message_storage == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
log_message(LOG_DEBUG, "sending stored logs");
|
||||||
|
|
||||||
|
for (i = 0; (ssize_t) i != vector_length (log_message_storage); ++i) {
|
||||||
|
string =
|
||||||
|
(char *) vector_getentry (log_message_storage, i, NULL);
|
||||||
|
|
||||||
|
ptr = strchr (string, ' ') + 1;
|
||||||
|
level = atoi (string);
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
if (log_level == LOG_CONN && level == LOG_INFO)
|
||||||
|
continue;
|
||||||
|
else if (log_level == LOG_INFO) {
|
||||||
|
if (level > LOG_INFO && level != LOG_CONN)
|
||||||
|
continue;
|
||||||
|
} else if (level > log_level)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
log_message (level, "%s", ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector_delete (log_message_storage);
|
||||||
|
log_message_storage = NULL;
|
||||||
|
|
||||||
|
log_message(LOG_DEBUG, "done sending stored logs");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the logging subsystem, based on the configuration.
|
||||||
|
* Returns 0 upon success, -1 upon failure.
|
||||||
|
*
|
||||||
|
* This function uses fprintf() instead of log_message(), since
|
||||||
|
* the logging is not yet set up...
|
||||||
|
*/
|
||||||
|
int setup_logging (void)
|
||||||
|
{
|
||||||
|
if (!config.syslog) {
|
||||||
|
if (open_log_file (config.logf_name) < 0) {
|
||||||
|
/*
|
||||||
|
* If opening the log file fails, we try
|
||||||
|
* to fall back to syslog logging...
|
||||||
|
*/
|
||||||
|
config.syslog = TRUE;
|
||||||
|
|
||||||
|
log_message (LOG_CRIT, "ERROR: Could not create log "
|
||||||
|
"file %s: %s.",
|
||||||
|
config.logf_name, strerror (errno));
|
||||||
|
log_message (LOG_CRIT,
|
||||||
|
"Falling back to syslog logging.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.syslog) {
|
||||||
|
if (config.godaemon == TRUE)
|
||||||
|
openlog ("tinyproxy", LOG_PID, LOG_DAEMON);
|
||||||
|
else
|
||||||
|
openlog ("tinyproxy", LOG_PID, LOG_USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
logging_initialized = TRUE;
|
||||||
|
send_stored_logs ();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the logging subsystem.
|
||||||
|
*/
|
||||||
|
void shutdown_logging (void)
|
||||||
|
{
|
||||||
|
if (!logging_initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.syslog) {
|
||||||
|
closelog ();
|
||||||
|
} else {
|
||||||
|
close_log_file ();
|
||||||
|
}
|
||||||
|
|
||||||
|
logging_initialized = FALSE;
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
/* $Id: log.h,v 1.7 2001-08-26 21:10:04 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2009 Michael Adam <obnox@samba.org>
|
||||||
*
|
*
|
||||||
* See 'log.c' for a detailed description.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 Steven Young
|
* This program is distributed in the hope that it will be useful,
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* See 'log.c' for detailed information. */
|
||||||
|
|
||||||
#ifndef TINYPROXY_LOG_H
|
#ifndef TINYPROXY_LOG_H
|
||||||
#define TINYPROXY_LOG_H
|
#define TINYPROXY_LOG_H
|
||||||
|
|
||||||
@@ -29,17 +33,17 @@
|
|||||||
* can see them below and I'll describe what each level should be for.
|
* can see them below and I'll describe what each level should be for.
|
||||||
* Hopefully tinyproxy will remain consistent with these levels.
|
* Hopefully tinyproxy will remain consistent with these levels.
|
||||||
* -- rjkaes
|
* -- rjkaes
|
||||||
* Sorry but I had to destroy the hope ;-) There was a need to log
|
* Sorry but I had to destroy the hope ;-) There was a need to log
|
||||||
* connections without the INFO stuff and not to have them as NOTICE.
|
* connections without the INFO stuff and not to have them as NOTICE.
|
||||||
* -- hgb
|
* -- hgb
|
||||||
*
|
*
|
||||||
* Level Description
|
* Level Description
|
||||||
* ----- -----------
|
* ----- -----------
|
||||||
* LOG_CRIT This is catastrophic. Basically, tinyproxy can not recover
|
* LOG_CRIT This is catastrophic. Basically, tinyproxy can not recover
|
||||||
* from this and will either close the thread (if we're lucky),
|
* from this and will either close the child (if we're lucky),
|
||||||
* or the entire daemon. I would relegate this to conditions
|
* or the entire daemon. I would relegate this to conditions
|
||||||
* like unable to create the listening socket, or unable to
|
* like unable to create the listening socket, or unable to
|
||||||
* create a thread. If you're going to log at this level provide
|
* create a child. If you're going to log at this level provide
|
||||||
* as much information as possible.
|
* as much information as possible.
|
||||||
*
|
*
|
||||||
* LOG_ERR Okay, something bad happened. We can recover from this, but
|
* LOG_ERR Okay, something bad happened. We can recover from this, but
|
||||||
@@ -56,10 +60,10 @@
|
|||||||
*
|
*
|
||||||
* LOG_NOTICE This is for a special condition. Nothing has gone wrong, but
|
* LOG_NOTICE This is for a special condition. Nothing has gone wrong, but
|
||||||
* it is more important than the common LOG_INFO level. Right
|
* it is more important than the common LOG_INFO level. Right
|
||||||
* now it is used for actions like creating/destroying threads,
|
* now it is used for actions like creating/destroying children,
|
||||||
* unauthorized access, signal handling, etc.
|
* unauthorized access, signal handling, etc.
|
||||||
*
|
*
|
||||||
* LOG_CONN This additional level is for logging connections only, so
|
* LOG_CONN This additional level is for logging connections only, so
|
||||||
* it is easy to control only the requests in the logfile.
|
* it is easy to control only the requests in the logfile.
|
||||||
* If we log through syslog, this is set to LOG_INFO.
|
* If we log through syslog, this is set to LOG_INFO.
|
||||||
* -- hgb
|
* -- hgb
|
||||||
@@ -73,18 +77,14 @@
|
|||||||
* don't advocate this, but it could be useful at times.)
|
* don't advocate this, but it could be useful at times.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#include <syslog.h>
|
||||||
# include <syslog.h>
|
|
||||||
#else
|
|
||||||
# define LOG_CRIT 2
|
|
||||||
# define LOG_ERR 3
|
|
||||||
# define LOG_WARNING 4
|
|
||||||
# define LOG_NOTICE 5
|
|
||||||
# define LOG_INFO 6
|
|
||||||
# define LOG_DEBUG 7
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_CONN 8 /* extra to log connections without the INFO stuff */
|
#define LOG_CONN 8 /* extra to log connections without the INFO stuff */
|
||||||
|
|
||||||
|
/* Suppress warnings when GCC is in -pedantic mode and not -std=c99 */
|
||||||
|
#if (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
|
||||||
|
#pragma GCC system_header
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use this for debugging. The format is specific:
|
* Use this for debugging. The format is specific:
|
||||||
@@ -92,14 +92,22 @@
|
|||||||
* DEBUG2("There was a big problem: %s in connptr %p", "hello", connptr);
|
* DEBUG2("There was a big problem: %s in connptr %p", "hello", connptr);
|
||||||
*/
|
*/
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
# define DEBUG1(x) log_message(LOG_DEBUG, "[%s:%d] " x, __FILE__, __LINE__)
|
# define DEBUG1(x) \
|
||||||
# define DEBUG2(x, y...) log_message(LOG_DEBUG, "[%s:%d] " x, __FILE__, __LINE__, ## y)
|
log_message(LOG_DEBUG, "[%s:%d] " x, __FILE__, __LINE__)
|
||||||
|
# define DEBUG2(x, y...) \
|
||||||
|
log_message(LOG_DEBUG, "[%s:%d] " x, __FILE__, __LINE__, ## y)
|
||||||
#else
|
#else
|
||||||
# define DEBUG1(x) do { } while(0)
|
# define DEBUG1(x) do { } while(0)
|
||||||
# define DEBUG2(x, y...) do { } while(0)
|
# define DEBUG2(x, y...) do { } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void log_message(short int level, char *fmt, ...);
|
extern int open_log_file (const char *file);
|
||||||
extern void set_log_level(short int level);
|
extern void close_log_file (void);
|
||||||
|
|
||||||
|
extern void log_message (int level, const char *fmt, ...);
|
||||||
|
extern void set_log_level (int level);
|
||||||
|
|
||||||
|
extern int setup_logging (void);
|
||||||
|
extern void shutdown_logging (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+463
@@ -0,0 +1,463 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1998-2002 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2000 Chris Lightfoot <chris@ex-parrot.com>
|
||||||
|
* Copyright (C) 2009-2010 Mukund Sivaraman <muks@banu.com>
|
||||||
|
* Copyright (C) 2009-2010 Michael Adam <obnox@samba.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The initialize routine. Basically sets up all the initial stuff (logfile,
|
||||||
|
* listening socket, config options, etc.) and then sits there and loops
|
||||||
|
* over the new connections until the daemon is closed. Also has additional
|
||||||
|
* functions to handle the "user friendly" aspects of a program (usage,
|
||||||
|
* stats, etc.) Like any good program, most of the work is actually done
|
||||||
|
* elsewhere.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "anonymous.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "conf.h"
|
||||||
|
#include "daemon.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "filter.h"
|
||||||
|
#include "child.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "reqs.h"
|
||||||
|
#include "sock.h"
|
||||||
|
#include "stats.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global Structures
|
||||||
|
*/
|
||||||
|
struct config_s config;
|
||||||
|
struct config_s config_defaults;
|
||||||
|
unsigned int received_sighup = FALSE; /* boolean */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle a signal
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
takesig (int sig)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
switch (sig) {
|
||||||
|
case SIGHUP:
|
||||||
|
received_sighup = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIGTERM:
|
||||||
|
config.quit = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIGCHLD:
|
||||||
|
while ((pid = waitpid (-1, &status, WNOHANG)) > 0) ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display the version information for the user.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
display_version (void)
|
||||||
|
{
|
||||||
|
printf ("%s %s\n", PACKAGE, VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display usage to the user.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
display_usage (void)
|
||||||
|
{
|
||||||
|
int features = 0;
|
||||||
|
|
||||||
|
printf ("Usage: %s [options]\n", PACKAGE);
|
||||||
|
printf ("\n"
|
||||||
|
"Options are:\n"
|
||||||
|
" -d Do not daemonize (run in foreground).\n"
|
||||||
|
" -c FILE Use an alternate configuration file.\n"
|
||||||
|
" -h Display this usage information.\n"
|
||||||
|
" -v Display version information.\n");
|
||||||
|
|
||||||
|
/* Display the modes compiled into tinyproxy */
|
||||||
|
printf ("\nFeatures compiled in:\n");
|
||||||
|
|
||||||
|
#ifdef XTINYPROXY_ENABLE
|
||||||
|
printf (" XTinyproxy header\n");
|
||||||
|
features++;
|
||||||
|
#endif /* XTINYPROXY */
|
||||||
|
|
||||||
|
#ifdef FILTER_ENABLE
|
||||||
|
printf (" Filtering\n");
|
||||||
|
features++;
|
||||||
|
#endif /* FILTER_ENABLE */
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
printf (" Debugging code\n");
|
||||||
|
features++;
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
|
#ifdef TRANSPARENT_PROXY
|
||||||
|
printf (" Transparent proxy support\n");
|
||||||
|
features++;
|
||||||
|
#endif /* TRANSPARENT_PROXY */
|
||||||
|
|
||||||
|
#ifdef REVERSE_SUPPORT
|
||||||
|
printf (" Reverse proxy support\n");
|
||||||
|
features++;
|
||||||
|
#endif /* REVERSE_SUPPORT */
|
||||||
|
|
||||||
|
#ifdef UPSTREAM_SUPPORT
|
||||||
|
printf (" Upstream proxy support\n");
|
||||||
|
features++;
|
||||||
|
#endif /* UPSTREAM_SUPPORT */
|
||||||
|
|
||||||
|
if (0 == features)
|
||||||
|
printf (" None\n");
|
||||||
|
|
||||||
|
printf ("\n"
|
||||||
|
"For support and bug reporting instructions, please visit\n"
|
||||||
|
"<https://tinyproxy.github.io/>.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
get_id (char *str)
|
||||||
|
{
|
||||||
|
char *tstr;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
tstr = str;
|
||||||
|
while (*tstr != 0) {
|
||||||
|
if (!isdigit (*tstr))
|
||||||
|
return -1;
|
||||||
|
tstr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return atoi (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* process_cmdline:
|
||||||
|
* @argc: argc as passed to main()
|
||||||
|
* @argv: argv as passed to main()
|
||||||
|
*
|
||||||
|
* This function parses command line arguments.
|
||||||
|
**/
|
||||||
|
static void
|
||||||
|
process_cmdline (int argc, char **argv, struct config_s *conf)
|
||||||
|
{
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
while ((opt = getopt (argc, argv, "c:vdh")) != EOF) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'v':
|
||||||
|
display_version ();
|
||||||
|
exit (EX_OK);
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
conf->godaemon = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
if (conf->config_file != NULL) {
|
||||||
|
safefree (conf->config_file);
|
||||||
|
}
|
||||||
|
conf->config_file = safestrdup (optarg);
|
||||||
|
if (!conf->config_file) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Could not allocate memory.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_SOFTWARE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
display_usage ();
|
||||||
|
exit (EX_OK);
|
||||||
|
|
||||||
|
default:
|
||||||
|
display_usage ();
|
||||||
|
exit (EX_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* change_user:
|
||||||
|
* @program: The name of the program. Pass argv[0] here.
|
||||||
|
*
|
||||||
|
* This function tries to change UID and GID to the ones specified in
|
||||||
|
* the config file. This function is typically called during
|
||||||
|
* initialization when the effective user is root.
|
||||||
|
**/
|
||||||
|
static void
|
||||||
|
change_user (const char *program)
|
||||||
|
{
|
||||||
|
if (config.group && strlen (config.group) > 0) {
|
||||||
|
int gid = get_id (config.group);
|
||||||
|
|
||||||
|
if (gid < 0) {
|
||||||
|
struct group *thisgroup = getgrnam (config.group);
|
||||||
|
|
||||||
|
if (!thisgroup) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Unable to find group \"%s\".\n",
|
||||||
|
program, config.group);
|
||||||
|
exit (EX_NOUSER);
|
||||||
|
}
|
||||||
|
|
||||||
|
gid = thisgroup->gr_gid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setgid (gid) < 0) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Unable to change to group \"%s\".\n",
|
||||||
|
program, config.group);
|
||||||
|
exit (EX_NOPERM);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SETGROUPS
|
||||||
|
/* Drop all supplementary groups, otherwise these are inherited from the calling process */
|
||||||
|
if (setgroups (0, NULL) < 0) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Unable to drop supplementary groups.\n",
|
||||||
|
program);
|
||||||
|
exit (EX_NOPERM);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
log_message (LOG_INFO, "Now running as group \"%s\".",
|
||||||
|
config.group);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.user && strlen (config.user) > 0) {
|
||||||
|
int uid = get_id (config.user);
|
||||||
|
|
||||||
|
if (uid < 0) {
|
||||||
|
struct passwd *thisuser = getpwnam (config.user);
|
||||||
|
|
||||||
|
if (!thisuser) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Unable to find user \"%s\".\n",
|
||||||
|
program, config.user);
|
||||||
|
exit (EX_NOUSER);
|
||||||
|
}
|
||||||
|
|
||||||
|
uid = thisuser->pw_uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setuid (uid) < 0) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Unable to change to user \"%s\".\n",
|
||||||
|
program, config.user);
|
||||||
|
exit (EX_NOPERM);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message (LOG_INFO, "Now running as user \"%s\".",
|
||||||
|
config.user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void initialize_config_defaults (struct config_s *conf)
|
||||||
|
{
|
||||||
|
memset (conf, 0, sizeof(*conf));
|
||||||
|
|
||||||
|
conf->config_file = safestrdup (SYSCONFDIR "/tinyproxy.conf");
|
||||||
|
if (!conf->config_file) {
|
||||||
|
fprintf (stderr, PACKAGE ": Could not allocate memory.\n");
|
||||||
|
exit (EX_SOFTWARE);
|
||||||
|
}
|
||||||
|
conf->godaemon = TRUE;
|
||||||
|
/*
|
||||||
|
* Make sure the HTML error pages array is NULL to begin with.
|
||||||
|
* (FIXME: Should have a better API for all this)
|
||||||
|
*/
|
||||||
|
conf->errorpages = NULL;
|
||||||
|
conf->stathost = safestrdup (TINYPROXY_STATHOST);
|
||||||
|
conf->idletimeout = MAX_IDLE_TIME;
|
||||||
|
conf->logf_name = NULL;
|
||||||
|
conf->pidpath = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convenience wrapper around reload_config_file
|
||||||
|
* that also re-initializes logging.
|
||||||
|
*/
|
||||||
|
int reload_config (void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
shutdown_logging ();
|
||||||
|
|
||||||
|
ret = reload_config_file (config_defaults.config_file, &config,
|
||||||
|
&config_defaults);
|
||||||
|
if (ret != 0) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = setup_logging ();
|
||||||
|
|
||||||
|
done:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Only allow u+rw bits. This may be required for some versions
|
||||||
|
* of glibc so that mkstemp() doesn't make us vulnerable.
|
||||||
|
*/
|
||||||
|
umask (0177);
|
||||||
|
|
||||||
|
log_message (LOG_INFO, "Initializing " PACKAGE " ...");
|
||||||
|
|
||||||
|
if (config_compile_regex()) {
|
||||||
|
exit (EX_SOFTWARE);
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize_config_defaults (&config_defaults);
|
||||||
|
process_cmdline (argc, argv, &config_defaults);
|
||||||
|
|
||||||
|
if (reload_config_file (config_defaults.config_file,
|
||||||
|
&config,
|
||||||
|
&config_defaults)) {
|
||||||
|
exit (EX_SOFTWARE);
|
||||||
|
}
|
||||||
|
|
||||||
|
init_stats ();
|
||||||
|
|
||||||
|
/* If ANONYMOUS is turned on, make sure that Content-Length is
|
||||||
|
* in the list of allowed headers, since it is required in a
|
||||||
|
* HTTP/1.0 request. Also add the Content-Type header since it
|
||||||
|
* goes hand in hand with Content-Length. */
|
||||||
|
if (is_anonymous_enabled ()) {
|
||||||
|
anonymous_insert ("Content-Length");
|
||||||
|
anonymous_insert ("Content-Type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.godaemon == TRUE) {
|
||||||
|
if (!config.syslog && config.logf_name == NULL)
|
||||||
|
fprintf(stderr, "WARNING: logging deactivated "
|
||||||
|
"(can't log to stdout when daemonized)\n");
|
||||||
|
|
||||||
|
makedaemon ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set_signal_handler (SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||||
|
fprintf (stderr, "%s: Could not set the \"SIGPIPE\" signal.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef FILTER_ENABLE
|
||||||
|
if (config.filter)
|
||||||
|
filter_init ();
|
||||||
|
#endif /* FILTER_ENABLE */
|
||||||
|
|
||||||
|
/* Start listening on the selected port. */
|
||||||
|
if (child_listening_sockets(config.listen_addrs, config.port) < 0) {
|
||||||
|
fprintf (stderr, "%s: Could not create listening sockets.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create pid file before we drop privileges */
|
||||||
|
if (config.pidpath) {
|
||||||
|
if (pidfile_create (config.pidpath) < 0) {
|
||||||
|
fprintf (stderr, "%s: Could not create PID file.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_OSERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Switch to a different user if we're running as root */
|
||||||
|
if (geteuid () == 0)
|
||||||
|
change_user (argv[0]);
|
||||||
|
else
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Not running as root, so not changing UID/GID.");
|
||||||
|
|
||||||
|
/* Create log file after we drop privileges */
|
||||||
|
if (setup_logging ()) {
|
||||||
|
exit (EX_SOFTWARE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child_pool_create () < 0) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"%s: Could not create the pool of children.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_SOFTWARE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* These signals are only for the parent process. */
|
||||||
|
log_message (LOG_INFO, "Setting the various signals.");
|
||||||
|
|
||||||
|
if (set_signal_handler (SIGCHLD, takesig) == SIG_ERR) {
|
||||||
|
fprintf (stderr, "%s: Could not set the \"SIGCHLD\" signal.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set_signal_handler (SIGTERM, takesig) == SIG_ERR) {
|
||||||
|
fprintf (stderr, "%s: Could not set the \"SIGTERM\" signal.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set_signal_handler (SIGHUP, takesig) == SIG_ERR) {
|
||||||
|
fprintf (stderr, "%s: Could not set the \"SIGHUP\" signal.\n",
|
||||||
|
argv[0]);
|
||||||
|
exit (EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start the main loop */
|
||||||
|
log_message (LOG_INFO, "Starting main loop. Accepting connections.");
|
||||||
|
|
||||||
|
child_main_loop ();
|
||||||
|
|
||||||
|
log_message (LOG_INFO, "Shutting down.");
|
||||||
|
|
||||||
|
child_kill_children (SIGTERM);
|
||||||
|
child_close_sock ();
|
||||||
|
|
||||||
|
/* Remove the PID file */
|
||||||
|
if (config.pidpath != NULL && unlink (config.pidpath) < 0) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Could not remove PID file \"%s\": %s.",
|
||||||
|
config.pidpath, strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef FILTER_ENABLE
|
||||||
|
if (config.filter)
|
||||||
|
filter_destroy ();
|
||||||
|
#endif /* FILTER_ENABLE */
|
||||||
|
|
||||||
|
shutdown_logging ();
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'main.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef __MAIN_H__
|
||||||
|
#define __MAIN_H__
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
/* Global variables for the main controls of the program */
|
||||||
|
#define MAXBUFFSIZE ((size_t)(1024 * 96)) /* Max size of buffer */
|
||||||
|
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
|
||||||
|
|
||||||
|
/* Global Structures used in the program */
|
||||||
|
extern struct config_s config;
|
||||||
|
extern unsigned int received_sighup; /* boolean */
|
||||||
|
|
||||||
|
extern int reload_config (void);
|
||||||
|
|
||||||
|
#endif /* __MAIN_H__ */
|
||||||
+332
@@ -0,0 +1,332 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002, 2004 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The functions found here are used for communicating across a
|
||||||
|
* network. They include both safe reading and writing (which are
|
||||||
|
* the basic building blocks) along with two functions for
|
||||||
|
* easily reading a line of text from the network, and a function
|
||||||
|
* to write an arbitrary amount of data to the network.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include "heap.h"
|
||||||
|
#include "network.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write the buffer to the socket. If an EINTR occurs, pick up and try
|
||||||
|
* again. Keep sending until the buffer has been sent.
|
||||||
|
*/
|
||||||
|
ssize_t safe_write (int fd, const void *buf, size_t count)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
size_t bytestosend;
|
||||||
|
const char *buffer = buf;
|
||||||
|
|
||||||
|
assert (fd >= 0);
|
||||||
|
assert (buffer != NULL);
|
||||||
|
assert (count > 0);
|
||||||
|
|
||||||
|
bytestosend = count;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
len = send (fd, buffer, bytestosend, MSG_NOSIGNAL);
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((size_t) len == bytestosend)
|
||||||
|
break;
|
||||||
|
|
||||||
|
buffer += len;
|
||||||
|
bytestosend -= len;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Matched pair for safe_write(). If an EINTR occurs, pick up and try
|
||||||
|
* again.
|
||||||
|
*/
|
||||||
|
ssize_t safe_read (int fd, void *buffer, size_t count)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
do {
|
||||||
|
len = read (fd, buffer, count);
|
||||||
|
} while (len < 0 && errno == EINTR);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send a "message" to the file descriptor provided. This handles the
|
||||||
|
* differences between the various implementations of vsnprintf. This code
|
||||||
|
* was basically stolen from the snprintf() man page of Debian Linux
|
||||||
|
* (although I did fix a memory leak. :)
|
||||||
|
*/
|
||||||
|
int write_message (int fd, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
size_t size = (1024 * 8); /* start with 8 KB and go from there */
|
||||||
|
char *buf, *tmpbuf;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if ((buf = (char *) safemalloc (size)) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
va_start (ap, fmt);
|
||||||
|
n = vsnprintf (buf, size, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
/* If that worked, break out so we can send the buffer */
|
||||||
|
if (n > -1 && (size_t) n < size)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Else, try again with more space */
|
||||||
|
if (n > -1)
|
||||||
|
/* precisely what is needed (glibc2.1) */
|
||||||
|
size = n + 1;
|
||||||
|
else
|
||||||
|
/* twice the old size (glibc2.0) */
|
||||||
|
size *= 2;
|
||||||
|
|
||||||
|
if ((tmpbuf = (char *) saferealloc (buf, size)) == NULL) {
|
||||||
|
safefree (buf);
|
||||||
|
return -1;
|
||||||
|
} else
|
||||||
|
buf = tmpbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (safe_write (fd, buf, n) < 0) {
|
||||||
|
safefree (buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
safefree (buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read in a "line" from the socket. It might take a few loops through
|
||||||
|
* the read sequence. The full string is allocate off the heap and stored
|
||||||
|
* at the whole_buffer pointer. The caller needs to free the memory when
|
||||||
|
* it is no longer in use. The returned line is NULL terminated.
|
||||||
|
*
|
||||||
|
* Returns the length of the buffer on success (not including the NULL
|
||||||
|
* termination), 0 if the socket was closed, and -1 on all other errors.
|
||||||
|
*/
|
||||||
|
#define SEGMENT_LEN (512)
|
||||||
|
#define MAXIMUM_BUFFER_LENGTH (128 * 1024)
|
||||||
|
ssize_t readline (int fd, char **whole_buffer)
|
||||||
|
{
|
||||||
|
ssize_t whole_buffer_len;
|
||||||
|
char buffer[SEGMENT_LEN];
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
ssize_t ret;
|
||||||
|
ssize_t diff;
|
||||||
|
|
||||||
|
struct read_lines_s {
|
||||||
|
char *data;
|
||||||
|
size_t len;
|
||||||
|
struct read_lines_s *next;
|
||||||
|
};
|
||||||
|
struct read_lines_s *first_line, *line_ptr;
|
||||||
|
|
||||||
|
first_line =
|
||||||
|
(struct read_lines_s *) safecalloc (sizeof (struct read_lines_s),
|
||||||
|
1);
|
||||||
|
if (!first_line)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
line_ptr = first_line;
|
||||||
|
|
||||||
|
whole_buffer_len = 0;
|
||||||
|
for (;;) {
|
||||||
|
ret = recv (fd, buffer, SEGMENT_LEN, MSG_PEEK);
|
||||||
|
if (ret <= 0)
|
||||||
|
goto CLEANUP;
|
||||||
|
|
||||||
|
ptr = (char *) memchr (buffer, '\n', ret);
|
||||||
|
if (ptr)
|
||||||
|
diff = ptr - buffer + 1;
|
||||||
|
else
|
||||||
|
diff = ret;
|
||||||
|
|
||||||
|
whole_buffer_len += diff;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't allow the buffer to grow without bound. If we
|
||||||
|
* get to more than MAXIMUM_BUFFER_LENGTH close.
|
||||||
|
*/
|
||||||
|
if (whole_buffer_len > MAXIMUM_BUFFER_LENGTH) {
|
||||||
|
ret = -ERANGE;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
line_ptr->data = (char *) safemalloc (diff);
|
||||||
|
if (!line_ptr->data) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = recv (fd, line_ptr->data, diff, 0);
|
||||||
|
if (ret == -1) {
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
line_ptr->len = diff;
|
||||||
|
|
||||||
|
if (ptr) {
|
||||||
|
line_ptr->next = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
line_ptr->next =
|
||||||
|
(struct read_lines_s *)
|
||||||
|
safecalloc (sizeof (struct read_lines_s), 1);
|
||||||
|
if (!line_ptr->next) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
line_ptr = line_ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
*whole_buffer = (char *) safemalloc (whole_buffer_len + 1);
|
||||||
|
if (!*whole_buffer) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(*whole_buffer + whole_buffer_len) = '\0';
|
||||||
|
|
||||||
|
whole_buffer_len = 0;
|
||||||
|
line_ptr = first_line;
|
||||||
|
while (line_ptr) {
|
||||||
|
memcpy (*whole_buffer + whole_buffer_len, line_ptr->data,
|
||||||
|
line_ptr->len);
|
||||||
|
whole_buffer_len += line_ptr->len;
|
||||||
|
|
||||||
|
line_ptr = line_ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = whole_buffer_len;
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
do {
|
||||||
|
line_ptr = first_line->next;
|
||||||
|
if (first_line->data)
|
||||||
|
safefree (first_line->data);
|
||||||
|
safefree (first_line);
|
||||||
|
first_line = line_ptr;
|
||||||
|
} while (first_line);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert the network address into either a dotted-decimal or an IPv6
|
||||||
|
* hex string.
|
||||||
|
*/
|
||||||
|
const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
|
||||||
|
{
|
||||||
|
const char *result;
|
||||||
|
|
||||||
|
assert (sa != NULL);
|
||||||
|
assert (buf != NULL);
|
||||||
|
assert (buflen != 0);
|
||||||
|
buf[0] = '\0'; /* start with an empty string */
|
||||||
|
|
||||||
|
switch (sa->sa_family) {
|
||||||
|
case AF_INET:
|
||||||
|
{
|
||||||
|
struct sockaddr_in *sa_in = (struct sockaddr_in *) sa;
|
||||||
|
|
||||||
|
result = inet_ntop (AF_INET, &sa_in->sin_addr, buf,
|
||||||
|
buflen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AF_INET6:
|
||||||
|
{
|
||||||
|
struct sockaddr_in6 *sa_in6 =
|
||||||
|
(struct sockaddr_in6 *) sa;
|
||||||
|
|
||||||
|
result = inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf,
|
||||||
|
buflen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
/* no valid family */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a numeric character string into an IPv6 network address
|
||||||
|
* (in binary form.) The function works just like inet_pton(), but it
|
||||||
|
* will accept both IPv4 and IPv6 numeric addresses.
|
||||||
|
*
|
||||||
|
* Returns the same as inet_pton().
|
||||||
|
*/
|
||||||
|
int full_inet_pton (const char *ip, void *dst)
|
||||||
|
{
|
||||||
|
char buf[24], tmp[24]; /* IPv4->IPv6 = ::FFFF:xxx.xxx.xxx.xxx\0 */
|
||||||
|
int n;
|
||||||
|
|
||||||
|
assert (ip != NULL && strlen (ip) != 0);
|
||||||
|
assert (dst != NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the string is an IPv4 numeric address. We use the
|
||||||
|
* older inet_aton() call since it handles more IPv4 numeric
|
||||||
|
* address formats.
|
||||||
|
*/
|
||||||
|
n = inet_aton (ip, (struct in_addr *) dst);
|
||||||
|
if (n == 0) {
|
||||||
|
/*
|
||||||
|
* Simple case: "ip" wasn't an IPv4 numeric address, so
|
||||||
|
* try doing the conversion as an IPv6 address. This
|
||||||
|
* will either succeed or fail, but we can't do any
|
||||||
|
* more processing anyway.
|
||||||
|
*/
|
||||||
|
return inet_pton (AF_INET6, ip, dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "ip" was an IPv4 address, so we need to convert it to
|
||||||
|
* an IPv4-mapped IPv6 address and do the conversion
|
||||||
|
* again to get the IPv6 network structure.
|
||||||
|
*
|
||||||
|
* We convert the IPv4 binary address back into the
|
||||||
|
* standard dotted-decimal format using inet_ntop()
|
||||||
|
* so we can be sure that inet_pton will accept the
|
||||||
|
* full string.
|
||||||
|
*/
|
||||||
|
snprintf (buf, sizeof (buf), "::ffff:%s",
|
||||||
|
inet_ntop (AF_INET, dst, tmp, sizeof (tmp)));
|
||||||
|
return inet_pton (AF_INET6, buf, dst);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2002, 2004 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'network.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_NETWORK_H
|
||||||
|
#define TINYPROXY_NETWORK_H
|
||||||
|
|
||||||
|
extern ssize_t safe_write (int fd, const void *buf, size_t count);
|
||||||
|
extern ssize_t safe_read (int fd, void *buf, size_t count);
|
||||||
|
|
||||||
|
extern int write_message (int fd, const char *fmt, ...);
|
||||||
|
extern ssize_t readline (int fd, char **whole_buffer);
|
||||||
|
|
||||||
|
extern const char *get_ip_string (struct sockaddr *sa, char *buf, size_t len);
|
||||||
|
extern int full_inet_pton (const char *ip, void *dst);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/* $Id: regexp.h,v 1.2 2000-09-11 23:50:07 rjkaes Exp $
|
|
||||||
*
|
|
||||||
* We need this little header to help distinguish whether to use the REGEX
|
|
||||||
* library installed in the system, or to include our own version (the GNU
|
|
||||||
* version to be exact.)
|
|
||||||
*
|
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TINYPROXY_REGEXP_H_
|
|
||||||
#define _TINYPROXY_REGEXP_H_
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_GNU_REGEX
|
|
||||||
# include "gnuregex.h"
|
|
||||||
#else
|
|
||||||
# include <regex.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+1585
-528
File diff suppressed because it is too large.
Load diff
+38
-14
@@ -1,24 +1,48 @@
|
|||||||
/* $Id: reqs.h,v 1.2 2000-09-12 00:04:42 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* See 'reqs.c' for a detailed description.
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 Steven Young
|
* This program is distributed in the hope that it will be useful,
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* You should have received a copy of the GNU General Public License along
|
||||||
* under the terms of the GNU General Public License as published by the
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* See 'reqs.c' for detailed information. */
|
||||||
|
|
||||||
#ifndef _TINYPROXY_REQS_H_
|
#ifndef _TINYPROXY_REQS_H_
|
||||||
#define _TINYPROXY_REQS_H_
|
#define _TINYPROXY_REQS_H_
|
||||||
|
|
||||||
extern void handle_connection(int fd);
|
#include "common.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Port constants for HTTP (80) and SSL (443)
|
||||||
|
*/
|
||||||
|
#define HTTP_PORT 80
|
||||||
|
#define HTTP_PORT_SSL 443
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure holds the information pulled from a URL request.
|
||||||
|
*/
|
||||||
|
struct request_s {
|
||||||
|
char *method;
|
||||||
|
char *protocol;
|
||||||
|
|
||||||
|
char *host;
|
||||||
|
uint16_t port;
|
||||||
|
|
||||||
|
char *path;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void handle_connection (int fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1999-2005 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Allow tinyproxy to be used as a reverse proxy. */
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "reverse-proxy.h"
|
||||||
|
|
||||||
|
#include "conns.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "html-error.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add entry to the reversepath list
|
||||||
|
*/
|
||||||
|
void reversepath_add (const char *path, const char *url,
|
||||||
|
struct reversepath **reversepath_list)
|
||||||
|
{
|
||||||
|
struct reversepath *reverse;
|
||||||
|
|
||||||
|
if (url == NULL) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Illegal reverse proxy rule: missing url");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strstr (url, "://")) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Skipping reverse proxy rule: '%s' is not a valid url",
|
||||||
|
url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path && *path != '/') {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Skipping reverse proxy rule: path '%s' "
|
||||||
|
"doesn't start with a /", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse = (struct reversepath *) safemalloc (sizeof
|
||||||
|
(struct reversepath));
|
||||||
|
if (!reverse) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Unable to allocate memory in reversepath_add()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
reverse->path = safestrdup ("/");
|
||||||
|
else
|
||||||
|
reverse->path = safestrdup (path);
|
||||||
|
|
||||||
|
reverse->url = safestrdup (url);
|
||||||
|
|
||||||
|
reverse->next = *reversepath_list;
|
||||||
|
*reversepath_list = reverse;
|
||||||
|
|
||||||
|
log_message (LOG_INFO,
|
||||||
|
"Added reverse proxy rule: %s -> %s", reverse->path,
|
||||||
|
reverse->url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if a request url is in the reversepath list
|
||||||
|
*/
|
||||||
|
struct reversepath *reversepath_get (char *url, struct reversepath *reverse)
|
||||||
|
{
|
||||||
|
while (reverse) {
|
||||||
|
if (strstr (url, reverse->path) == url)
|
||||||
|
return reverse;
|
||||||
|
|
||||||
|
reverse = reverse->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a reversepath list
|
||||||
|
*/
|
||||||
|
|
||||||
|
void free_reversepath_list (struct reversepath *reverse)
|
||||||
|
{
|
||||||
|
while (reverse) {
|
||||||
|
struct reversepath *tmp = reverse;
|
||||||
|
reverse = reverse->next;
|
||||||
|
safefree (tmp->url);
|
||||||
|
safefree (tmp->path);
|
||||||
|
safefree (tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rewrite the URL for reverse proxying.
|
||||||
|
*/
|
||||||
|
char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
|
||||||
|
char *url)
|
||||||
|
{
|
||||||
|
char *rewrite_url = NULL;
|
||||||
|
char *cookie = NULL;
|
||||||
|
char *cookieval;
|
||||||
|
struct reversepath *reverse = NULL;
|
||||||
|
|
||||||
|
/* Reverse requests always start with a slash */
|
||||||
|
if (*url == '/') {
|
||||||
|
/* First try locating the reverse mapping by request url */
|
||||||
|
reverse = reversepath_get (url, config.reversepath_list);
|
||||||
|
if (reverse) {
|
||||||
|
rewrite_url = (char *)
|
||||||
|
safemalloc (strlen (url) + strlen (reverse->url) +
|
||||||
|
1);
|
||||||
|
strcpy (rewrite_url, reverse->url);
|
||||||
|
strcat (rewrite_url, url + strlen (reverse->path));
|
||||||
|
} else if (config.reversemagic
|
||||||
|
&& hashmap_entry_by_key (hashofheaders,
|
||||||
|
"cookie",
|
||||||
|
(void **) &cookie) > 0) {
|
||||||
|
|
||||||
|
/* No match - try the magical tracking cookie next */
|
||||||
|
if ((cookieval = strstr (cookie, REVERSE_COOKIE "="))
|
||||||
|
&& (reverse =
|
||||||
|
reversepath_get (cookieval +
|
||||||
|
strlen (REVERSE_COOKIE) + 1,
|
||||||
|
config.reversepath_list)))
|
||||||
|
{
|
||||||
|
|
||||||
|
rewrite_url = (char *) safemalloc
|
||||||
|
(strlen (url) +
|
||||||
|
strlen (reverse->url) +
|
||||||
|
1);
|
||||||
|
strcpy (rewrite_url, reverse->url);
|
||||||
|
strcat (rewrite_url, url + 1);
|
||||||
|
|
||||||
|
log_message (LOG_INFO,
|
||||||
|
"Magical tracking cookie says: %s",
|
||||||
|
reverse->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rewrite_url == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message (LOG_CONN, "Rewriting URL: %s -> %s", url, rewrite_url);
|
||||||
|
|
||||||
|
/* Store reverse path so that the magical tracking cookie can be set */
|
||||||
|
if (config.reversemagic && reverse)
|
||||||
|
connptr->reversepath = safestrdup (reverse->path);
|
||||||
|
|
||||||
|
return rewrite_url;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 2005 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* See 'reverse-proxy.c' for detailed information. */
|
||||||
|
|
||||||
|
#ifndef TINYPROXY_REVERSE_PROXY_H
|
||||||
|
#define TINYPROXY_REVERSE_PROXY_H
|
||||||
|
|
||||||
|
#include "conns.h"
|
||||||
|
|
||||||
|
struct reversepath {
|
||||||
|
struct reversepath *next;
|
||||||
|
char *path;
|
||||||
|
char *url;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define REVERSE_COOKIE "yummy_magical_cookie"
|
||||||
|
|
||||||
|
extern void reversepath_add (const char *path, const char *url,
|
||||||
|
struct reversepath **reversepath_list);
|
||||||
|
extern struct reversepath *reversepath_get (char *url,
|
||||||
|
struct reversepath *reverse);
|
||||||
|
void free_reversepath_list (struct reversepath *reverse);
|
||||||
|
extern char *reverse_rewrite_url (struct conn_s *connptr,
|
||||||
|
hashmap_t hashofheaders, char *url);
|
||||||
|
|
||||||
|
#endif
|
||||||
-155
@@ -1,155 +0,0 @@
|
|||||||
/* $Id: scanner.l,v 1.4 2001-08-26 21:08:36 rjkaes Exp $
|
|
||||||
*
|
|
||||||
* This builds the scanner for the tinyproxy configuration file. This
|
|
||||||
* file needs to stay in sync with grammar.y. If someone knows lex and yacc
|
|
||||||
* better than I do, please update these files.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
|
||||||
%{
|
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
|
||||||
#include "grammar.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
struct keyword {
|
|
||||||
char *kw_name;
|
|
||||||
int kw_token;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct keyword keywords[] = {
|
|
||||||
/* statements */
|
|
||||||
{ "port", KW_PORT },
|
|
||||||
{ "logfile", KW_LOGFILE },
|
|
||||||
{ "syslog", KW_SYSLOG },
|
|
||||||
{ "maxclients", KW_MAXCLIENTS },
|
|
||||||
{ "maxspareservers", KW_MAXSPARESERVERS },
|
|
||||||
{ "minspareservers", KW_MINSPARESERVERS },
|
|
||||||
{ "startservers", KW_STARTSERVERS },
|
|
||||||
{ "maxrequestsperchild", KW_MAXREQUESTSPERCHILD },
|
|
||||||
{ "pidfile", KW_PIDFILE },
|
|
||||||
{ "timeout", KW_TIMEOUT },
|
|
||||||
{ "listen", KW_LISTEN },
|
|
||||||
{ "user", KW_USER },
|
|
||||||
{ "group", KW_GROUP },
|
|
||||||
{ "anonymous", KW_ANONYMOUS },
|
|
||||||
{ "filter", KW_FILTER },
|
|
||||||
{ "xtinyproxy", KW_XTINYPROXY },
|
|
||||||
{ "tunnel", KW_TUNNEL },
|
|
||||||
{ "allow", KW_ALLOW },
|
|
||||||
{ "deny", KW_DENY },
|
|
||||||
|
|
||||||
/* loglevel and the settings */
|
|
||||||
{ "loglevel", KW_LOGLEVEL },
|
|
||||||
{ "critical", KW_LOG_CRITICAL },
|
|
||||||
{ "error", KW_LOG_ERROR },
|
|
||||||
{ "warning", KW_LOG_WARNING },
|
|
||||||
{ "notice", KW_LOG_NOTICE },
|
|
||||||
{ "connect", KW_LOG_CONNECT },
|
|
||||||
{ "info", KW_LOG_INFO },
|
|
||||||
|
|
||||||
/* on/off switches */
|
|
||||||
{ "yes", KW_YES },
|
|
||||||
{ "on", KW_YES },
|
|
||||||
{ "no", KW_NO },
|
|
||||||
{ "off", KW_NO }
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#define YY_NO_UNPUT 1
|
|
||||||
|
|
||||||
#define MAX_REGEXP_LEN 1024
|
|
||||||
|
|
||||||
unsigned int yylineno = 1;
|
|
||||||
char tiny_buf[MAX_REGEXP_LEN];
|
|
||||||
char *tiny_str;
|
|
||||||
|
|
||||||
static int check_reserved_words(char *token);
|
|
||||||
static void append_string(int length, char *str);
|
|
||||||
static void append_char(char c);
|
|
||||||
%}
|
|
||||||
|
|
||||||
%option noyywrap
|
|
||||||
|
|
||||||
white [ \t]
|
|
||||||
digit [0-9]
|
|
||||||
alpha [a-zA-Z]
|
|
||||||
alphanum [a-zA-Z0-9]
|
|
||||||
word [^ \#'"\(\)\{\}\\;\n\t,|\.]
|
|
||||||
|
|
||||||
%x string
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
\#.*$ ;
|
|
||||||
\n { yylineno++; return '\n'; }
|
|
||||||
: { return ':'; }
|
|
||||||
{white}+ ;
|
|
||||||
0x{digit}+ { yylval.num = strtol(yytext, NULL, 16); return NUMBER; }
|
|
||||||
0{digit}+ { yylval.num = strtol(yytext, NULL, 8); return NUMBER; }
|
|
||||||
{digit}+ { yylval.num = atoi(yytext); return NUMBER; }
|
|
||||||
{alpha}+ { return check_reserved_words(yytext); }
|
|
||||||
\" {
|
|
||||||
tiny_str = tiny_buf;
|
|
||||||
BEGIN(string);
|
|
||||||
}
|
|
||||||
<string>\\a { append_char(7); }
|
|
||||||
<string>\\n { append_char(10); }
|
|
||||||
<string>\\r { append_char(13); }
|
|
||||||
<string>\\t { append_char(9); }
|
|
||||||
<string>\\v { append_char(11); }
|
|
||||||
<string>\\[^anrtv] { append_string(1, yytext + 1); }
|
|
||||||
<string>\" {
|
|
||||||
BEGIN(INITIAL);
|
|
||||||
yylval.cptr = strdup(tiny_buf);
|
|
||||||
return STRING;
|
|
||||||
}
|
|
||||||
<string>[^"\\]+ { append_string(strlen(yytext), yytext); }
|
|
||||||
|
|
||||||
|
|
||||||
({digit}{1,3}\.){3}{digit}{1,3} { yylval.cptr = strdup(yytext); return NUMERIC_ADDRESS; }
|
|
||||||
({digit}{1,3}\.){3}{digit}{1,3}\/{digit}+ { yylval.cptr = strdup(yytext); return NETMASK_ADDRESS; }
|
|
||||||
([-_a-z0-9]+\.)+[a-z]+ { yylval.cptr = strdup(yytext); return STRING_ADDRESS; }
|
|
||||||
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
int check_reserved_words(char *token)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(keywords) / sizeof(struct keyword)); i++) {
|
|
||||||
if (strcasecmp(keywords[i].kw_name, token) == 0) {
|
|
||||||
return keywords[i].kw_token;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yylval.cptr = strdup(token);
|
|
||||||
return IDENTIFIER;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void append_string(int length, char *s)
|
|
||||||
{
|
|
||||||
int to_copy = min(MAX_REGEXP_LEN - (tiny_str - tiny_buf) - 1, length);
|
|
||||||
|
|
||||||
memcpy(tiny_str, s, to_copy);
|
|
||||||
tiny_str += to_copy;
|
|
||||||
*tiny_str = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void append_char(char c)
|
|
||||||
{
|
|
||||||
*tiny_str = c;
|
|
||||||
tiny_str++;
|
|
||||||
*tiny_str = 0;
|
|
||||||
}
|
|
||||||
+312
-178
@@ -1,246 +1,380 @@
|
|||||||
/* $Id: sock.c,v 1.5 2001-05-27 02:31:20 rjkaes Exp $
|
/* tinyproxy - A fast light-weight HTTP proxy
|
||||||
|
* Copyright (C) 1998 Steven Young <sdyoung@miranda.org>
|
||||||
|
* Copyright (C) 1999, 2004 Robert James Kaes <rjkaes@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2000 Chris Lightfoot <chris@ex-parrot.com>
|
||||||
*
|
*
|
||||||
* Sockets are created and destroyed here. When a new connection comes in from
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Sockets are created and destroyed here. When a new connection comes in from
|
||||||
* a client, we need to copy the socket and the create a second socket to the
|
* a client, we need to copy the socket and the create a second socket to the
|
||||||
* remote server the client is trying to connect to. Also, the listening
|
* remote server the client is trying to connect to. Also, the listening
|
||||||
* socket is created and destroyed here. Sounds more impressive than it
|
* socket is created and destroyed here. Sounds more impressive than it
|
||||||
* actually is.
|
* actually is.
|
||||||
*
|
|
||||||
* Copyright (C) 1998 Steven Young
|
|
||||||
* Copyright (C) 1999 Robert James Kaes (rjkaes@flarenet.com)
|
|
||||||
* Copyright (C) 2000 Chris Lightfoot (chris@ex-parrot.com)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation; either version 2, or (at your option) any
|
|
||||||
* later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tinyproxy.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "dnscache.h"
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "network.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "utils.h"
|
#include "text.h"
|
||||||
|
#include "conf.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The mutex is used for locking around the calls to the dnscache since I
|
* Return a human readable error for getaddrinfo() and getnameinfo().
|
||||||
* don't want multiple threads accessing the linked list at the same time.
|
|
||||||
* This should be more fine grained, but it will do for now.
|
|
||||||
* - rjkaes
|
|
||||||
*/
|
*/
|
||||||
static pthread_mutex_t sock_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static const char * get_gai_error (int n)
|
||||||
|
|
||||||
#define SOCK_LOCK() pthread_mutex_lock(&sock_mutex);
|
|
||||||
#define SOCK_UNLOCK() pthread_mutex_unlock(&sock_mutex);
|
|
||||||
|
|
||||||
|
|
||||||
/* This routine is so old I can't even remember writing it. But I do
|
|
||||||
* remember that it was an .h file because I didn't know putting code in a
|
|
||||||
* header was bad magic yet. anyway, this routine opens a connection to a
|
|
||||||
* system and returns the fd.
|
|
||||||
* - steve
|
|
||||||
*
|
|
||||||
* Cleaned up some of the code to use memory routines which are now the
|
|
||||||
* default. Also, the routine first checks to see if the address is in
|
|
||||||
* dotted-decimal form before it does a name lookup.
|
|
||||||
* - rjkaes
|
|
||||||
*/
|
|
||||||
int opensock(char *ip_addr, uint16_t port)
|
|
||||||
{
|
{
|
||||||
int sock_fd;
|
if (n == EAI_SYSTEM)
|
||||||
struct sockaddr_in port_info;
|
return strerror (errno);
|
||||||
int ret;
|
else
|
||||||
|
return gai_strerror (n);
|
||||||
|
}
|
||||||
|
|
||||||
assert(ip_addr != NULL);
|
/*
|
||||||
assert(port > 0);
|
* Bind the given socket to the supplied address. The socket is
|
||||||
|
* returned if the bind succeeded. Otherwise, -1 is returned
|
||||||
|
* to indicate an error.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
bind_socket (int sockfd, const char *addr, int family)
|
||||||
|
{
|
||||||
|
struct addrinfo hints, *res, *ressave;
|
||||||
|
int n;
|
||||||
|
|
||||||
memset((struct sockaddr*)&port_info, 0, sizeof(port_info));
|
assert (sockfd >= 0);
|
||||||
|
assert (addr != NULL && strlen (addr) != 0);
|
||||||
|
|
||||||
port_info.sin_family = AF_INET;
|
memset (&hints, 0, sizeof (struct addrinfo));
|
||||||
|
hints.ai_family = family;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
/* chris - Could block; neet to ensure that this is never called
|
/* The local port is not important */
|
||||||
* before a non-blocking DNS query happens for this address. Not
|
n = getaddrinfo (addr, NULL, &hints, &res);
|
||||||
* relevant in the code as it stands.
|
if (n != 0) {
|
||||||
*/
|
log_message (LOG_INFO,
|
||||||
SOCK_LOCK();
|
"bind_socket: getaddrinfo failed for %s: ", addr, get_gai_error (n));
|
||||||
ret = dnscache(&port_info.sin_addr, ip_addr);
|
return -1;
|
||||||
SOCK_UNLOCK();
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
ressave = res;
|
||||||
log_message(LOG_ERR, "opensock: Could not lookup address: %s", ip_addr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
port_info.sin_port = htons(port);
|
/* Loop through the addresses and try to bind to each */
|
||||||
|
do {
|
||||||
|
if (bind (sockfd, res->ai_addr, res->ai_addrlen) == 0)
|
||||||
|
break; /* success */
|
||||||
|
} while ((res = res->ai_next) != NULL);
|
||||||
|
|
||||||
if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
freeaddrinfo (ressave);
|
||||||
log_message(LOG_ERR, "opensock: socket (%s)", strerror(errno));
|
if (res == NULL) /* was not able to bind to any address */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (connect(sock_fd, (struct sockaddr*)&port_info, sizeof(port_info)) < 0) {
|
return sockfd;
|
||||||
log_message(LOG_ERR, "connecting socket");
|
}
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sock_fd;
|
/*
|
||||||
|
* Open a connection to a remote host. It's been re-written to use
|
||||||
|
* the getaddrinfo() library function, which allows for a protocol
|
||||||
|
* independent implementation (mostly for IPv4 and IPv6 addresses.)
|
||||||
|
*/
|
||||||
|
int opensock (const char *host, int port, const char *bind_to)
|
||||||
|
{
|
||||||
|
int sockfd, n;
|
||||||
|
struct addrinfo hints, *res, *ressave;
|
||||||
|
char portstr[6];
|
||||||
|
|
||||||
|
assert (host != NULL);
|
||||||
|
assert (port > 0);
|
||||||
|
|
||||||
|
log_message(LOG_INFO,
|
||||||
|
"opensock: opening connection to %s:%d", host, port);
|
||||||
|
|
||||||
|
memset (&hints, 0, sizeof (struct addrinfo));
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
|
snprintf (portstr, sizeof (portstr), "%d", port);
|
||||||
|
|
||||||
|
n = getaddrinfo (host, portstr, &hints, &res);
|
||||||
|
if (n != 0) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"opensock: Could not retrieve address info for %s:%d: %s", host, port, get_gai_error (n));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message(LOG_INFO,
|
||||||
|
"opensock: getaddrinfo returned for %s:%d", host, port);
|
||||||
|
|
||||||
|
ressave = res;
|
||||||
|
do {
|
||||||
|
sockfd =
|
||||||
|
socket (res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||||
|
if (sockfd < 0)
|
||||||
|
continue; /* ignore this one */
|
||||||
|
|
||||||
|
/* Bind to the specified address */
|
||||||
|
if (bind_to) {
|
||||||
|
if (bind_socket (sockfd, bind_to,
|
||||||
|
res->ai_family) < 0) {
|
||||||
|
close (sockfd);
|
||||||
|
continue; /* can't bind, so try again */
|
||||||
|
}
|
||||||
|
} else if (config.bind_address) {
|
||||||
|
if (bind_socket (sockfd, config.bind_address,
|
||||||
|
res->ai_family) < 0) {
|
||||||
|
close (sockfd);
|
||||||
|
continue; /* can't bind, so try again */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connect (sockfd, res->ai_addr, res->ai_addrlen) == 0)
|
||||||
|
break; /* success */
|
||||||
|
|
||||||
|
close (sockfd);
|
||||||
|
} while ((res = res->ai_next) != NULL);
|
||||||
|
|
||||||
|
freeaddrinfo (ressave);
|
||||||
|
if (res == NULL) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"opensock: Could not establish a connection to %s:%d",
|
||||||
|
host,
|
||||||
|
port);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the socket to non blocking -rjkaes
|
* Set the socket to non blocking -rjkaes
|
||||||
*/
|
*/
|
||||||
int socket_nonblocking(int sock)
|
int socket_nonblocking (int sock)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
assert(sock >= 0);
|
assert (sock >= 0);
|
||||||
|
|
||||||
flags = fcntl(sock, F_GETFL, 0);
|
flags = fcntl (sock, F_GETFL, 0);
|
||||||
return fcntl(sock, F_SETFL, flags | O_NONBLOCK);
|
return fcntl (sock, F_SETFL, flags | O_NONBLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the socket to blocking -rjkaes
|
* Set the socket to blocking -rjkaes
|
||||||
*/
|
*/
|
||||||
int socket_blocking(int sock)
|
int socket_blocking (int sock)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
assert(sock >= 0);
|
assert (sock >= 0);
|
||||||
|
|
||||||
flags = fcntl(sock, F_GETFL, 0);
|
flags = fcntl (sock, F_GETFL, 0);
|
||||||
return fcntl(sock, F_SETFL, flags & ~O_NONBLOCK);
|
return fcntl (sock, F_SETFL, flags & ~O_NONBLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to listen on one socket based on the addrinfo
|
||||||
|
* as returned from getaddrinfo.
|
||||||
|
*
|
||||||
|
* Return the file descriptor upon success, -1 upon error.
|
||||||
|
*/
|
||||||
|
static int listen_on_one_socket(struct addrinfo *ad)
|
||||||
|
{
|
||||||
|
int listenfd;
|
||||||
|
int ret;
|
||||||
|
const int on = 1;
|
||||||
|
char numerichost[NI_MAXHOST];
|
||||||
|
int flags = NI_NUMERICHOST;
|
||||||
|
|
||||||
|
ret = getnameinfo(ad->ai_addr, ad->ai_addrlen,
|
||||||
|
numerichost, NI_MAXHOST, NULL, 0, flags);
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR, "getnameinfo failed: %s", get_gai_error (ret));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message(LOG_INFO, "trying to listen on host[%s], family[%d], "
|
||||||
|
"socktype[%d], proto[%d]", numerichost,
|
||||||
|
ad->ai_family, ad->ai_socktype, ad->ai_protocol);
|
||||||
|
|
||||||
|
listenfd = socket(ad->ai_family, ad->ai_socktype, ad->ai_protocol);
|
||||||
|
if (listenfd == -1) {
|
||||||
|
log_message(LOG_ERR, "socket() failed: %s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR,
|
||||||
|
"setsockopt failed to set SO_REUSEADDR: %s",
|
||||||
|
strerror(errno));
|
||||||
|
close(listenfd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ad->ai_family == AF_INET6) {
|
||||||
|
ret = setsockopt(listenfd, IPPROTO_IPV6, IPV6_V6ONLY, &on,
|
||||||
|
sizeof(on));
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR,
|
||||||
|
"setsockopt failed to set IPV6_V6ONLY: %s",
|
||||||
|
strerror(errno));
|
||||||
|
close(listenfd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = bind(listenfd, ad->ai_addr, ad->ai_addrlen);
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR, "bind failed: %s", strerror (errno));
|
||||||
|
close(listenfd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = listen(listenfd, MAXLISTEN);
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message(LOG_ERR, "listen failed: %s", strerror(errno));
|
||||||
|
close(listenfd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message(LOG_INFO, "listening on fd [%d]", listenfd);
|
||||||
|
|
||||||
|
return listenfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start listening to a socket. Create a socket with the selected port.
|
* Start listening on a socket. Create a socket with the selected port.
|
||||||
* The size of the socket address will be returned to the caller through
|
* If the provided address is NULL, we may listen on multiple sockets,
|
||||||
* the pointer, while the socket is returned as a default return.
|
* e.g. the wildcard addresse for IPv4 and IPv6, depending on what is
|
||||||
* - rjkaes
|
* supported. If the address is not NULL, we only listen on the first
|
||||||
|
* address reported by getaddrinfo that works.
|
||||||
|
*
|
||||||
|
* Upon success, the listen-fds are added to the listen_fds list
|
||||||
|
* and 0 is returned. Upon error, -1 is returned.
|
||||||
*/
|
*/
|
||||||
int listen_sock(uint16_t port, socklen_t *addrlen)
|
int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
|
||||||
{
|
{
|
||||||
int listenfd;
|
struct addrinfo hints, *result, *rp;
|
||||||
const int on = 1;
|
char portstr[6];
|
||||||
struct sockaddr_in addr;
|
int ret = -1;
|
||||||
|
int n;
|
||||||
|
|
||||||
assert(port > 0);
|
assert (port > 0);
|
||||||
assert(addrlen != NULL);
|
assert (listen_fds != NULL);
|
||||||
|
|
||||||
listenfd = socket(AF_INET, SOCK_STREAM, 0);
|
log_message(LOG_INFO, "listen_sock called with addr = '%s'",
|
||||||
setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
addr == NULL ? "(NULL)" : addr);
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset (&hints, 0, sizeof (struct addrinfo));
|
||||||
addr.sin_family = AF_INET;
|
hints.ai_family = AF_UNSPEC;
|
||||||
addr.sin_port = htons(port);
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
if (config.ipAddr) {
|
snprintf (portstr, sizeof (portstr), "%d", port);
|
||||||
addr.sin_addr.s_addr = inet_addr(config.ipAddr);
|
|
||||||
} else {
|
|
||||||
addr.sin_addr.s_addr = inet_addr("0.0.0.0");
|
|
||||||
}
|
|
||||||
|
|
||||||
bind(listenfd, (struct sockaddr *)&addr, sizeof(addr));
|
|
||||||
|
|
||||||
listen(listenfd, MAXLISTEN);
|
n = getaddrinfo (addr, portstr, &hints, &result);
|
||||||
|
if (n != 0) {
|
||||||
|
log_message (LOG_ERR,
|
||||||
|
"Unable to getaddrinfo() for %s:%d because of %s",
|
||||||
|
addr,
|
||||||
|
port,
|
||||||
|
get_gai_error (n));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
*addrlen = sizeof(addr);
|
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||||
|
int listenfd;
|
||||||
|
|
||||||
return listenfd;
|
listenfd = listen_on_one_socket(rp);
|
||||||
|
if (listenfd == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector_append (listen_fds, &listenfd, sizeof(int));
|
||||||
|
|
||||||
|
/* success */
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
if (addr != NULL) {
|
||||||
|
/*
|
||||||
|
* Unless wildcard is requested, only listen
|
||||||
|
* on the first result that works.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
log_message (LOG_ERR, "Unable to listen on any address.");
|
||||||
|
}
|
||||||
|
|
||||||
|
freeaddrinfo (result);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Takes a socket descriptor and returns the string contain the peer's
|
* Takes a socket descriptor and returns the socket's IP address.
|
||||||
* IP address.
|
|
||||||
*/
|
*/
|
||||||
char *getpeer_ip(int fd, char *ipaddr)
|
int getsock_ip (int fd, char *ipaddr)
|
||||||
{
|
{
|
||||||
struct sockaddr_in name;
|
struct sockaddr_storage name;
|
||||||
size_t namelen = sizeof(name);
|
socklen_t namelen = sizeof (name);
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert (fd >= 0);
|
||||||
assert(ipaddr != NULL);
|
|
||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr*)&name, &namelen) != 0) {
|
if (getsockname (fd, (struct sockaddr *) &name, &namelen) != 0) {
|
||||||
log_message(LOG_ERR, "Connect: 'could not get peer name'");
|
log_message (LOG_ERR, "getsock_ip: getsockname() error: %s",
|
||||||
} else {
|
strerror (errno));
|
||||||
strlcpy(ipaddr,
|
return -1;
|
||||||
inet_ntoa(*(struct in_addr*)&name.sin_addr.s_addr),
|
}
|
||||||
PEER_IP_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ipaddr;
|
if (get_ip_string ((struct sockaddr *) &name, ipaddr, IP_LENGTH) ==
|
||||||
|
NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Takes a socket descriptor and returns the string containing the peer's
|
* Return the peer's socket information.
|
||||||
* address.
|
|
||||||
*/
|
*/
|
||||||
char *getpeer_string(int fd, char *string)
|
int getpeer_information (int fd, char *ipaddr, char *string_addr)
|
||||||
{
|
{
|
||||||
struct sockaddr_in name;
|
struct sockaddr_storage sa;
|
||||||
size_t namelen = sizeof(name);
|
socklen_t salen = sizeof sa;
|
||||||
struct hostent *peername;
|
|
||||||
|
|
||||||
assert(fd >= 0);
|
assert (fd >= 0);
|
||||||
assert(string != NULL);
|
assert (ipaddr != NULL);
|
||||||
|
assert (string_addr != NULL);
|
||||||
|
|
||||||
if (getpeername(fd, (struct sockaddr *)&name, &namelen) != 0) {
|
/* Set the strings to default values */
|
||||||
log_message(LOG_ERR, "Connect: 'could not get peer name'");
|
ipaddr[0] = '\0';
|
||||||
} else {
|
strlcpy (string_addr, "[unknown]", HOSTNAME_LENGTH);
|
||||||
SOCK_LOCK();
|
|
||||||
peername = gethostbyaddr((char *)&name.sin_addr.s_addr,
|
|
||||||
sizeof(name.sin_addr.s_addr),
|
|
||||||
AF_INET);
|
|
||||||
if (peername) {
|
|
||||||
strlcpy(string, peername->h_name, PEER_STRING_LENGTH);
|
|
||||||
}
|
|
||||||
SOCK_UNLOCK();
|
|
||||||
}
|
|
||||||
|
|
||||||
return string;
|
/* Look up the IP address */
|
||||||
}
|
if (getpeername (fd, (struct sockaddr *) &sa, &salen) != 0)
|
||||||
|
return -1;
|
||||||
/*
|
|
||||||
* Reads in a line of text one character at a time. Finishes when either a
|
if (get_ip_string ((struct sockaddr *) &sa, ipaddr, IP_LENGTH) == NULL)
|
||||||
* newline is detected, or maxlen characters have been read. The function
|
return -1;
|
||||||
* will actually copy one less than maxlen into the buffer. In other words,
|
|
||||||
* the returned string will _always_ be '\0' terminated.
|
/* Get the full host name */
|
||||||
*/
|
return getnameinfo ((struct sockaddr *) &sa, salen,
|
||||||
ssize_t readline(int fd, char *ptr, size_t maxlen)
|
string_addr, HOSTNAME_LENGTH, NULL, 0, 0);
|
||||||
{
|
|
||||||
size_t n;
|
|
||||||
ssize_t rc;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
assert(fd >= 0);
|
|
||||||
assert(ptr != NULL);
|
|
||||||
|
|
||||||
for (n = 1; n < maxlen; n++) {
|
|
||||||
again:
|
|
||||||
if ((rc = read(fd, &c, 1)) == 1) {
|
|
||||||
*ptr++ = c;
|
|
||||||
if (c == '\n')
|
|
||||||
break;
|
|
||||||
} else if (rc == 0) {
|
|
||||||
if (n == 1)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (errno == EINTR)
|
|
||||||
goto again;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tack a NIL to the end to make is a standard "C" string */
|
|
||||||
*ptr = '\0';
|
|
||||||
return (ssize_t)n;
|
|
||||||
}
|
}
|
||||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user