Compare commits
2608 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4169484361 | |||
| aed19e6be3 | |||
| 0d7094582f | |||
| 32f1a958bf | |||
| 60e975ee27 | |||
| e27e3e98c7 | |||
| 2b3663b7f2 | |||
| f418bcbd75 | |||
| b90448a71d | |||
| 6cab32aa5a | |||
| a9153e1a2b | |||
| ba6ccb3dbb | |||
| 623b2f8879 | |||
| 5e36b3d56f | |||
| 983ed4e2cb | |||
| e19222597b | |||
| ff2e85e14d | |||
| 5345c065f6 | |||
| 07bfc8e98f | |||
| 1deffbca75 | |||
| 0f36e361a0 | |||
| 085ce82751 | |||
| 74bc407b7a | |||
| 3f25d99a3e | |||
| ae28f55062 | |||
| 9715f28615 | |||
| 46c408c19b | |||
| 76fdc3af55 | |||
| c3fce509c0 | |||
| ac2575bd5b | |||
| e9f0fb2315 | |||
| 9b688f00f9 | |||
| 2c0c337a6d | |||
| 14893629ba | |||
| e82571beed | |||
| bcbc3e41ef | |||
| 5aca7bd1b4 | |||
| 18d3cfeeac | |||
| 96f82d9f3a | |||
| 34bf25066c | |||
| c610f92b7f | |||
| 8469506b0f | |||
| ceaee85d3b | |||
| eda8f71065 | |||
| 57bb0b1e9a | |||
| 7df9051019 | |||
| b9223e0555 | |||
| 2cc1f2d3f7 | |||
| 59bfb5095b | |||
| 6191c740fe | |||
| 9a8fb7a696 | |||
| 99b8190180 | |||
| b6cbaee339 | |||
| 92a1106405 | |||
| 0faf2b9899 | |||
| eafb79546d | |||
| 6c699f2ce5 | |||
| 260efcc5a6 | |||
| d77a9ae509 | |||
| 43f5181b6a | |||
| 0d60caab07 | |||
| acc87400eb | |||
| c87938cd42 | |||
| f5d5b73c26 | |||
| 2fb8017a72 | |||
| db0f47a10a | |||
| 722c1cf7f8 | |||
| c1908949fc | |||
| 164fbfd2d5 | |||
| e6c97f4148 | |||
| cd0adf5550 | |||
| d75ace7440 | |||
| a93b232c68 | |||
| 04cc9d0699 | |||
| f948279583 | |||
| c737565c13 | |||
| f295a3b123 | |||
| 153b5a37f1 | |||
| ba9c401697 | |||
| 4c4545428d | |||
| fd00877141 | |||
| f1c796b129 | |||
| b9617be068 | |||
| e0f230dd15 | |||
| 567e170338 | |||
| d52f0004a4 | |||
| fc02b0306b | |||
| 839d45675c | |||
| 88073e9816 | |||
| 15adc798e5 | |||
| 98261856db | |||
| 668dc88b96 | |||
| f049892e39 | |||
| 1b518e5b46 | |||
| 4445926033 | |||
| e3aaefd2e9 | |||
| 732f1ae851 | |||
| 0dc6f620c1 | |||
| b8745330e4 | |||
| 0b259ce52f | |||
| fdb4428191 | |||
| 33d090e8b6 | |||
| 52838c0f7b | |||
| 10585fff80 | |||
| f5207ea5f4 | |||
| 66e6293a92 | |||
| 159f7d98b7 | |||
| fa58d770be | |||
| 4568bd892e | |||
| 23b6701174 | |||
| 7aec3f702d | |||
| c7bd6fafc7 | |||
| 275963c6fb | |||
| e4567b255b | |||
| 166b2d4658 | |||
| a462413025 | |||
| 58ed05f187 | |||
| 2960938f96 | |||
| 5544b34253 | |||
| 835b076c99 | |||
| b664435ef6 | |||
| 368dca4379 | |||
| ef557fbb6a | |||
| 17fc123a54 | |||
| 0b967cc765 | |||
| 65c9aa63eb | |||
| 3ef108634c | |||
| 0a35bd4c59 | |||
| 2b33e231e4 | |||
| 0e479083f3 | |||
| 2a853f44ee | |||
| 2ecd2bdd13 | |||
| 9b8a547ca8 | |||
| 2f327ce463 | |||
| 2669745975 | |||
| 47b8a13911 | |||
| 5504f85373 | |||
| a42cc8da66 | |||
| 4387556026 | |||
| 005a86da1c | |||
| 1afc4d929d | |||
| 19513cdf14 | |||
| e09b2600c6 | |||
| 280a2f1c00 | |||
| c64fd17550 | |||
| 9d1fa83a39 | |||
| 23d3a73b01 | |||
| 567587718b | |||
| 4c671ead1c | |||
| 3ba160c52a | |||
| 3ef2b78014 | |||
| c7c133ef1d | |||
| 9e8eebac15 | |||
| bfce8ffb61 | |||
| e23fed0a47 | |||
| 775b71134c | |||
| fcb8b3e72b | |||
| d0a23274b4 | |||
| 575ec3f165 | |||
| a699623ada | |||
| f5d13f3263 | |||
| c22653e001 | |||
| 5ba0c006ab | |||
| b6d06e16c0 | |||
| 0bdae3b18c | |||
| 40993037b2 | |||
| 5f5d809b10 | |||
| c40aafcd1a | |||
| d10aaf8ffd | |||
| 02b70e2266 | |||
| dcb693ba54 | |||
| b0fb8d2d12 | |||
| 270c370c2a | |||
| 1ae46203c3 | |||
| 84b0cecfa3 | |||
| 0d8cdd59fa | |||
| 493ddde07a | |||
| 7994bda7b5 | |||
| d459d54271 | |||
| eafc4dd625 | |||
| 52a41b37d5 | |||
| 4a43761e72 | |||
| b2eecb9a3d | |||
| 7bc9067674 | |||
| bac3e5fb41 | |||
| 4d30cf3b07 | |||
| 967935195c | |||
| 43b9f607d3 | |||
| b837adde3c | |||
| 0ee37818f2 | |||
| d9db68ac5f | |||
| cacf778480 | |||
| be3df87b97 | |||
| e2a35c3694 | |||
| 440b189372 | |||
| 0f9bfe3fda | |||
| d3e6a3ee3a | |||
| 30b57a1e42 | |||
| 8b1ae7cee8 | |||
| 59f8837ab2 | |||
| 07d75a6d65 | |||
| 405fa77e3f | |||
| b7f479e9fc | |||
| 93c95407aa | |||
| 1131a79aaf | |||
| a920a3aa67 | |||
| bf4f484fe0 | |||
| a34f6739a5 | |||
| efeede599b | |||
| c1b84508ea | |||
| 74f7acb69d | |||
| bfeccabcdb | |||
| 4046d811a7 | |||
| 6751bd8d52 | |||
| 2debad91d0 | |||
| 2b4ddde690 | |||
| bf213b752d | |||
| e61d38a61d | |||
| c8bbb35aac | |||
| b6b989440d | |||
| e6cf472b01 | |||
| 7dfed291ae | |||
| c43b419939 | |||
| 02b3959ac4 | |||
| 88a89436ae | |||
| 284fffb750 | |||
| c585f73f8c | |||
| e1733604a5 | |||
| 18f6429f32 | |||
| 565b8ef51d | |||
| 68a6a58780 | |||
| 02542a4527 | |||
| 721c2a07d4 | |||
| c8d9e7c5c8 | |||
| 019dc37836 | |||
| 6a6a402cc3 | |||
| 594c8177f5 | |||
| 099c06f11d | |||
| 07261b0389 | |||
| 6be1fb1d02 | |||
| e7e030d54d | |||
| 481b821bae | |||
| 10caea1b92 | |||
| b524f7561b | |||
| 59d17ee112 | |||
| 6b775e1cac | |||
| 309d3fc7c5 | |||
| 82b79ef4d6 | |||
| 5ad93297ed | |||
| 19b023529d | |||
| 8c509d93b2 | |||
| fd412dad00 | |||
| 13750e09e5 | |||
| 701ebe442d | |||
| 8fee805ca1 | |||
| 9365836307 | |||
| c3dfe61b57 | |||
| 488267a6cf | |||
| 0b85c80ac9 | |||
| 2bedc9243e | |||
| a794481941 | |||
| a385c10890 | |||
| 7832c364d7 | |||
| b8897b3250 | |||
| 86a17f9a2b | |||
| 3e442e73ff | |||
| 5a95db314a | |||
| 4d8f04d406 | |||
| 3702139dcf | |||
| 8791e8929e | |||
| cdf375623d | |||
| d98eaed44c | |||
| cea0240240 | |||
| e256e65846 | |||
| 3a7e04c69c | |||
| e28bbf04d2 | |||
| 381b066344 | |||
| 9511b9dde5 | |||
| 7a0a9e2156 | |||
| dd06eeea99 | |||
| 55ec5e4ab4 | |||
| c2cebad52b | |||
| d4d46855c2 | |||
| ba6d9ee127 | |||
| 2b5de12b38 | |||
| 97277cfd1a | |||
| 5bf0cf9fea | |||
| 69d8a34c90 | |||
| 7e70f91686 | |||
| f947c66f66 | |||
| c62d667287 | |||
| 6285933470 | |||
| a48708021c | |||
| edfc8bcff1 | |||
| 4e8c310156 | |||
| 0c8416f5df | |||
| 6b1348a7f1 | |||
| fd2f23f3e7 | |||
| ccfc8c31c2 | |||
| 99e9b70c9b | |||
| e9f98f80f0 | |||
| cb03731e90 | |||
| e2a665e13b | |||
| dc3eb1e735 | |||
| 26de428c18 | |||
| f06aeb2340 | |||
| 309cf8e9a6 | |||
| 5ed6ace0f5 | |||
| 090c212d09 | |||
| 7b354c1cf7 | |||
| 69f5515ea3 | |||
| eda47a1ffc | |||
| a81c480d5e | |||
| 7410465496 | |||
| fbcd6d9c98 | |||
| c6089ba4fd | |||
| 2b70ef0203 | |||
| 8334348a13 | |||
| d3d205ece9 | |||
| d9b1baab76 | |||
| 31799a28c0 | |||
| 42c5dc9288 | |||
| 196c3becb2 | |||
| d7980e5f94 | |||
| c5c953b2f5 | |||
| 929fe9ade7 | |||
| 846dbbeb85 | |||
| eedd984e0d | |||
| 06e33c5421 | |||
| 4aaa9845eb | |||
| d60a7da9c3 | |||
| 20ade83792 | |||
| 80f3b39502 | |||
| 1bb335dc17 | |||
| cfd75ec877 | |||
| c1e4f4c533 | |||
| 80c7f273f2 | |||
| 8b75c064e3 | |||
| 177044c941 | |||
| b38de07b94 | |||
| 07f8349edb | |||
| 40d4dc986e | |||
| d1d7097fe9 | |||
| 268b87d21d | |||
| 120b3f90a0 | |||
| 6a19dac69d | |||
| 16c98885b7 | |||
| ce7af03e66 | |||
| 6d68ec389d | |||
| e44f7a506e | |||
| 2797bfdf02 | |||
| ce40532680 | |||
| 34fc78c89d | |||
| b7e2d57290 | |||
| 3aed346370 | |||
| 5108486af3 | |||
| 9a4c26f13f | |||
| f15cb17755 | |||
| acef784f41 | |||
| 58ed1f8ec6 | |||
| 0490401f3a | |||
| 9dfa482a96 | |||
| b73dd8bb1e | |||
| d97cdf7378 | |||
| b6ac03e8a1 | |||
| 18b1ef5ab4 | |||
| 8641a4198e | |||
| 460b416b7c | |||
| b22ef8d1ce | |||
| 3179ed7d57 | |||
| d31c8960f8 | |||
| 6419df26e0 | |||
| 8affa1126a | |||
| f300de0e01 | |||
| b5fbccb669 | |||
| 04d3c3ba96 | |||
| e30266427e | |||
| d9ac1542ac | |||
| 84709381af | |||
| 3aed0ac0f6 | |||
| 1669d72046 | |||
| 26c462acff | |||
| f9482cc1aa | |||
| d973e99933 | |||
| b39bf70345 | |||
| 130d32ae1a | |||
| 48e8dc008c | |||
| fb7896b2bd | |||
| aecb3d5fed | |||
| e87ab8729d | |||
| 4b39011d69 | |||
| e34e0db1e5 | |||
| dfc41df02a | |||
| 72f555d9a6 | |||
| dbf21c3df5 | |||
| 78de4c894b | |||
| 02a49c8735 | |||
| d4fe793820 | |||
| fd90812453 | |||
| f1d2025b39 | |||
| 60a06c1706 | |||
| 741a0c3508 | |||
| 2bb2b5c9de | |||
| 7883b5931f | |||
| 98099b6a02 | |||
| a615ddc57d | |||
| f98d4304b1 | |||
| e6202fcf23 | |||
| 4aefefc295 | |||
| 51d88128f4 | |||
| 73ea0c4b1e | |||
| a8ac90c466 | |||
| d78724b4c9 | |||
| 022b68e3b3 | |||
| 6733151051 | |||
| 0d667ba503 | |||
| bb9cca20ba | |||
| e4c333dded | |||
| 5bd9c6a3b4 | |||
| a30457892d | |||
| 32d0a6bf4f | |||
| 59e569e59f | |||
| db5c7089bb | |||
| 7e27920421 | |||
| 128a25e6d5 | |||
| 4619ce1e03 | |||
| e84bc1aa80 | |||
| cc4e9f953e | |||
| 58df7bcea5 | |||
| f94b16e7ca | |||
| 9d18a74440 | |||
| 864782d48d | |||
| b536a9dcce | |||
| 0d981fcb86 | |||
| 2f71892daf | |||
| 55061e4dc7 | |||
| 668363eb1b | |||
| 2c7f40aa1e | |||
| d93674485d | |||
| aa12313ee4 | |||
| 62a3624f1f | |||
| 6fafd4964a | |||
| 1fb1a6647f | |||
| 020ca7f651 | |||
| 7faa1cb195 | |||
| 7af3980f96 | |||
| 68bb6fbeb9 | |||
| e35898342d | |||
| 74b9251c40 | |||
| f9fc569c5d | |||
| d97acf8b05 | |||
| c3db29a036 | |||
| 6003c72b5c | |||
| 400c662462 | |||
| 7e5f63d9d2 | |||
| d4f09b7821 | |||
| bdff9336e5 | |||
| 8c92422bce | |||
| 4f49833fc9 | |||
| 1db631bab3 | |||
| 4267203a64 | |||
| fd9e77a4c8 | |||
| a7c9193e03 | |||
| dd0e242ac0 | |||
| 1c1c11f31f | |||
| 2cc8655ed2 | |||
| 2fb79a5961 | |||
| 33dcbbe2ef | |||
| 7116e167fe | |||
| b043b45a1e | |||
| fb1de8ac51 | |||
| 55a9bc66b2 | |||
| 93322d2dce | |||
| c3df4cc0c4 | |||
| c0e626fecf | |||
| 7e9524c7bb | |||
| eb13701244 | |||
| a47fa22ca4 | |||
| 69f8eae646 | |||
| 8da2f97d07 | |||
| b0a33ec353 | |||
| 8d4a0e7e9f | |||
| 0af650be44 | |||
| 7f7f452388 | |||
| d4ce2533f6 | |||
| ed37d4ba16 | |||
| c2ff0e9ffa | |||
| c33790674a | |||
| 1a99a8dd65 | |||
| 227d115d71 | |||
| 3fe8959d00 | |||
| fb0fc710a3 | |||
| 47b0fc5219 | |||
| c0ede6cf6a | |||
| 197edb2730 | |||
| c29849f06a | |||
| a8218e8de3 | |||
| 4c9d8817b7 | |||
| 8e899414fb | |||
| adfb3bc537 | |||
| 34cefef45f | |||
| b73214abba | |||
| 5dba47f945 | |||
| 1bf557e307 | |||
| f94c85c8e1 | |||
| 3d7b8fa803 | |||
| a78094a7aa | |||
| b386099b49 | |||
| cc60537436 | |||
| 23a0a76d93 | |||
| 3f6ac66970 | |||
| 004a597837 | |||
| 926da9c59a | |||
| 99d488d1be | |||
| 0bcb16cc59 | |||
| 469b783b2c | |||
| 6be46c890e | |||
| 812219e372 | |||
| 82e6d490b4 | |||
| 2db0531fa9 | |||
| d53c4c1ce9 | |||
| d4bfdd3039 | |||
| f7bfa7123b | |||
| d2cdb8f2ba | |||
| 99ea373eb7 | |||
| ff4b63ed14 | |||
| 1b67de854d | |||
| 1196bbe826 | |||
| 8bf485fd1d | |||
| d8edd18c10 | |||
| 97c43af83e | |||
| 797da0eae1 | |||
| 00f5a6f940 | |||
| e51533bc31 | |||
| a9a22cce36 | |||
| 1dfddafcf5 | |||
| 801d47eb8d | |||
| b5d6fc0a39 | |||
| e8818b76d4 | |||
| b19bd737d3 | |||
| 96316701e4 | |||
| 427d2d61c1 | |||
| 2a733ffe17 | |||
| b2257b7640 | |||
| 5c9714fa54 | |||
| dfb036c7f2 | |||
| 1a0672cb78 | |||
| 7cd98fb1f9 | |||
| 363579c370 | |||
| 3fb15d74a8 | |||
| 155de9a352 | |||
| b69ebc5c67 | |||
| ff7ad0f287 | |||
| c6af20c86c | |||
| 62c36fb1a0 | |||
| 6184480b06 | |||
| e2ccf68c03 | |||
| 112f929814 | |||
| 69d157062c | |||
| 20f1ee4cef | |||
| a3f7958830 | |||
| c98e858886 | |||
| 9fe8fb960b | |||
| 2d7947eb93 | |||
| 148e644590 | |||
| 0003150796 | |||
| d4dbbe53af | |||
| 30982e446d | |||
| 6001a9aaf4 | |||
| 1935ae6979 | |||
| 6029627a5f | |||
| f67ba78513 | |||
| 2cec984288 | |||
| fe90ba6b5d | |||
| c635de6e85 | |||
| e6077f5ac7 | |||
| d5398e4691 | |||
| d4be55a236 | |||
| c16e034f7c | |||
| b98117f821 | |||
| 5edc71f31a | |||
| 96a929df0b | |||
| a2fdadfaed | |||
| 0692dfb67e | |||
| 7120d50bf6 | |||
| 0f12a87e31 | |||
| d38ea97fa4 | |||
| 8897bf5e4d | |||
| 2a228f68cf | |||
| 3eb59e9052 | |||
| 2c7cd731d9 | |||
| e128394360 | |||
| e672cf5350 | |||
| cfa8d8ff6e | |||
| 7fe8d91bc2 | |||
| bb0bae1cd9 | |||
| 90eed2d001 | |||
| 7fd42fde05 | |||
| fe6fc9eb74 | |||
| 751840ba10 | |||
| 077425689d | |||
| fa1ca78ea7 | |||
| 6aae658e7f | |||
| 04104a3e4d | |||
| 150d748c67 | |||
| 4a565a89da | |||
| a06e00d4af | |||
| 4420267709 | |||
| cde889101b | |||
| 897337cb8e | |||
| 98acb4963d | |||
| c7e6e6be8d | |||
| f0268dabb0 | |||
| 609332a03a | |||
| c3273fba0d | |||
| 0905633810 | |||
| 3391f5946e | |||
| 73e15645d6 | |||
| 4d7b90af99 | |||
| 1965d2d419 | |||
| f2f4855ed7 | |||
| ee1e567503 | |||
| d1baaf4983 | |||
| 52730e6b0e | |||
| 26d18490d4 | |||
| b0e4a4e6f5 | |||
| dd4371a97c | |||
| a7732eeb81 | |||
| 715d8cafa6 | |||
| ecd3ba5a10 | |||
| bb87f4dd6b | |||
| 661f383edc | |||
| afb4cdc685 | |||
| 8fcf4cd652 | |||
| 3030b80c2b | |||
| 732d6067c3 | |||
| 657db63432 | |||
| e251e5e509 | |||
| 0d7f8d474f | |||
| 7801b33e35 | |||
| 7554623cff | |||
| d130dc729e | |||
| 92299999e7 | |||
| 8fb7d51106 | |||
| b3dc10cc7c | |||
| 471a4b15a8 | |||
| 0d75d4ff88 | |||
| 6777f89078 | |||
| e987751b19 | |||
| 73c178a3ea | |||
| 08c09d1d65 | |||
| 5be90fd7ea | |||
| 2878c154d6 | |||
| 2e43a9944e | |||
| 4539ef8d9d | |||
| 994161a0a2 | |||
| e2b6417bd2 | |||
| 2b9a008208 | |||
| 8c732e94ab | |||
| e4d4b7118c | |||
| 167cbdd17c | |||
| e6bb6005ec | |||
| 40e9a5b7b3 | |||
| b105caff07 | |||
| a9eb4be896 | |||
| de82c49fb3 | |||
| fdc7c089c2 | |||
| 2b610dc791 | |||
| 7c21de8aa8 | |||
| d7b1e7d23d | |||
| 9e49ecc8c3 | |||
| d9b48b8efe | |||
| e1402db6cc | |||
| 5c50484068 | |||
| 1e1e196e10 | |||
| 7ceb1a711e | |||
| 3fca094dfa | |||
| 15dacd15ec | |||
| 4f2ea4de8a | |||
| 507dc05998 | |||
| 40ea9d2dc0 | |||
| 03a94807eb | |||
| d8a82090cb | |||
| 8ac718a606 | |||
| 44d0be4604 | |||
| 1508a0f53f | |||
| 61fe3e2bf9 | |||
| 72bfb9a515 | |||
| 5a6e1868a8 | |||
| a10d9e4b80 | |||
| 7760786e7e | |||
| f63d884cfe | |||
| 80716280a8 | |||
| 44689dead7 | |||
| a8d00a8080 | |||
| f85f83c337 | |||
| c80fc3dff8 | |||
| 300bdd6f5f | |||
| a3c567e864 | |||
| 13616f49f3 | |||
| 3da11862c2 | |||
| 4c94dcba5c | |||
| df17a410b0 | |||
| ea08cd429a | |||
| a0527ca81b | |||
| a5d5e7d940 | |||
| d5eae21a9c | |||
| 6b9f08a1fe | |||
| ce8917d3a0 | |||
| d05ae52575 | |||
| 72bcd36ef1 | |||
| 8b8dcfd968 | |||
| d0994583ce | |||
| 0047140dcc | |||
| 56b26f7120 | |||
| 5934095301 | |||
| 86b6c8ce49 | |||
| c65c9e786f | |||
| 67bfde277a | |||
| 55ae435c89 | |||
| c8b4faf93a | |||
| d0dc9da015 | |||
| 405847cac6 | |||
| 7e03be6930 | |||
| 180e110f50 | |||
| fd3498a1f8 | |||
| fcab850687 | |||
| 4bb10f5b70 | |||
| 6c561a6875 | |||
| 3f645612e0 | |||
| 6fd7dcc3b5 | |||
| 3e7f521936 | |||
| 9173e046e5 | |||
| 517a3c4dfe | |||
| b5a5b0a996 | |||
| e6ae8f0920 | |||
| 6cd46eed6b | |||
| 00be5d7b4c | |||
| 0a72ce8c19 | |||
| c4f9b721e7 | |||
| b9d1fa38c9 | |||
| b00343d24d | |||
| b9b55142fc | |||
| aaca8eda3b | |||
| 8954e6ec7e | |||
| 7a6ab5fcf8 | |||
| c7d66927b2 | |||
| 32769998df | |||
| 613119e964 | |||
| 5de0eb4c80 | |||
| 43fb606b3c | |||
| 86ab8c62b1 | |||
| e6cab58414 | |||
| 2f06e28f23 | |||
| 9efb1665ad | |||
| 755fe60075 | |||
| 2e63945f60 | |||
| 241f223536 | |||
| 13775ba4b2 | |||
| 1dcab7a7e6 | |||
| c6031dc1dc | |||
| 4a0c591657 | |||
| c94d8fa93b | |||
| 14d06815b7 | |||
| 0d5d67b20e | |||
| 531ccfc0a0 | |||
| 64f32ef864 | |||
| 49ed5fcc42 | |||
| 4ecb13a3be | |||
| a7d4e0111d | |||
| a148f7b227 | |||
| ce57ec8a38 | |||
| da635a0ebe | |||
| 995917db93 | |||
| 0d71cac44a | |||
| 171a501cb5 | |||
| bb2c5a63d0 | |||
| fbc8e55d09 | |||
| 0a1cb87151 | |||
| b19d6137fb | |||
| 25e374848f | |||
| 97d9f5ce31 | |||
| 94f99a9ce2 | |||
| 28d00949f4 | |||
| 1c33d93a18 | |||
| e78648b8c7 | |||
| 3b6d12ce2d | |||
| 1b1a130e38 | |||
| eaee2d1f3a | |||
| 1e6fda11e7 | |||
| f38d72dec5 | |||
| 206dc56cab | |||
| 0125f1539e | |||
| 5056cd6409 | |||
| 780b7166b8 | |||
| 9715fe4b94 | |||
| 194e08b669 | |||
| ca30b24f75 | |||
| e4eb9a0d1f | |||
| ffa6493677 | |||
| a1854d4567 | |||
| e5f1364bda | |||
| 1712d9bb5b | |||
| 90a4b95b61 | |||
| 6fdde3a251 | |||
| 2616671c6e | |||
| 8112c39485 | |||
| c786d457a7 | |||
| 590d2d88ae | |||
| 980c304629 | |||
| 63786a41c2 | |||
| 70c4ce8e40 | |||
| b55d8a26f2 | |||
| b73eb367f2 | |||
| 9032f24f4b | |||
| 5985577fbe | |||
| e7d822be11 | |||
| 5f14b67e66 | |||
| 222cfe5c16 | |||
| 93e781048c | |||
| 8b863d5370 | |||
| 2970ac60a6 | |||
| 0fd299adf2 | |||
| 5398e2f72a | |||
| 6175559fda | |||
| d41d949642 | |||
| 0cce92d4d7 | |||
| 9278c9e40c | |||
| 98cd0e0541 | |||
| 5f59a811e8 | |||
| 104122925b | |||
| 31e58ff044 | |||
| 6b81f519e7 | |||
| 72f316712b | |||
| 872d978d63 | |||
| 863db549f7 | |||
| c249403c16 | |||
| 325ea6de7b | |||
| 2947081b41 | |||
| c705dddf8d | |||
| ffe581225c | |||
| 27cf643135 | |||
| 73dc7a9225 | |||
| 9ad1dd9312 | |||
| 88a4776891 | |||
| 8f88998c90 | |||
| 7c7dc58665 | |||
| 1062145b49 | |||
| 0eab8c6efa | |||
| 820ccc4709 | |||
| 7c51555438 | |||
| cabad4a933 | |||
| f800305abe | |||
| 94eb2b32de | |||
| 18bdf03623 | |||
| a2c77619dc | |||
| f5669177de | |||
| b76e117366 | |||
| bdd6c4fb17 | |||
| d84cd93c57 | |||
| 5ee05f1143 | |||
| 75397c7d47 | |||
| 811af79b16 | |||
| 12ddca1070 | |||
| 6954db1843 | |||
| e31078615b | |||
| ac7c8c0716 | |||
| b5b28450f3 | |||
| 18f75f5e7c | |||
| e932ad78b0 | |||
| e7502ef9bc | |||
| 7740886ff9 | |||
| a7c2d5b868 | |||
| ddac2c8048 | |||
| ef068314cb | |||
| 0e66dbd79a | |||
| c079c2e8b7 | |||
| 0f175d9478 | |||
| 9290ee29da | |||
| 3605937049 | |||
| 8323d9272d | |||
| e2ab5e9858 | |||
| b5af1289f2 | |||
| 79e4527163 | |||
| 430d364a88 | |||
| e5b7ef40d1 | |||
| d6ad3ad3c4 | |||
| b62516fcce | |||
| 6249a6af5e | |||
| 6f6410adb4 | |||
| 441bb6d56f | |||
| 0670bb86c1 | |||
| 1a15391b9a | |||
| d0a25a8f77 | |||
| eeb25b2b66 | |||
| a1e0f7c8e9 | |||
| d584a7febb | |||
| b204d8b179 | |||
| 3077b4747d | |||
| a576ee8ec9 | |||
| 8788403baa | |||
| 12eb66a669 | |||
| 4d0daa24d0 | |||
| 4665bb6598 | |||
| 02cf5a3f29 | |||
| a3a0ff7980 | |||
| 4030c2ffb0 | |||
| 3873d80ea8 | |||
| 3b36be9beb | |||
| 044f1f7dd5 | |||
| fa95f33fb1 | |||
| 22d3d1cf4b | |||
| 44a8d8d84d | |||
| 37fecb5ebe | |||
| 8795b06c73 | |||
| 17e13b609b | |||
| 67864f195f | |||
| 71aff1c671 | |||
| 02e0fa7b8e | |||
| e542dcb38a | |||
| f7c0fa23bc | |||
| 80b07eb2a2 | |||
| e11b27a2a1 | |||
| 0302f7d034 | |||
| 147a9ab43e | |||
| 11bbf39cc6 | |||
| 006bb855f4 | |||
| 9be0364003 | |||
| 71e41b3a5a | |||
| 5f7f2e5ce0 | |||
| 100c344a14 | |||
| df20e85811 | |||
| c3d6d57db3 | |||
| a99156a21d | |||
| 859e66d8af | |||
| 253428dd93 | |||
| a96ff42d61 | |||
| ca6ac5eef9 | |||
| a58cdb2902 | |||
| 797c56e015 | |||
| 463733b30b | |||
| b0a7d0a0d2 | |||
| ff5d1a3d5b | |||
| aa9f280240 | |||
| f223db6c59 | |||
| 9117b48176 | |||
| b63c4e1466 | |||
| be9d45eb73 | |||
| 8f857aaf04 | |||
| b92c805bc5 | |||
| 0530e3f789 | |||
| 265b3a6a08 | |||
| f1d7052770 | |||
| d6385b7754 | |||
| bb986c0546 | |||
| e483598fb3 | |||
| 3e7e6a03ed | |||
| ef90f8e157 | |||
| f2e7f6b2a0 | |||
| 4c29d1f236 | |||
| 9ed46b892f | |||
| e80daa7670 | |||
| a5d7dbc081 | |||
| 2c7a00aaad | |||
| dad7daf429 | |||
| ed880162cb | |||
| 24bdb147e0 | |||
| d375a00046 | |||
| 3d2b77e1b5 | |||
| 5b640b575c | |||
| 62d8cce314 | |||
| 1a0e039f6f | |||
| 2fbf1e32ff | |||
| 5c5eb9101d | |||
| 4b83f8dcce | |||
| dcb044fb28 | |||
| 4e8a896f84 | |||
| 8a464c060f | |||
| 1025ec5748 | |||
| 254ecb4c6a | |||
| 3902c88916 | |||
| f6438592c4 | |||
| 7fe1264f00 | |||
| 1448313fb8 | |||
| 1480e0a88b | |||
| 4ecc125adb | |||
| 709253498a | |||
| 0dc96ec9b8 | |||
| ee50524242 | |||
| 47afba18cb | |||
| 7c4f1f1052 | |||
| 148c67bf9b | |||
| d80deeb364 | |||
| ba8eb7eea8 | |||
| 6287ce8f7e | |||
| d626281228 | |||
| b295e617df | |||
| 4c97a041cc | |||
| 6dac0b5798 | |||
| a87c0fa755 | |||
| 0f2f437c8c | |||
| bdea7336ee | |||
| 5fdb253448 | |||
| 0eaf9db416 | |||
| 78d7c4984c | |||
| 4858687501 | |||
| a8e61fe115 | |||
| 1b9e5de787 | |||
| 9ab0e57389 | |||
| b07a835629 | |||
| 8b51c37b98 | |||
| 4a730bfcf0 | |||
| 43676a0918 | |||
| efed228527 | |||
| 0cce75c47c | |||
| d6ac2aacf0 | |||
| 05f14a9f5a | |||
| 4433f91e69 | |||
| 57304aa628 | |||
| 1eff19d1b0 | |||
| 12325943a1 | |||
| d758e6b591 | |||
| 9fbb248531 | |||
| 6ce61621a4 | |||
| a2130e3d89 | |||
| d49bc18718 | |||
| e29009d1ba | |||
| 7f6194e195 | |||
| adfb237b4a | |||
| afa74da11c | |||
| e571ca1def | |||
| e3867132ea | |||
| c348799a44 | |||
| 2944725b69 | |||
| d0affbb4e4 | |||
| 2a05ef7969 | |||
| bf7480863b | |||
| 2677f67a43 | |||
| 3df6aff87a | |||
| 79a972e92f | |||
| 0e56ffeba0 | |||
| d0af671d2f | |||
| ff3cd29f2a | |||
| 6646955b09 | |||
| d91aceb41e | |||
| 8cb627cb31 | |||
| b141f4a410 | |||
| 1ac7f7141c | |||
| c9ff0a414e | |||
| 4b13006687 | |||
| aa0b68d8c5 | |||
| 5723673ab3 | |||
| 1bf4137aba | |||
| d35b4d127d | |||
| 36cde3030a | |||
| 91412bf73b | |||
| 0dc26512a3 | |||
| f0ade5eda0 | |||
| 2f631807fe | |||
| c8e147874b | |||
| dc6d32bf68 | |||
| c3d060c973 | |||
| b3bb1f38fc | |||
| 24bb0112d9 | |||
| 3010116e97 | |||
| 48c9089f77 | |||
| aca77bd482 | |||
| ffe93c92fc | |||
| 698c6ce698 | |||
| 8b233d562e | |||
| 67a82a7e1d | |||
| 4466096c18 | |||
| 7e46e92e1b | |||
| d91b86486b | |||
| 0204a597c7 | |||
| 0ffd02cf1c | |||
| c004d90a6c | |||
| e64793a809 | |||
| 03cc73d77e | |||
| b835364dfd | |||
| 2f3170ef18 | |||
| abba5bdb15 | |||
| a319d59eed | |||
| a3cd4d555a | |||
| 21b277bd1c | |||
| cc6e5ec94d | |||
| ecd211479f | |||
| 1fb5bcf38e | |||
| b51b3dfb59 | |||
| 77033efcf4 | |||
| 94f161359e | |||
| 8eaffe46fe | |||
| fb9414b9ae | |||
| 85ef7dafc4 | |||
| cb00982db9 | |||
| 92e56848cf | |||
| efe2303b23 | |||
| 8da4c647a8 | |||
| 6d7e2f44a3 | |||
| 325de34183 | |||
| affa3a3638 | |||
| 4d17c0ae02 | |||
| 9545fcbbc9 | |||
| 2e1240ba22 | |||
| 73f417fe39 | |||
| eab43b12f5 | |||
| 26535ec09c | |||
| 92afc37753 | |||
| 6c26d1b3f6 | |||
| 8f894f50f1 | |||
| 35698284d6 | |||
| dc8fba51cc | |||
| d5f24aef12 | |||
| b41bda08bd | |||
| 313a843836 | |||
| 29fada318b | |||
| 4bac189d6d | |||
| d15c4c81b8 | |||
| cf500aba28 | |||
| 629eb18529 | |||
| 59cd4916ee | |||
| 673fa12d4a | |||
| 9b329c6c92 | |||
| 86318adc5c | |||
| 44f5cc8467 | |||
| 552d07af03 | |||
| 74a3d1f4ae | |||
| a9586eba1d | |||
| 33dafbd085 | |||
| c0daacc6dc | |||
| 7423eb63f1 | |||
| 1459a3aa53 | |||
| ec09fa2607 | |||
| a24940a095 | |||
| e08c279a50 | |||
| be1e9f6b2c | |||
| 822cdb4f85 | |||
| c7a4cb28d5 | |||
| 5e03dfb398 | |||
| aa9f0dc1d9 | |||
| 154cbab69a | |||
| 14c5a5b9df | |||
| 530dff515b | |||
| 057c6c20e8 | |||
| 5f2f390cb9 | |||
| bf91c8e9a2 | |||
| 72a62b4772 | |||
| 885f064b61 | |||
| 50c42997cf | |||
| f3b2e9fe69 | |||
| 5f7fa8ee2a | |||
| c957ccca57 | |||
| d2ed47410d | |||
| 06237977a1 | |||
| 55459bc112 | |||
| bf3fc9ff78 | |||
| cb73854822 | |||
| b5e976adcf | |||
| 1c025c15da | |||
| 86af52a1be | |||
| 31543ef39a | |||
| aa8832d1b6 | |||
| 08a9ffcd90 | |||
| 912547bc26 | |||
| 892b82104a | |||
| d414125098 | |||
| fb3fb774fa | |||
| 2c3804d321 | |||
| 1965691612 | |||
| 2e2de24368 | |||
| d4544bec17 | |||
| 35628a3e2c | |||
| 9944cbb0a7 | |||
| 6631c516f8 | |||
| a22f0ec65e | |||
| dee5033c0a | |||
| e11cbbc88f | |||
| 0ce1d8991d | |||
| 1c49f0319e | |||
| 55c321b678 | |||
| dcae514215 | |||
| 563e5a704c | |||
| 7e0eadb254 | |||
| 93667e2f46 | |||
| 27c5b2d589 | |||
| 148e1449d1 | |||
| 3cf539d90e | |||
| 9cbb2b0166 | |||
| ddd3b91d28 | |||
| fbf821c714 | |||
| 6313f50433 | |||
| ed897f0615 | |||
| 91e8f3c571 | |||
| b8503f190e | |||
| 3d569bf02e | |||
| 37b55759f2 | |||
| f7da64165d | |||
| 9b63c41c2a | |||
| 5ee2f4b732 | |||
| b9feb9602c | |||
| feb1a8325d | |||
| dc53c4f0dc | |||
| 298152a899 | |||
| f26c3a2349 | |||
| 2c87f68022 | |||
| 971b993a52 | |||
| 5c12922510 | |||
| da82fd3a16 | |||
| b606b91272 | |||
| 2624bcadec | |||
| 13a9b69d6d | |||
| 7a56b89beb | |||
| bc6561eeb5 | |||
| 959022fa07 | |||
| 8002559603 | |||
| f545369922 | |||
| 3600354ab7 | |||
| 86cbd17b42 | |||
| 5e6b864fdf | |||
| 9b89c3d815 | |||
| f9bddffc3e | |||
| e4a44c3663 | |||
| e7ff92136a | |||
| eb5ac2dac1 | |||
| 9ab56b1606 | |||
| 5fdff4c671 | |||
| 43ceac124a | |||
| 08b86b102b | |||
| b85e007b85 | |||
| 938d7144c5 | |||
| 2217826e56 | |||
| c920aff4c7 | |||
| da1bf30532 | |||
| 626d984054 | |||
| 9459c393df | |||
| 41388a4a7e | |||
| 8894f82477 | |||
| 560b5d8165 | |||
| 83d19d183d | |||
| e823d1d3ca | |||
| 5ea97d22a7 | |||
| 890387e6f4 | |||
| da0f824da9 | |||
| dad36dff47 | |||
| 3f885e7040 | |||
| f2cad36147 | |||
| ac24978984 | |||
| 2439399c08 | |||
| 19bdfec0b9 | |||
| ca8b96df32 | |||
| ab27481094 | |||
| c0c6e8aebc | |||
| cb220b6c94 | |||
| f802658d10 | |||
| 39b29ad284 | |||
| 3e0bbaa2f0 | |||
| 9f6e029e59 | |||
| 519e7221da | |||
| bda8f3910b | |||
| 88028d1da2 | |||
| 3d5354dd79 | |||
| 71d711902f | |||
| c6c66bb44a | |||
| 560e19e880 | |||
| 719ed77457 | |||
| 150f3e1e64 | |||
| 639e36f0eb | |||
| 1c343badcd | |||
| a87944ef44 | |||
| 12e9171e7d | |||
| 63f7510ebd | |||
| 93790772ae | |||
| 6b1b4f2448 | |||
| ba56d99e8b | |||
| c2e3b5a038 | |||
| 9808c57f1e | |||
| 33193806ed | |||
| 7d127738ca | |||
| 8386c25037 | |||
| e02718bc76 | |||
| f356c7d287 | |||
| 36987228f9 | |||
| 32b7bb9679 | |||
| b50559accd | |||
| 0f9c9b946f | |||
| 5f7468958f | |||
| 67213c247e | |||
| f79ae2f3ae | |||
| bb48a885d4 | |||
| 426e5d766b | |||
| 1c743429ae | |||
| ea3751aca8 | |||
| ead0f15e46 | |||
| 2d85ced5dd | |||
| 0ed6a0c8f3 | |||
| be46250dff | |||
| f60df79b15 | |||
| b5148f0fbd | |||
| d065179034 | |||
| 95e2cab689 | |||
| c0047ebf97 | |||
| 6fe42449dd | |||
| 6bd322e195 | |||
| f06da2f6ac | |||
| 632831a76e | |||
| f5693b0b86 | |||
| 3079caf246 | |||
| 9d4b7d27ed | |||
| 413ec650ed | |||
| 6f9484421e | |||
| a6661af96a | |||
| 60e15aaaac | |||
| f0a2781682 | |||
| d3235763dc | |||
| 41ff9b4579 | |||
| 99602c4add | |||
| faccabef47 | |||
| 344c588844 | |||
| 6886e38103 | |||
| cbcb4ef59a | |||
| 47b768b7d7 | |||
| 7f24732078 | |||
| 7b21150c10 | |||
| 48f820cc33 | |||
| faae572342 | |||
| 992dcbd0c9 | |||
| 3acdd9403c | |||
| 990aab5f5d | |||
| 50344b19c0 | |||
| d0d78f3450 | |||
| a25a662a02 | |||
| c38eb784aa | |||
| 7e15a61ed7 | |||
| becf99ad1f | |||
| b515c7f050 | |||
| 9fea866da9 | |||
| bbf1456fd8 | |||
| 20cf96e969 | |||
| a611ea24b5 | |||
| d633a62bdc | |||
| 4b3b005833 | |||
| 433da491d1 | |||
| 96174ea80e | |||
| 5aae04915c | |||
| a915981b6a | |||
| 35c3541d70 | |||
| 38f9eaf312 | |||
| 3f18352bdc | |||
| 2c57def881 | |||
| 2d50bdd375 | |||
| 91ffa16e17 | |||
| 6dd5b4aa6b | |||
| 1bce7ec7ec | |||
| 39d5ceaa03 | |||
| eef94a8048 | |||
| 5e5cc1e426 | |||
| 4471b1ac32 | |||
| 93d117b45d | |||
| 1b37e41e00 | |||
| 71e4a6c1a9 | |||
| d1881e474f | |||
| 0d43f5dea7 | |||
| ffb1a0769a | |||
| e7e8f19d02 | |||
| 3660a2f116 | |||
| aa10266c05 | |||
| bd100c1f4f | |||
| 1fcdf783e5 | |||
| 6d6570e92c | |||
| 917fb303f2 | |||
| 0e41248edd | |||
| 795575a074 | |||
| ecf7ad1ad2 | |||
| 66d0825a67 | |||
| dab92bdca6 | |||
| ca530221eb | |||
| 479efe7e7d | |||
| ad8606c782 | |||
| c291c5166d | |||
| a8b4f05de2 | |||
| 3c21bfb9f4 | |||
| 27265c533e | |||
| 0e431e2984 | |||
| 3b4410c9d9 | |||
| c46d07cde5 | |||
| 1375d12a08 | |||
| 26088f8ba5 | |||
| ab99abcbae | |||
| 4e4972d440 | |||
| 78b83266e3 | |||
| c6f4da1c04 | |||
| 62026e5ba3 | |||
| 4c965bd2d5 | |||
| 14ce11c778 | |||
| 13c9b4b74d | |||
| 4437e01af7 | |||
| 92641323db | |||
| 36a36c38cd | |||
| 0e008d0885 | |||
| e8bae220e6 | |||
| f96f0da3f8 | |||
| e6320100e8 | |||
| 8401827afb | |||
| ae6d69a173 | |||
| 391823d677 | |||
| 9388618ac5 | |||
| 2f1455d53b | |||
| ed6b4e4c6a | |||
| ac1d4a7076 | |||
| 99d354224e | |||
| 7474f785e5 | |||
| 4df73e1e61 | |||
| 69fc1a5b73 | |||
| 734217e0da | |||
| b4f015e4c0 | |||
| e8a2900beb | |||
| 922e77e4a6 | |||
| edb88c3f57 | |||
| 38204c4053 | |||
| b8e60cd7ef | |||
| 13d8f5fd7c | |||
| 6c06651759 | |||
| eb07593088 | |||
| b8faaba829 | |||
| 8726770c03 | |||
| 7d267fa13d | |||
| d1d95aa643 | |||
| 694b446e1a | |||
| 05817056e5 | |||
| dad4e4cfc9 | |||
| d85334ced7 | |||
| d0b65f2638 | |||
| 8753c9c931 | |||
| 77df5f6129 | |||
| 95a901d653 | |||
| f1595837df | |||
| 2c5c3eddbf | |||
| a7fdf52eaf | |||
| 1100364efd | |||
| d4fb7207aa | |||
| 6f0a9b7123 | |||
| dd83225447 | |||
| a6b20ad398 | |||
| 02d2fff162 | |||
| ac8407cd19 | |||
| f1348373cb | |||
| 1b80ba69a1 | |||
| 3b3018b173 | |||
| 09400814d2 | |||
| 3bde48937f | |||
| f4ec48675b | |||
| c61cf9d10a | |||
| 7d8a9de746 | |||
| a815b217b8 | |||
| 0413a838d3 | |||
| 542917efea | |||
| 08f9580b54 | |||
| 26673810ec | |||
| ccbfcf2e66 | |||
| c49324eeff | |||
| 7223456b53 | |||
| 9ce0033c88 | |||
| 4daffd0294 | |||
| 7cb385c35c | |||
| 52fd0d331b | |||
| 5f7602cd79 | |||
| 33ee2d7217 | |||
| bc792926ae | |||
| 34e4341ab0 | |||
| 744a0fc32a | |||
| 2307e892a9 | |||
| 38f01b02a6 | |||
| b9be5eae5e | |||
| 0ef5a689f9 | |||
| d99dc6846b | |||
| d13cb056f0 | |||
| 2475f952df | |||
| 055d6cdcd7 | |||
| a3cb5e253c | |||
| 7b5ef26e7e | |||
| 9c061a77ae | |||
| e4a0830ad1 | |||
| 06880647b7 | |||
| 918bd8f34e | |||
| 99c1f4c87c | |||
| 4efba7e295 | |||
| 744d93b938 | |||
| 17ebe08e52 | |||
| f7b57643ef | |||
| 9a4b87626a | |||
| cfaad3b04c | |||
| 1517302940 | |||
| 82d3165a19 | |||
| 03689cdd77 | |||
| d355f82de2 | |||
| ea5295cdb3 | |||
| dfd0261cda | |||
| c73f21ce0d | |||
| 5e0c4c074e | |||
| 919674e25a | |||
| 976c0018e9 | |||
| 10d26f6fbf | |||
| 631bc150ac | |||
| 2ae6bcc5dd | |||
| efbfb2b320 | |||
| f89b34f2b0 | |||
| 063b753892 | |||
| f704df9365 | |||
| a04a2de5c5 | |||
| 6b8f893299 | |||
| 49ce068117 | |||
| b6b6dfe01a | |||
| 9e7fbdf6bf | |||
| 041994aa58 | |||
| ed1fb3c8a3 | |||
| fa500b947c | |||
| 7c8ac6822e | |||
| 6489cf7bf8 | |||
| a17bc9bf9d | |||
| 5660f461e0 | |||
| 6b5017f016 | |||
| a42a7a8f00 | |||
| e34007c1b7 | |||
| 2fc551ac99 | |||
| 6a8f3a44c0 | |||
| 847ef6c6a6 | |||
| ce724611d5 | |||
| 178371eed6 | |||
| 3d92fb099f | |||
| 68be4a5f65 | |||
| 931a0f0b3b | |||
| fd113ae212 | |||
| 07ef076472 | |||
| a722390fbf | |||
| 6abc381aec | |||
| c69932eaae | |||
| d2e34d3bcf | |||
| 7bf373248b | |||
| 0d54063c5e | |||
| 31eba101f6 | |||
| 5ef157063c | |||
| 8ff7cdeddb | |||
| 58e59a9193 | |||
| 38c072c871 | |||
| c024b0fa97 | |||
| 1a72f3a8b8 | |||
| 76f87c5e08 | |||
| cb0ba6cf7e | |||
| 5fddf72bed | |||
| 795410a6c9 | |||
| 4f59ac109b | |||
| 408774cba3 | |||
| f509d042ab | |||
| 15977512dd | |||
| faae4b0533 | |||
| 8e26bd9711 | |||
| 4296b78333 | |||
| 44ea050a13 | |||
| 40609d803f | |||
| 1471ac699c | |||
| 9083aef7a0 | |||
| ab1230f5e1 | |||
| 0ec4723b46 | |||
| e7072aaf6e | |||
| 95cddcd6a2 | |||
| 6928a91060 | |||
| 9b3443dcd6 | |||
| 8c2ec8a565 | |||
| b3b76bfc35 | |||
| ee98b0c128 | |||
| 7f58cc1f5f | |||
| b1b9886f65 | |||
| 5bd45c66a0 | |||
| 470b1b376c | |||
| d29cbccf50 | |||
| f50a7de5a1 | |||
| b62a45397b | |||
| 67d75d9eba | |||
| 8ddf285340 | |||
| 544d0bf7b4 | |||
| 390ec689c2 | |||
| 78c7b11c36 | |||
| 5f8590054d | |||
| 29c8d09583 | |||
| cdacd7ca2e | |||
| 7bcc9e2e5a | |||
| a722036b8a | |||
| 1927da75c1 | |||
| cc60b9e32b | |||
| 79135a988d | |||
| 9ed9056ff1 | |||
| 52168ba071 | |||
| 6d5c24af2f | |||
| b02cb1a6bc | |||
| 98cc1649f1 | |||
| c81d957094 | |||
| bb83c2c7a1 | |||
| dc9c05ba8b | |||
| 3106a59fc4 | |||
| fcefdbece2 | |||
| 1ceae353bf | |||
| 64eeeaafc8 | |||
| 40b066a3b9 | |||
| af9cd2135d | |||
| 11c3758976 | |||
| 55f6786b2e | |||
| 50562d49a9 | |||
| 3ce74d7c57 | |||
| 750660c333 | |||
| 882589d5b0 | |||
| 93aed1b818 | |||
| d157084851 | |||
| 7e68fdd63e | |||
| ceed9b79b8 | |||
| 93d21a4c97 | |||
| 68b93fd1bc | |||
| e903534862 | |||
| 71af5ad8b1 | |||
| e3c027907f | |||
| 5d04730011 | |||
| f34134b215 | |||
| 4c00d5f5ae | |||
| cc0a590ec6 | |||
| 7497af7022 | |||
| 7f4dbb3e2e | |||
| 3ef2575788 | |||
| e01a754315 | |||
| ac7b024a38 | |||
| 413cb0a987 | |||
| 9b56a35f26 | |||
| 0a2e6964ca | |||
| 8a21ac8737 | |||
| a956c52e6b | |||
| 9248aae9a9 | |||
| dffe13e344 | |||
| a7d5d5a715 | |||
| 7e16db1b62 | |||
| b1fc0bf6bf | |||
| 013a50e87e | |||
| e41ef67f99 | |||
| 8b951cbc17 | |||
| 179f6a19d6 | |||
| 1e1305c24c | |||
| 8b08f066a5 | |||
| bf147efeec | |||
| b2f1b85900 | |||
| 6fbf05175e | |||
| f5bd331c3c | |||
| 7506932ff3 | |||
| 108d595edd | |||
| 5aa5b65662 | |||
| 3e281fe41a | |||
| 3d6b5b3a4a | |||
| fed19d9c02 | |||
| b70a4dd41c | |||
| ec3ebca433 | |||
| aa014cbe91 | |||
| 9c531401af | |||
| c1c71b3b64 | |||
| a5bd6563dd | |||
| a9505b4d2f | |||
| b3cfdb7126 | |||
| 57cf532863 | |||
| 1d32fe52f5 | |||
| caeec11624 | |||
| 1ca8c8fdf5 | |||
| c3b4fe53e9 | |||
| 627e400a02 | |||
| 38c19fc150 | |||
| 8d0b1b79be | |||
| d208452096 | |||
| 0c787fcbfe | |||
| 9bf64cccda | |||
| 79a565f4d9 | |||
| 94c3a75a96 | |||
| 7028149361 | |||
| 9fecaf1372 | |||
| 703d9f2ce0 | |||
| 70aea65078 | |||
| 35e0b73ada | |||
| 023e479beb | |||
| 0a471f2e56 | |||
| 6ec571a1b9 | |||
| 375653fc30 | |||
| 43855925da | |||
| b105285d88 | |||
| a3b877231f | |||
| a8a1880f0f | |||
| 0c40e05195 | |||
| 601b26ebfb | |||
| 39a3da9e8f | |||
| 718c4055a7 | |||
| 4f95851a4e | |||
| 1d76446890 | |||
| cfc893cd56 | |||
| bc43f5ecc5 | |||
| 230a4349d8 | |||
| 153b5b71ba | |||
| e6456b022f | |||
| 03e6e332c2 | |||
| 65814d625c | |||
| a85e25da74 | |||
| d79d7255aa | |||
| b169972f72 | |||
| 91621b5393 | |||
| 6e6a5fc4e4 | |||
| a9b8c9dd02 | |||
| 49319139e0 | |||
| 3b547687f9 | |||
| 77b10f6c27 | |||
| 8ee296529a | |||
| dd013f3a70 | |||
| b48f49c444 | |||
| aa171353df | |||
| 98c7c0f215 | |||
| 855c13cb57 | |||
| fd8f4d5a16 | |||
| 585efd1eb2 | |||
| 6b25fb0482 | |||
| 5c961dd25e | |||
| 4e1a285119 | |||
| bbb9a86275 | |||
| 78b83125f4 | |||
| 6c038db4bb | |||
| f2deb4428c | |||
| 2bc390d9e3 | |||
| ab547d8cca | |||
| 1202d6899a | |||
| 74a8cb927a | |||
| 5abd33d9dc | |||
| 821809c994 | |||
| 1d6466249f | |||
| ce56d05d5d | |||
| ac22fec171 | |||
| 8c6b27aedb | |||
| e5b112504a | |||
| bbd419d69c | |||
| 8628ea8030 | |||
| fcfec701d0 | |||
| 04bc1cd02f | |||
| a01c031331 | |||
| feb671ca7c | |||
| 0a9c821500 | |||
| 66f71b4bbb | |||
| d7061e154a | |||
| 9af2e54f6f | |||
| 00fa8ca383 | |||
| 493cb0a56c | |||
| 09bde1a85b | |||
| 30b75f16b4 | |||
| df92e08671 | |||
| b3eb11b9f0 | |||
| e64abba601 | |||
| 2392b99817 | |||
| f37e0db153 | |||
| 4f164cdb55 | |||
| 1f63b68908 | |||
| 283c9b5922 | |||
| 35b4a9f498 | |||
| d36fca5a1e | |||
| 3d7765f066 | |||
| 7fe805cd48 | |||
| 6735dc79fb | |||
| ccd0150df3 | |||
| 0289fea89a | |||
| 3b23f6b13d | |||
| 03a25aab88 | |||
| 756c47980d | |||
| 4e923e1aeb | |||
| 775aac53b5 | |||
| f932be684f | |||
| fa5af4a1ec | |||
| a6f0e97ed3 | |||
| 3873826036 | |||
| 580de6574e | |||
| 7af68d6d9f | |||
| 0986ba8497 | |||
| c8eca17adc | |||
| b55689ebf4 | |||
| c731c371d3 | |||
| 98e2d2fd7c | |||
| b6fe9892c7 | |||
| 0f36373920 | |||
| 428ef88fce | |||
| 62ba209e52 | |||
| 36025ee6ba | |||
| 75a95382a4 | |||
| 82a0d1f4bb | |||
| 8723224548 | |||
| 3135239602 | |||
| 06019c095b | |||
| 3a2f3045e5 | |||
| 82f7bb99f8 | |||
| ee3ea72208 | |||
| 7b5c123071 | |||
| 731443616f | |||
| 94f1198fe3 | |||
| 7a9d867fd1 | |||
| 21107efaf5 | |||
| 53d967abce | |||
| b41b71169f | |||
| 2d2d3822d7 | |||
| 2dcee8eae1 | |||
| 1109ff8160 | |||
| aaa4094cdd | |||
| 209f3ec710 | |||
| 22ba423e36 | |||
| ba1c0e4a7b | |||
| 0864958ac8 | |||
| 5389fcb030 | |||
| 9011d62bf4 | |||
| f20ef8cc67 | |||
| 9aaec5e69c | |||
| da11f3829a | |||
| 0fc19d9959 | |||
| ab2d01ad0c | |||
| 0ef32f9df4 | |||
| 082fe28cc8 | |||
| 31e3099c7c | |||
| 29649a7d79 | |||
| e81f3e5959 | |||
| 6eea1e55da | |||
| b512c16c7d | |||
| c31bd24494 | |||
| d1f3612825 | |||
| 4440a2d44a | |||
| 60556207bf | |||
| 28885e75a1 | |||
| 9dd5b9762b | |||
| 149e6aa9a7 | |||
| c7df199a2f | |||
| 8151645882 | |||
| daa3afe812 | |||
| ec864e6b71 | |||
| d858fc8eb3 | |||
| 0f1e93ab7d | |||
| 80cfa7e736 | |||
| 0c80e7afaf | |||
| 82b2f2f8fe | |||
| 205bc5f65c | |||
| d82ed41f65 | |||
| 36b99d5651 | |||
| 867b92a6ea | |||
| f88617ab05 | |||
| b936b00df7 | |||
| 31925a9c85 | |||
| 1b7332dea4 | |||
| 78f0196571 | |||
| c425f20994 | |||
| bd6fd1d103 | |||
| 3ebc962a71 | |||
| af21acc641 | |||
| 4ffa307bc5 | |||
| d1d26af5ee | |||
| 5ddfdf7dc3 | |||
| db8a289ff8 | |||
| d0de74737e | |||
| 5f2c8eb9dd | |||
| 9e14904eb2 | |||
| c4ba5f8da8 | |||
| 67eca005d9 | |||
| 105f96a4d7 | |||
| 5fa25b65f4 | |||
| 1b11b31a18 | |||
| 3146238b35 | |||
| 915c5f6531 | |||
| 0b1aeddc31 | |||
| 609515a4d8 | |||
| dc98c93c02 | |||
| ebb1fb41d4 | |||
| f7520a9195 | |||
| 5257b95dbd | |||
| 54f926a946 | |||
| 5894ac7f4f | |||
| 419310c4f7 | |||
| eadc5bc027 | |||
| 1e8d3a58e4 | |||
| 42ca45db68 | |||
| 252970c2e5 | |||
| 87459991a9 | |||
| ca84b8b85d | |||
| 1fb8c54efb | |||
| 474953daa5 | |||
| e303d7433d | |||
| 1c7262b1d8 | |||
| 76c554227c | |||
| 4b41477379 | |||
| 243321d442 | |||
| 28d75a78e5 | |||
| 081fff5e0a | |||
| 5a00738390 | |||
| 11a5c60ecf | |||
| 7c138b2f77 | |||
| e056d9b1a7 | |||
| 3d53184985 | |||
| 1e9319b239 | |||
| 8a4fbce55b | |||
| 14e6ae0cdf | |||
| e2102f6e1e | |||
| ca208da2fb | |||
| de99ef67e6 | |||
| d62498a099 | |||
| 4b17cf9b6f | |||
| 1dd627c9c3 | |||
| 5267970499 | |||
| bb7ca06680 | |||
| 157c498e79 | |||
| 3e79c6d06b | |||
| 74e699e560 | |||
| 1f8dc86e76 | |||
| df906a343f | |||
| 82aa3db9ff | |||
| 19b8cd81eb | |||
| 2489a45e18 | |||
| 0ac1a2f9ce | |||
| 294dc041c6 | |||
| f811b3f6bb | |||
| f8407848c1 | |||
| 2384f56ec0 | |||
| d0e74392fe | |||
| e51dae3b9f | |||
| 38e95423b8 | |||
| ae00227275 | |||
| b0c407d4c3 | |||
| e26e98dbba | |||
| 6772775696 | |||
| 168cb146ea | |||
| f1343f95f1 | |||
| a5ca5718b4 | |||
| 83ddeca71a | |||
| 5b2f73f74b | |||
| e63be19fe5 | |||
| d9211d2c40 | |||
| c57a1b4da3 | |||
| edfe606cc3 | |||
| 1afd639b6a | |||
| e1126e464e | |||
| 02d8ddfe42 | |||
| 279126262b | |||
| bb0f599a2f | |||
| 14faae9c6d | |||
| 51fc20c96f | |||
| 526e1d2869 | |||
| 17aae92f7f | |||
| 1b06ae8c30 | |||
| 2b71d7f814 | |||
| 532f5c9c37 | |||
| 398fefa919 | |||
| 7bdb4d7c6c | |||
| 266f8dd3a8 | |||
| 19388f063c | |||
| bfc333624d | |||
| c9e9d93f92 | |||
| 55f10e2a09 | |||
| bbf358f161 | |||
| 068767c80d | |||
| 827248cc74 | |||
| d9835634b8 | |||
| 8a4467a33c | |||
| c5708f746c | |||
| e72aa19280 | |||
| 731b044d50 | |||
| f744ef7464 | |||
| 21dee86554 | |||
| ffb7d19497 | |||
| 8994711cd4 | |||
| 8e1081e8b6 | |||
| eeba0187bc | |||
| 64f64bd139 | |||
| 1b98d3c25c | |||
| b2bcd08c99 | |||
| fac1558de3 | |||
| b5fafaada2 | |||
| d1bf5f628b | |||
| a6993eae9e | |||
| 379b9255b2 | |||
| e8867012cd | |||
| 0a275a74de | |||
| 2e060c3e5f | |||
| 14c519fa1c | |||
| a4ed49d510 | |||
| 5149eaab2a | |||
| 210e694e6c | |||
| 9aef3bc41a | |||
| 5fed774201 | |||
| 9a00e7cba9 | |||
| 3f63746052 | |||
| 1f17c35656 | |||
| 62a32c08be | |||
| 8f42e2346c | |||
| 94881ba4c0 | |||
| ebe9695cc6 | |||
| 95dffd86e7 | |||
| a8e372ebef | |||
| 60136d89b4 | |||
| 952a842509 | |||
| bf3628f33a | |||
| fde5cbc313 | |||
| d767fe7f12 | |||
| 7f622c7401 | |||
| 8bb91a070e | |||
| d277684331 | |||
| d7a63f2277 | |||
| 3dd430026b | |||
| efcb30ed69 | |||
| 96b68f0dba | |||
| fcee7086eb | |||
| 13253957ec | |||
| bc17eec490 | |||
| 625458ecda | |||
| 1a829d5273 | |||
| 2a3d80ac18 | |||
| 71c986ed29 | |||
| 5d99bd934e | |||
| fb100aaa79 | |||
| a4ec72dbd4 | |||
| 8f3b3fabaa | |||
| 4f719c7c7e | |||
| 02a07a59d9 | |||
| 078bf9a18a | |||
| cf284194f2 | |||
| cba3d9acdb | |||
| 7cfac8b59c | |||
| 65df50346a | |||
| b92cf09eb2 | |||
| 175e73202a | |||
| 43a2225778 | |||
| 7811150fe5 | |||
| 7a94df491a | |||
| f6ba7f0e0e | |||
| b4347bd901 | |||
| 697aef6be6 | |||
| 58e8752e45 | |||
| 096e4e917b | |||
| aa08d8c7ae | |||
| d80a8334c8 | |||
| 0614fcdf51 | |||
| ce2a679a3c | |||
| 0765354589 | |||
| 9d3d04a00c | |||
| 2ab6c09339 | |||
| 532a126289 | |||
| be5c39e50a | |||
| b2b11a6ffd | |||
| b66618093a | |||
| 3d5059e882 | |||
| 145ced3ea9 | |||
| ce83b03fc7 | |||
| 26d4b32987 | |||
| eaa8a29d2d | |||
| 67de70303e | |||
| 8bc65c5320 | |||
| 2f079c3ca4 | |||
| 2f566a3c25 | |||
| 41c4c7ec37 | |||
| 32f77551ae | |||
| c261027930 | |||
| f87121f42d | |||
| 070fdb7275 | |||
| cecf41cb20 | |||
| 8091a4fc34 | |||
| 47ca296b66 | |||
| a245a28c4b | |||
| f7a7dc61d3 | |||
| 2f5daac8b2 | |||
| 67c3f8fcc4 | |||
| 1fdec50702 | |||
| 0d23cb0d30 | |||
| 7c3e390c04 | |||
| 36aee4324c | |||
| 1385341bc8 | |||
| 8a188747ae | |||
| adcb2f3e87 | |||
| 5e40d76375 | |||
| d8425e7bd9 | |||
| e3c113f11d | |||
| fda91f045d | |||
| 99eb79957e | |||
| a683f775ce | |||
| 399261b643 | |||
| ce79ed9657 | |||
| f2cf17804b | |||
| 4c95630c4c | |||
| ce9ac484d9 | |||
| edaf7e9d6f | |||
| 49181fb06d | |||
| 3c3369f64b | |||
| 765e232693 | |||
| 35b40c4434 | |||
| 17e0f159b0 | |||
| 1d95cf19f0 | |||
| c3f21c4a95 | |||
| a7ad3dd8e8 | |||
| ea317649ac | |||
| c2f788c69b | |||
| 6d3404c763 | |||
| 52a24d511e | |||
| 9ef4523f47 | |||
| 37dfa061c4 | |||
| 9a989dddb3 | |||
| ae2ff8a3b2 | |||
| 80a34b036d | |||
| f2e39bf9be | |||
| 5f2339d105 | |||
| f5b4355a9a | |||
| 0bc97cbc88 | |||
| 3bd03b0129 | |||
| 67a0b93456 | |||
| 1d66235e57 | |||
| d653ccd38b | |||
| d30b62ad0a | |||
| b7b3415e9a | |||
| 22cc0ce643 | |||
| 5bec2323ac | |||
| 95b5764edf | |||
| 08fe4a0c96 | |||
| 06f6a164f1 | |||
| a654b13a9a | |||
| f0b7d6631b | |||
| 01b390fcb7 | |||
| 727a49fb46 | |||
| e9f55cc418 | |||
| dc87322f43 | |||
| 6560136ec4 | |||
| 6a70625563 | |||
| fca08c03bf | |||
| f572ff84ea | |||
| cbe07715fd | |||
| 01a93d5488 | |||
| fd2f4ea5bf | |||
| f7dd8ba630 | |||
| 748cf0b8b1 | |||
| 64a9f4fef7 | |||
| 265608196d | |||
| b4b6f98d1f | |||
| da64502850 | |||
| 93158337c1 | |||
| f1a6e22cb6 | |||
| 342d8676bf | |||
| 6aa0f69ce0 | |||
| 318bd7a92d | |||
| d62bb7a516 | |||
| f44424a75a | |||
| c2a2058fcf | |||
| 02a6a45796 | |||
| 5798ca100f | |||
| 487f71bd0b | |||
| 99caf8d74e | |||
| b79cf1b9b4 | |||
| 8a58c5eb1a | |||
| e1aac9cc13 | |||
| 0dd6014135 | |||
| dbaf23ed69 | |||
| 45986fb2da | |||
| 637a75f0fc | |||
| a52e05598b | |||
| f32de44b19 | |||
| 04372a3738 | |||
| 6906e2cac4 | |||
| 7818fb1c96 | |||
| 96e7ad74c9 | |||
| 664ed5c7aa | |||
| d139cc3fb1 | |||
| 8ce7457f3f | |||
| 0a9b5f4f0a | |||
| 850652f527 | |||
| 6bba09cbf2 | |||
| 891792b987 | |||
| c8ccc5c9bd | |||
| a57a39082b | |||
| 8da2368e26 | |||
| 6987468364 | |||
| 566d8606d0 | |||
| 02d4df2a02 | |||
| 143cb1de21 | |||
| 06f65b44b3 | |||
| 325d3be574 | |||
| c7162adf31 | |||
| 2af76d2e69 | |||
| 7a8b5e755f | |||
| 0dfdb3af4e | |||
| be3d4d1d74 | |||
| 33ff9c1f7c | |||
| 347311e78d | |||
| 0044e210ae | |||
| 606764fc9e | |||
| b2fa981e36 | |||
| e62eb56f4a | |||
| 43a8bb9a39 | |||
| d6857176d8 | |||
| 574ab0a834 | |||
| 8e5ec60e2d | |||
| 4de8ff7269 | |||
| faa0781c8b | |||
| 38f71856a2 | |||
| 91ff747733 | |||
| 41734c682e | |||
| d7144c0a24 | |||
| 2b2ed7551d | |||
| a6470864fb | |||
| a2021c2704 | |||
| 1331f5b634 | |||
| a7c7d1426e | |||
| bc0549397a | |||
| 5894a82ced | |||
| 11853c6f5b | |||
| cdeb113846 | |||
| 97b847314b | |||
| 6cb397247f | |||
| a658e20b27 | |||
| f5837b5245 | |||
| 45ad808d0d | |||
| d847b85c7a | |||
| 4927f38429 | |||
| 294fef724b | |||
| 6413493e9d | |||
| 393bbd547c | |||
| 60657014ea | |||
| daf199c520 | |||
| 451601348a | |||
| e8447d24ac | |||
| 2a8225ddeb | |||
| b0cbdd8ba7 | |||
| e1789dcc81 | |||
| c47bd93bb2 | |||
| 886a027c6b | |||
| a9774d3920 | |||
| 391882fbf6 | |||
| bb33238efc | |||
| 2113c1308c | |||
| dc6a5fce29 | |||
| ad98a01899 | |||
| 0fa8720145 | |||
| 0feb4c18c2 | |||
| 3472e11ef8 | |||
| 1b4c33da51 | |||
| 331f2c441a | |||
| 0933bf3682 | |||
| d882a94368 | |||
| a96a8184a2 | |||
| a3c03d139a | |||
| 9ad88fece8 | |||
| 44a9f8491d | |||
| b528c2e57c | |||
| 37e40e4a0d | |||
| 0861cbbd80 | |||
| 43b46ceccb | |||
| 1f3a6348b0 | |||
| 0b4379b06d | |||
| a7e100888b | |||
| 357285a579 | |||
| 6447659882 | |||
| 3df663e0fe | |||
| 35625c3f81 | |||
| 97dc035bcc | |||
| 2d51cdae66 | |||
| f166322976 | |||
| e5addc8965 | |||
| 8267989279 | |||
| a8d7c8a9c4 | |||
| d4d3515c8a | |||
| f40546b1f5 | |||
| a41b66ae8f | |||
| 4d8eab61cb | |||
| 76c49a67dd | |||
| af0115d4f5 | |||
| cb09463326 | |||
| 26df96b886 | |||
| 4e9c666886 | |||
| 8bcfa19259 | |||
| 9944effb93 | |||
| 8d72e632cc | |||
| 566359a20f | |||
| e3a126af54 | |||
| bc6f48e1b6 | |||
| 885150daac | |||
| e404792c29 | |||
| 3d38d0be9f | |||
| 43146eac1f | |||
| 3997e7fa65 | |||
| 5a77d39355 | |||
| d348235050 | |||
| 4617ed15a9 | |||
| e7d3488ea6 | |||
| 23d1a51134 | |||
| cb5c5fc67c | |||
| 6fdef21374 | |||
| 32be9063b8 | |||
| 8b3c8024a7 | |||
| e4a8a2662b | |||
| 14aad65c0c | |||
| 0e07a54085 | |||
| 60797bddca | |||
| ca4a0c37e8 | |||
| d02fea28ea | |||
| d1e79a7d7a | |||
| 19bebc50de | |||
| 78ee899da0 | |||
| df283db810 | |||
| dcc02f75c3 | |||
| 328a77bd03 | |||
| 0c7bf67e99 | |||
| f79a258c80 | |||
| 4dc037bac8 | |||
| e1d403057b | |||
| 2e886e9405 | |||
| cff869e33c | |||
| 9943db95a3 | |||
| d4e47e9dd6 | |||
| da69d6cd2e | |||
| 00d97e59b3 | |||
| 6a9bdd0c6a | |||
| 9dd573f971 | |||
| bf9a58bdd4 | |||
| be832ceb4d | |||
| 5f565184c1 | |||
| d75de7f627 | |||
| b4e18b48f3 | |||
| 75d45f811f | |||
| c0e8922500 | |||
| 66deb345a2 | |||
| 1ab2389cdb | |||
| a009893522 | |||
| 6507fa5b1d | |||
| 121c796d48 | |||
| 88e5c9a1ba | |||
| af3c686111 | |||
| c980451725 | |||
| ed704a4dd7 | |||
| 0c22d50477 | |||
| 3cff5465d6 | |||
| 6d0106df22 | |||
| 7316e74b65 | |||
| 61ae46383e | |||
| f646621cc8 | |||
| 2911e71bc6 | |||
| 5b4146c967 | |||
| ae74401668 | |||
| 72a6e9473a | |||
| 7f72419e3c | |||
| ff9c31b88e | |||
| 615a1300ec | |||
| 6503b98e28 | |||
| ccd4fca695 | |||
| 75cba2cccd | |||
| ab3f3efceb | |||
| 992df72fac | |||
| ddadd81f4a | |||
| b2ca3ef066 | |||
| 5ae5329de8 | |||
| 251f61a039 | |||
| 486985f330 | |||
| d0d2b246e4 | |||
| c2c27470ff | |||
| 69e8f8e050 | |||
| 9255d01d6d | |||
| f2257718c6 | |||
| 5edc98545d | |||
| 5058866698 | |||
| 1a3f4d37be | |||
| 3e536dd4a8 | |||
| 85c20f7b4b | |||
| e4f3365414 | |||
| 8165bd59a4 | |||
| a89de7da1f | |||
| d566e54dfe | |||
| c9e0f26fd0 | |||
| 6573a64544 | |||
| 7fd2cab387 | |||
| a56b5382e1 | |||
| 9f59ab6081 | |||
| 5ce2f4aeff | |||
| e3d4841808 | |||
| f2e40a87d4 | |||
| 2ae8c3dca5 | |||
| 73bd4bb628 | |||
| a0333cfffc | |||
| 65d5cd5918 | |||
| 6b49f49ba0 | |||
| 5aebdf4119 | |||
| dfa7f535ab | |||
| e25a128bb7 | |||
| e1eb605394 | |||
| 0cd4115c25 | |||
| f37663053e | |||
| 1281376681 | |||
| 42ed0a0345 | |||
| 48750943db | |||
| 5ec7481030 | |||
| b543fae655 | |||
| f31800fad9 | |||
| f6295a2e4a | |||
| e5905d5b59 | |||
| 1e540cb6d0 | |||
| 09af30f24f | |||
| 4a317336fe | |||
| 4affeb3107 | |||
| d4341061e5 | |||
| fb544e8ad5 | |||
| db3ea84b02 | |||
| b8e3b08153 | |||
| 882efc32d1 | |||
| 0efea59a55 | |||
| 2598ceef51 | |||
| 88bb8e0920 | |||
| aad1ea6a01 | |||
| 0cd974fa6d | |||
| e1526d87b8 | |||
| 581bcfe066 | |||
| 2ed4d470b2 | |||
| ad6b1da130 | |||
| 09d946edea | |||
| f035629a35 | |||
| 279bbfe00c | |||
| 4a2c89f0d0 | |||
| fd7ae69b13 | |||
| 8e03cfb2cb | |||
| 2a88167957 | |||
| 49b855c55f | |||
| 97933a097c | |||
| efbe7a8fb3 | |||
| fb2abdbe1e | |||
| 05291b606d | |||
| efa9ffbd3a | |||
| b4b3541088 | |||
| 319231ecf4 | |||
| 4d144a10b1 | |||
| 5e0c752f37 | |||
| f23a9a0b7c | |||
| 2de81f9d1f | |||
| 25c8884db9 | |||
| 0ec5a237dd | |||
| 6bbbb6ac34 | |||
| 6c699fed35 | |||
| da173dc398 | |||
| b93a9b37ca | |||
| 5c3b2d3591 | |||
| 5344f90338 | |||
| 95506cff4f | |||
| 991266a50c | |||
| cc0c879538 | |||
| bd3a260096 | |||
| d8ebb6163a | |||
| 5dddaeb89d | |||
| 8c4f470d16 | |||
| 11b9c86ad0 | |||
| bccff56e74 | |||
| a74408c966 | |||
| 56679cf481 | |||
| f7662ab0a5 | |||
| ed3930edac | |||
| c9a4e980a1 | |||
| d4a2633699 | |||
| 6336fb0d2d | |||
| d8928959e3 | |||
| 6ec262af8d | |||
| 5a45794726 | |||
| 3b4dfac6f6 | |||
| 0a3d63ab01 | |||
| ec83606bf1 | |||
| c1df4145db | |||
| 0d3e8ff2ff | |||
| 4469e71cb5 | |||
| 22b6dadcbb | |||
| 56464c99f4 | |||
| 976cff1783 | |||
| f3926d247e | |||
| 7d5776f731 | |||
| 19dad1f586 | |||
| 63ba9b0431 | |||
| b6fa7eb1ef | |||
| f65fe67d86 | |||
| f48ef1c9c6 | |||
| 94df72ed99 | |||
| 80b4fa8a6e | |||
| 4d2801f6ae | |||
| 8d1db9572f | |||
| e00855f877 | |||
| 923f8e7497 | |||
| f26917ad37 | |||
| 2e61009a4c | |||
| fdbed20394 | |||
| 203fe955aa | |||
| e50879f5a3 | |||
| 8c1adf2189 | |||
| 119f64c25c | |||
| 2b88bc3fcd | |||
| 6d0bcb46ae | |||
| 00fd4ccebc | |||
| 06860070ab | |||
| 858066dc20 | |||
| 66b07aeb13 | |||
| 28067ea3e1 | |||
| 0f8ce8dba1 | |||
| 92b2486dab | |||
| 8c66b261d3 | |||
| 9348064432 | |||
| df09953d8e | |||
| 94a577bc72 | |||
| 7472400477 | |||
| 90af5ef06d | |||
| 6b55c264e5 | |||
| b5fe7e2a56 | |||
| bcf8ada78f | |||
| f84fe7b854 | |||
| 2b512ed4bf | |||
| 3bca687f19 | |||
| 440c023f42 | |||
| 223599f4e4 | |||
| 1559472ca3 | |||
| ad3301e932 | |||
| b2cba84ac0 | |||
| eb77dc369a | |||
| 883abd17d5 | |||
| 7a08431a58 | |||
| 0aaa44e063 | |||
| d7d89119e2 | |||
| d3b40684c1 | |||
| c7915f4387 | |||
| df19c361be | |||
| d9e682babd | |||
| c755f57c17 | |||
| 5a6b95d343 | |||
| 71ee300143 | |||
| 18dcec7bdd | |||
| 3656c654e9 | |||
| 1a489a91e8 | |||
| b2b415a5a0 | |||
| a3061f3ab5 | |||
| 0c82384137 | |||
| 7e55d8d183 | |||
| 76b3a1ae71 | |||
| 7f320909ff | |||
| dbe612e9dc | |||
| 53ea38aa3c | |||
| 88f69a298e | |||
| 6942bf541a | |||
| a0493aa6f0 | |||
| 60fef3d0e0 | |||
| d100d6cad7 | |||
| 7f55a93825 | |||
| 37d2e46a3d | |||
| 4619a22b97 | |||
| 397b5b5635 | |||
| 11a1eb8869 | |||
| 646b8f68b9 | |||
| e78fe1e233 | |||
| 2235c90136 | |||
| c0304a1a19 | |||
| 31301cd5f9 | |||
| 271550778f | |||
| 95ceae7711 | |||
| 79353bc30e | |||
| 744d339c9e | |||
| 4404f07691 | |||
| bf7e6ef42e | |||
| f3d2bab969 | |||
| e536ec678e | |||
| f779070199 | |||
| 2c31840fae | |||
| 2a3ae83eb2 | |||
| 6d7d2cd893 | |||
| 6da6a347fb | |||
| 15b0610051 | |||
| 024d0f8f16 | |||
| 3fb154355f | |||
| be56571256 | |||
| 54f166805e | |||
| 3889703ca7 | |||
| 536e85263a | |||
| e6aaa620ef | |||
| bb845fc267 | |||
| be1e58013b | |||
| 6578d99845 | |||
| 6da68ea87e | |||
| dba59f32ad | |||
| 68471a932d | |||
| b310936e45 | |||
| 245a8050db | |||
| 812c262b7e | |||
| edf31114c6 | |||
| 6f306c1622 | |||
| 1342d5408b | |||
| 82a62df7d5 | |||
| 7e061d8c8c | |||
| 166a811104 | |||
| 500d650ad0 | |||
| ae524435cc | |||
| b0684cb748 | |||
| 8361a9648b | |||
| bcbd5ba880 | |||
| 2ee9b482c3 | |||
| 4679447591 | |||
| ff19028f87 | |||
| 57e55c99ec | |||
| f9d059e706 | |||
| ecc0bbd5d4 | |||
| 8a890f15f5 | |||
| 19042479fb | |||
| a083033a73 | |||
| ece2db5782 | |||
| bc810ca90c | |||
| d970d06624 | |||
| c3123d70d8 | |||
| bf39d5d017 | |||
| 49a35624c8 | |||
| 4d993012d7 | |||
| c0c5cf747a |
+10
-1
@@ -1,6 +1,13 @@
|
||||
# application stuff
|
||||
uploads/*
|
||||
templates_c/*
|
||||
serendipity_config_local.inc.php
|
||||
plugins/additional_plugins*
|
||||
|
||||
# php stuff
|
||||
composer.lock
|
||||
|
||||
# ide / dev stuff
|
||||
.cvsignore
|
||||
.htaccess*
|
||||
*.db
|
||||
@@ -8,8 +15,10 @@ private/*
|
||||
archives/*
|
||||
*~
|
||||
DEADJOE
|
||||
plugins/additional_plugins*
|
||||
/.settings
|
||||
/.buildpath
|
||||
/.project
|
||||
.DS_Store
|
||||
.editorconfig
|
||||
*.git
|
||||
tests/phpunit.xml
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at `serendipity {at} supergarv (dot) de`. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -0,0 +1 @@
|
||||
Please see [Contributing/support](https://docs.s9y.org/docs/contributing/index.html).
|
||||
@@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2003-2019, Jannis Hermanns (on behalf the Serendipity Developer Team)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+2
-8
@@ -1,9 +1,3 @@
|
||||
# Serendipity - a PHP Weblog/Blog software
|
||||
# Serendipity - A reliable, secure & extensible PHP blog
|
||||
|
||||
[Serendipity](http://s9y.org) is a PHP-powered weblog application which gives the user an easy way to maintain an online diary, weblog or even a complete homepage. While the default package is designed for the casual blogger, Serendipity offers a flexible, expandable and easy-to-use framework with the power for professional applications.
|
||||
|
||||
This is a testing branch to mainly support the new backend smartification.
|
||||
|
||||
Use with care!
|
||||
|
||||
https://github.com/ophian/s9y-admin-tpl forked from https://github.com/yellowled/s9y-admin-tpl
|
||||
[Serendipity](https://s9y.org) is a PHP-powered weblog engine which gives the user an easy way to maintain a blog. While the default package is designed for the casual blogger, Serendipity offers an expandable framework with the power for professional applications.
|
||||
@@ -1,11 +1,15 @@
|
||||
Cache_Lite 1.5.1
|
||||
HTTP_Request 1.2.4
|
||||
Net_CheckIP 1.1
|
||||
Net_Socket 1.0.6
|
||||
Net_URL 1.0.14
|
||||
PEAR 1.3.5
|
||||
Text_Wiki 0.25.0
|
||||
XML_RPC 1.4.0
|
||||
Onyx 1.0 (customized)
|
||||
Smarty 2.6.9
|
||||
Net_DNSBL 1.0.0
|
||||
Cache_Lite 1.5.1 (CVS 1.54)
|
||||
HTTP_Request 1.2.4 (CVS 1.43)
|
||||
HTTP_Request2 2.2.1 (CVS 2.2.1)
|
||||
Net_CheckIP 1.1 (CVS 1.5)
|
||||
Net_DNSBL 1.0.0 (CVS 1.4)
|
||||
Net_Socket 1.0.6 (CVS 1.24)
|
||||
Net_URL 1.0.4 (CVS 1.36)
|
||||
Net_SURBL 1.4
|
||||
Onyx (customized) 1.0
|
||||
PEAR 1.9.5 (CVS 1.83)
|
||||
SimplePie 1.2.1
|
||||
Smarty 3.1.18
|
||||
Text_Wiki 0.25.0 (CVS 1.27)
|
||||
XML_RPC 1.4.0 (1.5.5)
|
||||
|
||||
|
||||
+63
-12
@@ -19,8 +19,8 @@
|
||||
*
|
||||
* @package Cache_Lite
|
||||
* @category Caching
|
||||
* @version $Id: Lite.php,v 1.54 2009/07/07 05:34:37 tacker Exp $
|
||||
* @author Fabien MARTY <fab@php.net>
|
||||
* @author Markus Tacker <tacker@php.net>
|
||||
*/
|
||||
|
||||
define('CACHE_LITE_ERROR_RETURN', 1);
|
||||
@@ -247,6 +247,12 @@ class Cache_Lite
|
||||
* @var boolean
|
||||
*/
|
||||
var $_errorHandlingAPIBreak = false;
|
||||
|
||||
var $_hashedDirectoryGroup = NULL;
|
||||
|
||||
var $_cacheFileMode = NULL;
|
||||
|
||||
var $_cacheFileGroup = NULL;
|
||||
|
||||
// --- Public methods ---
|
||||
|
||||
@@ -272,16 +278,30 @@ class Cache_Lite
|
||||
* 'hashedDirectoryLevel' => level of the hashed directory system (int),
|
||||
* 'hashedDirectoryUmask' => umask for hashed directory structure (int),
|
||||
* 'errorHandlingAPIBreak' => API break for better error handling ? (boolean)
|
||||
* 'hashedDirectoryGroup' => group of hashed directory structure (int | string) (see function chgrp)
|
||||
* 'cacheFileMode' => filesystem mode of newly created cache files (int)
|
||||
* 'cacheFileGroup' => group of newly created cache files (int | string) (see function chgrp)
|
||||
* );
|
||||
*
|
||||
* If sys_get_temp_dir() is available and the
|
||||
* 'cacheDir' option is not provided in the
|
||||
* constructor options array its output is used
|
||||
* to determine the suitable temporary directory.
|
||||
*
|
||||
* @see http://de.php.net/sys_get_temp_dir
|
||||
* @see http://pear.php.net/bugs/bug.php?id=18328
|
||||
*
|
||||
* @param array $options options
|
||||
* @access public
|
||||
*/
|
||||
function Cache_Lite($options = array(NULL))
|
||||
function __construct($options = array(NULL))
|
||||
{
|
||||
foreach($options as $key => $value) {
|
||||
$this->setOption($key, $value);
|
||||
}
|
||||
if (!isset($options['cacheDir']) && function_exists('sys_get_temp_dir')) {
|
||||
$this->setOption('cacheDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,7 +315,7 @@ class Cache_Lite
|
||||
*/
|
||||
function setOption($name, $value)
|
||||
{
|
||||
$availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode');
|
||||
$availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode', 'hashedDirectoryGroup', 'cacheFileMode', 'cacheFileGroup');
|
||||
if (in_array($name, $availableOptions)) {
|
||||
$property = '_'.$name;
|
||||
$this->$property = $value;
|
||||
@@ -534,7 +554,7 @@ class Cache_Lite
|
||||
*/
|
||||
function raiseError($msg, $code)
|
||||
{
|
||||
include_once dirname(__FILE__) . '/../PEAR.php';
|
||||
include_once('PEAR.php');
|
||||
return PEAR::raiseError($msg, $code, $this->_pearErrorMode);
|
||||
}
|
||||
|
||||
@@ -613,7 +633,7 @@ class Cache_Lite
|
||||
return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
|
||||
}
|
||||
$result = true;
|
||||
while ($file = readdir($dh)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
if (substr($file, 0, 6)=='cache_') {
|
||||
$file2 = $dir . $file;
|
||||
@@ -654,7 +674,19 @@ class Cache_Lite
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Touch the cache file while are recreating it to avoid
|
||||
* launch this task more then once when necessary
|
||||
* When the cache recreated and Added in Cache Memory
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function _touchCacheFile(){
|
||||
if (file_exists($this->_file)) {
|
||||
@touch($this->_file);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add some date in the memory caching array
|
||||
*
|
||||
@@ -663,6 +695,7 @@ class Cache_Lite
|
||||
*/
|
||||
function _memoryCacheAdd($data)
|
||||
{
|
||||
$this->_touchCacheFile();
|
||||
$this->_memoryCachingArray[$this->_file] = $data;
|
||||
if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
|
||||
list($key, ) = each($this->_memoryCachingArray);
|
||||
@@ -707,8 +740,8 @@ class Cache_Lite
|
||||
function _read()
|
||||
{
|
||||
$fp = @fopen($this->_file, "rb");
|
||||
if ($this->_fileLocking) @flock($fp, LOCK_SH);
|
||||
if ($fp) {
|
||||
if ($this->_fileLocking) @flock($fp, LOCK_SH);
|
||||
clearstatcache();
|
||||
$length = @filesize($this->_file);
|
||||
$mqr = get_magic_quotes_runtime();
|
||||
@@ -718,9 +751,13 @@ class Cache_Lite
|
||||
if ($this->_readControl) {
|
||||
$hashControl = @fread($fp, 32);
|
||||
$length = $length - 32;
|
||||
}
|
||||
}
|
||||
|
||||
if ($length) {
|
||||
$data = @fread($fp, $length);
|
||||
$data = '';
|
||||
// See https://bugs.php.net/bug.php?id=30936
|
||||
// The 8192 magic number is the chunk size used internally by PHP.
|
||||
while(!feof($fp)) $data .= fread($fp, 8192);
|
||||
} else {
|
||||
$data = '';
|
||||
}
|
||||
@@ -760,13 +797,29 @@ class Cache_Lite
|
||||
for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
|
||||
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
|
||||
if (!(@is_dir($root))) {
|
||||
@mkdir($root, $this->_hashedDirectoryUmask);
|
||||
if (@mkdir($root))
|
||||
{
|
||||
@chmod($root, $this->_hashedDirectoryUmask);
|
||||
if (! is_null($this->_hashedDirectoryGroup))
|
||||
@chgrp($root, $this->_hashedDirectoryGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if both _cacheFileMode and _cacheFileGroup is null, then we don't need to call
|
||||
// file_exists (see below: if ($is_newfile) ...)
|
||||
$is_newfile = (! is_null($this->_cacheFileMode) || !is_null($this->_cacheFileGroup))
|
||||
&& ! @file_exists($this->_file);
|
||||
$fp = @fopen($this->_file, "wb");
|
||||
if ($fp) {
|
||||
if ($this->_fileLocking) @flock($fp, LOCK_EX);
|
||||
if ($is_newfile)
|
||||
{
|
||||
if (! is_null($this->_cacheFileMode))
|
||||
@chmod($this->_file, $this->_cacheFileMode);
|
||||
if (! is_null($this->_cacheFileGroup))
|
||||
@chgrp($this->_file, $this->_cacheFileGroup);
|
||||
}
|
||||
if ($this->_readControl) {
|
||||
@fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
|
||||
}
|
||||
@@ -831,5 +884,3 @@ class Cache_Lite
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This class extends Cache_Lite and offers a cache system driven by a master file
|
||||
*
|
||||
* With this class, cache validity is only dependent of a given file. Cache files
|
||||
* are valid only if they are older than the master file. It's a perfect way for
|
||||
* caching templates results (if the template file is newer than the cache, cache
|
||||
* must be rebuild...) or for config classes...
|
||||
* There are some examples in the 'docs/examples' file
|
||||
* Technical choices are described in the 'docs/technical' file
|
||||
*
|
||||
* @package Cache_Lite
|
||||
* @author Fabien MARTY <fab@php.net>
|
||||
*/
|
||||
|
||||
require_once('Cache/Lite.php');
|
||||
|
||||
class Cache_Lite_File extends Cache_Lite
|
||||
{
|
||||
|
||||
// --- Private properties ---
|
||||
|
||||
/**
|
||||
* Complete path of the file used for controlling the cache lifetime
|
||||
*
|
||||
* @var string $_masterFile
|
||||
*/
|
||||
var $_masterFile = '';
|
||||
|
||||
/**
|
||||
* Masterfile mtime
|
||||
*
|
||||
* @var int $_masterFile_mtime
|
||||
*/
|
||||
var $_masterFile_mtime = 0;
|
||||
|
||||
// --- Public methods ----
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* $options is an assoc. To have a look at availables options,
|
||||
* see the constructor of the Cache_Lite class in 'Cache_Lite.php'
|
||||
*
|
||||
* Comparing to Cache_Lite constructor, there is another option :
|
||||
* $options = array(
|
||||
* (...) see Cache_Lite constructor
|
||||
* 'masterFile' => complete path of the file used for controlling the cache lifetime(string)
|
||||
* );
|
||||
*
|
||||
* @param array $options options
|
||||
* @access public
|
||||
*/
|
||||
function __construct($options = array(NULL))
|
||||
{
|
||||
$options['lifetime'] = 0;
|
||||
parent::__construct($options);
|
||||
if (isset($options['masterFile'])) {
|
||||
$this->_masterFile = $options['masterFile'];
|
||||
} else {
|
||||
return $this->raiseError('Cache_Lite_File : masterFile option must be set !');
|
||||
}
|
||||
if (!($this->_masterFile_mtime = @filemtime($this->_masterFile))) {
|
||||
return $this->raiseError('Cache_Lite_File : Unable to read masterFile : '.$this->_masterFile, -3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a cache is available and (if yes) return it
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @param string $group name of the cache group
|
||||
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
|
||||
* @return string data of the cache (else : false)
|
||||
* @access public
|
||||
*/
|
||||
function get($id, $group = 'default', $doNotTestCacheValidity = false)
|
||||
{
|
||||
if ($data = parent::get($id, $group, true)) {
|
||||
if ($filemtime = $this->lastModified()) {
|
||||
if ($filemtime > $this->_masterFile_mtime) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,12 +11,11 @@
|
||||
* Technical choices are described in the 'docs/technical' file
|
||||
*
|
||||
* @package Cache_Lite
|
||||
* @version $Id: Function.php,v 1.11 2006/12/14 12:59:43 cweiske Exp $
|
||||
* @author Sebastian BERGMANN <sb@sebastian-bergmann.de>
|
||||
* @author Fabien MARTY <fab@php.net>
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../Lite.php';
|
||||
require_once('Cache/Lite.php');
|
||||
|
||||
class Cache_Lite_Function extends Cache_Lite
|
||||
{
|
||||
@@ -82,7 +81,7 @@ class Cache_Lite_Function extends Cache_Lite
|
||||
* @param array $options options
|
||||
* @access public
|
||||
*/
|
||||
function Cache_Lite_Function($options = array(NULL))
|
||||
function __construct($options = array(NULL))
|
||||
{
|
||||
$availableOptions = array('debugCacheLiteFunction', 'defaultGroup', 'dontCacheWhenTheOutputContainsNOCACHE', 'dontCacheWhenTheResultIsFalse', 'dontCacheWhenTheResultIsNull');
|
||||
while (list($name, $value) = each($options)) {
|
||||
@@ -92,7 +91,7 @@ class Cache_Lite_Function extends Cache_Lite
|
||||
}
|
||||
}
|
||||
reset($options);
|
||||
$this->Cache_Lite($options);
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,5 +206,3 @@ class Cache_Lite_Function extends Cache_Lite
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This class extends Cache_Lite and uses output buffering to get the data to cache.
|
||||
* It supports nesting of caches
|
||||
*
|
||||
* @package Cache_Lite
|
||||
* @author Markus Tacker <tacker@php.net>
|
||||
*/
|
||||
|
||||
require_once('Cache/Lite/Output.php');
|
||||
|
||||
class Cache_Lite_NestedOutput extends Cache_Lite_Output
|
||||
{
|
||||
private $nestedIds = array();
|
||||
private $nestedGroups = array();
|
||||
|
||||
/**
|
||||
* Start the cache
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @param string $group name of the cache group
|
||||
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
|
||||
* @return boolean|string false if the cache is not hit else the data
|
||||
* @access public
|
||||
*/
|
||||
function start($id, $group = 'default', $doNotTestCacheValidity = false)
|
||||
{
|
||||
$this->nestedIds[] = $id;
|
||||
$this->nestedGroups[] = $group;
|
||||
$data = $this->get($id, $group, $doNotTestCacheValidity);
|
||||
if ($data !== false) {
|
||||
return $data;
|
||||
}
|
||||
ob_start();
|
||||
ob_implicit_flush(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the cache
|
||||
*
|
||||
* @param boolen
|
||||
* @return string return contents of cache
|
||||
*/
|
||||
function end()
|
||||
{
|
||||
$data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$id = array_pop($this->nestedIds);
|
||||
$group = array_pop($this->nestedGroups);
|
||||
$this->save($data, $id, $group);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,11 +7,10 @@
|
||||
* Technical choices are described in the 'docs/technical' file
|
||||
*
|
||||
* @package Cache_Lite
|
||||
* @version $Id: Output.php,v 1.4 2006/01/29 00:22:07 fab Exp $
|
||||
* @author Fabien MARTY <fab@php.net>
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../Lite.php';
|
||||
require_once('Cache/Lite.php');
|
||||
|
||||
class Cache_Lite_Output extends Cache_Lite
|
||||
{
|
||||
@@ -27,9 +26,9 @@ class Cache_Lite_Output extends Cache_Lite
|
||||
* @param array $options options
|
||||
* @access public
|
||||
*/
|
||||
function Cache_Lite_Output($options)
|
||||
function __construct($options)
|
||||
{
|
||||
$this->Cache_Lite($options);
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +66,3 @@ class Cache_Lite_Output extends Cache_Lite
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -89,7 +89,7 @@ class HTTP_Request {
|
||||
* @var string
|
||||
*/
|
||||
var $_user;
|
||||
|
||||
|
||||
/**
|
||||
* Basic Auth Password
|
||||
* @var string
|
||||
@@ -101,25 +101,25 @@ class HTTP_Request {
|
||||
* @var object Net_Socket
|
||||
*/
|
||||
var $_sock;
|
||||
|
||||
|
||||
/**
|
||||
* Proxy server
|
||||
* @var string
|
||||
*/
|
||||
var $_proxy_host;
|
||||
|
||||
|
||||
/**
|
||||
* Proxy port
|
||||
* @var integer
|
||||
*/
|
||||
var $_proxy_port;
|
||||
|
||||
|
||||
/**
|
||||
* Proxy username
|
||||
* @var string
|
||||
*/
|
||||
var $_proxy_user;
|
||||
|
||||
|
||||
/**
|
||||
* Proxy password
|
||||
* @var string
|
||||
@@ -133,7 +133,7 @@ class HTTP_Request {
|
||||
var $_postData;
|
||||
|
||||
/**
|
||||
* Request body
|
||||
* Request body
|
||||
* @var string
|
||||
*/
|
||||
var $_body;
|
||||
@@ -145,7 +145,7 @@ class HTTP_Request {
|
||||
var $_bodyDisallowed = array('TRACE');
|
||||
|
||||
/**
|
||||
* Files to post
|
||||
* Files to post
|
||||
* @var array
|
||||
*/
|
||||
var $_postFiles = array();
|
||||
@@ -155,25 +155,25 @@ class HTTP_Request {
|
||||
* @var float
|
||||
*/
|
||||
var $_timeout;
|
||||
|
||||
|
||||
/**
|
||||
* HTTP_Response object
|
||||
* @var object HTTP_Response
|
||||
*/
|
||||
var $_response;
|
||||
|
||||
|
||||
/**
|
||||
* Whether to allow redirects
|
||||
* @var boolean
|
||||
*/
|
||||
var $_allowRedirects;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum redirects allowed
|
||||
* @var integer
|
||||
*/
|
||||
var $_maxRedirects;
|
||||
|
||||
|
||||
/**
|
||||
* Current number of redirects
|
||||
* @var integer
|
||||
@@ -193,7 +193,7 @@ class HTTP_Request {
|
||||
var $_listeners = array();
|
||||
|
||||
/**
|
||||
* Whether to save response body in response object property
|
||||
* Whether to save response body in response object property
|
||||
* @var bool
|
||||
*/
|
||||
var $_saveBody = true;
|
||||
@@ -286,7 +286,7 @@ class HTTP_Request {
|
||||
$this->addHeader('Accept-Encoding', 'gzip');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a Host header for HTTP/1.1 requests
|
||||
*
|
||||
@@ -303,14 +303,14 @@ class HTTP_Request {
|
||||
|
||||
} elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) {
|
||||
$host = $this->_url->host . ':' . $this->_url->port;
|
||||
|
||||
|
||||
} else {
|
||||
$host = $this->_url->host;
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the object to its initial state (DEPRECATED).
|
||||
* Takes the same parameters as the constructor.
|
||||
@@ -344,7 +344,7 @@ class HTTP_Request {
|
||||
$this->addHeader('Host', $this->_generateHostHeader());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a proxy to be used
|
||||
*
|
||||
@@ -438,8 +438,8 @@ class HTTP_Request {
|
||||
function addQueryString($name, $value, $preencoded = false)
|
||||
{
|
||||
$this->_url->addQueryString($name, $value, $preencoded);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the querystring to literally what you supply
|
||||
*
|
||||
@@ -546,7 +546,7 @@ class HTTP_Request {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears any postdata that has been added (DEPRECATED).
|
||||
* Clears any postdata that has been added (DEPRECATED).
|
||||
*
|
||||
* Useful for multiple request scenarios.
|
||||
*
|
||||
@@ -570,9 +570,9 @@ class HTTP_Request {
|
||||
$cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : '';
|
||||
$this->addHeader('Cookie', $cookies . $name . '=' . $value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears any cookies that have been added (DEPRECATED).
|
||||
* Clears any cookies that have been added (DEPRECATED).
|
||||
*
|
||||
* Useful for multiple request scenarios
|
||||
*
|
||||
@@ -645,7 +645,7 @@ class HTTP_Request {
|
||||
AND $this->getResponseCode() < 399
|
||||
AND !empty($this->_response->_headers['location'])) {
|
||||
|
||||
|
||||
|
||||
$redirect = $this->_response->_headers['location'];
|
||||
|
||||
// Absolute URL
|
||||
@@ -655,7 +655,7 @@ class HTTP_Request {
|
||||
// Absolute path
|
||||
} elseif ($redirect[0] == '/') {
|
||||
$this->_url->path = $redirect;
|
||||
|
||||
|
||||
// Relative path
|
||||
} elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') {
|
||||
if (substr($this->_url->path, -1) == '/') {
|
||||
@@ -665,7 +665,7 @@ class HTTP_Request {
|
||||
}
|
||||
$redirect = Net_URL::resolvePath($redirect);
|
||||
$this->_url->path = $redirect;
|
||||
|
||||
|
||||
// Filename, no path
|
||||
} else {
|
||||
if (substr($this->_url->path, -1) == '/') {
|
||||
@@ -842,7 +842,7 @@ class HTTP_Request {
|
||||
$request .= 'Content-Length: ' . strlen($this->_body) . "\r\n\r\n";
|
||||
$request .= $this->_body;
|
||||
}
|
||||
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
@@ -894,7 +894,7 @@ class HTTP_Request {
|
||||
|
||||
|
||||
/**
|
||||
* Removes a Listener from the list of listeners
|
||||
* Removes a Listener from the list of listeners
|
||||
*
|
||||
* @param object HTTP_Request_Listener instance to detach
|
||||
* @return boolean whether the listener was successfully detached
|
||||
@@ -951,13 +951,13 @@ class HTTP_Response
|
||||
* @var string
|
||||
*/
|
||||
var $_protocol;
|
||||
|
||||
|
||||
/**
|
||||
* Return code
|
||||
* @var string
|
||||
*/
|
||||
var $_code;
|
||||
|
||||
|
||||
/**
|
||||
* Response headers
|
||||
* @var array
|
||||
@@ -965,7 +965,7 @@ class HTTP_Response
|
||||
var $_headers;
|
||||
|
||||
/**
|
||||
* Cookies set in response
|
||||
* Cookies set in response
|
||||
* @var array
|
||||
*/
|
||||
var $_cookies;
|
||||
@@ -1078,7 +1078,7 @@ class HTTP_Response
|
||||
list($headername, $headervalue) = explode(':', $header, 2);
|
||||
$headername = strtolower($headername);
|
||||
$headervalue = ltrim($headervalue);
|
||||
|
||||
|
||||
if ('set-cookie' != $headername) {
|
||||
if (isset($this->_headers[$headername])) {
|
||||
$this->_headers[$headername] .= ',' . $headervalue;
|
||||
@@ -1154,7 +1154,7 @@ class HTTP_Response
|
||||
if (0 == $this->_chunkLength) {
|
||||
$line = $this->_sock->readLine();
|
||||
if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) {
|
||||
$this->_chunkLength = hexdec($matches[1]);
|
||||
$this->_chunkLength = hexdec($matches[1]);
|
||||
// Chunk with zero length indicates the end
|
||||
if (0 == $this->_chunkLength) {
|
||||
$this->_sock->readLine(); // make this an eof()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Base class for HTTP_Request2 adapters
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class representing a HTTP response
|
||||
*/
|
||||
require_once 'HTTP/Request2/Response.php';
|
||||
|
||||
/**
|
||||
* Base class for HTTP_Request2 adapters
|
||||
*
|
||||
* HTTP_Request2 class itself only defines methods for aggregating the request
|
||||
* data, all actual work of sending the request to the remote server and
|
||||
* receiving its response is performed by adapters.
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
abstract class HTTP_Request2_Adapter
|
||||
{
|
||||
/**
|
||||
* A list of methods that MUST NOT have a request body, per RFC 2616
|
||||
* @var array
|
||||
*/
|
||||
protected static $bodyDisallowed = array('TRACE');
|
||||
|
||||
/**
|
||||
* Methods having defined semantics for request body
|
||||
*
|
||||
* Content-Length header (indicating that the body follows, section 4.3 of
|
||||
* RFC 2616) will be sent for these methods even if no body was added
|
||||
*
|
||||
* @var array
|
||||
* @link http://pear.php.net/bugs/bug.php?id=12900
|
||||
* @link http://pear.php.net/bugs/bug.php?id=14740
|
||||
*/
|
||||
protected static $bodyRequired = array('POST', 'PUT');
|
||||
|
||||
/**
|
||||
* Request being sent
|
||||
* @var HTTP_Request2
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Request body
|
||||
* @var string|resource|HTTP_Request2_MultipartBody
|
||||
* @see HTTP_Request2::getBody()
|
||||
*/
|
||||
protected $requestBody;
|
||||
|
||||
/**
|
||||
* Length of the request body
|
||||
* @var integer
|
||||
*/
|
||||
protected $contentLength;
|
||||
|
||||
/**
|
||||
* Sends request to the remote server and returns its response
|
||||
*
|
||||
* @param HTTP_Request2 $request HTTP request message
|
||||
*
|
||||
* @return HTTP_Request2_Response
|
||||
* @throws HTTP_Request2_Exception
|
||||
*/
|
||||
abstract public function sendRequest(HTTP_Request2 $request);
|
||||
|
||||
/**
|
||||
* Calculates length of the request body, adds proper headers
|
||||
*
|
||||
* @param array &$headers associative array of request headers, this method
|
||||
* will add proper 'Content-Length' and 'Content-Type'
|
||||
* headers to this array (or remove them if not needed)
|
||||
*/
|
||||
protected function calculateRequestLength(&$headers)
|
||||
{
|
||||
$this->requestBody = $this->request->getBody();
|
||||
|
||||
if (is_string($this->requestBody)) {
|
||||
$this->contentLength = strlen($this->requestBody);
|
||||
} elseif (is_resource($this->requestBody)) {
|
||||
$stat = fstat($this->requestBody);
|
||||
$this->contentLength = $stat['size'];
|
||||
rewind($this->requestBody);
|
||||
} else {
|
||||
$this->contentLength = $this->requestBody->getLength();
|
||||
$headers['content-type'] = 'multipart/form-data; boundary=' .
|
||||
$this->requestBody->getBoundary();
|
||||
$this->requestBody->rewind();
|
||||
}
|
||||
|
||||
if (in_array($this->request->getMethod(), self::$bodyDisallowed)
|
||||
|| 0 == $this->contentLength
|
||||
) {
|
||||
// No body: send a Content-Length header nonetheless (request #12900),
|
||||
// but do that only for methods that require a body (bug #14740)
|
||||
if (in_array($this->request->getMethod(), self::$bodyRequired)) {
|
||||
$headers['content-length'] = 0;
|
||||
} else {
|
||||
unset($headers['content-length']);
|
||||
// if the method doesn't require a body and doesn't have a
|
||||
// body, don't send a Content-Type header. (request #16799)
|
||||
unset($headers['content-type']);
|
||||
}
|
||||
} else {
|
||||
if (empty($headers['content-type'])) {
|
||||
$headers['content-type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
// Content-Length should not be sent for chunked Transfer-Encoding (bug #20125)
|
||||
if (!isset($headers['transfer-encoding'])) {
|
||||
$headers['content-length'] = $this->contentLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,577 @@
|
||||
<?php
|
||||
/**
|
||||
* Adapter for HTTP_Request2 wrapping around cURL extension
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for HTTP_Request2 adapters
|
||||
*/
|
||||
require_once 'HTTP/Request2/Adapter.php';
|
||||
|
||||
/**
|
||||
* Adapter for HTTP_Request2 wrapping around cURL extension
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter
|
||||
{
|
||||
/**
|
||||
* Mapping of header names to cURL options
|
||||
* @var array
|
||||
*/
|
||||
protected static $headerMap = array(
|
||||
'accept-encoding' => CURLOPT_ENCODING,
|
||||
'cookie' => CURLOPT_COOKIE,
|
||||
'referer' => CURLOPT_REFERER,
|
||||
'user-agent' => CURLOPT_USERAGENT
|
||||
);
|
||||
|
||||
/**
|
||||
* Mapping of SSL context options to cURL options
|
||||
* @var array
|
||||
*/
|
||||
protected static $sslContextMap = array(
|
||||
'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER,
|
||||
'ssl_cafile' => CURLOPT_CAINFO,
|
||||
'ssl_capath' => CURLOPT_CAPATH,
|
||||
'ssl_local_cert' => CURLOPT_SSLCERT,
|
||||
'ssl_passphrase' => CURLOPT_SSLCERTPASSWD
|
||||
);
|
||||
|
||||
/**
|
||||
* Mapping of CURLE_* constants to Exception subclasses and error codes
|
||||
* @var array
|
||||
*/
|
||||
protected static $errorMap = array(
|
||||
CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException',
|
||||
HTTP_Request2_Exception::NON_HTTP_REDIRECT),
|
||||
CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'),
|
||||
CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'),
|
||||
CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'),
|
||||
// error returned from write callback
|
||||
CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException',
|
||||
HTTP_Request2_Exception::NON_HTTP_REDIRECT),
|
||||
CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException',
|
||||
HTTP_Request2_Exception::TIMEOUT),
|
||||
CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'),
|
||||
CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'),
|
||||
CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION),
|
||||
CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION),
|
||||
CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException',
|
||||
HTTP_Request2_Exception::NON_HTTP_REDIRECT),
|
||||
CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException',
|
||||
HTTP_Request2_Exception::TOO_MANY_REDIRECTS),
|
||||
CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'),
|
||||
CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'),
|
||||
CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION),
|
||||
CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION),
|
||||
CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'),
|
||||
CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'),
|
||||
CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException',
|
||||
HTTP_Request2_Exception::INVALID_ARGUMENT),
|
||||
CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'),
|
||||
CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'),
|
||||
CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Response being received
|
||||
* @var HTTP_Request2_Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Whether 'sentHeaders' event was sent to observers
|
||||
* @var boolean
|
||||
*/
|
||||
protected $eventSentHeaders = false;
|
||||
|
||||
/**
|
||||
* Whether 'receivedHeaders' event was sent to observers
|
||||
* @var boolean
|
||||
*/
|
||||
protected $eventReceivedHeaders = false;
|
||||
|
||||
/**
|
||||
* Whether 'sentBoody' event was sent to observers
|
||||
* @var boolean
|
||||
*/
|
||||
protected $eventSentBody = false;
|
||||
|
||||
/**
|
||||
* Position within request body
|
||||
* @var integer
|
||||
* @see callbackReadBody()
|
||||
*/
|
||||
protected $position = 0;
|
||||
|
||||
/**
|
||||
* Information about last transfer, as returned by curl_getinfo()
|
||||
* @var array
|
||||
*/
|
||||
protected $lastInfo;
|
||||
|
||||
/**
|
||||
* Creates a subclass of HTTP_Request2_Exception from curl error data
|
||||
*
|
||||
* @param resource $ch curl handle
|
||||
*
|
||||
* @return HTTP_Request2_Exception
|
||||
*/
|
||||
protected static function wrapCurlError($ch)
|
||||
{
|
||||
$nativeCode = curl_errno($ch);
|
||||
$message = 'Curl error: ' . curl_error($ch);
|
||||
if (!isset(self::$errorMap[$nativeCode])) {
|
||||
return new HTTP_Request2_Exception($message, 0, $nativeCode);
|
||||
} else {
|
||||
$class = self::$errorMap[$nativeCode][0];
|
||||
$code = empty(self::$errorMap[$nativeCode][1])
|
||||
? 0 : self::$errorMap[$nativeCode][1];
|
||||
return new $class($message, $code, $nativeCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends request to the remote server and returns its response
|
||||
*
|
||||
* @param HTTP_Request2 $request HTTP request message
|
||||
*
|
||||
* @return HTTP_Request2_Response
|
||||
* @throws HTTP_Request2_Exception
|
||||
*/
|
||||
public function sendRequest(HTTP_Request2 $request)
|
||||
{
|
||||
if (!extension_loaded('curl')) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION
|
||||
);
|
||||
}
|
||||
|
||||
$this->request = $request;
|
||||
$this->response = null;
|
||||
$this->position = 0;
|
||||
$this->eventSentHeaders = false;
|
||||
$this->eventReceivedHeaders = false;
|
||||
$this->eventSentBody = false;
|
||||
|
||||
try {
|
||||
if (false === curl_exec($ch = $this->createCurlHandle())) {
|
||||
$e = self::wrapCurlError($ch);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
if (isset($ch)) {
|
||||
$this->lastInfo = curl_getinfo($ch);
|
||||
if (CURLE_OK !== curl_errno($ch)) {
|
||||
$this->request->setLastEvent('warning', curl_error($ch));
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
$response = $this->response;
|
||||
unset($this->request, $this->requestBody, $this->response);
|
||||
|
||||
if (!empty($e)) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($jar = $request->getCookieJar()) {
|
||||
$jar->addCookiesFromResponse($response);
|
||||
}
|
||||
|
||||
if (0 < $this->lastInfo['size_download']) {
|
||||
$request->setLastEvent('receivedBody', $response);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about last transfer
|
||||
*
|
||||
* @return array associative array as returned by curl_getinfo()
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return $this->lastInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new cURL handle and populates it with data from the request
|
||||
*
|
||||
* @return resource a cURL handle, as created by curl_init()
|
||||
* @throws HTTP_Request2_LogicException
|
||||
* @throws HTTP_Request2_NotImplementedException
|
||||
*/
|
||||
protected function createCurlHandle()
|
||||
{
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt_array($ch, array(
|
||||
// setup write callbacks
|
||||
CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'),
|
||||
CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'),
|
||||
// buffer size
|
||||
CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'),
|
||||
// connection timeout
|
||||
CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'),
|
||||
// save full outgoing headers, in case someone is interested
|
||||
CURLINFO_HEADER_OUT => true,
|
||||
// request url
|
||||
CURLOPT_URL => $this->request->getUrl()->getUrl()
|
||||
));
|
||||
|
||||
// set up redirects
|
||||
if (!$this->request->getConfig('follow_redirects')) {
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||
} else {
|
||||
if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Redirect support in curl is unavailable due to open_basedir or safe_mode setting',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION
|
||||
);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects'));
|
||||
// limit redirects to http(s), works in 5.2.10+
|
||||
if (defined('CURLOPT_REDIR_PROTOCOLS')) {
|
||||
curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
}
|
||||
// works in 5.3.2+, http://bugs.php.net/bug.php?id=49571
|
||||
if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) {
|
||||
curl_setopt($ch, CURLOPT_POSTREDIR, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// set local IP via CURLOPT_INTERFACE (request #19515)
|
||||
if ($ip = $this->request->getConfig('local_ip')) {
|
||||
curl_setopt($ch, CURLOPT_INTERFACE, $ip);
|
||||
}
|
||||
|
||||
// request timeout
|
||||
if ($timeout = $this->request->getConfig('timeout')) {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
}
|
||||
|
||||
// set HTTP version
|
||||
switch ($this->request->getConfig('protocol_version')) {
|
||||
case '1.0':
|
||||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
||||
break;
|
||||
case '1.1':
|
||||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||
}
|
||||
|
||||
// set request method
|
||||
switch ($this->request->getMethod()) {
|
||||
case HTTP_Request2::METHOD_GET:
|
||||
curl_setopt($ch, CURLOPT_HTTPGET, true);
|
||||
break;
|
||||
case HTTP_Request2::METHOD_POST:
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
break;
|
||||
case HTTP_Request2::METHOD_HEAD:
|
||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
break;
|
||||
case HTTP_Request2::METHOD_PUT:
|
||||
curl_setopt($ch, CURLOPT_UPLOAD, true);
|
||||
break;
|
||||
default:
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod());
|
||||
}
|
||||
|
||||
// set proxy, if needed
|
||||
if ($host = $this->request->getConfig('proxy_host')) {
|
||||
if (!($port = $this->request->getConfig('proxy_port'))) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE
|
||||
);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port);
|
||||
if ($user = $this->request->getConfig('proxy_user')) {
|
||||
curl_setopt(
|
||||
$ch, CURLOPT_PROXYUSERPWD,
|
||||
$user . ':' . $this->request->getConfig('proxy_password')
|
||||
);
|
||||
switch ($this->request->getConfig('proxy_auth_scheme')) {
|
||||
case HTTP_Request2::AUTH_BASIC:
|
||||
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
|
||||
break;
|
||||
case HTTP_Request2::AUTH_DIGEST:
|
||||
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
|
||||
}
|
||||
}
|
||||
if ($type = $this->request->getConfig('proxy_type')) {
|
||||
switch ($type) {
|
||||
case 'http':
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
||||
break;
|
||||
case 'socks5':
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||
break;
|
||||
default:
|
||||
throw new HTTP_Request2_NotImplementedException(
|
||||
"Proxy type '{$type}' is not supported"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set authentication data
|
||||
if ($auth = $this->request->getAuth()) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']);
|
||||
switch ($auth['scheme']) {
|
||||
case HTTP_Request2::AUTH_BASIC:
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
break;
|
||||
case HTTP_Request2::AUTH_DIGEST:
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
||||
}
|
||||
}
|
||||
|
||||
// set SSL options
|
||||
foreach ($this->request->getConfig() as $name => $value) {
|
||||
if ('ssl_verify_host' == $name && null !== $value) {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0);
|
||||
} elseif (isset(self::$sslContextMap[$name]) && null !== $value) {
|
||||
curl_setopt($ch, self::$sslContextMap[$name], $value);
|
||||
}
|
||||
}
|
||||
|
||||
$headers = $this->request->getHeaders();
|
||||
// make cURL automagically send proper header
|
||||
if (!isset($headers['accept-encoding'])) {
|
||||
$headers['accept-encoding'] = '';
|
||||
}
|
||||
|
||||
if (($jar = $this->request->getCookieJar())
|
||||
&& ($cookies = $jar->getMatching($this->request->getUrl(), true))
|
||||
) {
|
||||
$headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies;
|
||||
}
|
||||
|
||||
// set headers having special cURL keys
|
||||
foreach (self::$headerMap as $name => $option) {
|
||||
if (isset($headers[$name])) {
|
||||
curl_setopt($ch, $option, $headers[$name]);
|
||||
unset($headers[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->calculateRequestLength($headers);
|
||||
if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) {
|
||||
$this->workaroundPhpBug47204($ch, $headers);
|
||||
}
|
||||
|
||||
// set headers not having special keys
|
||||
$headersFmt = array();
|
||||
foreach ($headers as $name => $value) {
|
||||
$canonicalName = implode('-', array_map('ucfirst', explode('-', $name)));
|
||||
$headersFmt[] = $canonicalName . ': ' . $value;
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt);
|
||||
|
||||
return $ch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround for PHP bug #47204 that prevents rewinding request body
|
||||
*
|
||||
* The workaround consists of reading the entire request body into memory
|
||||
* and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large
|
||||
* file uploads, use Socket adapter instead.
|
||||
*
|
||||
* @param resource $ch cURL handle
|
||||
* @param array &$headers Request headers
|
||||
*/
|
||||
protected function workaroundPhpBug47204($ch, &$headers)
|
||||
{
|
||||
// no redirects, no digest auth -> probably no rewind needed
|
||||
// also apply workaround only for POSTs, othrerwise we get
|
||||
// https://pear.php.net/bugs/bug.php?id=20440 for PUTs
|
||||
if (!$this->request->getConfig('follow_redirects')
|
||||
&& (!($auth = $this->request->getAuth())
|
||||
|| HTTP_Request2::AUTH_DIGEST != $auth['scheme'])
|
||||
|| HTTP_Request2::METHOD_POST !== $this->request->getMethod()
|
||||
) {
|
||||
curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody'));
|
||||
|
||||
} else {
|
||||
// rewind may be needed, read the whole body into memory
|
||||
if ($this->requestBody instanceof HTTP_Request2_MultipartBody) {
|
||||
$this->requestBody = $this->requestBody->__toString();
|
||||
|
||||
} elseif (is_resource($this->requestBody)) {
|
||||
$fp = $this->requestBody;
|
||||
$this->requestBody = '';
|
||||
while (!feof($fp)) {
|
||||
$this->requestBody .= fread($fp, 16384);
|
||||
}
|
||||
}
|
||||
// curl hangs up if content-length is present
|
||||
unset($headers['content-length']);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function called by cURL for reading the request body
|
||||
*
|
||||
* @param resource $ch cURL handle
|
||||
* @param resource $fd file descriptor (not used)
|
||||
* @param integer $length maximum length of data to return
|
||||
*
|
||||
* @return string part of the request body, up to $length bytes
|
||||
*/
|
||||
protected function callbackReadBody($ch, $fd, $length)
|
||||
{
|
||||
if (!$this->eventSentHeaders) {
|
||||
$this->request->setLastEvent(
|
||||
'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT)
|
||||
);
|
||||
$this->eventSentHeaders = true;
|
||||
}
|
||||
if (in_array($this->request->getMethod(), self::$bodyDisallowed)
|
||||
|| 0 == $this->contentLength || $this->position >= $this->contentLength
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
if (is_string($this->requestBody)) {
|
||||
$string = substr($this->requestBody, $this->position, $length);
|
||||
} elseif (is_resource($this->requestBody)) {
|
||||
$string = fread($this->requestBody, $length);
|
||||
} else {
|
||||
$string = $this->requestBody->read($length);
|
||||
}
|
||||
$this->request->setLastEvent('sentBodyPart', strlen($string));
|
||||
$this->position += strlen($string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function called by cURL for saving the response headers
|
||||
*
|
||||
* @param resource $ch cURL handle
|
||||
* @param string $string response header (with trailing CRLF)
|
||||
*
|
||||
* @return integer number of bytes saved
|
||||
* @see HTTP_Request2_Response::parseHeaderLine()
|
||||
*/
|
||||
protected function callbackWriteHeader($ch, $string)
|
||||
{
|
||||
if (!$this->eventSentHeaders
|
||||
// we may receive a second set of headers if doing e.g. digest auth
|
||||
// but don't bother with 100-Continue responses (bug #15785)
|
||||
|| $this->eventReceivedHeaders && $this->response->getStatus() >= 200
|
||||
) {
|
||||
$this->request->setLastEvent(
|
||||
'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT)
|
||||
);
|
||||
}
|
||||
if (!$this->eventSentBody) {
|
||||
$upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD);
|
||||
// if body wasn't read by the callback, send event with total body size
|
||||
if ($upload > $this->position) {
|
||||
$this->request->setLastEvent(
|
||||
'sentBodyPart', $upload - $this->position
|
||||
);
|
||||
}
|
||||
if ($upload > 0) {
|
||||
$this->request->setLastEvent('sentBody', $upload);
|
||||
}
|
||||
}
|
||||
$this->eventSentHeaders = true;
|
||||
$this->eventSentBody = true;
|
||||
|
||||
if ($this->eventReceivedHeaders || empty($this->response)) {
|
||||
$this->eventReceivedHeaders = false;
|
||||
$this->response = new HTTP_Request2_Response(
|
||||
$string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)
|
||||
);
|
||||
|
||||
} else {
|
||||
$this->response->parseHeaderLine($string);
|
||||
if ('' == trim($string)) {
|
||||
// don't bother with 100-Continue responses (bug #15785)
|
||||
if (200 <= $this->response->getStatus()) {
|
||||
$this->request->setLastEvent('receivedHeaders', $this->response);
|
||||
}
|
||||
|
||||
if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) {
|
||||
$redirectUrl = new Net_URL2($this->response->getHeader('location'));
|
||||
|
||||
// for versions lower than 5.2.10, check the redirection URL protocol
|
||||
if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute()
|
||||
&& !in_array($redirectUrl->getScheme(), array('http', 'https'))
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($jar = $this->request->getCookieJar()) {
|
||||
$jar->addCookiesFromResponse($this->response);
|
||||
if (!$redirectUrl->isAbsolute()) {
|
||||
$redirectUrl = $this->request->getUrl()->resolve($redirectUrl);
|
||||
}
|
||||
if ($cookies = $jar->getMatching($redirectUrl, true)) {
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->eventReceivedHeaders = true;
|
||||
$this->eventSentBody = false;
|
||||
}
|
||||
}
|
||||
return strlen($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function called by cURL for saving the response body
|
||||
*
|
||||
* @param resource $ch cURL handle (not used)
|
||||
* @param string $string part of the response body
|
||||
*
|
||||
* @return integer number of bytes saved
|
||||
* @throws HTTP_Request2_MessageException
|
||||
* @see HTTP_Request2_Response::appendBody()
|
||||
*/
|
||||
protected function callbackWriteBody($ch, $string)
|
||||
{
|
||||
// cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if
|
||||
// response doesn't start with proper HTTP status line (see bug #15716)
|
||||
if (empty($this->response)) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
"Malformed response: {$string}",
|
||||
HTTP_Request2_Exception::MALFORMED_RESPONSE
|
||||
);
|
||||
}
|
||||
if ($this->request->getConfig('store_body')) {
|
||||
$this->response->appendBody($string);
|
||||
}
|
||||
$this->request->setLastEvent('receivedBodyPart', $string);
|
||||
return strlen($string);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Mock adapter intended for testing
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for HTTP_Request2 adapters
|
||||
*/
|
||||
require_once 'HTTP/Request2/Adapter.php';
|
||||
|
||||
/**
|
||||
* Mock adapter intended for testing
|
||||
*
|
||||
* Can be used to test applications depending on HTTP_Request2 package without
|
||||
* actually performing any HTTP requests. This adapter will return responses
|
||||
* previously added via addResponse()
|
||||
* <code>
|
||||
* $mock = new HTTP_Request2_Adapter_Mock();
|
||||
* $mock->addResponse("HTTP/1.1 ... ");
|
||||
*
|
||||
* $request = new HTTP_Request2();
|
||||
* $request->setAdapter($mock);
|
||||
*
|
||||
* // This will return the response set above
|
||||
* $response = $req->send();
|
||||
* </code>
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter
|
||||
{
|
||||
/**
|
||||
* A queue of responses to be returned by sendRequest()
|
||||
* @var array
|
||||
*/
|
||||
protected $responses = array();
|
||||
|
||||
/**
|
||||
* Returns the next response from the queue built by addResponse()
|
||||
*
|
||||
* Only responses without explicit URLs or with URLs equal to request URL
|
||||
* will be considered. If matching response is not found or the queue is
|
||||
* empty then default empty response with status 400 will be returned,
|
||||
* if an Exception object was added to the queue it will be thrown.
|
||||
*
|
||||
* @param HTTP_Request2 $request HTTP request message
|
||||
*
|
||||
* @return HTTP_Request2_Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendRequest(HTTP_Request2 $request)
|
||||
{
|
||||
$requestUrl = (string)$request->getUrl();
|
||||
$response = null;
|
||||
foreach ($this->responses as $k => $v) {
|
||||
if (!$v[1] || $requestUrl == $v[1]) {
|
||||
$response = $v[0];
|
||||
array_splice($this->responses, $k, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$response) {
|
||||
return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n");
|
||||
|
||||
} elseif ($response instanceof HTTP_Request2_Response) {
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
// rethrow the exception
|
||||
$class = get_class($response);
|
||||
$message = $response->getMessage();
|
||||
$code = $response->getCode();
|
||||
throw new $class($message, $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds response to the queue
|
||||
*
|
||||
* @param mixed $response either a string, a pointer to an open file,
|
||||
* an instance of HTTP_Request2_Response or Exception
|
||||
* @param string $url A request URL this response should be valid for
|
||||
* (see {@link http://pear.php.net/bugs/bug.php?id=19276})
|
||||
*
|
||||
* @throws HTTP_Request2_Exception
|
||||
*/
|
||||
public function addResponse($response, $url = null)
|
||||
{
|
||||
if (is_string($response)) {
|
||||
$response = self::createResponseFromString($response);
|
||||
} elseif (is_resource($response)) {
|
||||
$response = self::createResponseFromFile($response);
|
||||
} elseif (!$response instanceof HTTP_Request2_Response &&
|
||||
!$response instanceof Exception
|
||||
) {
|
||||
throw new HTTP_Request2_Exception('Parameter is not a valid response');
|
||||
}
|
||||
$this->responses[] = array($response, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HTTP_Request2_Response object from a string
|
||||
*
|
||||
* @param string $str string containing HTTP response message
|
||||
*
|
||||
* @return HTTP_Request2_Response
|
||||
* @throws HTTP_Request2_Exception
|
||||
*/
|
||||
public static function createResponseFromString($str)
|
||||
{
|
||||
$parts = preg_split('!(\r?\n){2}!m', $str, 2);
|
||||
$headerLines = explode("\n", $parts[0]);
|
||||
$response = new HTTP_Request2_Response(array_shift($headerLines));
|
||||
foreach ($headerLines as $headerLine) {
|
||||
$response->parseHeaderLine($headerLine);
|
||||
}
|
||||
$response->parseHeaderLine('');
|
||||
if (isset($parts[1])) {
|
||||
$response->appendBody($parts[1]);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HTTP_Request2_Response object from a file
|
||||
*
|
||||
* @param resource $fp file pointer returned by fopen()
|
||||
*
|
||||
* @return HTTP_Request2_Response
|
||||
* @throws HTTP_Request2_Exception
|
||||
*/
|
||||
public static function createResponseFromFile($fp)
|
||||
{
|
||||
$response = new HTTP_Request2_Response(fgets($fp));
|
||||
do {
|
||||
$headerLine = fgets($fp);
|
||||
$response->parseHeaderLine($headerLine);
|
||||
} while ('' != trim($headerLine));
|
||||
|
||||
while (!feof($fp)) {
|
||||
$response->appendBody(fread($fp, 8192));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
/**
|
||||
* Stores cookies and passes them between HTTP requests
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/** Class representing a HTTP request message */
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
/**
|
||||
* Stores cookies and passes them between HTTP requests
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_CookieJar implements Serializable
|
||||
{
|
||||
/**
|
||||
* Array of stored cookies
|
||||
*
|
||||
* The array is indexed by domain, path and cookie name
|
||||
* .example.com
|
||||
* /
|
||||
* some_cookie => cookie data
|
||||
* /subdir
|
||||
* other_cookie => cookie data
|
||||
* .example.org
|
||||
* ...
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cookies = array();
|
||||
|
||||
/**
|
||||
* Whether session cookies should be serialized when serializing the jar
|
||||
* @var bool
|
||||
*/
|
||||
protected $serializeSession = false;
|
||||
|
||||
/**
|
||||
* Whether Public Suffix List should be used for domain matching
|
||||
* @var bool
|
||||
*/
|
||||
protected $useList = true;
|
||||
|
||||
/**
|
||||
* Whether an attempt to store an invalid cookie should be ignored, rather than cause an Exception
|
||||
* @var bool
|
||||
*/
|
||||
protected $ignoreInvalid = false;
|
||||
|
||||
/**
|
||||
* Array with Public Suffix List data
|
||||
* @var array
|
||||
* @link http://publicsuffix.org/
|
||||
*/
|
||||
protected static $psl = array();
|
||||
|
||||
/**
|
||||
* Class constructor, sets various options
|
||||
*
|
||||
* @param bool $serializeSessionCookies Controls serializing session cookies,
|
||||
* see {@link serializeSessionCookies()}
|
||||
* @param bool $usePublicSuffixList Controls using Public Suffix List,
|
||||
* see {@link usePublicSuffixList()}
|
||||
* @param bool $ignoreInvalidCookies Whether invalid cookies should be ignored,
|
||||
* see {@link ignoreInvalidCookies()}
|
||||
*/
|
||||
public function __construct(
|
||||
$serializeSessionCookies = false, $usePublicSuffixList = true,
|
||||
$ignoreInvalidCookies = false
|
||||
) {
|
||||
$this->serializeSessionCookies($serializeSessionCookies);
|
||||
$this->usePublicSuffixList($usePublicSuffixList);
|
||||
$this->ignoreInvalidCookies($ignoreInvalidCookies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current time formatted in ISO-8601 at UTC timezone
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function now()
|
||||
{
|
||||
$dt = new DateTime();
|
||||
$dt->setTimezone(new DateTimeZone('UTC'));
|
||||
return $dt->format(DateTime::ISO8601);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields
|
||||
*
|
||||
* The checks are as follows:
|
||||
* - cookie array should contain 'name' and 'value' fields;
|
||||
* - name and value should not contain disallowed symbols;
|
||||
* - 'expires' should be either empty parseable by DateTime;
|
||||
* - 'domain' and 'path' should be either not empty or an URL where
|
||||
* cookie was set should be provided.
|
||||
* - if $setter is provided, then document at that URL should be allowed
|
||||
* to set a cookie for that 'domain'. If $setter is not provided,
|
||||
* then no domain checks will be made.
|
||||
*
|
||||
* 'expires' field will be converted to ISO8601 format from COOKIE format,
|
||||
* 'domain' and 'path' will be set from setter URL if empty.
|
||||
*
|
||||
* @param array $cookie cookie data, as returned by
|
||||
* {@link HTTP_Request2_Response::getCookies()}
|
||||
* @param Net_URL2 $setter URL of the document that sent Set-Cookie header
|
||||
*
|
||||
* @return array Updated cookie array
|
||||
* @throws HTTP_Request2_LogicException
|
||||
* @throws HTTP_Request2_MessageException
|
||||
*/
|
||||
protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null)
|
||||
{
|
||||
if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
"Cookie array should contain 'name' and 'value' fields",
|
||||
HTTP_Request2_Exception::MISSING_VALUE
|
||||
);
|
||||
}
|
||||
if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['name'])) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
"Invalid cookie name: '{$cookie['name']}'",
|
||||
HTTP_Request2_Exception::INVALID_ARGUMENT
|
||||
);
|
||||
}
|
||||
if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['value'])) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
"Invalid cookie value: '{$cookie['value']}'",
|
||||
HTTP_Request2_Exception::INVALID_ARGUMENT
|
||||
);
|
||||
}
|
||||
$cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false);
|
||||
|
||||
// Need ISO-8601 date @ UTC timezone
|
||||
if (!empty($cookie['expires'])
|
||||
&& !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie['expires'])
|
||||
) {
|
||||
try {
|
||||
$dt = new DateTime($cookie['expires']);
|
||||
$dt->setTimezone(new DateTimeZone('UTC'));
|
||||
$cookie['expires'] = $dt->format(DateTime::ISO8601);
|
||||
} catch (Exception $e) {
|
||||
throw new HTTP_Request2_LogicException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($cookie['domain']) || empty($cookie['path'])) {
|
||||
if (!$setter) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Cookie misses domain and/or path component, cookie setter URL needed',
|
||||
HTTP_Request2_Exception::MISSING_VALUE
|
||||
);
|
||||
}
|
||||
if (empty($cookie['domain'])) {
|
||||
if ($host = $setter->getHost()) {
|
||||
$cookie['domain'] = $host;
|
||||
} else {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Setter URL does not contain host part, can\'t set cookie domain',
|
||||
HTTP_Request2_Exception::MISSING_VALUE
|
||||
);
|
||||
}
|
||||
}
|
||||
if (empty($cookie['path'])) {
|
||||
$path = $setter->getPath();
|
||||
$cookie['path'] = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($setter && !$this->domainMatch($setter->getHost(), $cookie['domain'])) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
"Domain " . $setter->getHost() . " cannot set cookies for "
|
||||
. $cookie['domain']
|
||||
);
|
||||
}
|
||||
|
||||
return $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a cookie in the jar
|
||||
*
|
||||
* @param array $cookie cookie data, as returned by
|
||||
* {@link HTTP_Request2_Response::getCookies()}
|
||||
* @param Net_URL2 $setter URL of the document that sent Set-Cookie header
|
||||
*
|
||||
* @return bool whether the cookie was successfully stored
|
||||
* @throws HTTP_Request2_Exception
|
||||
*/
|
||||
public function store(array $cookie, Net_URL2 $setter = null)
|
||||
{
|
||||
try {
|
||||
$cookie = $this->checkAndUpdateFields($cookie, $setter);
|
||||
} catch (HTTP_Request2_Exception $e) {
|
||||
if ($this->ignoreInvalid) {
|
||||
return false;
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($cookie['value'])
|
||||
&& (is_null($cookie['expires']) || $cookie['expires'] > $this->now())
|
||||
) {
|
||||
if (!isset($this->cookies[$cookie['domain']])) {
|
||||
$this->cookies[$cookie['domain']] = array();
|
||||
}
|
||||
if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) {
|
||||
$this->cookies[$cookie['domain']][$cookie['path']] = array();
|
||||
}
|
||||
$this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie;
|
||||
|
||||
} elseif (isset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']])) {
|
||||
unset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds cookies set in HTTP response to the jar
|
||||
*
|
||||
* @param HTTP_Request2_Response $response HTTP response message
|
||||
* @param Net_URL2 $setter original request URL, needed for
|
||||
* setting default domain/path. If not given,
|
||||
* effective URL from response will be used.
|
||||
*
|
||||
* @return bool whether all cookies were successfully stored
|
||||
* @throws HTTP_Request2_LogicException
|
||||
*/
|
||||
public function addCookiesFromResponse(HTTP_Request2_Response $response, Net_URL2 $setter = null)
|
||||
{
|
||||
if (null === $setter) {
|
||||
if (!($effectiveUrl = $response->getEffectiveUrl())) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Response URL required for adding cookies from response',
|
||||
HTTP_Request2_Exception::MISSING_VALUE
|
||||
);
|
||||
}
|
||||
$setter = new Net_URL2($effectiveUrl);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($response->getCookies() as $cookie) {
|
||||
$success = $this->store($cookie, $setter) && $success;
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all cookies matching a given request URL
|
||||
*
|
||||
* The following checks are made:
|
||||
* - cookie domain should match request host
|
||||
* - cookie path should be a prefix for request path
|
||||
* - 'secure' cookies will only be sent for HTTPS requests
|
||||
*
|
||||
* @param Net_URL2 $url Request url
|
||||
* @param bool $asString Whether to return cookies as string for "Cookie: " header
|
||||
*
|
||||
* @return array|string Matching cookies
|
||||
*/
|
||||
public function getMatching(Net_URL2 $url, $asString = false)
|
||||
{
|
||||
$host = $url->getHost();
|
||||
$path = $url->getPath();
|
||||
$secure = 0 == strcasecmp($url->getScheme(), 'https');
|
||||
|
||||
$matched = $ret = array();
|
||||
foreach (array_keys($this->cookies) as $domain) {
|
||||
if ($this->domainMatch($host, $domain)) {
|
||||
foreach (array_keys($this->cookies[$domain]) as $cPath) {
|
||||
if (0 === strpos($path, $cPath)) {
|
||||
foreach ($this->cookies[$domain][$cPath] as $name => $cookie) {
|
||||
if (!$cookie['secure'] || $secure) {
|
||||
$matched[$name][strlen($cookie['path'])] = $cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($matched as $cookies) {
|
||||
krsort($cookies);
|
||||
$ret = array_merge($ret, $cookies);
|
||||
}
|
||||
if (!$asString) {
|
||||
return $ret;
|
||||
} else {
|
||||
$str = '';
|
||||
foreach ($ret as $c) {
|
||||
$str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value'];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all cookies stored in a jar
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$cookies = array();
|
||||
foreach (array_keys($this->cookies) as $domain) {
|
||||
foreach (array_keys($this->cookies[$domain]) as $path) {
|
||||
foreach ($this->cookies[$domain][$path] as $name => $cookie) {
|
||||
$cookies[] = $cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether session cookies should be serialized when serializing the jar
|
||||
*
|
||||
* @param boolean $serialize serialize?
|
||||
*/
|
||||
public function serializeSessionCookies($serialize)
|
||||
{
|
||||
$this->serializeSession = (bool)$serialize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether invalid cookies should be silently ignored or cause an Exception
|
||||
*
|
||||
* @param boolean $ignore ignore?
|
||||
* @link http://pear.php.net/bugs/bug.php?id=19937
|
||||
* @link http://pear.php.net/bugs/bug.php?id=20401
|
||||
*/
|
||||
public function ignoreInvalidCookies($ignore)
|
||||
{
|
||||
$this->ignoreInvalid = (bool)$ignore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether Public Suffix List should be used for restricting cookie-setting
|
||||
*
|
||||
* Without PSL {@link domainMatch()} will only prevent setting cookies for
|
||||
* top-level domains like '.com' or '.org'. However, it will not prevent
|
||||
* setting a cookie for '.co.uk' even though only third-level registrations
|
||||
* are possible in .uk domain.
|
||||
*
|
||||
* With the List it is possible to find the highest level at which a domain
|
||||
* may be registered for a particular top-level domain and consequently
|
||||
* prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by
|
||||
* Firefox, Chrome and Opera browsers to restrict cookie setting.
|
||||
*
|
||||
* Note that PSL is licensed differently to HTTP_Request2 package (refer to
|
||||
* the license information in public-suffix-list.php), so you can disable
|
||||
* its use if this is an issue for you.
|
||||
*
|
||||
* @param boolean $useList use the list?
|
||||
*
|
||||
* @link http://publicsuffix.org/learn/
|
||||
*/
|
||||
public function usePublicSuffixList($useList)
|
||||
{
|
||||
$this->useList = (bool)$useList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string representation of object
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see Serializable::serialize()
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
$cookies = $this->getAll();
|
||||
if (!$this->serializeSession) {
|
||||
for ($i = count($cookies) - 1; $i >= 0; $i--) {
|
||||
if (empty($cookies[$i]['expires'])) {
|
||||
unset($cookies[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return serialize(array(
|
||||
'cookies' => $cookies,
|
||||
'serializeSession' => $this->serializeSession,
|
||||
'useList' => $this->useList,
|
||||
'ignoreInvalid' => $this->ignoreInvalid
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the object from serialized string
|
||||
*
|
||||
* @param string $serialized string representation
|
||||
*
|
||||
* @see Serializable::unserialize()
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$data = unserialize($serialized);
|
||||
$now = $this->now();
|
||||
$this->serializeSessionCookies($data['serializeSession']);
|
||||
$this->usePublicSuffixList($data['useList']);
|
||||
if (array_key_exists('ignoreInvalid', $data)) {
|
||||
$this->ignoreInvalidCookies($data['ignoreInvalid']);
|
||||
}
|
||||
foreach ($data['cookies'] as $cookie) {
|
||||
if (!empty($cookie['expires']) && $cookie['expires'] <= $now) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($this->cookies[$cookie['domain']])) {
|
||||
$this->cookies[$cookie['domain']] = array();
|
||||
}
|
||||
if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) {
|
||||
$this->cookies[$cookie['domain']][$cookie['path']] = array();
|
||||
}
|
||||
$this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a cookie domain matches a request host.
|
||||
*
|
||||
* The method is used by {@link store()} to check for whether a document
|
||||
* at given URL can set a cookie with a given domain attribute and by
|
||||
* {@link getMatching()} to find cookies matching the request URL.
|
||||
*
|
||||
* @param string $requestHost request host
|
||||
* @param string $cookieDomain cookie domain
|
||||
*
|
||||
* @return bool match success
|
||||
*/
|
||||
public function domainMatch($requestHost, $cookieDomain)
|
||||
{
|
||||
if ($requestHost == $cookieDomain) {
|
||||
return true;
|
||||
}
|
||||
// IP address, we require exact match
|
||||
if (preg_match('/^(?:\d{1,3}\.){3}\d{1,3}$/', $requestHost)) {
|
||||
return false;
|
||||
}
|
||||
if ('.' != $cookieDomain[0]) {
|
||||
$cookieDomain = '.' . $cookieDomain;
|
||||
}
|
||||
// prevents setting cookies for '.com' and similar domains
|
||||
if (!$this->useList && substr_count($cookieDomain, '.') < 2
|
||||
|| $this->useList && !self::getRegisteredDomain($cookieDomain)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return substr('.' . $requestHost, -strlen($cookieDomain)) == $cookieDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes subdomains to get the registered domain (the first after top-level)
|
||||
*
|
||||
* The method will check Public Suffix List to find out where top-level
|
||||
* domain ends and registered domain starts. It will remove domain parts
|
||||
* to the left of registered one.
|
||||
*
|
||||
* @param string $domain domain name
|
||||
*
|
||||
* @return string|bool registered domain, will return false if $domain is
|
||||
* either invalid or a TLD itself
|
||||
*/
|
||||
public static function getRegisteredDomain($domain)
|
||||
{
|
||||
$domainParts = explode('.', ltrim($domain, '.'));
|
||||
|
||||
// load the list if needed
|
||||
if (empty(self::$psl)) {
|
||||
$path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2';
|
||||
if (0 === strpos($path, '@' . 'data_dir@')) {
|
||||
$path = realpath(
|
||||
dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'
|
||||
. DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data'
|
||||
);
|
||||
}
|
||||
self::$psl = include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php';
|
||||
}
|
||||
|
||||
if (!($result = self::checkDomainsList($domainParts, self::$psl))) {
|
||||
// known TLD, invalid domain name
|
||||
return false;
|
||||
}
|
||||
|
||||
// unknown TLD
|
||||
if (!strpos($result, '.')) {
|
||||
// fallback to checking that domain "has at least two dots"
|
||||
if (2 > ($count = count($domainParts))) {
|
||||
return false;
|
||||
}
|
||||
return $domainParts[$count - 2] . '.' . $domainParts[$count - 1];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive helper method for {@link getRegisteredDomain()}
|
||||
*
|
||||
* @param array $domainParts remaining domain parts
|
||||
* @param mixed $listNode node in {@link HTTP_Request2_CookieJar::$psl} to check
|
||||
*
|
||||
* @return string|null concatenated domain parts, null in case of error
|
||||
*/
|
||||
protected static function checkDomainsList(array $domainParts, $listNode)
|
||||
{
|
||||
$sub = array_pop($domainParts);
|
||||
$result = null;
|
||||
|
||||
if (!is_array($listNode) || is_null($sub)
|
||||
|| array_key_exists('!' . $sub, $listNode)
|
||||
) {
|
||||
return $sub;
|
||||
|
||||
} elseif (array_key_exists($sub, $listNode)) {
|
||||
$result = self::checkDomainsList($domainParts, $listNode[$sub]);
|
||||
|
||||
} elseif (array_key_exists('*', $listNode)) {
|
||||
$result = self::checkDomainsList($domainParts, $listNode['*']);
|
||||
|
||||
} else {
|
||||
return $sub;
|
||||
}
|
||||
|
||||
return (strlen($result) > 0) ? ($result . '.' . $sub) : null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception classes for HTTP_Request2 package
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for exceptions in PEAR
|
||||
*/
|
||||
require_once 'PEAR/Exception.php';
|
||||
|
||||
/**
|
||||
* Base exception class for HTTP_Request2 package
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132
|
||||
*/
|
||||
class HTTP_Request2_Exception extends PEAR_Exception
|
||||
{
|
||||
/** An invalid argument was passed to a method */
|
||||
const INVALID_ARGUMENT = 1;
|
||||
/** Some required value was not available */
|
||||
const MISSING_VALUE = 2;
|
||||
/** Request cannot be processed due to errors in PHP configuration */
|
||||
const MISCONFIGURATION = 3;
|
||||
/** Error reading the local file */
|
||||
const READ_ERROR = 4;
|
||||
|
||||
/** Server returned a response that does not conform to HTTP protocol */
|
||||
const MALFORMED_RESPONSE = 10;
|
||||
/** Failure decoding Content-Encoding or Transfer-Encoding of response */
|
||||
const DECODE_ERROR = 20;
|
||||
/** Operation timed out */
|
||||
const TIMEOUT = 30;
|
||||
/** Number of redirects exceeded 'max_redirects' configuration parameter */
|
||||
const TOO_MANY_REDIRECTS = 40;
|
||||
/** Redirect to a protocol other than http(s):// */
|
||||
const NON_HTTP_REDIRECT = 50;
|
||||
|
||||
/**
|
||||
* Native error code
|
||||
* @var int
|
||||
*/
|
||||
private $_nativeCode;
|
||||
|
||||
/**
|
||||
* Constructor, can set package error code and native error code
|
||||
*
|
||||
* @param string $message exception message
|
||||
* @param int $code package error code, one of class constants
|
||||
* @param int $nativeCode error code from underlying PHP extension
|
||||
*/
|
||||
public function __construct($message = null, $code = null, $nativeCode = null)
|
||||
{
|
||||
parent::__construct($message, $code);
|
||||
$this->_nativeCode = $nativeCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns error code produced by underlying PHP extension
|
||||
*
|
||||
* For Socket Adapter this may contain error number returned by
|
||||
* stream_socket_client(), for Curl Adapter this will contain error number
|
||||
* returned by curl_errno()
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getNativeCode()
|
||||
{
|
||||
return $this->_nativeCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown in case of missing features
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception that represents error in the program logic
|
||||
*
|
||||
* This exception usually implies a programmer's error, like passing invalid
|
||||
* data to methods or trying to use PHP extensions that weren't installed or
|
||||
* enabled. Usually exceptions of this kind will be thrown before request even
|
||||
* starts.
|
||||
*
|
||||
* The exception will usually contain a package error code.
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_LogicException extends HTTP_Request2_Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when connection to a web or proxy server fails
|
||||
*
|
||||
* The exception will not contain a package error code, but will contain
|
||||
* native error code, as returned by stream_socket_client() or curl_errno().
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when sending or receiving HTTP message fails
|
||||
*
|
||||
* The exception may contain both package error code and native error code.
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_MessageException extends HTTP_Request2_Exception
|
||||
{
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* Helper class for building multipart/form-data request body
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/** Exception class for HTTP_Request2 package */
|
||||
require_once 'HTTP/Request2/Exception.php';
|
||||
|
||||
/**
|
||||
* Class for building multipart/form-data request body
|
||||
*
|
||||
* The class helps to reduce memory consumption by streaming large file uploads
|
||||
* from disk, it also allows monitoring of upload progress (see request #7630)
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
* @link http://tools.ietf.org/html/rfc1867
|
||||
*/
|
||||
class HTTP_Request2_MultipartBody
|
||||
{
|
||||
/**
|
||||
* MIME boundary
|
||||
* @var string
|
||||
*/
|
||||
private $_boundary;
|
||||
|
||||
/**
|
||||
* Form parameters added via {@link HTTP_Request2::addPostParameter()}
|
||||
* @var array
|
||||
*/
|
||||
private $_params = array();
|
||||
|
||||
/**
|
||||
* File uploads added via {@link HTTP_Request2::addUpload()}
|
||||
* @var array
|
||||
*/
|
||||
private $_uploads = array();
|
||||
|
||||
/**
|
||||
* Header for parts with parameters
|
||||
* @var string
|
||||
*/
|
||||
private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n";
|
||||
|
||||
/**
|
||||
* Header for parts with uploads
|
||||
* @var string
|
||||
*/
|
||||
private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n";
|
||||
|
||||
/**
|
||||
* Current position in parameter and upload arrays
|
||||
*
|
||||
* First number is index of "current" part, second number is position within
|
||||
* "current" part
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_pos = array(0, 0);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor. Sets the arrays with POST data.
|
||||
*
|
||||
* @param array $params values of form fields set via
|
||||
* {@link HTTP_Request2::addPostParameter()}
|
||||
* @param array $uploads file uploads set via
|
||||
* {@link HTTP_Request2::addUpload()}
|
||||
* @param bool $useBrackets whether to append brackets to array variable names
|
||||
*/
|
||||
public function __construct(array $params, array $uploads, $useBrackets = true)
|
||||
{
|
||||
$this->_params = self::_flattenArray('', $params, $useBrackets);
|
||||
foreach ($uploads as $fieldName => $f) {
|
||||
if (!is_array($f['fp'])) {
|
||||
$this->_uploads[] = $f + array('name' => $fieldName);
|
||||
} else {
|
||||
for ($i = 0; $i < count($f['fp']); $i++) {
|
||||
$upload = array(
|
||||
'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName)
|
||||
);
|
||||
foreach (array('fp', 'filename', 'size', 'type') as $key) {
|
||||
$upload[$key] = $f[$key][$i];
|
||||
}
|
||||
$this->_uploads[] = $upload;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the body to use in Content-Length header
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
$boundaryLength = strlen($this->getBoundary());
|
||||
$headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength;
|
||||
$headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength;
|
||||
$length = $boundaryLength + 6;
|
||||
foreach ($this->_params as $p) {
|
||||
$length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2;
|
||||
}
|
||||
foreach ($this->_uploads as $u) {
|
||||
$length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) +
|
||||
strlen($u['filename']) + $u['size'] + 2;
|
||||
}
|
||||
return $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boundary to use in Content-Type header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBoundary()
|
||||
{
|
||||
if (empty($this->_boundary)) {
|
||||
$this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime());
|
||||
}
|
||||
return $this->_boundary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns next chunk of request body
|
||||
*
|
||||
* @param integer $length Number of bytes to read
|
||||
*
|
||||
* @return string Up to $length bytes of data, empty string if at end
|
||||
* @throws HTTP_Request2_LogicException
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
$ret = '';
|
||||
$boundary = $this->getBoundary();
|
||||
$paramCount = count($this->_params);
|
||||
$uploadCount = count($this->_uploads);
|
||||
while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) {
|
||||
$oldLength = $length;
|
||||
if ($this->_pos[0] < $paramCount) {
|
||||
$param = sprintf(
|
||||
$this->_headerParam, $boundary, $this->_params[$this->_pos[0]][0]
|
||||
) . $this->_params[$this->_pos[0]][1] . "\r\n";
|
||||
$ret .= substr($param, $this->_pos[1], $length);
|
||||
$length -= min(strlen($param) - $this->_pos[1], $length);
|
||||
|
||||
} elseif ($this->_pos[0] < $paramCount + $uploadCount) {
|
||||
$pos = $this->_pos[0] - $paramCount;
|
||||
$header = sprintf(
|
||||
$this->_headerUpload, $boundary, $this->_uploads[$pos]['name'],
|
||||
$this->_uploads[$pos]['filename'], $this->_uploads[$pos]['type']
|
||||
);
|
||||
if ($this->_pos[1] < strlen($header)) {
|
||||
$ret .= substr($header, $this->_pos[1], $length);
|
||||
$length -= min(strlen($header) - $this->_pos[1], $length);
|
||||
}
|
||||
$filePos = max(0, $this->_pos[1] - strlen($header));
|
||||
if ($filePos < $this->_uploads[$pos]['size']) {
|
||||
while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) {
|
||||
if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR
|
||||
);
|
||||
}
|
||||
$ret .= $chunk;
|
||||
$length -= strlen($chunk);
|
||||
}
|
||||
}
|
||||
if ($length > 0) {
|
||||
$start = $this->_pos[1] + ($oldLength - $length) -
|
||||
strlen($header) - $this->_uploads[$pos]['size'];
|
||||
$ret .= substr("\r\n", $start, $length);
|
||||
$length -= min(2 - $start, $length);
|
||||
}
|
||||
|
||||
} else {
|
||||
$closing = '--' . $boundary . "--\r\n";
|
||||
$ret .= substr($closing, $this->_pos[1], $length);
|
||||
$length -= min(strlen($closing) - $this->_pos[1], $length);
|
||||
}
|
||||
if ($length > 0) {
|
||||
$this->_pos = array($this->_pos[0] + 1, 0);
|
||||
} else {
|
||||
$this->_pos[1] += $oldLength;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current position to the start of the body
|
||||
*
|
||||
* This allows reusing the same body in another request
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->_pos = array(0, 0);
|
||||
foreach ($this->_uploads as $u) {
|
||||
rewind($u['fp']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the body as string
|
||||
*
|
||||
* Note that it reads all file uploads into memory so it is a good idea not
|
||||
* to use this method with large file uploads and rely on read() instead.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$this->rewind();
|
||||
return $this->read($this->getLength());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to change the (probably multidimensional) associative array
|
||||
* into the simple one.
|
||||
*
|
||||
* @param string $name name for item
|
||||
* @param mixed $values item's values
|
||||
* @param bool $useBrackets whether to append [] to array variables' names
|
||||
*
|
||||
* @return array array with the following items: array('item name', 'item value');
|
||||
*/
|
||||
private static function _flattenArray($name, $values, $useBrackets)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
return array(array($name, $values));
|
||||
} else {
|
||||
$ret = array();
|
||||
foreach ($values as $k => $v) {
|
||||
if (empty($name)) {
|
||||
$newName = $k;
|
||||
} elseif ($useBrackets) {
|
||||
$newName = $name . '[' . $k . ']';
|
||||
} else {
|
||||
$newName = $name;
|
||||
}
|
||||
$ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* An observer useful for debugging / testing.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author David Jean Louis <izi@php.net>
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception class for HTTP_Request2 package
|
||||
*/
|
||||
require_once 'HTTP/Request2/Exception.php';
|
||||
|
||||
/**
|
||||
* A debug observer useful for debugging / testing.
|
||||
*
|
||||
* This observer logs to a log target data corresponding to the various request
|
||||
* and response events, it logs by default to php://output but can be configured
|
||||
* to log to a file or via the PEAR Log package.
|
||||
*
|
||||
* A simple example:
|
||||
* <code>
|
||||
* require_once 'HTTP/Request2.php';
|
||||
* require_once 'HTTP/Request2/Observer/Log.php';
|
||||
*
|
||||
* $request = new HTTP_Request2('http://www.example.com');
|
||||
* $observer = new HTTP_Request2_Observer_Log();
|
||||
* $request->attach($observer);
|
||||
* $request->send();
|
||||
* </code>
|
||||
*
|
||||
* A more complex example with PEAR Log:
|
||||
* <code>
|
||||
* require_once 'HTTP/Request2.php';
|
||||
* require_once 'HTTP/Request2/Observer/Log.php';
|
||||
* require_once 'Log.php';
|
||||
*
|
||||
* $request = new HTTP_Request2('http://www.example.com');
|
||||
* // we want to log with PEAR log
|
||||
* $observer = new HTTP_Request2_Observer_Log(Log::factory('console'));
|
||||
*
|
||||
* // we only want to log received headers
|
||||
* $observer->events = array('receivedHeaders');
|
||||
*
|
||||
* $request->attach($observer);
|
||||
* $request->send();
|
||||
* </code>
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author David Jean Louis <izi@php.net>
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_Observer_Log implements SplObserver
|
||||
{
|
||||
// properties {{{
|
||||
|
||||
/**
|
||||
* The log target, it can be a a resource or a PEAR Log instance.
|
||||
*
|
||||
* @var resource|Log $target
|
||||
*/
|
||||
protected $target = null;
|
||||
|
||||
/**
|
||||
* The events to log.
|
||||
*
|
||||
* @var array $events
|
||||
*/
|
||||
public $events = array(
|
||||
'connect',
|
||||
'sentHeaders',
|
||||
'sentBody',
|
||||
'receivedHeaders',
|
||||
'receivedBody',
|
||||
'disconnect',
|
||||
);
|
||||
|
||||
// }}}
|
||||
// __construct() {{{
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $target Can be a file path (default: php://output), a resource,
|
||||
* or an instance of the PEAR Log class.
|
||||
* @param array $events Array of events to listen to (default: all events)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($target = 'php://output', array $events = array())
|
||||
{
|
||||
if (!empty($events)) {
|
||||
$this->events = $events;
|
||||
}
|
||||
if (is_resource($target) || $target instanceof Log) {
|
||||
$this->target = $target;
|
||||
} elseif (false === ($this->target = @fopen($target, 'ab'))) {
|
||||
throw new HTTP_Request2_Exception("Unable to open '{$target}'");
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// update() {{{
|
||||
|
||||
/**
|
||||
* Called when the request notifies us of an event.
|
||||
*
|
||||
* @param HTTP_Request2 $subject The HTTP_Request2 instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update(SplSubject $subject)
|
||||
{
|
||||
$event = $subject->getLastEvent();
|
||||
if (!in_array($event['name'], $this->events)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($event['name']) {
|
||||
case 'connect':
|
||||
$this->log('* Connected to ' . $event['data']);
|
||||
break;
|
||||
case 'sentHeaders':
|
||||
$headers = explode("\r\n", $event['data']);
|
||||
array_pop($headers);
|
||||
foreach ($headers as $header) {
|
||||
$this->log('> ' . $header);
|
||||
}
|
||||
break;
|
||||
case 'sentBody':
|
||||
$this->log('> ' . $event['data'] . ' byte(s) sent');
|
||||
break;
|
||||
case 'receivedHeaders':
|
||||
$this->log(sprintf(
|
||||
'< HTTP/%s %s %s', $event['data']->getVersion(),
|
||||
$event['data']->getStatus(), $event['data']->getReasonPhrase()
|
||||
));
|
||||
$headers = $event['data']->getHeader();
|
||||
foreach ($headers as $key => $val) {
|
||||
$this->log('< ' . $key . ': ' . $val);
|
||||
}
|
||||
$this->log('< ');
|
||||
break;
|
||||
case 'receivedBody':
|
||||
$this->log($event['data']->getBody());
|
||||
break;
|
||||
case 'disconnect':
|
||||
$this->log('* Disconnected');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// log() {{{
|
||||
|
||||
/**
|
||||
* Logs the given message to the configured target.
|
||||
*
|
||||
* @param string $message Message to display
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function log($message)
|
||||
{
|
||||
if ($this->target instanceof Log) {
|
||||
$this->target->debug($message);
|
||||
} elseif (is_resource($this->target)) {
|
||||
fwrite($this->target, $message . "\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* An observer that saves response body to stream, possibly uncompressing it
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Delian Krustev <krustev@krustev.net>
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
require_once 'HTTP/Request2/Response.php';
|
||||
|
||||
/**
|
||||
* An observer that saves response body to stream, possibly uncompressing it
|
||||
*
|
||||
* This Observer is written in compliment to pear's HTTP_Request2 in order to
|
||||
* avoid reading the whole response body in memory. Instead it writes the body
|
||||
* to a stream. If the body is transferred with content-encoding set to
|
||||
* "deflate" or "gzip" it is decoded on the fly.
|
||||
*
|
||||
* The constructor accepts an already opened (for write) stream (file_descriptor).
|
||||
* If the response is deflate/gzip encoded a "zlib.inflate" filter is applied
|
||||
* to the stream. When the body has been read from the request and written to
|
||||
* the stream ("receivedBody" event) the filter is removed from the stream.
|
||||
*
|
||||
* The "zlib.inflate" filter works fine with pure "deflate" encoding. It does
|
||||
* not understand the "deflate+zlib" and "gzip" headers though, so they have to
|
||||
* be removed prior to being passed to the stream. This is done in the "update"
|
||||
* method.
|
||||
*
|
||||
* It is also possible to limit the size of written extracted bytes by passing
|
||||
* "max_bytes" to the constructor. This is important because e.g. 1GB of
|
||||
* zeroes take about a MB when compressed.
|
||||
*
|
||||
* Exceptions are being thrown if data could not be written to the stream or
|
||||
* the written bytes have already exceeded the requested maximum. If the "gzip"
|
||||
* header is malformed or could not be parsed an exception will be thrown too.
|
||||
*
|
||||
* Example usage follows:
|
||||
*
|
||||
* <code>
|
||||
* require_once 'HTTP/Request2.php';
|
||||
* require_once 'HTTP/Request2/Observer/UncompressingDownload.php';
|
||||
*
|
||||
* #$inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html';
|
||||
* #$inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html?deflate=on';
|
||||
* $inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html?deflate=on&zlib=on';
|
||||
* #$outPath = "/dev/null";
|
||||
* $outPath = "delme";
|
||||
*
|
||||
* $stream = fopen($outPath, 'wb');
|
||||
* if (!$stream) {
|
||||
* throw new Exception('fopen failed');
|
||||
* }
|
||||
*
|
||||
* $request = new HTTP_Request2(
|
||||
* $inPath,
|
||||
* HTTP_Request2::METHOD_GET,
|
||||
* array(
|
||||
* 'store_body' => false,
|
||||
* 'connect_timeout' => 5,
|
||||
* 'timeout' => 10,
|
||||
* 'ssl_verify_peer' => true,
|
||||
* 'ssl_verify_host' => true,
|
||||
* 'ssl_cafile' => null,
|
||||
* 'ssl_capath' => '/etc/ssl/certs',
|
||||
* 'max_redirects' => 10,
|
||||
* 'follow_redirects' => true,
|
||||
* 'strict_redirects' => false
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* $observer = new HTTP_Request2_Observer_UncompressingDownload($stream, 9999999);
|
||||
* $request->attach($observer);
|
||||
*
|
||||
* $response = $request->send();
|
||||
*
|
||||
* fclose($stream);
|
||||
* echo "OK\n";
|
||||
* </code>
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Delian Krustev <krustev@krustev.net>
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
class HTTP_Request2_Observer_UncompressingDownload implements SplObserver
|
||||
{
|
||||
/**
|
||||
* The stream to write response body to
|
||||
* @var resource
|
||||
*/
|
||||
private $_stream;
|
||||
|
||||
/**
|
||||
* zlib.inflate filter possibly added to stream
|
||||
* @var resource
|
||||
*/
|
||||
private $_streamFilter;
|
||||
|
||||
/**
|
||||
* The value of response's Content-Encoding header
|
||||
* @var string
|
||||
*/
|
||||
private $_encoding;
|
||||
|
||||
/**
|
||||
* Whether the observer is still waiting for gzip/deflate header
|
||||
* @var bool
|
||||
*/
|
||||
private $_processingHeader = true;
|
||||
|
||||
/**
|
||||
* Starting position in the stream observer writes to
|
||||
* @var int
|
||||
*/
|
||||
private $_startPosition = 0;
|
||||
|
||||
/**
|
||||
* Maximum bytes to write
|
||||
* @var int|null
|
||||
*/
|
||||
private $_maxDownloadSize;
|
||||
|
||||
/**
|
||||
* Whether response being received is a redirect
|
||||
* @var bool
|
||||
*/
|
||||
private $_redirect = false;
|
||||
|
||||
/**
|
||||
* Accumulated body chunks that may contain (gzip) header
|
||||
* @var string
|
||||
*/
|
||||
private $_possibleHeader = '';
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* Note that there might be problems with max_bytes and files bigger
|
||||
* than 2 GB on 32bit platforms
|
||||
*
|
||||
* @param resource $stream a stream (or file descriptor) opened for writing.
|
||||
* @param int $maxDownloadSize maximum bytes to write
|
||||
*/
|
||||
public function __construct($stream, $maxDownloadSize = null)
|
||||
{
|
||||
$this->_stream = $stream;
|
||||
if ($maxDownloadSize) {
|
||||
$this->_maxDownloadSize = $maxDownloadSize;
|
||||
$this->_startPosition = ftell($this->_stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the request notifies us of an event.
|
||||
*
|
||||
* @param SplSubject $request The HTTP_Request2 instance
|
||||
*
|
||||
* @return void
|
||||
* @throws HTTP_Request2_MessageException
|
||||
*/
|
||||
public function update(SplSubject $request)
|
||||
{
|
||||
/* @var $request HTTP_Request2 */
|
||||
$event = $request->getLastEvent();
|
||||
$encoded = false;
|
||||
|
||||
/* @var $event['data'] HTTP_Request2_Response */
|
||||
switch ($event['name']) {
|
||||
case 'receivedHeaders':
|
||||
$this->_processingHeader = true;
|
||||
$this->_redirect = $event['data']->isRedirect();
|
||||
$this->_encoding = strtolower($event['data']->getHeader('content-encoding'));
|
||||
$this->_possibleHeader = '';
|
||||
break;
|
||||
|
||||
case 'receivedEncodedBodyPart':
|
||||
if (!$this->_streamFilter
|
||||
&& ($this->_encoding === 'deflate' || $this->_encoding === 'gzip')
|
||||
) {
|
||||
$this->_streamFilter = stream_filter_append(
|
||||
$this->_stream, 'zlib.inflate', STREAM_FILTER_WRITE
|
||||
);
|
||||
}
|
||||
$encoded = true;
|
||||
// fall-through is intentional
|
||||
|
||||
case 'receivedBodyPart':
|
||||
if ($this->_redirect) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$encoded || !$this->_processingHeader) {
|
||||
$bytes = fwrite($this->_stream, $event['data']);
|
||||
|
||||
} else {
|
||||
$offset = 0;
|
||||
$this->_possibleHeader .= $event['data'];
|
||||
if ('deflate' === $this->_encoding) {
|
||||
if (2 > strlen($this->_possibleHeader)) {
|
||||
break;
|
||||
}
|
||||
$header = unpack('n', substr($this->_possibleHeader, 0, 2));
|
||||
if (0 == $header[1] % 31) {
|
||||
$offset = 2;
|
||||
}
|
||||
|
||||
} elseif ('gzip' === $this->_encoding) {
|
||||
if (10 > strlen($this->_possibleHeader)) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
$offset = HTTP_Request2_Response::parseGzipHeader($this->_possibleHeader, false);
|
||||
|
||||
} catch (HTTP_Request2_MessageException $e) {
|
||||
// need more data?
|
||||
if (false !== strpos($e->getMessage(), 'data too short')) {
|
||||
break;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_processingHeader = false;
|
||||
$bytes = fwrite($this->_stream, substr($this->_possibleHeader, $offset));
|
||||
}
|
||||
|
||||
if (false === $bytes) {
|
||||
throw new HTTP_Request2_MessageException('fwrite failed.');
|
||||
}
|
||||
|
||||
if ($this->_maxDownloadSize
|
||||
&& ftell($this->_stream) - $this->_startPosition > $this->_maxDownloadSize
|
||||
) {
|
||||
throw new HTTP_Request2_MessageException(sprintf(
|
||||
'Body length limit (%d bytes) reached',
|
||||
$this->_maxDownloadSize
|
||||
));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'receivedBody':
|
||||
if ($this->_streamFilter) {
|
||||
stream_filter_remove($this->_streamFilter);
|
||||
$this->_streamFilter = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,680 @@
|
||||
<?php
|
||||
/**
|
||||
* Class representing a HTTP response
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception class for HTTP_Request2 package
|
||||
*/
|
||||
require_once 'HTTP/Request2/Exception.php';
|
||||
|
||||
/**
|
||||
* Class representing a HTTP response
|
||||
*
|
||||
* The class is designed to be used in "streaming" scenario, building the
|
||||
* response as it is being received:
|
||||
* <code>
|
||||
* $statusLine = read_status_line();
|
||||
* $response = new HTTP_Request2_Response($statusLine);
|
||||
* do {
|
||||
* $headerLine = read_header_line();
|
||||
* $response->parseHeaderLine($headerLine);
|
||||
* } while ($headerLine != '');
|
||||
*
|
||||
* while ($chunk = read_body()) {
|
||||
* $response->appendBody($chunk);
|
||||
* }
|
||||
*
|
||||
* var_dump($response->getHeader(), $response->getCookies(), $response->getBody());
|
||||
* </code>
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
* @link http://tools.ietf.org/html/rfc2616#section-6
|
||||
*/
|
||||
class HTTP_Request2_Response
|
||||
{
|
||||
/**
|
||||
* HTTP protocol version (e.g. 1.0, 1.1)
|
||||
* @var string
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Status code
|
||||
* @var integer
|
||||
* @link http://tools.ietf.org/html/rfc2616#section-6.1.1
|
||||
*/
|
||||
protected $code;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
* @var string
|
||||
* @link http://tools.ietf.org/html/rfc2616#section-6.1.1
|
||||
*/
|
||||
protected $reasonPhrase;
|
||||
|
||||
/**
|
||||
* Effective URL (may be different from original request URL in case of redirects)
|
||||
* @var string
|
||||
*/
|
||||
protected $effectiveUrl;
|
||||
|
||||
/**
|
||||
* Associative array of response headers
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = array();
|
||||
|
||||
/**
|
||||
* Cookies set in the response
|
||||
* @var array
|
||||
*/
|
||||
protected $cookies = array();
|
||||
|
||||
/**
|
||||
* Name of last header processed by parseHederLine()
|
||||
*
|
||||
* Used to handle the headers that span multiple lines
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lastHeader = null;
|
||||
|
||||
/**
|
||||
* Response body
|
||||
* @var string
|
||||
*/
|
||||
protected $body = '';
|
||||
|
||||
/**
|
||||
* Whether the body is still encoded by Content-Encoding
|
||||
*
|
||||
* cURL provides the decoded body to the callback; if we are reading from
|
||||
* socket the body is still gzipped / deflated
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $bodyEncoded;
|
||||
|
||||
/**
|
||||
* Associative array of HTTP status code / reason phrase.
|
||||
*
|
||||
* @var array
|
||||
* @link http://tools.ietf.org/html/rfc2616#section-10
|
||||
*/
|
||||
protected static $phrases = array(
|
||||
|
||||
// 1xx: Informational - Request received, continuing process
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
|
||||
// 2xx: Success - The action was successfully received, understood and
|
||||
// accepted
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
202 => 'Accepted',
|
||||
203 => 'Non-Authoritative Information',
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
|
||||
// 3xx: Redirection - Further action must be taken in order to complete
|
||||
// the request
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found', // 1.1
|
||||
303 => 'See Other',
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
|
||||
// 4xx: Client Error - The request contains bad syntax or cannot be
|
||||
// fulfilled
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
402 => 'Payment Required',
|
||||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
406 => 'Not Acceptable',
|
||||
407 => 'Proxy Authentication Required',
|
||||
408 => 'Request Timeout',
|
||||
409 => 'Conflict',
|
||||
410 => 'Gone',
|
||||
411 => 'Length Required',
|
||||
412 => 'Precondition Failed',
|
||||
413 => 'Request Entity Too Large',
|
||||
414 => 'Request-URI Too Long',
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
|
||||
// 5xx: Server Error - The server failed to fulfill an apparently
|
||||
// valid request
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
502 => 'Bad Gateway',
|
||||
503 => 'Service Unavailable',
|
||||
504 => 'Gateway Timeout',
|
||||
505 => 'HTTP Version Not Supported',
|
||||
509 => 'Bandwidth Limit Exceeded',
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the default reason phrase for the given code or all reason phrases
|
||||
*
|
||||
* @param int $code Response code
|
||||
*
|
||||
* @return string|array|null Default reason phrase for $code if $code is given
|
||||
* (null if no phrase is available), array of all
|
||||
* reason phrases if $code is null
|
||||
* @link http://pear.php.net/bugs/18716
|
||||
*/
|
||||
public static function getDefaultReasonPhrase($code = null)
|
||||
{
|
||||
if (null === $code) {
|
||||
return self::$phrases;
|
||||
} else {
|
||||
return isset(self::$phrases[$code]) ? self::$phrases[$code] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor, parses the response status line
|
||||
*
|
||||
* @param string $statusLine Response status line (e.g. "HTTP/1.1 200 OK")
|
||||
* @param bool $bodyEncoded Whether body is still encoded by Content-Encoding
|
||||
* @param string $effectiveUrl Effective URL of the response
|
||||
*
|
||||
* @throws HTTP_Request2_MessageException if status line is invalid according to spec
|
||||
*/
|
||||
public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null)
|
||||
{
|
||||
if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
"Malformed response: {$statusLine}",
|
||||
HTTP_Request2_Exception::MALFORMED_RESPONSE
|
||||
);
|
||||
}
|
||||
$this->version = $m[1];
|
||||
$this->code = intval($m[2]);
|
||||
$this->reasonPhrase = !empty($m[3]) ? trim($m[3]) : self::getDefaultReasonPhrase($this->code);
|
||||
$this->bodyEncoded = (bool)$bodyEncoded;
|
||||
$this->effectiveUrl = (string)$effectiveUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the line from HTTP response filling $headers array
|
||||
*
|
||||
* The method should be called after reading the line from socket or receiving
|
||||
* it into cURL callback. Passing an empty string here indicates the end of
|
||||
* response headers and triggers additional processing, so be sure to pass an
|
||||
* empty string in the end.
|
||||
*
|
||||
* @param string $headerLine Line from HTTP response
|
||||
*/
|
||||
public function parseHeaderLine($headerLine)
|
||||
{
|
||||
$headerLine = trim($headerLine, "\r\n");
|
||||
|
||||
if ('' == $headerLine) {
|
||||
// empty string signals the end of headers, process the received ones
|
||||
if (!empty($this->headers['set-cookie'])) {
|
||||
$cookies = is_array($this->headers['set-cookie'])?
|
||||
$this->headers['set-cookie']:
|
||||
array($this->headers['set-cookie']);
|
||||
foreach ($cookies as $cookieString) {
|
||||
$this->parseCookie($cookieString);
|
||||
}
|
||||
unset($this->headers['set-cookie']);
|
||||
}
|
||||
foreach (array_keys($this->headers) as $k) {
|
||||
if (is_array($this->headers[$k])) {
|
||||
$this->headers[$k] = implode(', ', $this->headers[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
} elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) {
|
||||
// string of the form header-name: header value
|
||||
$name = strtolower($m[1]);
|
||||
$value = trim($m[2]);
|
||||
if (empty($this->headers[$name])) {
|
||||
$this->headers[$name] = $value;
|
||||
} else {
|
||||
if (!is_array($this->headers[$name])) {
|
||||
$this->headers[$name] = array($this->headers[$name]);
|
||||
}
|
||||
$this->headers[$name][] = $value;
|
||||
}
|
||||
$this->lastHeader = $name;
|
||||
|
||||
} elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) {
|
||||
// continuation of a previous header
|
||||
if (!is_array($this->headers[$this->lastHeader])) {
|
||||
$this->headers[$this->lastHeader] .= ' ' . trim($m[1]);
|
||||
} else {
|
||||
$key = count($this->headers[$this->lastHeader]) - 1;
|
||||
$this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a Set-Cookie header to fill $cookies array
|
||||
*
|
||||
* @param string $cookieString value of Set-Cookie header
|
||||
*
|
||||
* @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html
|
||||
*/
|
||||
protected function parseCookie($cookieString)
|
||||
{
|
||||
$cookie = array(
|
||||
'expires' => null,
|
||||
'domain' => null,
|
||||
'path' => null,
|
||||
'secure' => false
|
||||
);
|
||||
|
||||
if (!strpos($cookieString, ';')) {
|
||||
// Only a name=value pair
|
||||
$pos = strpos($cookieString, '=');
|
||||
$cookie['name'] = trim(substr($cookieString, 0, $pos));
|
||||
$cookie['value'] = trim(substr($cookieString, $pos + 1));
|
||||
|
||||
} else {
|
||||
// Some optional parameters are supplied
|
||||
$elements = explode(';', $cookieString);
|
||||
$pos = strpos($elements[0], '=');
|
||||
$cookie['name'] = trim(substr($elements[0], 0, $pos));
|
||||
$cookie['value'] = trim(substr($elements[0], $pos + 1));
|
||||
|
||||
for ($i = 1; $i < count($elements); $i++) {
|
||||
if (false === strpos($elements[$i], '=')) {
|
||||
$elName = trim($elements[$i]);
|
||||
$elValue = null;
|
||||
} else {
|
||||
list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i]));
|
||||
}
|
||||
$elName = strtolower($elName);
|
||||
if ('secure' == $elName) {
|
||||
$cookie['secure'] = true;
|
||||
} elseif ('expires' == $elName) {
|
||||
$cookie['expires'] = str_replace('"', '', $elValue);
|
||||
} elseif ('path' == $elName || 'domain' == $elName) {
|
||||
$cookie[$elName] = urldecode($elValue);
|
||||
} else {
|
||||
$cookie[$elName] = $elValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->cookies[] = $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a string to the response body
|
||||
*
|
||||
* @param string $bodyChunk part of response body
|
||||
*/
|
||||
public function appendBody($bodyChunk)
|
||||
{
|
||||
$this->body .= $bodyChunk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effective URL of the response
|
||||
*
|
||||
* This may be different from the request URL if redirects were followed.
|
||||
*
|
||||
* @return string
|
||||
* @link http://pear.php.net/bugs/bug.php?id=18412
|
||||
*/
|
||||
public function getEffectiveUrl()
|
||||
{
|
||||
return $this->effectiveUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status code
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason phrase
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReasonPhrase()
|
||||
{
|
||||
return $this->reasonPhrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether response is a redirect that can be automatically handled by HTTP_Request2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isRedirect()
|
||||
{
|
||||
return in_array($this->code, array(300, 301, 302, 303, 307))
|
||||
&& isset($this->headers['location']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns either the named header or all response headers
|
||||
*
|
||||
* @param string $headerName Name of header to return
|
||||
*
|
||||
* @return string|array Value of $headerName header (null if header is
|
||||
* not present), array of all response headers if
|
||||
* $headerName is null
|
||||
*/
|
||||
public function getHeader($headerName = null)
|
||||
{
|
||||
if (null === $headerName) {
|
||||
return $this->headers;
|
||||
} else {
|
||||
$headerName = strtolower($headerName);
|
||||
return isset($this->headers[$headerName])? $this->headers[$headerName]: null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cookies set in response
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCookies()
|
||||
{
|
||||
return $this->cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the body of the response
|
||||
*
|
||||
* @return string
|
||||
* @throws HTTP_Request2_Exception if body cannot be decoded
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
if (0 == strlen($this->body) || !$this->bodyEncoded
|
||||
|| !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate'))
|
||||
) {
|
||||
return $this->body;
|
||||
|
||||
} else {
|
||||
if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) {
|
||||
$oldEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('8bit');
|
||||
}
|
||||
|
||||
try {
|
||||
switch (strtolower($this->getHeader('content-encoding'))) {
|
||||
case 'gzip':
|
||||
$decoded = self::decodeGzip($this->body);
|
||||
break;
|
||||
case 'deflate':
|
||||
$decoded = self::decodeDeflate($this->body);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
if (!empty($oldEncoding)) {
|
||||
mb_internal_encoding($oldEncoding);
|
||||
}
|
||||
if (!empty($e)) {
|
||||
throw $e;
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP version of the response
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether data starts with GZIP format identification bytes from RFC 1952
|
||||
*
|
||||
* @param string $data gzip-encoded (presumably) data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasGzipIdentification($data)
|
||||
{
|
||||
return 0 === strcmp(substr($data, 0, 2), "\x1f\x8b");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse GZIP format header in the given string
|
||||
*
|
||||
* If the header conforms to RFC 1952, its length is returned. If any
|
||||
* sanity check fails, HTTP_Request2_MessageException is thrown.
|
||||
*
|
||||
* Note: This function might be usable outside of HTTP_Request2 so it might
|
||||
* be good idea to be moved to some common package. (Delian Krustev)
|
||||
*
|
||||
* @param string $data Either the complete response body or
|
||||
* the leading part of it
|
||||
* @param boolean $dataComplete Whether $data contains complete response body
|
||||
*
|
||||
* @return int gzip header length in bytes
|
||||
* @throws HTTP_Request2_MessageException
|
||||
* @link http://tools.ietf.org/html/rfc1952
|
||||
*/
|
||||
public static function parseGzipHeader($data, $dataComplete = false)
|
||||
{
|
||||
// if data is complete, trailing 8 bytes should be present for size and crc32
|
||||
$length = strlen($data) - ($dataComplete ? 8 : 0);
|
||||
|
||||
if ($length < 10 || !self::hasGzipIdentification($data)) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'The data does not seem to contain a valid gzip header',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$method = ord(substr($data, 2, 1));
|
||||
if (8 != $method) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: unknown compression method',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$flags = ord(substr($data, 3, 1));
|
||||
if ($flags & 224) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: reserved bits are set',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
// header is 10 bytes minimum. may be longer, though.
|
||||
$headerLength = 10;
|
||||
// extra fields, need to skip 'em
|
||||
if ($flags & 4) {
|
||||
if ($length - $headerLength - 2 < 0) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$extraLength = unpack('v', substr($data, 10, 2));
|
||||
if ($length - $headerLength - 2 - $extraLength[1] < 0) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$headerLength += $extraLength[1] + 2;
|
||||
}
|
||||
// file name, need to skip that
|
||||
if ($flags & 8) {
|
||||
if ($length - $headerLength - 1 < 0) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$filenameLength = strpos(substr($data, $headerLength), chr(0));
|
||||
if (false === $filenameLength
|
||||
|| $length - $headerLength - $filenameLength - 1 < 0
|
||||
) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$headerLength += $filenameLength + 1;
|
||||
}
|
||||
// comment, need to skip that also
|
||||
if ($flags & 16) {
|
||||
if ($length - $headerLength - 1 < 0) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$commentLength = strpos(substr($data, $headerLength), chr(0));
|
||||
if (false === $commentLength
|
||||
|| $length - $headerLength - $commentLength - 1 < 0
|
||||
) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$headerLength += $commentLength + 1;
|
||||
}
|
||||
// have a CRC for header. let's check
|
||||
if ($flags & 2) {
|
||||
if ($length - $headerLength - 2 < 0) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Error parsing gzip header: data too short',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$crcReal = 0xffff & crc32(substr($data, 0, $headerLength));
|
||||
$crcStored = unpack('v', substr($data, $headerLength, 2));
|
||||
if ($crcReal != $crcStored[1]) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Header CRC check failed',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
$headerLength += 2;
|
||||
}
|
||||
return $headerLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the message-body encoded by gzip
|
||||
*
|
||||
* The real decoding work is done by gzinflate() built-in function, this
|
||||
* method only parses the header and checks data for compliance with
|
||||
* RFC 1952
|
||||
*
|
||||
* @param string $data gzip-encoded data
|
||||
*
|
||||
* @return string decoded data
|
||||
* @throws HTTP_Request2_LogicException
|
||||
* @throws HTTP_Request2_MessageException
|
||||
* @link http://tools.ietf.org/html/rfc1952
|
||||
*/
|
||||
public static function decodeGzip($data)
|
||||
{
|
||||
// If it doesn't look like gzip-encoded data, don't bother
|
||||
if (!self::hasGzipIdentification($data)) {
|
||||
return $data;
|
||||
}
|
||||
if (!function_exists('gzinflate')) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Unable to decode body: gzip extension not available',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION
|
||||
);
|
||||
}
|
||||
|
||||
// unpacked data CRC and size at the end of encoded data
|
||||
$tmp = unpack('V2', substr($data, -8));
|
||||
$dataCrc = $tmp[1];
|
||||
$dataSize = $tmp[2];
|
||||
|
||||
$headerLength = self::parseGzipHeader($data, true);
|
||||
|
||||
// don't pass $dataSize to gzinflate, see bugs #13135, #14370
|
||||
$unpacked = gzinflate(substr($data, $headerLength, -8));
|
||||
if (false === $unpacked) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'gzinflate() call failed',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
} elseif ($dataSize != strlen($unpacked)) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Data size check failed',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
} elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Data CRC check failed',
|
||||
HTTP_Request2_Exception::DECODE_ERROR
|
||||
);
|
||||
}
|
||||
return $unpacked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the message-body encoded by deflate
|
||||
*
|
||||
* @param string $data deflate-encoded data
|
||||
*
|
||||
* @return string decoded data
|
||||
* @throws HTTP_Request2_LogicException
|
||||
*/
|
||||
public static function decodeDeflate($data)
|
||||
{
|
||||
if (!function_exists('gzuncompress')) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
'Unable to decode body: gzip extension not available',
|
||||
HTTP_Request2_Exception::MISCONFIGURATION
|
||||
);
|
||||
}
|
||||
// RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950,
|
||||
// while many applications send raw deflate stream from RFC 1951.
|
||||
// We should check for presence of zlib header and use gzuncompress() or
|
||||
// gzinflate() as needed. See bug #15305
|
||||
$header = unpack('n', substr($data, 0, 2));
|
||||
return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* SOCKS5 proxy connection class
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/** Socket wrapper class used by Socket Adapter */
|
||||
require_once 'HTTP/Request2/SocketWrapper.php';
|
||||
|
||||
/**
|
||||
* SOCKS5 proxy connection class (used by Socket Adapter)
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
* @link http://pear.php.net/bugs/bug.php?id=19332
|
||||
* @link http://tools.ietf.org/html/rfc1928
|
||||
*/
|
||||
class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper
|
||||
{
|
||||
/**
|
||||
* Constructor, tries to connect and authenticate to a SOCKS5 proxy
|
||||
*
|
||||
* @param string $address Proxy address, e.g. 'tcp://localhost:1080'
|
||||
* @param int $timeout Connection timeout (seconds)
|
||||
* @param array $contextOptions Stream context options
|
||||
* @param string $username Proxy user name
|
||||
* @param string $password Proxy password
|
||||
*
|
||||
* @throws HTTP_Request2_LogicException
|
||||
* @throws HTTP_Request2_ConnectionException
|
||||
* @throws HTTP_Request2_MessageException
|
||||
*/
|
||||
public function __construct(
|
||||
$address, $timeout = 10, array $contextOptions = array(),
|
||||
$username = null, $password = null
|
||||
) {
|
||||
parent::__construct($address, $timeout, $contextOptions);
|
||||
|
||||
if (strlen($username)) {
|
||||
$request = pack('C4', 5, 2, 0, 2);
|
||||
} else {
|
||||
$request = pack('C3', 5, 1, 0);
|
||||
}
|
||||
$this->write($request);
|
||||
$response = unpack('Cversion/Cmethod', $this->read(3));
|
||||
if (5 != $response['version']) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Invalid version received from SOCKS5 proxy: ' . $response['version'],
|
||||
HTTP_Request2_Exception::MALFORMED_RESPONSE
|
||||
);
|
||||
}
|
||||
switch ($response['method']) {
|
||||
case 2:
|
||||
$this->performAuthentication($username, $password);
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
throw new HTTP_Request2_ConnectionException(
|
||||
"Connection rejected by proxy due to unsupported auth method"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs username/password authentication for SOCKS5
|
||||
*
|
||||
* @param string $username Proxy user name
|
||||
* @param string $password Proxy password
|
||||
*
|
||||
* @throws HTTP_Request2_ConnectionException
|
||||
* @throws HTTP_Request2_MessageException
|
||||
* @link http://tools.ietf.org/html/rfc1929
|
||||
*/
|
||||
protected function performAuthentication($username, $password)
|
||||
{
|
||||
$request = pack('C2', 1, strlen($username)) . $username
|
||||
. pack('C', strlen($password)) . $password;
|
||||
|
||||
$this->write($request);
|
||||
$response = unpack('Cvn/Cstatus', $this->read(3));
|
||||
if (1 != $response['vn'] || 0 != $response['status']) {
|
||||
throw new HTTP_Request2_ConnectionException(
|
||||
'Connection rejected by proxy due to invalid username and/or password'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a remote host via proxy
|
||||
*
|
||||
* @param string $remoteHost Remote host
|
||||
* @param int $remotePort Remote port
|
||||
*
|
||||
* @throws HTTP_Request2_ConnectionException
|
||||
* @throws HTTP_Request2_MessageException
|
||||
*/
|
||||
public function connect($remoteHost, $remotePort)
|
||||
{
|
||||
$request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost))
|
||||
. $remoteHost . pack('n', $remotePort);
|
||||
|
||||
$this->write($request);
|
||||
$response = unpack('Cversion/Creply/Creserved', $this->read(1024));
|
||||
if (5 != $response['version'] || 0 != $response['reserved']) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
'Invalid response received from SOCKS5 proxy',
|
||||
HTTP_Request2_Exception::MALFORMED_RESPONSE
|
||||
);
|
||||
} elseif (0 != $response['reply']) {
|
||||
throw new HTTP_Request2_ConnectionException(
|
||||
"Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy",
|
||||
0, $response['reply']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
/**
|
||||
* Socket wrapper class used by Socket Adapter
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to BSD 3-Clause License that is bundled
|
||||
* with this package in the file LICENSE and available at the URL
|
||||
* https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @copyright 2008-2016 Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
*/
|
||||
|
||||
/** Exception classes for HTTP_Request2 package */
|
||||
require_once 'HTTP/Request2/Exception.php';
|
||||
|
||||
/**
|
||||
* Socket wrapper class used by Socket Adapter
|
||||
*
|
||||
* Needed to properly handle connection errors, global timeout support and
|
||||
* similar things. Loosely based on Net_Socket used by older HTTP_Request.
|
||||
*
|
||||
* @category HTTP
|
||||
* @package HTTP_Request2
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
|
||||
* @version Release: 2.3.0
|
||||
* @link http://pear.php.net/package/HTTP_Request2
|
||||
* @link http://pear.php.net/bugs/bug.php?id=19332
|
||||
* @link http://tools.ietf.org/html/rfc1928
|
||||
*/
|
||||
class HTTP_Request2_SocketWrapper
|
||||
{
|
||||
/**
|
||||
* PHP warning messages raised during stream_socket_client() call
|
||||
* @var array
|
||||
*/
|
||||
protected $connectionWarnings = array();
|
||||
|
||||
/**
|
||||
* Connected socket
|
||||
* @var resource
|
||||
*/
|
||||
protected $socket;
|
||||
|
||||
/**
|
||||
* Sum of start time and global timeout, exception will be thrown if request continues past this time
|
||||
* @var integer
|
||||
*/
|
||||
protected $deadline;
|
||||
|
||||
/**
|
||||
* Global timeout value, mostly for exception messages
|
||||
* @var integer
|
||||
*/
|
||||
protected $timeout;
|
||||
|
||||
/**
|
||||
* Class constructor, tries to establish connection
|
||||
*
|
||||
* @param string $address Address for stream_socket_client() call,
|
||||
* e.g. 'tcp://localhost:80'
|
||||
* @param int $timeout Connection timeout (seconds)
|
||||
* @param array $contextOptions Context options
|
||||
*
|
||||
* @throws HTTP_Request2_LogicException
|
||||
* @throws HTTP_Request2_ConnectionException
|
||||
*/
|
||||
public function __construct($address, $timeout, array $contextOptions = array())
|
||||
{
|
||||
if (!empty($contextOptions)
|
||||
&& !isset($contextOptions['socket']) && !isset($contextOptions['ssl'])
|
||||
) {
|
||||
// Backwards compatibility with 2.1.0 and 2.1.1 releases
|
||||
$contextOptions = array('ssl' => $contextOptions);
|
||||
}
|
||||
if (isset($contextOptions['ssl'])) {
|
||||
$contextOptions['ssl'] += array(
|
||||
// Using "Intermediate compatibility" cipher bundle from
|
||||
// https://wiki.mozilla.org/Security/Server_Side_TLS
|
||||
'ciphers' => 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:'
|
||||
. 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:'
|
||||
. 'DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:'
|
||||
. 'ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:'
|
||||
. 'ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:'
|
||||
. 'ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:'
|
||||
. 'ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:'
|
||||
. 'DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:'
|
||||
. 'DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:'
|
||||
. 'ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:'
|
||||
. 'AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:'
|
||||
. 'AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:'
|
||||
. '!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'
|
||||
);
|
||||
if (version_compare(phpversion(), '5.4.13', '>=')) {
|
||||
$contextOptions['ssl']['disable_compression'] = true;
|
||||
if (version_compare(phpversion(), '5.6', '>=')) {
|
||||
$contextOptions['ssl']['crypto_method'] = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
|
||||
| STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
$context = stream_context_create();
|
||||
foreach ($contextOptions as $wrapper => $options) {
|
||||
foreach ($options as $name => $value) {
|
||||
if (!stream_context_set_option($context, $wrapper, $name, $value)) {
|
||||
throw new HTTP_Request2_LogicException(
|
||||
"Error setting '{$wrapper}' wrapper context option '{$name}'"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
set_error_handler(array($this, 'connectionWarningsHandler'));
|
||||
$this->socket = stream_socket_client(
|
||||
$address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context
|
||||
);
|
||||
restore_error_handler();
|
||||
// if we fail to bind to a specified local address (see request #19515),
|
||||
// connection still succeeds, albeit with a warning. Throw an Exception
|
||||
// with the warning text in this case as that connection is unlikely
|
||||
// to be what user wants and as Curl throws an error in similar case.
|
||||
if ($this->connectionWarnings) {
|
||||
if ($this->socket) {
|
||||
fclose($this->socket);
|
||||
}
|
||||
$error = $errstr ? $errstr : implode("\n", $this->connectionWarnings);
|
||||
throw new HTTP_Request2_ConnectionException(
|
||||
"Unable to connect to {$address}. Error: {$error}", 0, $errno
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor, disconnects socket
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
fclose($this->socket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around fread(), handles global request timeout
|
||||
*
|
||||
* @param int $length Reads up to this number of bytes
|
||||
*
|
||||
* @return string Data read from socket
|
||||
* @throws HTTP_Request2_MessageException In case of timeout
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
if ($this->deadline) {
|
||||
stream_set_timeout($this->socket, max($this->deadline - time(), 1));
|
||||
}
|
||||
$data = fread($this->socket, $length);
|
||||
$this->checkTimeout();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads until either the end of the socket or a newline, whichever comes first
|
||||
*
|
||||
* Strips the trailing newline from the returned data, handles global
|
||||
* request timeout. Method idea borrowed from Net_Socket PEAR package.
|
||||
*
|
||||
* @param int $bufferSize buffer size to use for reading
|
||||
* @param int $localTimeout timeout value to use just for this call
|
||||
* (used when waiting for "100 Continue" response)
|
||||
*
|
||||
* @return string Available data up to the newline (not including newline)
|
||||
* @throws HTTP_Request2_MessageException In case of timeout
|
||||
*/
|
||||
public function readLine($bufferSize, $localTimeout = null)
|
||||
{
|
||||
$line = '';
|
||||
while (!feof($this->socket)) {
|
||||
if (null !== $localTimeout) {
|
||||
stream_set_timeout($this->socket, $localTimeout);
|
||||
} elseif ($this->deadline) {
|
||||
stream_set_timeout($this->socket, max($this->deadline - time(), 1));
|
||||
}
|
||||
|
||||
$line .= @fgets($this->socket, $bufferSize);
|
||||
|
||||
if (null === $localTimeout) {
|
||||
$this->checkTimeout();
|
||||
|
||||
} else {
|
||||
$info = stream_get_meta_data($this->socket);
|
||||
// reset socket timeout if we don't have request timeout specified,
|
||||
// prevents further calls failing with a bogus Exception
|
||||
if (!$this->deadline) {
|
||||
$default = (int)@ini_get('default_socket_timeout');
|
||||
stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX);
|
||||
}
|
||||
if ($info['timed_out']) {
|
||||
throw new HTTP_Request2_MessageException(
|
||||
"readLine() call timed out", HTTP_Request2_Exception::TIMEOUT
|
||||
);
|
||||
}
|
||||
}
|
||||
if (substr($line, -1) == "\n") {
|
||||
return rtrim($line, "\r\n");
|
||||
}
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around fwrite(), handles global request timeout
|
||||
*
|
||||
* @param string $data String to be written
|
||||
*
|
||||
* @return int
|
||||
* @throws HTTP_Request2_MessageException
|
||||
*/
|
||||
public function write($data)
|
||||
{
|
||||
if ($this->deadline) {
|
||||
stream_set_timeout($this->socket, max($this->deadline - time(), 1));
|
||||
}
|
||||
$written = fwrite($this->socket, $data);
|
||||
$this->checkTimeout();
|
||||
// http://www.php.net/manual/en/function.fwrite.php#96951
|
||||
if ($written < strlen($data)) {
|
||||
throw new HTTP_Request2_MessageException('Error writing request');
|
||||
}
|
||||
return $written;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for end-of-file on a socket
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eof()
|
||||
{
|
||||
return feof($this->socket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets request deadline
|
||||
*
|
||||
* @param int $deadline Exception will be thrown if request continues
|
||||
* past this time
|
||||
* @param int $timeout Original request timeout value, to use in
|
||||
* Exception message
|
||||
*/
|
||||
public function setDeadline($deadline, $timeout)
|
||||
{
|
||||
$this->deadline = $deadline;
|
||||
$this->timeout = $timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on encryption on a socket
|
||||
*
|
||||
* @throws HTTP_Request2_ConnectionException
|
||||
*/
|
||||
public function enableCrypto()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.6', '<')) {
|
||||
$cryptoMethod = STREAM_CRYPTO_METHOD_TLS_CLIENT;
|
||||
} else {
|
||||
$cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
|
||||
| STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
|
||||
}
|
||||
|
||||
if (!stream_socket_enable_crypto($this->socket, true, $cryptoMethod)) {
|
||||
throw new HTTP_Request2_ConnectionException(
|
||||
'Failed to enable secure connection when connecting through proxy'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an Exception if stream timed out
|
||||
*
|
||||
* @throws HTTP_Request2_MessageException
|
||||
*/
|
||||
protected function checkTimeout()
|
||||
{
|
||||
$info = stream_get_meta_data($this->socket);
|
||||
if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
|
||||
$reason = $this->deadline
|
||||
? "after {$this->timeout} second(s)"
|
||||
: 'due to default_socket_timeout php.ini setting';
|
||||
throw new HTTP_Request2_MessageException(
|
||||
"Request timed out {$reason}", HTTP_Request2_Exception::TIMEOUT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler to use during stream_socket_client() call
|
||||
*
|
||||
* One stream_socket_client() call may produce *multiple* PHP warnings
|
||||
* (especially OpenSSL-related), we keep them in an array to later use for
|
||||
* the message of HTTP_Request2_ConnectionException
|
||||
*
|
||||
* @param int $errno error level
|
||||
* @param string $errstr error message
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function connectionWarningsHandler($errno, $errstr)
|
||||
{
|
||||
if ($errno & E_WARNING) {
|
||||
array_unshift($this->connectionWarnings, $errstr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* a class to handle converting RR bitmaps to arrays and back; used on NSEC
|
||||
* and NSEC3 RR's
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_BitMap
|
||||
{
|
||||
/**
|
||||
* parses a RR bitmap field defined in RFC3845, into an array of RR names.
|
||||
*
|
||||
* Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) +
|
||||
*
|
||||
* @param string $data a bitmap stringto parse
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function bitMapToArray($data)
|
||||
{
|
||||
if (strlen($data) == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$output = array();
|
||||
$offset = 0;
|
||||
$length = strlen($data);
|
||||
|
||||
while ($offset < $length) {
|
||||
|
||||
//
|
||||
// unpack the window and length values
|
||||
//
|
||||
$x = unpack('@' . $offset . '/Cwindow/Clength', $data);
|
||||
$offset += 2;
|
||||
|
||||
//
|
||||
// copy out the bitmap value
|
||||
//
|
||||
$bitmap = unpack('C*', substr($data, $offset, $x['length']));
|
||||
$offset += $x['length'];
|
||||
|
||||
//
|
||||
// I'm not sure if there's a better way of doing this, but PHP doesn't
|
||||
// have a 'B' flag for unpack()
|
||||
//
|
||||
$bitstr = '';
|
||||
foreach ($bitmap as $r) {
|
||||
|
||||
$bitstr .= sprintf('%08b', $r);
|
||||
}
|
||||
|
||||
$blen = strlen($bitstr);
|
||||
for ($i=0; $i<$blen; $i++) {
|
||||
|
||||
if ($bitstr[$i] == '1') {
|
||||
|
||||
$type = $x['window'] * 256 + $i;
|
||||
|
||||
if (isset(Net_DNS2_Lookups::$rr_types_by_id[$type])) {
|
||||
|
||||
$output[] = Net_DNS2_Lookups::$rr_types_by_id[$type];
|
||||
} else {
|
||||
|
||||
$output[] = 'TYPE' . $type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a RR Bit map from an array of RR type names
|
||||
*
|
||||
* @param array $data a list of RR names
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function arrayToBitMap(array $data)
|
||||
{
|
||||
if (count($data) == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$current_window = 0;
|
||||
|
||||
//
|
||||
// go through each RR
|
||||
//
|
||||
$max = 0;
|
||||
$bm = array();
|
||||
|
||||
foreach ($data as $rr) {
|
||||
|
||||
$rr = strtoupper($rr);
|
||||
|
||||
//
|
||||
// get the type id for the RR
|
||||
//
|
||||
$type = @Net_DNS2_Lookups::$rr_types_by_name[$rr];
|
||||
if (isset($type)) {
|
||||
|
||||
//
|
||||
// skip meta types or qtypes
|
||||
//
|
||||
if ( (isset(Net_DNS2_Lookups::$rr_qtypes_by_id[$type]))
|
||||
|| (isset(Net_DNS2_Lookups::$rr_metatypes_by_id[$type]))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// if it's not found, then it must be defined as TYPE<id>, per
|
||||
// RFC3845 section 2.2, if it's not, we ignore it.
|
||||
//
|
||||
list($name, $type) = explode('TYPE', $rr);
|
||||
if (!isset($type)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// build the current window
|
||||
//
|
||||
$current_window = (int)($type / 256);
|
||||
|
||||
$val = $type - $current_window * 256.0;
|
||||
if ($val > $max) {
|
||||
$max = $val;
|
||||
}
|
||||
|
||||
$bm[$current_window][$val] = 1;
|
||||
$bm[$current_window]['length'] = ceil(($max + 1) / 8);
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach ($bm as $window => $bitdata) {
|
||||
|
||||
$bitstr = '';
|
||||
|
||||
for ($i=0; $i<$bm[$window]['length'] * 8; $i++) {
|
||||
if (isset($bm[$window][$i])) {
|
||||
$bitstr .= '1';
|
||||
} else {
|
||||
$bitstr .= '0';
|
||||
}
|
||||
}
|
||||
|
||||
$output .= pack('CC', $window, $bm[$window]['length']);
|
||||
$output .= pack('H*', self::bigBaseConvert($bitstr));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* a base_convert that handles large numbers; forced to 2/16
|
||||
*
|
||||
* @param string $number a bit string
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function bigBaseConvert($number)
|
||||
{
|
||||
$result = '';
|
||||
|
||||
$bin = substr(chunk_split(strrev($number), 4, '-'), 0, -1);
|
||||
$temp = preg_split('[-]', $bin, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
for ($i = count($temp)-1;$i >= 0;$i--) {
|
||||
|
||||
$result = $result . base_convert(strrev($temp[$i]), 2, 16);
|
||||
}
|
||||
|
||||
return strtoupper($result);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.1.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class to provide simple dns lookup caching.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Cache
|
||||
{
|
||||
/*
|
||||
* the filename of the cache file
|
||||
*/
|
||||
protected $cache_file = '';
|
||||
|
||||
/*
|
||||
* the local data store for the cache
|
||||
*/
|
||||
protected $cache_data = array();
|
||||
|
||||
/*
|
||||
* the size of the cache to use
|
||||
*/
|
||||
protected $cache_size = 0;
|
||||
|
||||
/*
|
||||
* the cache serializer
|
||||
*/
|
||||
protected $cache_serializer;
|
||||
|
||||
/*
|
||||
* an internal flag to make sure we don't load the cache content more
|
||||
* than once per instance.
|
||||
*/
|
||||
protected $cache_opened = false;
|
||||
|
||||
/**
|
||||
* returns true/false if the provided key is defined in the cache
|
||||
*
|
||||
* @param string $key the key to lookup in the local cache
|
||||
*
|
||||
* @return boolean
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->cache_data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the value for the given key
|
||||
*
|
||||
* @param string $key the key to lookup in the local cache
|
||||
*
|
||||
* @return mixed returns the cache data on sucess, false on error
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
if (isset($this->cache_data[$key])) {
|
||||
|
||||
if ($this->cache_serializer == 'json') {
|
||||
return json_decode($this->cache_data[$key]['object']);
|
||||
} else {
|
||||
return unserialize($this->cache_data[$key]['object']);
|
||||
}
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a new key/value pair to the cache
|
||||
*
|
||||
* @param string $key the key for the new cache entry
|
||||
* @param mixed $data the data to store in cache
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function put($key, $data)
|
||||
{
|
||||
$ttl = 86400 * 365;
|
||||
|
||||
//
|
||||
// clear the rdata values
|
||||
//
|
||||
$data->rdata = '';
|
||||
$data->rdlength = 0;
|
||||
|
||||
//
|
||||
// find the lowest TTL, and use that as the TTL for the whole cached
|
||||
// object. The downside to using one TTL for the whole object, is that
|
||||
// we'll invalidate entries before they actuall expire, causing a
|
||||
// real lookup to happen.
|
||||
//
|
||||
// The upside is that we don't need to require() each RR type in the
|
||||
// cache, so we can look at their individual TTL's on each run- we only
|
||||
// unserialize the actual RR object when it's get() from the cache.
|
||||
//
|
||||
foreach ($data->answer as $index => $rr) {
|
||||
|
||||
if ($rr->ttl < $ttl) {
|
||||
$ttl = $rr->ttl;
|
||||
}
|
||||
|
||||
$rr->rdata = '';
|
||||
$rr->rdlength = 0;
|
||||
}
|
||||
foreach ($data->authority as $index => $rr) {
|
||||
|
||||
if ($rr->ttl < $ttl) {
|
||||
$ttl = $rr->ttl;
|
||||
}
|
||||
|
||||
$rr->rdata = '';
|
||||
$rr->rdlength = 0;
|
||||
}
|
||||
foreach ($data->additional as $index => $rr) {
|
||||
|
||||
if ($rr->ttl < $ttl) {
|
||||
$ttl = $rr->ttl;
|
||||
}
|
||||
|
||||
$rr->rdata = '';
|
||||
$rr->rdlength = 0;
|
||||
}
|
||||
|
||||
$this->cache_data[$key] = array(
|
||||
|
||||
'cache_date' => time(),
|
||||
'ttl' => $ttl
|
||||
);
|
||||
|
||||
if ($this->cache_serializer == 'json') {
|
||||
$this->cache_data[$key]['object'] = json_encode($data);
|
||||
} else {
|
||||
$this->cache_data[$key]['object'] = serialize($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a clean up process on the cache data
|
||||
*
|
||||
* @return void
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function clean()
|
||||
{
|
||||
if (count($this->cache_data) > 0) {
|
||||
|
||||
//
|
||||
// go through each entry and adjust their TTL, and remove entries that
|
||||
// have expired
|
||||
//
|
||||
$now = time();
|
||||
|
||||
foreach ($this->cache_data as $key => $data) {
|
||||
|
||||
$diff = $now - $data['cache_date'];
|
||||
|
||||
if ($data['ttl'] <= $diff) {
|
||||
|
||||
unset($this->cache_data[$key]);
|
||||
} else {
|
||||
|
||||
$this->cache_data[$key]['ttl'] -= $diff;
|
||||
$this->cache_data[$key]['cache_date'] = $now;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a clean up process on the cache data
|
||||
*
|
||||
* @return mixed
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function resize()
|
||||
{
|
||||
if (count($this->cache_data) > 0) {
|
||||
|
||||
//
|
||||
// serialize the cache data
|
||||
//
|
||||
if ($this->cache_serializer == 'json') {
|
||||
$cache = json_encode($this->cache_data);
|
||||
} else {
|
||||
$cache = serialize($this->cache_data);
|
||||
}
|
||||
|
||||
//
|
||||
// only do this part if the size allocated to the cache storage
|
||||
// is smaller than the actual cache data
|
||||
//
|
||||
if (strlen($cache) > $this->cache_size) {
|
||||
|
||||
while (strlen($cache) > $this->cache_size) {
|
||||
|
||||
//
|
||||
// go through the data, and remove the entries closed to
|
||||
// their expiration date.
|
||||
//
|
||||
$smallest_ttl = time();
|
||||
$smallest_key = null;
|
||||
|
||||
foreach ($this->cache_data as $key => $data) {
|
||||
|
||||
if ($data['ttl'] < $smallest_ttl) {
|
||||
|
||||
$smallest_ttl = $data['ttl'];
|
||||
$smallest_key = $key;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// unset the key with the smallest TTL
|
||||
//
|
||||
unset($this->cache_data[$smallest_key]);
|
||||
|
||||
//
|
||||
// re-serialize
|
||||
//
|
||||
if ($this->cache_serializer == 'json') {
|
||||
$cache = json_encode($this->cache_data);
|
||||
} else {
|
||||
$cache = serialize($this->cache_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ($cache == 'a:0:{}') || ($cache == '{}') ) {
|
||||
return null;
|
||||
} else {
|
||||
return $cache;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.1.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* File-based caching for the Net_DNS2_Cache class
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Cache_File extends Net_DNS2_Cache
|
||||
{
|
||||
/**
|
||||
* open a cache object
|
||||
*
|
||||
* @param string $cache_file path to a file to use for cache storage
|
||||
* @param integer $size the size of the shared memory segment to create
|
||||
* @param string $serializer the name of the cache serialize to use
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function open($cache_file, $size, $serializer)
|
||||
{
|
||||
$this->cache_size = $size;
|
||||
$this->cache_file = $cache_file;
|
||||
$this->cache_serializer = $serializer;
|
||||
|
||||
//
|
||||
// check that the file exists first
|
||||
//
|
||||
if ( ($this->cache_opened == false)
|
||||
&& (file_exists($this->cache_file) == true)
|
||||
&& (filesize($this->cache_file) > 0)
|
||||
) {
|
||||
//
|
||||
// open the file for reading
|
||||
//
|
||||
$fp = @fopen($this->cache_file, 'r');
|
||||
if ($fp !== false) {
|
||||
|
||||
//
|
||||
// lock the file just in case
|
||||
//
|
||||
flock($fp, LOCK_EX);
|
||||
|
||||
//
|
||||
// read the file contents
|
||||
//
|
||||
$data = fread($fp, filesize($this->cache_file));
|
||||
|
||||
$decoded = null;
|
||||
|
||||
if ($this->cache_serializer == 'json') {
|
||||
|
||||
$decoded = json_decode($data, true);
|
||||
} else {
|
||||
|
||||
$decoded = unserialize($data);
|
||||
}
|
||||
|
||||
if (is_array($decoded) == true) {
|
||||
|
||||
$this->cache_data = $decoded;
|
||||
} else {
|
||||
|
||||
$this->cache_data = array();
|
||||
}
|
||||
|
||||
//
|
||||
// unlock
|
||||
//
|
||||
flock($fp, LOCK_UN);
|
||||
|
||||
//
|
||||
// close the file
|
||||
//
|
||||
fclose($fp);
|
||||
|
||||
//
|
||||
// clean up the data
|
||||
//
|
||||
$this->clean();
|
||||
|
||||
//
|
||||
// mark this so we don't read this contents more than once per instance.
|
||||
//
|
||||
$this->cache_opened = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
//
|
||||
// if there's no cache file set, then there's nothing to do
|
||||
//
|
||||
if (strlen($this->cache_file) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// open the file for reading/writing
|
||||
//
|
||||
$fp = fopen($this->cache_file, 'a+');
|
||||
if ($fp !== false) {
|
||||
|
||||
//
|
||||
// lock the file just in case
|
||||
//
|
||||
flock($fp, LOCK_EX);
|
||||
|
||||
//
|
||||
// seek to the start of the file to read
|
||||
//
|
||||
fseek($fp, 0, SEEK_SET);
|
||||
|
||||
//
|
||||
// read the file contents
|
||||
//
|
||||
$data = @fread($fp, filesize($this->cache_file));
|
||||
if ( ($data !== false) && (strlen($data) > 0) ) {
|
||||
|
||||
//
|
||||
// unserialize and store the data
|
||||
//
|
||||
$c = $this->cache_data;
|
||||
|
||||
$decoded = null;
|
||||
|
||||
if ($this->cache_serializer == 'json') {
|
||||
|
||||
$decoded = json_decode($data, true);
|
||||
} else {
|
||||
|
||||
$decoded = unserialize($data);
|
||||
}
|
||||
|
||||
if (is_array($decoded) == true) {
|
||||
|
||||
$this->cache_data = array_merge($c, $decoded);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// trucate the file
|
||||
//
|
||||
ftruncate($fp, 0);
|
||||
|
||||
//
|
||||
// clean the data
|
||||
//
|
||||
$this->clean();
|
||||
|
||||
//
|
||||
// resize the data
|
||||
//
|
||||
$data = $this->resize();
|
||||
if (!is_null($data)) {
|
||||
|
||||
//
|
||||
// write the file contents
|
||||
//
|
||||
fwrite($fp, $data);
|
||||
}
|
||||
|
||||
//
|
||||
// unlock
|
||||
//
|
||||
flock($fp, LOCK_UN);
|
||||
|
||||
//
|
||||
// close the file
|
||||
//
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.1.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shared Memory-based caching for the Net_DNS2_Cache class
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Cache_Shm extends Net_DNS2_Cache
|
||||
{
|
||||
/*
|
||||
* resource id of the shared memory cache
|
||||
*/
|
||||
private $_cache_id = false;
|
||||
|
||||
/*
|
||||
* the IPC key
|
||||
*/
|
||||
private $_cache_file_tok = -1;
|
||||
|
||||
/**
|
||||
* open a cache object
|
||||
*
|
||||
* @param string $cache_file path to a file to use for cache storage
|
||||
* @param integer $size the size of the shared memory segment to create
|
||||
* @param string $serializer the name of the cache serialize to use
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function open($cache_file, $size, $serializer)
|
||||
{
|
||||
$this->cache_size = $size;
|
||||
$this->cache_file = $cache_file;
|
||||
$this->cache_serializer = $serializer;
|
||||
|
||||
//
|
||||
// if we've already loaded the cache data, then just return right away
|
||||
//
|
||||
if ($this->cache_opened == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// make sure the file exists first
|
||||
//
|
||||
if (!file_exists($cache_file)) {
|
||||
|
||||
if (file_put_contents($cache_file, '') === false) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to create empty SHM file: ' . $cache_file,
|
||||
Net_DNS2_Lookups::E_CACHE_SHM_FILE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// convert the filename to a IPC key
|
||||
//
|
||||
$this->_cache_file_tok = ftok($cache_file, 't');
|
||||
if ($this->_cache_file_tok == -1) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed on ftok() file: ' . $this->_cache_file_tok,
|
||||
Net_DNS2_Lookups::E_CACHE_SHM_FILE
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// try to open an existing cache; if it doesn't exist, then there's no
|
||||
// cache, and nothing to do.
|
||||
//
|
||||
$this->_cache_id = @shmop_open($this->_cache_file_tok, 'w', 0, 0);
|
||||
if ($this->_cache_id !== false) {
|
||||
|
||||
//
|
||||
// this returns the size allocated, and not the size used, but it's
|
||||
// still a good check to make sure there's space allocated.
|
||||
//
|
||||
$allocated = shmop_size($this->_cache_id);
|
||||
if ($allocated > 0) {
|
||||
|
||||
//
|
||||
// read the data from the shared memory segment
|
||||
//
|
||||
$data = trim(shmop_read($this->_cache_id, 0, $allocated));
|
||||
if ( ($data !== false) && (strlen($data) > 0) ) {
|
||||
|
||||
//
|
||||
// unserialize and store the data
|
||||
//
|
||||
$decoded = null;
|
||||
|
||||
if ($this->cache_serializer == 'json') {
|
||||
|
||||
$decoded = json_decode($data, true);
|
||||
} else {
|
||||
|
||||
$decoded = unserialize($data);
|
||||
}
|
||||
|
||||
if (is_array($decoded) == true) {
|
||||
|
||||
$this->cache_data = $decoded;
|
||||
} else {
|
||||
|
||||
$this->cache_data = array();
|
||||
}
|
||||
|
||||
//
|
||||
// call clean to clean up old entries
|
||||
//
|
||||
$this->clean();
|
||||
|
||||
//
|
||||
// mark the cache as loaded, so we don't load it more than once
|
||||
//
|
||||
$this->cache_opened = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
//
|
||||
// if there's no cache file set, then there's nothing to do
|
||||
//
|
||||
if (strlen($this->cache_file) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fp = fopen($this->cache_file, 'r');
|
||||
if ($fp !== false) {
|
||||
|
||||
//
|
||||
// lock the file
|
||||
//
|
||||
flock($fp, LOCK_EX);
|
||||
|
||||
//
|
||||
// check to see if we have an open shm segment
|
||||
//
|
||||
if ($this->_cache_id === false) {
|
||||
|
||||
//
|
||||
// try opening it again, incase it was created by another
|
||||
// process in the mean time
|
||||
//
|
||||
$this->_cache_id = @shmop_open(
|
||||
$this->_cache_file_tok, 'w', 0, 0
|
||||
);
|
||||
if ($this->_cache_id === false) {
|
||||
|
||||
//
|
||||
// otherwise, create it.
|
||||
//
|
||||
$this->_cache_id = @shmop_open(
|
||||
$this->_cache_file_tok, 'c', 0, $this->cache_size
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get the size allocated to the segment
|
||||
//
|
||||
$allocated = shmop_size($this->_cache_id);
|
||||
|
||||
//
|
||||
// read the contents
|
||||
//
|
||||
$data = trim(shmop_read($this->_cache_id, 0, $allocated));
|
||||
|
||||
//
|
||||
// if there was some data
|
||||
//
|
||||
if ( ($data !== false) && (strlen($data) > 0) ) {
|
||||
|
||||
//
|
||||
// unserialize and store the data
|
||||
//
|
||||
$c = $this->cache_data;
|
||||
|
||||
$decoded = null;
|
||||
|
||||
if ($this->cache_serializer == 'json') {
|
||||
|
||||
$decoded = json_decode($data, true);
|
||||
} else {
|
||||
|
||||
$decoded = unserialize($data);
|
||||
}
|
||||
|
||||
if (is_array($decoded) == true) {
|
||||
|
||||
$this->cache_data = array_merge($c, $decoded);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// delete the segment
|
||||
//
|
||||
shmop_delete($this->_cache_id);
|
||||
|
||||
//
|
||||
// clean the data
|
||||
//
|
||||
$this->clean();
|
||||
|
||||
//
|
||||
// clean up and write the data
|
||||
//
|
||||
$data = $this->resize();
|
||||
if (!is_null($data)) {
|
||||
|
||||
//
|
||||
// re-create segment
|
||||
//
|
||||
$this->_cache_id = @shmop_open(
|
||||
$this->_cache_file_tok, 'c', 0644, $this->cache_size
|
||||
);
|
||||
if ($this->_cache_id === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$o = shmop_write($this->_cache_id, $data, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// close the segment
|
||||
//
|
||||
shmop_close($this->_cache_id);
|
||||
|
||||
//
|
||||
// unlock
|
||||
//
|
||||
flock($fp, LOCK_UN);
|
||||
|
||||
//
|
||||
// close the file
|
||||
//
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception handler used by Net_DNS2
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Exception extends Exception
|
||||
{
|
||||
private $_request;
|
||||
private $_response;
|
||||
|
||||
/**
|
||||
* Constructor - overload the constructor so we can pass in the request
|
||||
* and response object (when it's available)
|
||||
*
|
||||
* @param string $message the exception message
|
||||
* @param int $code the exception code
|
||||
* @param object $previous the previous Exception object
|
||||
* @param object $request the Net_DNS2_Packet_Request object for this request
|
||||
* @param object $response the Net_DNS2_Packet_Response object for this request
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct(
|
||||
$message = '',
|
||||
$code = 0,
|
||||
$previous = null,
|
||||
Net_DNS2_Packet_Request $request = null,
|
||||
Net_DNS2_Packet_Response $response = null
|
||||
) {
|
||||
//
|
||||
// store the request/response objects (if passed)
|
||||
//
|
||||
$this->_request = $request;
|
||||
$this->_response = $response;
|
||||
|
||||
//
|
||||
// call the parent constructor
|
||||
//
|
||||
// the "previous" argument was added in PHP 5.3.0
|
||||
//
|
||||
// https://code.google.com/p/netdns2/issues/detail?id=25
|
||||
//
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=') == true) {
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
} else {
|
||||
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the Net_DNS2_Packet_Request object (if available)
|
||||
*
|
||||
* @return Net_DNS2_Packet_Request object
|
||||
* @access public
|
||||
* @since function available since release 1.3.1
|
||||
*
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->_request;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the Net_DNS2_Packet_Response object (if available)
|
||||
*
|
||||
* @return Net_DNS2_Packet_Response object
|
||||
* @access public
|
||||
* @since function available since release 1.3.1
|
||||
*
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->_response;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* DNS Packet Header class
|
||||
*
|
||||
* This class handles parsing and constructing DNS Packet Headers as defined
|
||||
* by section 4.1.1 of RFC1035.
|
||||
*
|
||||
* DNS header format - RFC1035 section 4.1.1
|
||||
* DNS header format - RFC4035 section 3.2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ID |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QDCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ANCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | NSCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ARCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Header
|
||||
{
|
||||
public $id; // 16 bit - identifier
|
||||
public $qr; // 1 bit - 0 = query, 1 = response
|
||||
public $opcode; // 4 bit - op code
|
||||
public $aa; // 1 bit - Authoritative Answer
|
||||
public $tc; // 1 bit - TrunCation
|
||||
public $rd; // 1 bit - Recursion Desired
|
||||
public $ra; // 1 bit - Recursion Available
|
||||
public $z; // 1 bit - Reserved
|
||||
public $ad; // 1 bit - Authentic Data (RFC4035)
|
||||
public $cd; // 1 bit - Checking Disabled (RFC4035)
|
||||
public $rcode; // 4 bit - Response code
|
||||
public $qdcount; // 16 bit - entries in the question section
|
||||
public $ancount; // 16 bit - resource records in the answer section
|
||||
public $nscount; // 16 bit - name server rr in the authority records section
|
||||
public $arcount; // 16 bit - rr's in the additional records section
|
||||
|
||||
/**
|
||||
* Constructor - builds a new Net_DNS2_Header object
|
||||
*
|
||||
* @param mixed &$packet either a Net_DNS2_Packet object or null
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct(Net_DNS2_Packet &$packet = null)
|
||||
{
|
||||
if (!is_null($packet)) {
|
||||
|
||||
$this->set($packet);
|
||||
} else {
|
||||
|
||||
$this->id = $this->nextPacketId();
|
||||
$this->qr = Net_DNS2_Lookups::QR_QUERY;
|
||||
$this->opcode = Net_DNS2_Lookups::OPCODE_QUERY;
|
||||
$this->aa = 0;
|
||||
$this->tc = 0;
|
||||
$this->rd = 1;
|
||||
$this->ra = 0;
|
||||
$this->z = 0;
|
||||
$this->ad = 0;
|
||||
$this->cd = 0;
|
||||
$this->rcode = Net_DNS2_Lookups::RCODE_NOERROR;
|
||||
$this->qdcount = 1;
|
||||
$this->ancount = 0;
|
||||
$this->nscount = 0;
|
||||
$this->arcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the next available packet id
|
||||
*
|
||||
* @return integer
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function nextPacketId()
|
||||
{
|
||||
if (++Net_DNS2_Lookups::$next_packet_id > 65535) {
|
||||
|
||||
Net_DNS2_Lookups::$next_packet_id = 1;
|
||||
}
|
||||
|
||||
return Net_DNS2_Lookups::$next_packet_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* magic __toString() method to return the header as a string
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$output = ";;\n;; Header:\n";
|
||||
|
||||
$output .= ";;\t id = " . $this->id . "\n";
|
||||
$output .= ";;\t qr = " . $this->qr . "\n";
|
||||
$output .= ";;\t opcode = " . $this->opcode . "\n";
|
||||
$output .= ";;\t aa = " . $this->aa . "\n";
|
||||
$output .= ";;\t tc = " . $this->tc . "\n";
|
||||
$output .= ";;\t rd = " . $this->rd . "\n";
|
||||
$output .= ";;\t ra = " . $this->ra . "\n";
|
||||
$output .= ";;\t z = " . $this->z . "\n";
|
||||
$output .= ";;\t ad = " . $this->ad . "\n";
|
||||
$output .= ";;\t cd = " . $this->cd . "\n";
|
||||
$output .= ";;\t rcode = " . $this->rcode . "\n";
|
||||
$output .= ";;\t qdcount = " . $this->qdcount . "\n";
|
||||
$output .= ";;\t ancount = " . $this->ancount . "\n";
|
||||
$output .= ";;\t nscount = " . $this->nscount . "\n";
|
||||
$output .= ";;\t arcount = " . $this->arcount . "\n";
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* constructs a Net_DNS2_Header from a Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet Object
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function set(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// the header must be at least 12 bytes long.
|
||||
//
|
||||
if ($packet->rdlength < Net_DNS2_Lookups::DNS_HEADER_SIZE) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid header data provided; to small',
|
||||
Net_DNS2_Lookups::E_HEADER_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
$offset = 0;
|
||||
|
||||
//
|
||||
// parse the values
|
||||
//
|
||||
$this->id = ord($packet->rdata[$offset]) << 8 |
|
||||
ord($packet->rdata[++$offset]);
|
||||
|
||||
++$offset;
|
||||
$this->qr = (ord($packet->rdata[$offset]) >> 7) & 0x1;
|
||||
$this->opcode = (ord($packet->rdata[$offset]) >> 3) & 0xf;
|
||||
$this->aa = (ord($packet->rdata[$offset]) >> 2) & 0x1;
|
||||
$this->tc = (ord($packet->rdata[$offset]) >> 1) & 0x1;
|
||||
$this->rd = ord($packet->rdata[$offset]) & 0x1;
|
||||
|
||||
++$offset;
|
||||
$this->ra = (ord($packet->rdata[$offset]) >> 7) & 0x1;
|
||||
$this->z = (ord($packet->rdata[$offset]) >> 6) & 0x1;
|
||||
$this->ad = (ord($packet->rdata[$offset]) >> 5) & 0x1;
|
||||
$this->cd = (ord($packet->rdata[$offset]) >> 4) & 0x1;
|
||||
$this->rcode = ord($packet->rdata[$offset]) & 0xf;
|
||||
|
||||
$this->qdcount = ord($packet->rdata[++$offset]) << 8 |
|
||||
ord($packet->rdata[++$offset]);
|
||||
$this->ancount = ord($packet->rdata[++$offset]) << 8 |
|
||||
ord($packet->rdata[++$offset]);
|
||||
$this->nscount = ord($packet->rdata[++$offset]) << 8 |
|
||||
ord($packet->rdata[++$offset]);
|
||||
$this->arcount = ord($packet->rdata[++$offset]) << 8 |
|
||||
ord($packet->rdata[++$offset]);
|
||||
|
||||
//
|
||||
// increment the internal offset
|
||||
//
|
||||
$packet->offset += Net_DNS2_Lookups::DNS_HEADER_SIZE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a binary packed DNS Header
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet Object
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function get(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$packet->offset += Net_DNS2_Lookups::DNS_HEADER_SIZE;
|
||||
|
||||
return pack('n', $this->id) .
|
||||
chr(
|
||||
($this->qr << 7) | ($this->opcode << 3) |
|
||||
($this->aa << 2) | ($this->tc << 1) | ($this->rd)
|
||||
) .
|
||||
chr(
|
||||
($this->ra << 7) | ($this->ad << 5) | ($this->cd << 4) | $this->rcode
|
||||
) .
|
||||
pack('n4', $this->qdcount, $this->ancount, $this->nscount, $this->arcount);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,578 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// initalize the packet id value
|
||||
//
|
||||
Net_DNS2_Lookups::$next_packet_id = mt_rand(0, 65535);
|
||||
|
||||
//
|
||||
// build the reverse lookup tables; this is just so we don't have to
|
||||
// have duplicate static content laying around.
|
||||
//
|
||||
Net_DNS2_Lookups::$rr_types_by_id = array_flip(Net_DNS2_Lookups::$rr_types_by_name);
|
||||
Net_DNS2_Lookups::$classes_by_id = array_flip(Net_DNS2_Lookups::$classes_by_name);
|
||||
Net_DNS2_Lookups::$rr_types_class_to_id = array_flip(Net_DNS2_Lookups::$rr_types_id_to_class);
|
||||
Net_DNS2_Lookups::$algorithm_name_to_id = array_flip(Net_DNS2_Lookups::$algorithm_id_to_name);
|
||||
Net_DNS2_Lookups::$digest_name_to_id = array_flip(Net_DNS2_Lookups::$digest_id_to_name);
|
||||
Net_DNS2_Lookups::$rr_qtypes_by_id = array_flip(Net_DNS2_Lookups::$rr_qtypes_by_name);
|
||||
Net_DNS2_Lookups::$rr_metatypes_by_id = array_flip(Net_DNS2_Lookups::$rr_metatypes_by_name);
|
||||
Net_DNS2_Lookups::$protocol_by_id = array_flip(Net_DNS2_Lookups::$protocol_by_name);
|
||||
|
||||
/**
|
||||
* This class provides simple lookups used througout the Net_DNS2 code
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Lookups
|
||||
{
|
||||
/*
|
||||
* size (in bytes) of a header in a standard DNS packet
|
||||
*/
|
||||
const DNS_HEADER_SIZE = 12;
|
||||
|
||||
/*
|
||||
* max size of a UDP packet
|
||||
*/
|
||||
const DNS_MAX_UDP_SIZE = 512;
|
||||
|
||||
/*
|
||||
* Query/Response flag
|
||||
*/
|
||||
const QR_QUERY = 0; // RFC 1035
|
||||
const QR_RESPONSE = 1; // RFC 1035
|
||||
|
||||
/*
|
||||
* DNS Op Codes
|
||||
*/
|
||||
const OPCODE_QUERY = 0; // RFC 1035
|
||||
const OPCODE_IQUERY = 1; // RFC 1035, RFC 3425
|
||||
const OPCODE_STATUS = 2; // RFC 1035
|
||||
const OPCODE_NOTIFY = 4; // RFC 1996
|
||||
const OPCODE_UPDATE = 5; // RFC 2136
|
||||
|
||||
/*
|
||||
* Resource Record Classes
|
||||
*/
|
||||
const RR_CLASS_IN = 1; // RFC 1035
|
||||
const RR_CLASS_CH = 3; // RFC 1035
|
||||
const RR_CLASS_HS = 4; // RFC 1035
|
||||
const RR_CLASS_NONE = 254; // RFC 2136
|
||||
const RR_CLASS_ANY = 255; // RFC 1035
|
||||
|
||||
/*
|
||||
* DNS Response Codes
|
||||
*/
|
||||
const RCODE_NOERROR = 0; // RFC 1035
|
||||
const RCODE_FORMERR = 1; // RFC 1035
|
||||
const RCODE_SERVFAIL = 2; // RFC 1035
|
||||
const RCODE_NXDOMAIN = 3; // RFC 1035
|
||||
const RCODE_NOTIMP = 4; // RFC 1035
|
||||
const RCODE_REFUSED = 5; // RFC 1035
|
||||
const RCODE_YXDOMAIN = 6; // RFC 2136
|
||||
const RCODE_YXRRSET = 7; // RFC 2136
|
||||
const RCODE_NXRRSET = 8; // RFC 2136
|
||||
const RCODE_NOTAUTH = 9; // RFC 2136
|
||||
const RCODE_NOTZONE = 10; // RFC 2136
|
||||
|
||||
// 11-15 reserved
|
||||
|
||||
const RCODE_BADSIG = 16; // RFC 2845
|
||||
const RCODE_BADVERS = 16; // RFC 6891
|
||||
const RCODE_BADKEY = 17; // RFC 2845
|
||||
const RCODE_BADTIME = 18; // RFC 2845
|
||||
const RCODE_BADMODE = 19; // RFC 2930
|
||||
const RCODE_BADNAME = 20; // RFC 2930
|
||||
const RCODE_BADALG = 21; // RFC 2930
|
||||
const RCODE_BADTRUNC = 22; // RFC 4635
|
||||
const RCODE_BADCOOKIE = 23; // RFC 7873
|
||||
|
||||
/*
|
||||
* internal errors codes returned by the exceptions class
|
||||
*/
|
||||
const E_NONE = 0;
|
||||
const E_DNS_FORMERR = self::RCODE_FORMERR;
|
||||
const E_DNS_SERVFAIL = self::RCODE_SERVFAIL;
|
||||
const E_DNS_NXDOMAIN = self::RCODE_NXDOMAIN;
|
||||
const E_DNS_NOTIMP = self::RCODE_NOTIMP;
|
||||
const E_DNS_REFUSED = self::RCODE_REFUSED;
|
||||
const E_DNS_YXDOMAIN = self::RCODE_YXDOMAIN;
|
||||
const E_DNS_YXRRSET = self::RCODE_YXRRSET;
|
||||
const E_DNS_NXRRSET = self::RCODE_NXRRSET;
|
||||
const E_DNS_NOTAUTH = self::RCODE_NOTAUTH;
|
||||
const E_DNS_NOTZONE = self::RCODE_NOTZONE;
|
||||
|
||||
// 11-15 reserved
|
||||
|
||||
const E_DNS_BADSIG = self::RCODE_BADSIG;
|
||||
const E_DNS_BADKEY = self::RCODE_BADKEY;
|
||||
const E_DNS_BADTIME = self::RCODE_BADTIME;
|
||||
const E_DNS_BADMODE = self::RCODE_BADMODE;
|
||||
const E_DNS_BADNAME = self::RCODE_BADNAME;
|
||||
const E_DNS_BADALG = self::RCODE_BADALG;
|
||||
const E_DNS_BADTRUNC = self::RCODE_BADTRUNC;
|
||||
const E_DNS_BADCOOKIE = self::RCODE_BADCOOKIE;
|
||||
|
||||
// other error conditions
|
||||
|
||||
const E_NS_INVALID_FILE = 200;
|
||||
const E_NS_INVALID_ENTRY = 201;
|
||||
const E_NS_FAILED = 202;
|
||||
const E_NS_SOCKET_FAILED = 203;
|
||||
const E_NS_INVALID_SOCKET = 204;
|
||||
|
||||
const E_PACKET_INVALID = 300;
|
||||
const E_PARSE_ERROR = 301;
|
||||
const E_HEADER_INVALID = 302;
|
||||
const E_QUESTION_INVALID = 303;
|
||||
const E_RR_INVALID = 304;
|
||||
|
||||
const E_OPENSSL_ERROR = 400;
|
||||
const E_OPENSSL_UNAVAIL = 401;
|
||||
const E_OPENSSL_INV_PKEY = 402;
|
||||
const E_OPENSSL_INV_ALGO = 403;
|
||||
|
||||
const E_CACHE_UNSUPPORTED = 500;
|
||||
const E_CACHE_SHM_FILE = 501;
|
||||
const E_CACHE_SHM_UNAVAIL = 502;
|
||||
|
||||
/*
|
||||
* EDNS0 Option Codes (OPT)
|
||||
*/
|
||||
// 0 - Reserved
|
||||
const EDNS0_OPT_LLQ = 1;
|
||||
const EDNS0_OPT_UL = 2;
|
||||
const EDNS0_OPT_NSID = 3;
|
||||
// 4 - Reserved
|
||||
const EDNS0_OPT_DAU = 5;
|
||||
const EDNS0_OPT_DHU = 6;
|
||||
const EDNS0_OPT_N3U = 7;
|
||||
const EDNS0_OPT_CLIENT_SUBNET = 8;
|
||||
const EDNS0_OPT_EXPIRE = 9;
|
||||
const EDNS0_OPT_COOKIE = 10;
|
||||
const EDNS0_OPT_TCP_KEEPALIVE = 11;
|
||||
const EDNS0_OPT_PADDING = 12;
|
||||
const EDNS0_OPT_CHAIN = 13;
|
||||
|
||||
/*
|
||||
* DNSSEC Algorithms
|
||||
*/
|
||||
const DNSSEC_ALGORITHM_RES = 0;
|
||||
const DNSSEC_ALGORITHM_RSAMD5 = 1;
|
||||
const DNSSEC_ALGORITHM_DH = 2;
|
||||
const DNSSEC_ALGORITHM_DSA = 3;
|
||||
const DNSSEC_ALGORITHM_ECC = 4;
|
||||
const DNSSEC_ALGORITHM_RSASHA1 = 5;
|
||||
const DNSSEC_ALGORITHM_DSANSEC3SHA1 = 6;
|
||||
const DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1 = 7;
|
||||
const DNSSEC_ALGORITHM_RSASHA256 = 8;
|
||||
const DNSSEC_ALGORITHM_RSASHA512 = 10;
|
||||
const DNSSEC_ALGORITHM_ECCGOST = 12;
|
||||
const DNSSEC_ALGORITHM_INDIRECT = 252;
|
||||
const DNSSEC_ALGORITHM_PRIVATEDNS = 253;
|
||||
const DNSSEC_ALGORITHM_PRIVATEOID = 254;
|
||||
|
||||
/*
|
||||
* DNSSEC Digest Types
|
||||
*/
|
||||
const DNSSEC_DIGEST_RES = 0;
|
||||
const DNSSEC_DIGEST_SHA1 = 1;
|
||||
|
||||
/*
|
||||
* The packet id used when sending requests
|
||||
*/
|
||||
public static $next_packet_id;
|
||||
|
||||
/*
|
||||
* Used to map resource record types to their id's, and back
|
||||
*/
|
||||
public static $rr_types_by_id = array();
|
||||
public static $rr_types_by_name = array(
|
||||
|
||||
'SIG0' => 0, // RFC 2931 pseudo type
|
||||
'A' => 1, // RFC 1035
|
||||
'NS' => 2, // RFC 1035
|
||||
'MD' => 3, // RFC 1035 - obsolete, Not implemented
|
||||
'MF' => 4, // RFC 1035 - obsolete, Not implemented
|
||||
'CNAME' => 5, // RFC 1035
|
||||
'SOA' => 6, // RFC 1035
|
||||
'MB' => 7, // RFC 1035 - obsolete, Not implemented
|
||||
'MG' => 8, // RFC 1035 - obsolete, Not implemented
|
||||
'MR' => 9, // RFC 1035 - obsolete, Not implemented
|
||||
'NULL' => 10, // RFC 1035 - obsolete, Not implemented
|
||||
'WKS' => 11, // RFC 1035
|
||||
'PTR' => 12, // RFC 1035
|
||||
'HINFO' => 13, // RFC 1035
|
||||
'MINFO' => 14, // RFC 1035 - obsolete, Not implemented
|
||||
'MX' => 15, // RFC 1035
|
||||
'TXT' => 16, // RFC 1035
|
||||
'RP' => 17, // RFC 1183
|
||||
'AFSDB' => 18, // RFC 1183
|
||||
'X25' => 19, // RFC 1183
|
||||
'ISDN' => 20, // RFC 1183
|
||||
'RT' => 21, // RFC 1183
|
||||
'NSAP' => 22, // RFC 1706
|
||||
'NSAP_PTR' => 23, // RFC 1348 - obsolete, Not implemented
|
||||
'SIG' => 24, // RFC 2535
|
||||
'KEY' => 25, // RFC 2535, RFC 2930
|
||||
'PX' => 26, // RFC 2163
|
||||
'GPOS' => 27, // RFC 1712 - Not implemented
|
||||
'AAAA' => 28, // RFC 3596
|
||||
'LOC' => 29, // RFC 1876
|
||||
'NXT' => 30, // RFC 2065, obsoleted by by RFC 3755
|
||||
'EID' => 31, // [Patton][Patton1995]
|
||||
'NIMLOC' => 32, // [Patton][Patton1995]
|
||||
'SRV' => 33, // RFC 2782
|
||||
'ATMA' => 34, // Windows only
|
||||
'NAPTR' => 35, // RFC 2915
|
||||
'KX' => 36, // RFC 2230
|
||||
'CERT' => 37, // RFC 4398
|
||||
'A6' => 38, // downgraded to experimental by RFC 3363
|
||||
'DNAME' => 39, // RFC 2672
|
||||
'SINK' => 40, // Not implemented
|
||||
'OPT' => 41, // RFC 2671
|
||||
'APL' => 42, // RFC 3123
|
||||
'DS' => 43, // RFC 4034
|
||||
'SSHFP' => 44, // RFC 4255
|
||||
'IPSECKEY' => 45, // RFC 4025
|
||||
'RRSIG' => 46, // RFC 4034
|
||||
'NSEC' => 47, // RFC 4034
|
||||
'DNSKEY' => 48, // RFC 4034
|
||||
'DHCID' => 49, // RFC 4701
|
||||
'NSEC3' => 50, // RFC 5155
|
||||
'NSEC3PARAM' => 51, // RFC 5155
|
||||
'TLSA' => 52, // RFC 6698
|
||||
'SMIMEA' => 53, // draft-ietf-dane-smime-10
|
||||
|
||||
// 54 unassigned
|
||||
|
||||
'HIP' => 55, // RFC 5205
|
||||
'NINFO' => 56, // Not implemented
|
||||
'RKEY' => 57, // Not implemented
|
||||
'TALINK' => 58, //
|
||||
'CDS' => 59, // RFC 7344
|
||||
'CDNSKEY' => 60, // RFC 7344
|
||||
'OPENPGPKEY' => 61, // RFC 7929
|
||||
'CSYNC' => 62, // RFC 7477
|
||||
|
||||
// 63 - 98 unassigned
|
||||
|
||||
'SPF' => 99, // RFC 4408
|
||||
'UINFO' => 100, // no RFC, Not implemented
|
||||
'UID' => 101, // no RFC, Not implemented
|
||||
'GID' => 102, // no RFC, Not implemented
|
||||
'UNSPEC' => 103, // no RFC, Not implemented
|
||||
'NID' => 104, // RFC 6742
|
||||
'L32' => 105, // RFC 6742
|
||||
'L64' => 106, // RFC 6742
|
||||
'LP' => 107, // RFC 6742
|
||||
'EUI48' => 108, // RFC 7043
|
||||
'EUI64' => 109, // RFC 7043
|
||||
|
||||
// 110 - 248 unassigned
|
||||
|
||||
'TKEY' => 249, // RFC 2930
|
||||
'TSIG' => 250, // RFC 2845
|
||||
'IXFR' => 251, // RFC 1995 - only a full (AXFR) is supported
|
||||
'AXFR' => 252, // RFC 1035
|
||||
'MAILB' => 253, // RFC 883, Not implemented
|
||||
'MAILA' => 254, // RFC 973, Not implemented
|
||||
'ANY' => 255, // RFC 1035 - we support both 'ANY' and '*'
|
||||
'URI' => 256, // tools.ietf.org/html/draft-faltstrom-uri-06
|
||||
'CAA' => 257, // tools.ietf.org/html/draft-ietf-pkix-caa-03
|
||||
'AVC' => 258, // Application Visibility and Control
|
||||
|
||||
// 259 - 32767 unassigned
|
||||
|
||||
'TA' => 32768, // same as DS
|
||||
'DLV' => 32769 // RFC 4431
|
||||
);
|
||||
|
||||
/*
|
||||
* Qtypes and Metatypes - defined in RFC2929 section 3.1
|
||||
*/
|
||||
public static $rr_qtypes_by_id = array();
|
||||
public static $rr_qtypes_by_name = array(
|
||||
|
||||
'IXFR' => 251, // RFC 1995 - only a full (AXFR) is supported
|
||||
'AXFR' => 252, // RFC 1035
|
||||
'MAILB' => 253, // RFC 883, Not implemented
|
||||
'MAILA' => 254, // RFC 973, Not implemented
|
||||
'ANY' => 255 // RFC 1035 - we support both 'ANY' and '*'
|
||||
);
|
||||
|
||||
public static $rr_metatypes_by_id = array();
|
||||
public static $rr_metatypes_by_name = array(
|
||||
|
||||
'OPT' => 41, // RFC 2671
|
||||
'TKEY' => 249, // RFC 2930
|
||||
'TSIG' => 250 // RFC 2845
|
||||
);
|
||||
|
||||
/*
|
||||
* used to map resource record id's to RR class names
|
||||
*/
|
||||
public static $rr_types_class_to_id = array();
|
||||
public static $rr_types_id_to_class = array(
|
||||
|
||||
1 => 'Net_DNS2_RR_A',
|
||||
2 => 'Net_DNS2_RR_NS',
|
||||
5 => 'Net_DNS2_RR_CNAME',
|
||||
6 => 'Net_DNS2_RR_SOA',
|
||||
11 => 'Net_DNS2_RR_WKS',
|
||||
12 => 'Net_DNS2_RR_PTR',
|
||||
13 => 'Net_DNS2_RR_HINFO',
|
||||
15 => 'Net_DNS2_RR_MX',
|
||||
16 => 'Net_DNS2_RR_TXT',
|
||||
17 => 'Net_DNS2_RR_RP',
|
||||
18 => 'Net_DNS2_RR_AFSDB',
|
||||
19 => 'Net_DNS2_RR_X25',
|
||||
20 => 'Net_DNS2_RR_ISDN',
|
||||
21 => 'Net_DNS2_RR_RT',
|
||||
22 => 'Net_DNS2_RR_NSAP',
|
||||
24 => 'Net_DNS2_RR_SIG',
|
||||
25 => 'Net_DNS2_RR_KEY',
|
||||
26 => 'Net_DNS2_RR_PX',
|
||||
28 => 'Net_DNS2_RR_AAAA',
|
||||
29 => 'Net_DNS2_RR_LOC',
|
||||
31 => 'Net_DNS2_RR_EID',
|
||||
32 => 'Net_DNS2_RR_NIMLOC',
|
||||
33 => 'Net_DNS2_RR_SRV',
|
||||
34 => 'Net_DNS2_RR_ATMA',
|
||||
35 => 'Net_DNS2_RR_NAPTR',
|
||||
36 => 'Net_DNS2_RR_KX',
|
||||
37 => 'Net_DNS2_RR_CERT',
|
||||
39 => 'Net_DNS2_RR_DNAME',
|
||||
41 => 'Net_DNS2_RR_OPT',
|
||||
42 => 'Net_DNS2_RR_APL',
|
||||
43 => 'Net_DNS2_RR_DS',
|
||||
44 => 'Net_DNS2_RR_SSHFP',
|
||||
45 => 'Net_DNS2_RR_IPSECKEY',
|
||||
46 => 'Net_DNS2_RR_RRSIG',
|
||||
47 => 'Net_DNS2_RR_NSEC',
|
||||
48 => 'Net_DNS2_RR_DNSKEY',
|
||||
49 => 'Net_DNS2_RR_DHCID',
|
||||
50 => 'Net_DNS2_RR_NSEC3',
|
||||
51 => 'Net_DNS2_RR_NSEC3PARAM',
|
||||
52 => 'Net_DNS2_RR_TLSA',
|
||||
53 => 'Net_DNS2_RR_SMIMEA',
|
||||
55 => 'Net_DNS2_RR_HIP',
|
||||
58 => 'Net_DNS2_RR_TALINK',
|
||||
59 => 'Net_DNS2_RR_CDS',
|
||||
60 => 'Net_DNS2_RR_CDNSKEY',
|
||||
61 => 'Net_DNS2_RR_OPENPGPKEY',
|
||||
62 => 'Net_DNS2_RR_CSYNC',
|
||||
99 => 'Net_DNS2_RR_SPF',
|
||||
104 => 'Net_DNS2_RR_NID',
|
||||
105 => 'Net_DNS2_RR_L32',
|
||||
106 => 'Net_DNS2_RR_L64',
|
||||
107 => 'Net_DNS2_RR_LP',
|
||||
108 => 'Net_DNS2_RR_EUI48',
|
||||
109 => 'Net_DNS2_RR_EUI64',
|
||||
|
||||
249 => 'Net_DNS2_RR_TKEY',
|
||||
250 => 'Net_DNS2_RR_TSIG',
|
||||
|
||||
// 251 - IXFR - handled as a full zone transfer (252)
|
||||
// 252 - AXFR - handled as a function call
|
||||
|
||||
255 => 'Net_DNS2_RR_ANY',
|
||||
256 => 'Net_DNS2_RR_URI',
|
||||
257 => 'Net_DNS2_RR_CAA',
|
||||
258 => 'Net_DNS2_RR_AVC',
|
||||
32768 => 'Net_DNS2_RR_TA',
|
||||
32769 => 'Net_DNS2_RR_DLV'
|
||||
);
|
||||
|
||||
/*
|
||||
* used to map resource record class names to their id's, and back
|
||||
*/
|
||||
public static $classes_by_id = array();
|
||||
public static $classes_by_name = array(
|
||||
|
||||
'IN' => self::RR_CLASS_IN, // RFC 1035
|
||||
'CH' => self::RR_CLASS_CH, // RFC 1035
|
||||
'HS' => self::RR_CLASS_HS, // RFC 1035
|
||||
'NONE' => self::RR_CLASS_NONE, // RFC 2136
|
||||
'ANY' => self::RR_CLASS_ANY // RFC 1035
|
||||
);
|
||||
|
||||
/*
|
||||
* maps response codes to error messages
|
||||
*/
|
||||
public static $result_code_messages = array(
|
||||
|
||||
self::RCODE_NOERROR => 'The request completed successfully.',
|
||||
self::RCODE_FORMERR => 'The name server was unable to interpret the query.',
|
||||
self::RCODE_SERVFAIL => 'The name server was unable to process this query due to a problem with the name server.',
|
||||
self::RCODE_NXDOMAIN => 'The domain name referenced in the query does not exist.',
|
||||
self::RCODE_NOTIMP => 'The name server does not support the requested kind of query.',
|
||||
self::RCODE_REFUSED => 'The name server refuses to perform the specified operation for policy reasons.',
|
||||
self::RCODE_YXDOMAIN => 'Name Exists when it should not.',
|
||||
self::RCODE_YXRRSET => 'RR Set Exists when it should not.',
|
||||
self::RCODE_NXRRSET => 'RR Set that should exist does not.',
|
||||
self::RCODE_NOTAUTH => 'Server Not Authoritative for zone.',
|
||||
self::RCODE_NOTZONE => 'Name not contained in zone.',
|
||||
|
||||
self::RCODE_BADSIG => 'TSIG Signature Failure.',
|
||||
self::RCODE_BADKEY => 'Key not recognized.',
|
||||
self::RCODE_BADTIME => 'Signature out of time window.',
|
||||
self::RCODE_BADMODE => 'Bad TKEY Mode.',
|
||||
self::RCODE_BADNAME => 'Duplicate key name.',
|
||||
self::RCODE_BADALG => 'Algorithm not supported.',
|
||||
self::RCODE_BADTRUNC => 'Bad truncation.'
|
||||
);
|
||||
|
||||
/*
|
||||
* maps DNS SEC alrorithms to their mnemonics
|
||||
*/
|
||||
public static $algorithm_name_to_id = array();
|
||||
public static $algorithm_id_to_name = array(
|
||||
|
||||
self::DNSSEC_ALGORITHM_RES => 'RES',
|
||||
self::DNSSEC_ALGORITHM_RSAMD5 => 'RSAMD5',
|
||||
self::DNSSEC_ALGORITHM_DH => 'DH',
|
||||
self::DNSSEC_ALGORITHM_DSA => 'DSA',
|
||||
self::DNSSEC_ALGORITHM_ECC => 'ECC',
|
||||
self::DNSSEC_ALGORITHM_RSASHA1 => 'RSASHA1',
|
||||
self::DNSSEC_ALGORITHM_DSANSEC3SHA1 => 'DSA-NSEC3-SHA1',
|
||||
self::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1 => 'RSASHA1-NSEC3-SHA1',
|
||||
self::DNSSEC_ALGORITHM_RSASHA256 => 'RSASHA256',
|
||||
self::DNSSEC_ALGORITHM_RSASHA512 => 'RSASHA512',
|
||||
self::DNSSEC_ALGORITHM_ECCGOST => 'ECC-GOST',
|
||||
self::DNSSEC_ALGORITHM_INDIRECT => 'INDIRECT',
|
||||
self::DNSSEC_ALGORITHM_PRIVATEDNS => 'PRIVATEDNS',
|
||||
self::DNSSEC_ALGORITHM_PRIVATEOID => 'PRIVATEOID'
|
||||
);
|
||||
|
||||
/*
|
||||
* maps DNSSEC digest types to their mnemonics
|
||||
*/
|
||||
public static $digest_name_to_id = array();
|
||||
public static $digest_id_to_name = array(
|
||||
|
||||
self::DNSSEC_DIGEST_RES => 'RES',
|
||||
self::DNSSEC_DIGEST_SHA1 => 'SHA-1'
|
||||
);
|
||||
|
||||
/*
|
||||
* Protocols names - RFC 1010
|
||||
*/
|
||||
public static $protocol_by_id = array();
|
||||
public static $protocol_by_name = array(
|
||||
|
||||
'ICMP' => 1,
|
||||
'IGMP' => 2,
|
||||
'GGP' => 3,
|
||||
'ST' => 5,
|
||||
'TCP' => 6,
|
||||
'UCL' => 7,
|
||||
'EGP' => 8,
|
||||
'IGP' => 9,
|
||||
'BBN-RCC-MON' => 10,
|
||||
'NVP-II' => 11,
|
||||
'PUP' => 12,
|
||||
'ARGUS' => 13,
|
||||
'EMCON' => 14,
|
||||
'XNET' => 15,
|
||||
'CHAOS' => 16,
|
||||
'UDP' => 17,
|
||||
'MUX' => 18,
|
||||
'DCN-MEAS' => 19,
|
||||
'HMP' => 20,
|
||||
'PRM' => 21,
|
||||
'XNS-IDP' => 22,
|
||||
'TRUNK-1' => 23,
|
||||
'TRUNK-2' => 24,
|
||||
'LEAF-1' => 25,
|
||||
'LEAF-2' => 26,
|
||||
'RDP' => 27,
|
||||
'IRTP' => 28,
|
||||
'ISO-TP4' => 29,
|
||||
'NETBLT' => 30,
|
||||
'MFE-NSP' => 31,
|
||||
'MERIT-INP' => 32,
|
||||
'SEP' => 33,
|
||||
// 34 - 60 - Unassigned
|
||||
// 61 - any host internal protocol
|
||||
'CFTP' => 62,
|
||||
// 63 - any local network
|
||||
'SAT-EXPAK' => 64,
|
||||
'MIT-SUBNET' => 65,
|
||||
'RVD' => 66,
|
||||
'IPPC' => 67,
|
||||
// 68 - any distributed file system
|
||||
'SAT-MON' => 69,
|
||||
// 70 - Unassigned
|
||||
'IPCV' => 71,
|
||||
// 72 - 75 - Unassigned
|
||||
'BR-SAT-MON' => 76,
|
||||
// 77 - Unassigned
|
||||
'WB-MON' => 78,
|
||||
'WB-EXPAK' => 79
|
||||
// 80 - 254 - Unassigned
|
||||
// 255 - Reserved
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,434 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
* This file contains code based off the Net::DNS Perl module by
|
||||
* Michael Fuhr.
|
||||
*
|
||||
* This is the copyright notice from the PERL Net::DNS module:
|
||||
*
|
||||
* Copyright (c) 1997-2000 Michael Fuhr. All rights reserved. This
|
||||
* program is free software; you can redistribute it and/or modify it
|
||||
* under the same terms as Perl itself.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is the base class that holds a standard DNS packet.
|
||||
*
|
||||
* The Net_DNS2_Packet_Request and Net_DNS2_Packet_Response classes extend this
|
||||
* class.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet_Request, Net_DNS2_Packet_Response
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Packet
|
||||
{
|
||||
/*
|
||||
* the full binary data and length for this packet
|
||||
*/
|
||||
public $rdata;
|
||||
public $rdlength;
|
||||
|
||||
/*
|
||||
* the offset pointer used when building/parsing packets
|
||||
*/
|
||||
public $offset = 0;
|
||||
|
||||
/*
|
||||
* Net_DNS2_Header object with the DNS packet header
|
||||
*/
|
||||
public $header;
|
||||
|
||||
/*
|
||||
* array of Net_DNS2_Question objects
|
||||
*
|
||||
* used as "zone" for updates per RFC2136
|
||||
*
|
||||
*/
|
||||
public $question = array();
|
||||
|
||||
/*
|
||||
* array of Net_DNS2_RR Objects for Answers
|
||||
*
|
||||
* used as "prerequisite" for updates per RFC2136
|
||||
*
|
||||
*/
|
||||
public $answer = array();
|
||||
|
||||
/*
|
||||
* array of Net_DNS2_RR Objects for Authority
|
||||
*
|
||||
* used as "update" for updates per RFC2136
|
||||
*
|
||||
*/
|
||||
public $authority = array();
|
||||
|
||||
/*
|
||||
* array of Net_DNS2_RR Objects for Addtitional
|
||||
*/
|
||||
public $additional = array();
|
||||
|
||||
/*
|
||||
* array of compressed labeles
|
||||
*/
|
||||
private $_compressed = array();
|
||||
|
||||
/**
|
||||
* magic __toString() method to return the Net_DNS2_Packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$output = $this->header->__toString();
|
||||
|
||||
foreach ($this->question as $x) {
|
||||
|
||||
$output .= $x->__toString() . "\n";
|
||||
}
|
||||
foreach ($this->answer as $x) {
|
||||
|
||||
$output .= $x->__toString() . "\n";
|
||||
}
|
||||
foreach ($this->authority as $x) {
|
||||
|
||||
$output .= $x->__toString() . "\n";
|
||||
}
|
||||
foreach ($this->additional as $x) {
|
||||
|
||||
$output .= $x->__toString() . "\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a full binary DNS packet
|
||||
*
|
||||
* @return string
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$data = $this->header->get($this);
|
||||
|
||||
foreach ($this->question as $x) {
|
||||
|
||||
$data .= $x->get($this);
|
||||
}
|
||||
foreach ($this->answer as $x) {
|
||||
|
||||
$data .= $x->get($this);
|
||||
}
|
||||
foreach ($this->authority as $x) {
|
||||
|
||||
$data .= $x->get($this);
|
||||
}
|
||||
foreach ($this->additional as $x) {
|
||||
|
||||
$data .= $x->get($this);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* applies a standard DNS name compression on the given name/offset
|
||||
*
|
||||
* This logic was based on the Net::DNS::Packet::dn_comp() function
|
||||
* by Michanel Fuhr
|
||||
*
|
||||
* @param string $name the name to be compressed
|
||||
* @param integer &$offset the offset into the given packet object
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function compress($name, &$offset)
|
||||
{
|
||||
$names = explode('.', $name);
|
||||
$compname = '';
|
||||
|
||||
while (!empty($names)) {
|
||||
|
||||
$dname = join('.', $names);
|
||||
|
||||
if (isset($this->_compressed[$dname])) {
|
||||
|
||||
$compname .= pack('n', 0xc000 | $this->_compressed[$dname]);
|
||||
$offset += 2;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_compressed[$dname] = $offset;
|
||||
$first = array_shift($names);
|
||||
|
||||
$length = strlen($first);
|
||||
if ($length <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// truncate see RFC1035 2.3.1
|
||||
//
|
||||
if ($length > 63) {
|
||||
|
||||
$length = 63;
|
||||
$first = substr($first, 0, $length);
|
||||
}
|
||||
|
||||
$compname .= pack('Ca*', $length, $first);
|
||||
$offset += $length + 1;
|
||||
}
|
||||
|
||||
if (empty($names)) {
|
||||
|
||||
$compname .= pack('C', 0);
|
||||
$offset++;
|
||||
}
|
||||
|
||||
return $compname;
|
||||
}
|
||||
|
||||
/**
|
||||
* applies a standard DNS name compression on the given name/offset
|
||||
*
|
||||
* This logic was based on the Net::DNS::Packet::dn_comp() function
|
||||
* by Michanel Fuhr
|
||||
*
|
||||
* @param string $name the name to be compressed
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function pack($name)
|
||||
{
|
||||
$offset = 0;
|
||||
$names = explode('.', $name);
|
||||
$compname = '';
|
||||
|
||||
while (!empty($names)) {
|
||||
|
||||
$first = array_shift($names);
|
||||
$length = strlen($first);
|
||||
|
||||
$compname .= pack('Ca*', $length, $first);
|
||||
$offset += $length + 1;
|
||||
}
|
||||
|
||||
$compname .= "\0";
|
||||
$offset++;
|
||||
|
||||
return $compname;
|
||||
}
|
||||
|
||||
/**
|
||||
* expands the domain name stored at a given offset in a DNS Packet
|
||||
*
|
||||
* This logic was based on the Net::DNS::Packet::dn_expand() function
|
||||
* by Michanel Fuhr
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name
|
||||
* @param integer &$offset the offset into the given packet object
|
||||
*
|
||||
* @return mixed either the domain name or null if it's not found.
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function expand(Net_DNS2_Packet &$packet, &$offset)
|
||||
{
|
||||
$name = '';
|
||||
|
||||
while (1) {
|
||||
if ($packet->rdlength < ($offset + 1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$xlen = ord($packet->rdata[$offset]);
|
||||
if ($xlen == 0) {
|
||||
|
||||
++$offset;
|
||||
break;
|
||||
|
||||
} else if (($xlen & 0xc0) == 0xc0) {
|
||||
if ($packet->rdlength < ($offset + 2)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$ptr = ord($packet->rdata[$offset]) << 8 |
|
||||
ord($packet->rdata[$offset+1]);
|
||||
$ptr = $ptr & 0x3fff;
|
||||
|
||||
$name2 = Net_DNS2_Packet::expand($packet, $ptr);
|
||||
if (is_null($name2)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$name .= $name2;
|
||||
$offset += 2;
|
||||
|
||||
break;
|
||||
} else {
|
||||
++$offset;
|
||||
|
||||
if ($packet->rdlength < ($offset + $xlen)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$elem = '';
|
||||
$elem = substr($packet->rdata, $offset, $xlen);
|
||||
$name .= $elem . '.';
|
||||
$offset += $xlen;
|
||||
}
|
||||
}
|
||||
|
||||
return trim($name, '.');
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a domain label from a DNS Packet at the given offset
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet the DNS packet to look in for the domain name
|
||||
* @param integer &$offset the offset into the given packet object
|
||||
*
|
||||
* @return mixed either the domain name or null if it's not found.
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function label(Net_DNS2_Packet &$packet, &$offset)
|
||||
{
|
||||
$name = '';
|
||||
|
||||
if ($packet->rdlength < ($offset + 1)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$xlen = ord($packet->rdata[$offset]);
|
||||
++$offset;
|
||||
|
||||
if (($xlen + $offset) > $packet->rdlength) {
|
||||
|
||||
$name = substr($packet->rdata, $offset);
|
||||
$offset = $packet->rdlength;
|
||||
} else {
|
||||
|
||||
$name = substr($packet->rdata, $offset, $xlen);
|
||||
$offset += $xlen;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* copies the contents of the given packet, to the local packet object. this
|
||||
* function intentionally ignores some of the packet data.
|
||||
*
|
||||
* @param Net_DNS2_Packet $packet the DNS packet to copy the data from
|
||||
*
|
||||
* @return boolean
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function copy(Net_DNS2_Packet $packet)
|
||||
{
|
||||
$this->header = $packet->header;
|
||||
$this->question = $packet->question;
|
||||
$this->answer = $packet->answer;
|
||||
$this->authority = $packet->authority;
|
||||
$this->additional = $packet->additional;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets the values in the current packet object
|
||||
*
|
||||
* @return boolean
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->header->id = $this->header->nextPacketId();
|
||||
$this->rdata = '';
|
||||
$this->rdlength = 0;
|
||||
$this->offset = 0;
|
||||
$this->answer = array();
|
||||
$this->authority = array();
|
||||
$this->additional = array();
|
||||
$this->_compressed = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This class handles building new DNS request packets; packets used for DNS
|
||||
* queries and updates.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Packet_Request extends Net_DNS2_Packet
|
||||
{
|
||||
/**
|
||||
* Constructor - builds a new Net_DNS2_Packet_Request object
|
||||
*
|
||||
* @param string $name the domain name for the packet
|
||||
* @param string $type the DNS RR type for the packet
|
||||
* @param string $class the DNS class for the packet
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct($name, $type = null, $class = null)
|
||||
{
|
||||
$this->set($name, $type, $class);
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a new Net_DNS2_Packet_Request object
|
||||
*
|
||||
* @param string $name the domain name for the packet
|
||||
* @param string $type the DNS RR type for the packet
|
||||
* @param string $class the DNS class for the packet
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function set($name, $type = 'A', $class = 'IN')
|
||||
{
|
||||
//
|
||||
// generate a new header
|
||||
//
|
||||
$this->header = new Net_DNS2_Header;
|
||||
|
||||
//
|
||||
// add a new question
|
||||
//
|
||||
$q = new Net_DNS2_Question();
|
||||
|
||||
//
|
||||
// allow queries directly to . for the root name servers
|
||||
//
|
||||
if ($name != '.') {
|
||||
$name = trim(strtolower($name), " \t\n\r\0\x0B.");
|
||||
}
|
||||
|
||||
$type = strtoupper(trim($type));
|
||||
$class = strtoupper(trim($class));
|
||||
|
||||
//
|
||||
// check that the input string has some data in it
|
||||
//
|
||||
if (empty($name)) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'empty query string provided',
|
||||
Net_DNS2_Lookups::E_PACKET_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// if the type is "*", rename it to "ANY"- both are acceptable.
|
||||
//
|
||||
if ($type == '*') {
|
||||
|
||||
$type = 'ANY';
|
||||
}
|
||||
|
||||
//
|
||||
// check that the type and class are valid
|
||||
//
|
||||
if ( (!isset(Net_DNS2_Lookups::$rr_types_by_name[$type]))
|
||||
|| (!isset(Net_DNS2_Lookups::$classes_by_name[$class]))
|
||||
) {
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid type (' . $type . ') or class (' . $class . ') specified.',
|
||||
Net_DNS2_Lookups::E_PACKET_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
if ($type == 'PTR') {
|
||||
|
||||
//
|
||||
// if it's a PTR request for an IP address, then make sure we tack on
|
||||
// the arpa domain.
|
||||
//
|
||||
// there are other types of PTR requests, so if an IP adress doesn't match,
|
||||
// then just let it flow through and assume it's a hostname
|
||||
//
|
||||
if (Net_DNS2::isIPv4($name) == true) {
|
||||
|
||||
//
|
||||
// IPv4
|
||||
//
|
||||
$name = implode('.', array_reverse(explode('.', $name)));
|
||||
$name .= '.in-addr.arpa';
|
||||
|
||||
} else if (Net_DNS2::isIPv6($name) == true) {
|
||||
|
||||
//
|
||||
// IPv6
|
||||
//
|
||||
$e = Net_DNS2::expandIPv6($name);
|
||||
if ($e !== false) {
|
||||
|
||||
$name = implode(
|
||||
'.', array_reverse(str_split(str_replace(':', '', $e)))
|
||||
);
|
||||
|
||||
$name .= '.ip6.arpa';
|
||||
|
||||
} else {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'unsupported PTR value: ' . $name,
|
||||
Net_DNS2_Lookups::E_PACKET_INVALID
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// store the data
|
||||
//
|
||||
$q->qname = $name;
|
||||
$q->qtype = $type;
|
||||
$q->qclass = $class;
|
||||
|
||||
$this->question[] = $q;
|
||||
|
||||
//
|
||||
// the answer, authority and additional are empty; they can be modified
|
||||
// after the request is created for UPDATE requests if needed.
|
||||
//
|
||||
$this->answer = array();
|
||||
$this->authority = array();
|
||||
$this->additional = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This class handles building new DNS response packets; it parses binary packed
|
||||
* packets that come off the wire
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Packet_Response extends Net_DNS2_Packet
|
||||
{
|
||||
/*
|
||||
* The name servers that this response came from
|
||||
*/
|
||||
public $answer_from;
|
||||
|
||||
/*
|
||||
* The socket type the answer came from (TCP/UDP)
|
||||
*/
|
||||
public $answer_socket_type;
|
||||
|
||||
/*
|
||||
* The query response time in microseconds
|
||||
*/
|
||||
public $response_time = 0;
|
||||
|
||||
/**
|
||||
* Constructor - builds a new Net_DNS2_Packet_Response object
|
||||
*
|
||||
* @param string $data binary DNS packet
|
||||
* @param integer $size the length of the DNS packet
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct($data, $size)
|
||||
{
|
||||
$this->set($data, $size);
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a new Net_DNS2_Packet_Response object
|
||||
*
|
||||
* @param string $data binary DNS packet
|
||||
* @param integer $size the length of the DNS packet
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function set($data, $size)
|
||||
{
|
||||
//
|
||||
// store the full packet
|
||||
//
|
||||
$this->rdata = $data;
|
||||
$this->rdlength = $size;
|
||||
|
||||
//
|
||||
// parse the header
|
||||
//
|
||||
// we don't bother checking the size earlier, because the first thing the
|
||||
// header class does, is check the size and throw and exception if it's
|
||||
// invalid.
|
||||
//
|
||||
$this->header = new Net_DNS2_Header($this);
|
||||
|
||||
//
|
||||
// if the truncation bit is set, then just return right here, because the
|
||||
// rest of the packet is probably empty; and there's no point in processing
|
||||
// anything else.
|
||||
//
|
||||
// we also don't need to worry about checking to see if the the header is
|
||||
// null or not, since the Net_DNS2_Header() constructor will throw an
|
||||
// exception if the packet is invalid.
|
||||
//
|
||||
if ($this->header->tc == 1) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// parse the questions
|
||||
//
|
||||
for ($x = 0; $x < $this->header->qdcount; ++$x) {
|
||||
|
||||
$this->question[$x] = new Net_DNS2_Question($this);
|
||||
}
|
||||
|
||||
//
|
||||
// parse the answers
|
||||
//
|
||||
for ($x = 0; $x < $this->header->ancount; ++$x) {
|
||||
|
||||
$o = Net_DNS2_RR::parse($this);
|
||||
if (!is_null($o)) {
|
||||
|
||||
$this->answer[] = $o;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// parse the authority section
|
||||
//
|
||||
for ($x = 0; $x < $this->header->nscount; ++$x) {
|
||||
|
||||
$o = Net_DNS2_RR::parse($this);
|
||||
if (!is_null($o)) {
|
||||
|
||||
$this->authority[] = $o;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// parse the additional section
|
||||
//
|
||||
for ($x = 0; $x < $this->header->arcount; ++$x) {
|
||||
|
||||
$o = Net_DNS2_RR::parse($this);
|
||||
if (!is_null($o)) {
|
||||
|
||||
$this->additional[] = $o;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.1.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SSL Private Key container class
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_PrivateKey
|
||||
{
|
||||
/*
|
||||
* the filename that was loaded; stored for reference
|
||||
*/
|
||||
public $filename;
|
||||
|
||||
/*
|
||||
* the keytag for the signature
|
||||
*/
|
||||
public $keytag;
|
||||
|
||||
/*
|
||||
* the sign name for the signature
|
||||
*/
|
||||
public $signname;
|
||||
|
||||
/*
|
||||
* the algorithm used for the signature
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* the key format fo the signature
|
||||
*/
|
||||
public $key_format;
|
||||
|
||||
/*
|
||||
* the openssl private key id
|
||||
*/
|
||||
public $instance;
|
||||
|
||||
/*
|
||||
* RSA: modulus
|
||||
*/
|
||||
private $_modulus;
|
||||
|
||||
/*
|
||||
* RSA: public exponent
|
||||
*/
|
||||
private $_public_exponent;
|
||||
|
||||
/*
|
||||
* RSA: rivate exponent
|
||||
*/
|
||||
private $_private_exponent;
|
||||
|
||||
/*
|
||||
* RSA: prime1
|
||||
*/
|
||||
private $_prime1;
|
||||
|
||||
/*
|
||||
* RSA: prime2
|
||||
*/
|
||||
private $_prime2;
|
||||
|
||||
/*
|
||||
* RSA: exponent 1
|
||||
*/
|
||||
private $_exponent1;
|
||||
|
||||
/*
|
||||
* RSA: exponent 2
|
||||
*/
|
||||
private $_exponent2;
|
||||
|
||||
/*
|
||||
* RSA: coefficient
|
||||
*/
|
||||
private $_coefficient;
|
||||
|
||||
/*
|
||||
* DSA: prime
|
||||
*/
|
||||
public $prime;
|
||||
|
||||
/*
|
||||
* DSA: subprime
|
||||
*/
|
||||
public $subprime;
|
||||
|
||||
/*
|
||||
* DSA: base
|
||||
*/
|
||||
public $base;
|
||||
|
||||
/*
|
||||
* DSA: private value
|
||||
*/
|
||||
public $private_value;
|
||||
|
||||
/*
|
||||
* DSA: public value
|
||||
*/
|
||||
public $public_value;
|
||||
|
||||
/**
|
||||
* Constructor - base constructor the private key container class
|
||||
*
|
||||
* @param string $file path to a private-key file to parse and load
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct($file = null)
|
||||
{
|
||||
if (isset($file)) {
|
||||
$this->parseFile($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a private key file generated by dnssec-keygen
|
||||
*
|
||||
* @param string $file path to a private-key file to parse and load
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function parseFile($file)
|
||||
{
|
||||
//
|
||||
// check for OpenSSL
|
||||
//
|
||||
if (extension_loaded('openssl') === false) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'the OpenSSL extension is required to use parse private key.',
|
||||
Net_DNS2_Lookups::E_OPENSSL_UNAVAIL
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// check to make sure the file exists
|
||||
//
|
||||
if (is_readable($file) == false) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid private key file: ' . $file,
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// get the base filename, and parse it for the local value
|
||||
//
|
||||
$keyname = basename($file);
|
||||
if (strlen($keyname) == 0) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to get basename() for: ' . $file,
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// parse the keyname
|
||||
//
|
||||
if (preg_match("/K(.*)\.\+(\d{3})\+(\d*)\.private/", $keyname, $matches)) {
|
||||
|
||||
$this->signname = $matches[1];
|
||||
$this->algorithm = intval($matches[2]);
|
||||
$this->keytag = intval($matches[3]);
|
||||
|
||||
} else {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'file ' . $keyname . ' does not look like a private key file!',
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// read all the data from the
|
||||
//
|
||||
$data = file($file, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
if (count($data) == 0) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'file ' . $keyname . ' is empty!',
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($data as $line) {
|
||||
|
||||
list($key, $value) = explode(':', $line);
|
||||
|
||||
$key = trim($key);
|
||||
$value = trim($value);
|
||||
|
||||
switch(strtolower($key)) {
|
||||
|
||||
case 'private-key-format':
|
||||
$this->_key_format = $value;
|
||||
break;
|
||||
|
||||
case 'algorithm':
|
||||
if ($this->algorithm != $value) {
|
||||
throw new Net_DNS2_Exception(
|
||||
'Algorithm mis-match! filename is ' . $this->algorithm .
|
||||
', contents say ' . $value,
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
// RSA
|
||||
//
|
||||
case 'modulus':
|
||||
$this->_modulus = $value;
|
||||
break;
|
||||
|
||||
case 'publicexponent':
|
||||
$this->_public_exponent = $value;
|
||||
break;
|
||||
|
||||
case 'privateexponent':
|
||||
$this->_private_exponent = $value;
|
||||
break;
|
||||
|
||||
case 'prime1':
|
||||
$this->_prime1 = $value;
|
||||
break;
|
||||
|
||||
case 'prime2':
|
||||
$this->_prime2 = $value;
|
||||
break;
|
||||
|
||||
case 'exponent1':
|
||||
$this->_exponent1 = $value;
|
||||
break;
|
||||
|
||||
case 'exponent2':
|
||||
$this->_exponent2 = $value;
|
||||
break;
|
||||
|
||||
case 'coefficient':
|
||||
$this->_coefficient = $value;
|
||||
break;
|
||||
|
||||
//
|
||||
// DSA - this won't work in PHP until the OpenSSL extension is better
|
||||
//
|
||||
case 'prime(p)':
|
||||
$this->prime = $value;
|
||||
break;
|
||||
|
||||
case 'subprime(q)':
|
||||
$this->subprime = $value;
|
||||
break;
|
||||
|
||||
case 'base(g)':
|
||||
$this->base = $value;
|
||||
break;
|
||||
|
||||
case 'private_value(x)':
|
||||
$this->private_value = $value;
|
||||
break;
|
||||
|
||||
case 'public_value(y)':
|
||||
$this->public_value = $value;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Net_DNS2_Exception(
|
||||
'unknown private key data: ' . $key . ': ' . $value,
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// generate the private key
|
||||
//
|
||||
$args = array();
|
||||
|
||||
switch($this->algorithm) {
|
||||
|
||||
//
|
||||
// RSA
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
|
||||
|
||||
$args = array(
|
||||
|
||||
'rsa' => array(
|
||||
|
||||
'n' => base64_decode($this->_modulus),
|
||||
'e' => base64_decode($this->_public_exponent),
|
||||
'd' => base64_decode($this->_private_exponent),
|
||||
'p' => base64_decode($this->_prime1),
|
||||
'q' => base64_decode($this->_prime2),
|
||||
'dmp1' => base64_decode($this->_exponent1),
|
||||
'dmq1' => base64_decode($this->_exponent2),
|
||||
'iqmp' => base64_decode($this->_coefficient)
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
//
|
||||
// DSA - this won't work in PHP until the OpenSSL extension is better
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
|
||||
|
||||
$args = array(
|
||||
|
||||
'dsa' => array(
|
||||
|
||||
'p' => base64_decode($this->prime),
|
||||
'q' => base64_decode($this->subprime),
|
||||
'g' => base64_decode($this->base),
|
||||
'priv_key' => base64_decode($this->private_value),
|
||||
'pub_key' => base64_decode($this->public_value)
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Net_DNS2_Exception(
|
||||
'we only currently support RSAMD5 and RSASHA1 encryption.',
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_PKEY
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// generate and store the key
|
||||
//
|
||||
$this->instance = openssl_pkey_new($args);
|
||||
if ($this->instance === false) {
|
||||
throw new Net_DNS2_Exception(
|
||||
openssl_error_string(),
|
||||
Net_DNS2_Lookups::E_OPENSSL_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// store the filename incase we need it for something
|
||||
//
|
||||
$this->filename = $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class handles parsing and constructing the question sectino of DNS
|
||||
* packets.
|
||||
*
|
||||
* This is referred to as the "zone" for update per RFC2136
|
||||
*
|
||||
* DNS question format - RFC1035 section 4.1.2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | |
|
||||
* / QNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QTYPE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QCLASS |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_Packet
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_Question
|
||||
{
|
||||
/*
|
||||
* The name of the question
|
||||
*
|
||||
* referred to as "zname" for updates per RFC2136
|
||||
*
|
||||
*/
|
||||
public $qname;
|
||||
|
||||
/*
|
||||
* The RR type for the questino
|
||||
*
|
||||
* referred to as "ztype" for updates per RFC2136
|
||||
*
|
||||
*/
|
||||
public $qtype;
|
||||
|
||||
/*
|
||||
* The RR class for the questino
|
||||
*
|
||||
* referred to as "zclass" for updates per RFC2136
|
||||
*
|
||||
*/
|
||||
public $qclass;
|
||||
|
||||
/**
|
||||
* Constructor - builds a new Net_DNS2_Question object
|
||||
*
|
||||
* @param mixed &$packet either a Net_DNS2_Packet object, or null to
|
||||
* build an empty object
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct(Net_DNS2_Packet &$packet = null)
|
||||
{
|
||||
if (!is_null($packet)) {
|
||||
|
||||
$this->set($packet);
|
||||
} else {
|
||||
|
||||
$this->qname = '';
|
||||
$this->qtype = 'A';
|
||||
$this->qclass = 'IN';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* magic __toString() function to return the Net_DNS2_Question object as a string
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return ";;\n;; Question:\n;;\t " . $this->qname . '. ' .
|
||||
$this->qtype . ' ' . $this->qclass . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a new Net_DNS2_Header object from a Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet object
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function set(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// expand the name
|
||||
//
|
||||
$this->qname = $packet->expand($packet, $packet->offset);
|
||||
if ($packet->rdlength < ($packet->offset + 4)) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid question section: to small',
|
||||
Net_DNS2_Lookups::E_QUESTION_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// unpack the type and class
|
||||
//
|
||||
$type = ord($packet->rdata[$packet->offset++]) << 8 |
|
||||
ord($packet->rdata[$packet->offset++]);
|
||||
$class = ord($packet->rdata[$packet->offset++]) << 8 |
|
||||
ord($packet->rdata[$packet->offset++]);
|
||||
|
||||
//
|
||||
// validate it
|
||||
//
|
||||
$type_name = Net_DNS2_Lookups::$rr_types_by_id[$type];
|
||||
$class_name = Net_DNS2_Lookups::$classes_by_id[$class];
|
||||
|
||||
if ( (!isset($type_name)) || (!isset($class_name)) ) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid question section: invalid type (' . $type .
|
||||
') or class (' . $class . ') specified.',
|
||||
Net_DNS2_Lookups::E_QUESTION_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// store it
|
||||
//
|
||||
$this->qtype = $type_name;
|
||||
$this->qclass = $class_name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a binary packed Net_DNS2_Question object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet the Net_DNS2_Packet object this question is
|
||||
* part of. This needs to be passed in so that
|
||||
* the compressed qname value can be packed in
|
||||
* with the names of the other parts of the
|
||||
* packet.
|
||||
*
|
||||
* @return string
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function get(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// validate the type and class
|
||||
//
|
||||
$type = Net_DNS2_Lookups::$rr_types_by_name[$this->qtype];
|
||||
$class = Net_DNS2_Lookups::$classes_by_name[$this->qclass];
|
||||
|
||||
if ( (!isset($type)) || (!isset($class)) ) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid question section: invalid type (' . $this->qtype .
|
||||
') or class (' . $this->qclass . ') specified.',
|
||||
Net_DNS2_Lookups::E_QUESTION_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
$data = $packet->compress($this->qname, $packet->offset);
|
||||
|
||||
$data .= chr($type >> 8) . chr($type) . chr($class >> 8) . chr($class);
|
||||
$packet->offset += 4;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This is the base class for DNS Resource Records
|
||||
*
|
||||
* Each resource record type (defined in RR/*.php) extends this class for
|
||||
* base functionality.
|
||||
*
|
||||
* This class handles parsing and constructing the common parts of the DNS
|
||||
* resource records, while the RR specific functionality is handled in each
|
||||
* child class.
|
||||
*
|
||||
* DNS resource record format - RFC1035 section 4.1.3
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | |
|
||||
* / /
|
||||
* / NAME /
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | TYPE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | CLASS |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | TTL |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | RDLENGTH |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
|
||||
* / RDATA /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
*
|
||||
*/
|
||||
abstract class Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The name of the resource record
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/*
|
||||
* The resource record type
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/*
|
||||
* The resouce record class
|
||||
*/
|
||||
public $class;
|
||||
|
||||
/*
|
||||
* The time to live for this resource record
|
||||
*/
|
||||
public $ttl;
|
||||
|
||||
/*
|
||||
* The length of the rdata field
|
||||
*/
|
||||
public $rdlength;
|
||||
|
||||
/*
|
||||
* The resource record specific data as a packed binary string
|
||||
*/
|
||||
public $rdata;
|
||||
|
||||
/**
|
||||
* abstract definition - method to return a RR as a string; not to
|
||||
* be confused with the __toString() magic method.
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
abstract protected function rrToString();
|
||||
|
||||
/**
|
||||
* abstract definition - parses a RR from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
abstract protected function rrFromString(array $rdata);
|
||||
|
||||
/**
|
||||
* abstract definition - sets a Net_DNS2_RR from a Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
abstract protected function rrSet(Net_DNS2_Packet &$packet);
|
||||
|
||||
/**
|
||||
* abstract definition - returns a binary packet DNS RR object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed string or
|
||||
* null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
abstract protected function rrGet(Net_DNS2_Packet &$packet);
|
||||
|
||||
/**
|
||||
* Constructor - builds a new Net_DNS2_RR object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create
|
||||
* an empty object
|
||||
* @param array $rr an array with RR parse values or null to
|
||||
* create an empty object
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
|
||||
{
|
||||
if ( (!is_null($packet)) && (!is_null($rr)) ) {
|
||||
|
||||
if ($this->set($packet, $rr) == false) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to generate resource record',
|
||||
Net_DNS2_Lookups::E_RR_INVALID
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
$class = Net_DNS2_Lookups::$rr_types_class_to_id[get_class($this)];
|
||||
if (isset($class)) {
|
||||
|
||||
$this->type = Net_DNS2_Lookups::$rr_types_by_id[$class];
|
||||
}
|
||||
|
||||
$this->class = 'IN';
|
||||
$this->ttl = 86400;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* magic __toString() method to return the Net_DNS2_RR object object as a string
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->name . '. ' . $this->ttl . ' ' . $this->class .
|
||||
' ' . $this->type . ' ' . $this->rrToString();
|
||||
}
|
||||
|
||||
/**
|
||||
* return a formatted string; if a string has spaces in it, then return
|
||||
* it with double quotes around it, otherwise, return it as it was passed in.
|
||||
*
|
||||
* @param string $string the string to format
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function formatString($string)
|
||||
{
|
||||
return '"' . str_replace('"', '\"', trim($string, '"')) . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* builds an array of strings from an array of chunks of text split by spaces
|
||||
*
|
||||
* @param array $chunks an array of chunks of text split by spaces
|
||||
*
|
||||
* @return array
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function buildString(array $chunks)
|
||||
{
|
||||
$data = array();
|
||||
$c = 0;
|
||||
$in = false;
|
||||
|
||||
foreach ($chunks as $r) {
|
||||
|
||||
$r = trim($r);
|
||||
if (strlen($r) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ($r[0] == '"')
|
||||
&& ($r[strlen($r) - 1] == '"')
|
||||
&& ($r[strlen($r) - 2] != '\\')
|
||||
) {
|
||||
|
||||
$data[$c] = $r;
|
||||
++$c;
|
||||
$in = false;
|
||||
|
||||
} else if ($r[0] == '"') {
|
||||
|
||||
$data[$c] = $r;
|
||||
$in = true;
|
||||
|
||||
} else if ( ($r[strlen($r) - 1] == '"')
|
||||
&& ($r[strlen($r) - 2] != '\\')
|
||||
) {
|
||||
|
||||
$data[$c] .= ' ' . $r;
|
||||
++$c;
|
||||
$in = false;
|
||||
|
||||
} else {
|
||||
|
||||
if ($in == true) {
|
||||
$data[$c] .= ' ' . $r;
|
||||
} else {
|
||||
$data[$c++] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data as $index => $string) {
|
||||
|
||||
$data[$index] = str_replace('\"', '"', trim($string, '"'));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a new Net_DNS2_RR object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create
|
||||
* an empty object
|
||||
* @param array $rr an array with RR parse values or null to
|
||||
* create an empty object
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function set(Net_DNS2_Packet &$packet, array $rr)
|
||||
{
|
||||
$this->name = $rr['name'];
|
||||
$this->type = Net_DNS2_Lookups::$rr_types_by_id[$rr['type']];
|
||||
|
||||
//
|
||||
// for RR OPT (41), the class value includes the requestors UDP payload size,
|
||||
// and not a class value
|
||||
//
|
||||
if ($this->type == 'OPT') {
|
||||
$this->class = $rr['class'];
|
||||
} else {
|
||||
$this->class = Net_DNS2_Lookups::$classes_by_id[$rr['class']];
|
||||
}
|
||||
|
||||
$this->ttl = $rr['ttl'];
|
||||
$this->rdlength = $rr['rdlength'];
|
||||
$this->rdata = substr($packet->rdata, $packet->offset, $rr['rdlength']);
|
||||
|
||||
return $this->rrSet($packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a binary packed DNS RR object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for
|
||||
* compressing names
|
||||
*
|
||||
* @return string
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function get(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$data = '';
|
||||
$rdata = '';
|
||||
|
||||
//
|
||||
// pack the name
|
||||
//
|
||||
$data = $packet->compress($this->name, $packet->offset);
|
||||
|
||||
//
|
||||
// pack the main values
|
||||
//
|
||||
if ($this->type == 'OPT') {
|
||||
|
||||
//
|
||||
// pre-build the TTL value
|
||||
//
|
||||
$this->preBuild();
|
||||
|
||||
//
|
||||
// the class value is different for OPT types
|
||||
//
|
||||
$data .= pack(
|
||||
'nnN',
|
||||
Net_DNS2_Lookups::$rr_types_by_name[$this->type],
|
||||
$this->class,
|
||||
$this->ttl
|
||||
);
|
||||
} else {
|
||||
|
||||
$data .= pack(
|
||||
'nnN',
|
||||
Net_DNS2_Lookups::$rr_types_by_name[$this->type],
|
||||
Net_DNS2_Lookups::$classes_by_name[$this->class],
|
||||
$this->ttl
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// increase the offset, and allow for the rdlength
|
||||
//
|
||||
$packet->offset += 10;
|
||||
|
||||
//
|
||||
// get the RR specific details
|
||||
//
|
||||
if ($this->rdlength != -1) {
|
||||
|
||||
$rdata = $this->rrGet($packet);
|
||||
}
|
||||
|
||||
//
|
||||
// add the RR
|
||||
//
|
||||
$data .= pack('n', strlen($rdata)) . $rdata;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a binary packet, and returns the appropriate Net_DNS2_RR object,
|
||||
* based on the RR type of the binary content.
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for
|
||||
* decompressing names
|
||||
*
|
||||
* @return mixed returns a new Net_DNS2_RR_* object for
|
||||
* the given RR
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function parse(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$object = array();
|
||||
|
||||
//
|
||||
// expand the name
|
||||
//
|
||||
$object['name'] = $packet->expand($packet, $packet->offset);
|
||||
if (is_null($object['name'])) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to parse resource record: failed to expand name.',
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
if ($packet->rdlength < ($packet->offset + 10)) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to parse resource record: packet too small.',
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// unpack the RR details
|
||||
//
|
||||
$object['type'] = ord($packet->rdata[$packet->offset++]) << 8 |
|
||||
ord($packet->rdata[$packet->offset++]);
|
||||
$object['class'] = ord($packet->rdata[$packet->offset++]) << 8 |
|
||||
ord($packet->rdata[$packet->offset++]);
|
||||
|
||||
$object['ttl'] = ord($packet->rdata[$packet->offset++]) << 24 |
|
||||
ord($packet->rdata[$packet->offset++]) << 16 |
|
||||
ord($packet->rdata[$packet->offset++]) << 8 |
|
||||
ord($packet->rdata[$packet->offset++]);
|
||||
|
||||
$object['rdlength'] = ord($packet->rdata[$packet->offset++]) << 8 |
|
||||
ord($packet->rdata[$packet->offset++]);
|
||||
|
||||
if ($packet->rdlength < ($packet->offset + $object['rdlength'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// lookup the class to use
|
||||
//
|
||||
$o = null;
|
||||
$class = Net_DNS2_Lookups::$rr_types_id_to_class[$object['type']];
|
||||
|
||||
if (isset($class)) {
|
||||
|
||||
$o = new $class($packet, $object);
|
||||
if ($o) {
|
||||
|
||||
$packet->offset += $object['rdlength'];
|
||||
}
|
||||
} else {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'un-implemented resource record type: ' . $object['type'],
|
||||
Net_DNS2_Lookups::E_RR_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* cleans up some RR data
|
||||
*
|
||||
* @param string $data the text string to clean
|
||||
*
|
||||
* @return string returns the cleaned string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function cleanString($data)
|
||||
{
|
||||
return strtolower(rtrim($data, '.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a standard RR format lines, as defined by rfc1035 (kinda)
|
||||
*
|
||||
* In our implementation, the domain *must* be specified- format must be
|
||||
*
|
||||
* <name> [<ttl>] [<class>] <type> <rdata>
|
||||
* or
|
||||
* <name> [<class>] [<ttl>] <type> <rdata>
|
||||
*
|
||||
* name, title, class and type are parsed by this function, rdata is passed
|
||||
* to the RR specific classes for parsing.
|
||||
*
|
||||
* @param string $line a standard DNS config line
|
||||
*
|
||||
* @return mixed returns a new Net_DNS2_RR_* object for the given RR
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public static function fromString($line)
|
||||
{
|
||||
if (strlen($line) == 0) {
|
||||
throw new Net_DNS2_Exception(
|
||||
'empty config line provided.',
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$name = '';
|
||||
$type = '';
|
||||
$class = 'IN';
|
||||
$ttl = 86400;
|
||||
|
||||
//
|
||||
// split the line by spaces
|
||||
//
|
||||
$values = preg_split('/[\s]+/', $line);
|
||||
if (count($values) < 3) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to parse config: minimum of name, type and rdata required.',
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// assume the first value is the name
|
||||
//
|
||||
$name = trim(strtolower(array_shift($values)), '.');
|
||||
|
||||
//
|
||||
// The next value is either a TTL, Class or Type
|
||||
//
|
||||
foreach ($values as $value) {
|
||||
|
||||
switch(true) {
|
||||
case is_numeric($value):
|
||||
|
||||
$ttl = array_shift($values);
|
||||
break;
|
||||
|
||||
//
|
||||
// this is here because of a bug in is_numeric() in certain versions of
|
||||
// PHP on windows.
|
||||
//
|
||||
case ($value === 0):
|
||||
|
||||
$ttl = array_shift($values);
|
||||
break;
|
||||
|
||||
case isset(Net_DNS2_Lookups::$classes_by_name[strtoupper($value)]):
|
||||
|
||||
$class = strtoupper(array_shift($values));
|
||||
break;
|
||||
|
||||
case isset(Net_DNS2_Lookups::$rr_types_by_name[strtoupper($value)]):
|
||||
|
||||
$type = strtoupper(array_shift($values));
|
||||
break 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid config line provided: unknown file: ' . $value,
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// lookup the class to use
|
||||
//
|
||||
$o = null;
|
||||
$class_name = Net_DNS2_Lookups::$rr_types_id_to_class[
|
||||
Net_DNS2_Lookups::$rr_types_by_name[$type]
|
||||
];
|
||||
|
||||
if (isset($class_name)) {
|
||||
|
||||
$o = new $class_name;
|
||||
if (!is_null($o)) {
|
||||
|
||||
//
|
||||
// set the parsed values
|
||||
//
|
||||
$o->name = $name;
|
||||
$o->class = $class;
|
||||
$o->ttl = $ttl;
|
||||
|
||||
//
|
||||
// parse the rdata
|
||||
//
|
||||
if ($o->rrFromString($values) === false) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to parse rdata for config: ' . $line,
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'failed to create new RR record for type: ' . $type,
|
||||
Net_DNS2_Lookups::E_RR_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'un-implemented resource record type: '. $type,
|
||||
Net_DNS2_Lookups::E_RR_INVALID
|
||||
);
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Resource Record - RFC1035 section 3.4.1
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ADDRESS |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_A extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The IPv4 address in quad-dotted notation
|
||||
*/
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$value = array_shift($rdata);
|
||||
|
||||
if (Net_DNS2::isIPv4($value) == true) {
|
||||
|
||||
$this->address = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$this->address = inet_ntop($this->rdata);
|
||||
if ($this->address !== false) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$packet->offset += 4;
|
||||
return inet_pton($this->address);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Resource Record - RFC1035 section 3.4.1
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | ADDRESS |
|
||||
* | |
|
||||
* | (128 bit) |
|
||||
* | |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_AAAA extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the IPv6 address in the preferred hexadecimal values of the eight
|
||||
* 16-bit pieces
|
||||
* per RFC1884
|
||||
*
|
||||
*/
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// expand out compressed formats
|
||||
//
|
||||
$value = array_shift($rdata);
|
||||
if (Net_DNS2::isIPv6($value) == true) {
|
||||
|
||||
$this->address = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// must be 8 x 16bit chunks, or 16 x 8bit
|
||||
//
|
||||
if ($this->rdlength == 16) {
|
||||
|
||||
//
|
||||
// PHP's inet_ntop returns IPv6 addresses in their compressed form,
|
||||
// but we want to keep with the preferred standard, so we'll parse
|
||||
// it manually.
|
||||
//
|
||||
$x = unpack('n8', $this->rdata);
|
||||
if (count($x) == 8) {
|
||||
|
||||
$this->address = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $x);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$packet->offset += 16;
|
||||
return inet_pton($this->address);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* AFSDB Resource Record - RFC1183 section 1
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | SUBTYPE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / HOSTNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_AFSDB extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The AFSDB sub type
|
||||
*/
|
||||
public $subtype;
|
||||
|
||||
/*
|
||||
* The AFSDB hostname
|
||||
*/
|
||||
public $hostname;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->subtype . ' ' . $this->cleanString($this->hostname) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->subtype = array_shift($rdata);
|
||||
$this->hostname = $this->cleanString(array_shift($rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the subtype
|
||||
//
|
||||
$x = unpack('nsubtype', $this->rdata);
|
||||
|
||||
$this->subtype = $x['subtype'];
|
||||
$offset = $packet->offset + 2;
|
||||
|
||||
$this->hostname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->hostname) > 0) {
|
||||
|
||||
$data = pack('n', $this->subtype);
|
||||
$packet->offset += 2;
|
||||
|
||||
$data .= $packet->compress($this->hostname, $packet->offset);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is only used for generating an empty ANY RR.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_ANY extends Net_DNS2_RR
|
||||
{
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.0.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* APL Resource Record - RFC3123
|
||||
*
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | ADDRESSFAMILY |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | PREFIX | N | AFDLENGTH |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* / AFDPART /
|
||||
* | |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_APL extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* a list of all the address prefix list items
|
||||
*/
|
||||
public $apl_items = array();
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = '';
|
||||
|
||||
foreach ($this->apl_items as $item) {
|
||||
|
||||
if ($item['n'] == 1) {
|
||||
|
||||
$out .= '!';
|
||||
}
|
||||
|
||||
$out .= $item['address_family'] . ':' .
|
||||
$item['afd_part'] . '/' . $item['prefix'] . ' ';
|
||||
}
|
||||
|
||||
return trim($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
foreach ($rdata as $item) {
|
||||
|
||||
if (preg_match('/^(!?)([1|2])\:([^\/]*)\/([0-9]{1,3})$/', $item, $m)) {
|
||||
|
||||
$i = array(
|
||||
|
||||
'address_family' => $m[2],
|
||||
'prefix' => $m[4],
|
||||
'n' => ($m[1] == '!') ? 1 : 0,
|
||||
'afd_part' => strtolower($m[3])
|
||||
);
|
||||
|
||||
$address = $this->_trimZeros(
|
||||
$i['address_family'], $i['afd_part']
|
||||
);
|
||||
|
||||
$i['afd_length'] = count(explode('.', $address));
|
||||
|
||||
$this->apl_items[] = $i;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = 0;
|
||||
|
||||
while ($offset < $this->rdlength) {
|
||||
|
||||
//
|
||||
// unpack the family, prefix, negate and length values
|
||||
//
|
||||
$x = unpack(
|
||||
'naddress_family/Cprefix/Cextra', substr($this->rdata, $offset)
|
||||
);
|
||||
|
||||
$item = array(
|
||||
|
||||
'address_family' => $x['address_family'],
|
||||
'prefix' => $x['prefix'],
|
||||
'n' => ($x['extra'] >> 7) & 0x1,
|
||||
'afd_length' => $x['extra'] & 0xf
|
||||
);
|
||||
|
||||
switch($item['address_family']) {
|
||||
|
||||
case 1:
|
||||
$r = unpack(
|
||||
'C*', substr($this->rdata, $offset + 4, $item['afd_length'])
|
||||
);
|
||||
if (count($r) < 4) {
|
||||
|
||||
for ($c=count($r)+1; $c<4+1; $c++) {
|
||||
|
||||
$r[$c] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$item['afd_part'] = implode('.', $r);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
$r = unpack(
|
||||
'C*', substr($this->rdata, $offset + 4, $item['afd_length'])
|
||||
);
|
||||
if (count($r) < 8) {
|
||||
|
||||
for ($c=count($r)+1; $c<8+1; $c++) {
|
||||
|
||||
$r[$c] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$item['afd_part'] = sprintf(
|
||||
'%x:%x:%x:%x:%x:%x:%x:%x',
|
||||
$r[1], $r[2], $r[3], $r[4], $r[5], $r[6], $r[7], $r[8]
|
||||
);
|
||||
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->apl_items[] = $item;
|
||||
|
||||
$offset += 4 + $item['afd_length'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (count($this->apl_items) > 0) {
|
||||
|
||||
$data = '';
|
||||
|
||||
foreach ($this->apl_items as $item) {
|
||||
|
||||
//
|
||||
// pack the address_family and prefix values
|
||||
//
|
||||
$data .= pack(
|
||||
'nCC',
|
||||
$item['address_family'],
|
||||
$item['prefix'],
|
||||
($item['n'] << 7) | $item['afd_length']
|
||||
);
|
||||
|
||||
switch($item['address_family']) {
|
||||
case 1:
|
||||
$address = explode(
|
||||
'.',
|
||||
$this->_trimZeros($item['address_family'], $item['afd_part'])
|
||||
);
|
||||
|
||||
foreach ($address as $b) {
|
||||
$data .= chr($b);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$address = explode(
|
||||
':',
|
||||
$this->_trimZeros($item['address_family'], $item['afd_part'])
|
||||
);
|
||||
|
||||
foreach ($address as $b) {
|
||||
$data .= pack('H', $b);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an IP address with the right-hand zero's trimmed
|
||||
*
|
||||
* @param integer $family the IP address family from the rdata
|
||||
* @param string $address the IP address
|
||||
*
|
||||
* @return string the trimmed IP addresss.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
private function _trimZeros($family, $address)
|
||||
{
|
||||
$a = array();
|
||||
|
||||
switch($family) {
|
||||
case 1:
|
||||
$a = array_reverse(explode('.', $address));
|
||||
break;
|
||||
case 2:
|
||||
$a = array_reverse(explode(':', $address));
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
foreach ($a as $value) {
|
||||
|
||||
if ($value === '0') {
|
||||
|
||||
array_shift($a);
|
||||
}
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
switch($family) {
|
||||
case 1:
|
||||
$out = implode('.', array_reverse($a));
|
||||
break;
|
||||
case 2:
|
||||
$out = implode(':', array_reverse($a));
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.1.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* ATMA Resource Record
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | FORMAT | |
|
||||
* | +--+--+--+--+--+--+--+--+
|
||||
* / ADDRESS /
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_ATMA extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* One octet that indicates the format of ADDRESS. The two possible values
|
||||
* for FORMAT are value 0 indicating ATM End System Address (AESA) format
|
||||
* and value 1 indicating E.164 format
|
||||
*/
|
||||
public $format;
|
||||
|
||||
/*
|
||||
* The IPv4 address in quad-dotted notation
|
||||
*/
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$value = array_shift($rdata);
|
||||
|
||||
if (ctype_xdigit($value) == true) {
|
||||
|
||||
$this->format = 0;
|
||||
$this->address = $value;
|
||||
|
||||
} else if (is_numeric($value) == true) {
|
||||
|
||||
$this->format = 1;
|
||||
$this->address = $value;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the format
|
||||
//
|
||||
$x = unpack('Cformat/N*address', $this->rdata);
|
||||
|
||||
$this->format = $x['format'];
|
||||
|
||||
if ($this->format == 0) {
|
||||
|
||||
$a = unpack('@1/H*address', $this->rdata);
|
||||
|
||||
$this->address = $a['address'];
|
||||
|
||||
} else if ($this->format == 1) {
|
||||
|
||||
$this->address = substr($this->rdata, 1, $this->rdlength - 1);
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$data = chr($this->format);
|
||||
|
||||
if ($this->format == 0) {
|
||||
|
||||
$data .= pack('H*', $this->address);
|
||||
|
||||
} else if ($this->format == 1) {
|
||||
|
||||
$data .= $this->address;
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2016, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2016 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.4.2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The AVC RR is implemented exactly like the TXT record, so
|
||||
* for now we just extend the TXT RR and use it.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_AVC extends Net_DNS2_RR_TXT
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2011, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.2.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* CAA Resource Record - http://tools.ietf.org/html/draft-ietf-pkix-caa-03
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | FLAGS | TAG LENGTH |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / TAG /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / DATA /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_CAA extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The critcal flag
|
||||
*/
|
||||
public $flags;
|
||||
|
||||
/*
|
||||
* The property identifier
|
||||
*/
|
||||
public $tag;
|
||||
|
||||
/*
|
||||
* The property value
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->flags . ' ' . $this->tag . ' "' .
|
||||
trim($this->cleanString($this->value), '"') . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->flags = array_shift($rdata);
|
||||
$this->tag = array_shift($rdata);
|
||||
|
||||
$this->value = trim($this->cleanString(implode($rdata, ' ')), '"');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the flags and tag length
|
||||
//
|
||||
$x = unpack('Cflags/Ctag_length', $this->rdata);
|
||||
|
||||
$this->flags = $x['flags'];
|
||||
$offset = 2;
|
||||
|
||||
$this->tag = substr($this->rdata, $offset, $x['tag_length']);
|
||||
$offset += $x['tag_length'];
|
||||
|
||||
$this->value = substr($this->rdata, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->value) > 0) {
|
||||
|
||||
$data = chr($this->flags);
|
||||
$data .= chr(strlen($this->tag)) . $this->tag . $this->value;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2014, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2014 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.4.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The CDNSKEY RR is implemented exactly like the DNSKEY record, so
|
||||
* for now we just extend the DNSKEY RR and use it.
|
||||
*
|
||||
* http://www.rfc-editor.org/rfc/rfc7344.txt
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_CDNSKEY extends Net_DNS2_RR_DNSKEY
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2011, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.2.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The CDS RR is implemented exactly like the DS record, so
|
||||
* for now we just extend the DS RR and use it.
|
||||
*
|
||||
* http://www.rfc-editor.org/rfc/rfc7344.txt
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_CDS extends Net_DNS2_RR_DS
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* CERT Resource Record - RFC4398 section 2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | format | key tag |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | algorithm | /
|
||||
* +---------------+ certificate or CRL /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_CERT extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* format's allowed for certificates
|
||||
*/
|
||||
const CERT_FORMAT_RES = 0;
|
||||
const CERT_FORMAT_PKIX = 1;
|
||||
const CERT_FORMAT_SPKI = 2;
|
||||
const CERT_FORMAT_PGP = 3;
|
||||
const CERT_FORMAT_IPKIX = 4;
|
||||
const CERT_FORMAT_ISPKI = 5;
|
||||
const CERT_FORMAT_IPGP = 6;
|
||||
const CERT_FORMAT_ACPKIX = 7;
|
||||
const CERT_FORMAT_IACPKIX = 8;
|
||||
const CERT_FORMAT_URI = 253;
|
||||
const CERT_FORMAT_OID = 254;
|
||||
|
||||
public $cert_format_name_to_id = array();
|
||||
public $cert_format_id_to_name = array(
|
||||
|
||||
self::CERT_FORMAT_RES => 'Reserved',
|
||||
self::CERT_FORMAT_PKIX => 'PKIX',
|
||||
self::CERT_FORMAT_SPKI => 'SPKI',
|
||||
self::CERT_FORMAT_PGP => 'PGP',
|
||||
self::CERT_FORMAT_IPKIX => 'IPKIX',
|
||||
self::CERT_FORMAT_ISPKI => 'ISPKI',
|
||||
self::CERT_FORMAT_IPGP => 'IPGP',
|
||||
self::CERT_FORMAT_ACPKIX => 'ACPKIX',
|
||||
self::CERT_FORMAT_IACPKIX => 'IACPKIX',
|
||||
self::CERT_FORMAT_URI => 'URI',
|
||||
self::CERT_FORMAT_OID => 'OID'
|
||||
);
|
||||
|
||||
/*
|
||||
* certificate format
|
||||
*/
|
||||
public $format;
|
||||
|
||||
/*
|
||||
* key tag
|
||||
*/
|
||||
public $keytag;
|
||||
|
||||
/*
|
||||
* The algorithm used for the CERt
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* certificate
|
||||
*/
|
||||
public $certificate;
|
||||
|
||||
/**
|
||||
* we have our own constructor so that we can load our certificate
|
||||
* information for parsing.
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
* @param array $rr a array with parsed RR values
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
|
||||
{
|
||||
parent::__construct($packet, $rr);
|
||||
|
||||
//
|
||||
// load the lookup values
|
||||
//
|
||||
$this->cert_format_name_to_id = array_flip($this->cert_format_id_to_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->format . ' ' . $this->keytag . ' ' . $this->algorithm .
|
||||
' ' . base64_encode($this->certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// load and check the format; can be an int, or a mnemonic symbol
|
||||
//
|
||||
$this->format = array_shift($rdata);
|
||||
if (!is_numeric($this->format)) {
|
||||
|
||||
$mnemonic = strtoupper(trim($this->format));
|
||||
if (!isset($this->cert_format_name_to_id[$mnemonic])) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->format = $this->cert_format_name_to_id[$mnemonic];
|
||||
} else {
|
||||
|
||||
if (!isset($this->cert_format_id_to_name[$this->format])) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->keytag = array_shift($rdata);
|
||||
|
||||
//
|
||||
// parse and check the algorithm; can be an int, or a mnemonic symbol
|
||||
//
|
||||
$this->algorithm = array_shift($rdata);
|
||||
if (!is_numeric($this->algorithm)) {
|
||||
|
||||
$mnemonic = strtoupper(trim($this->algorithm));
|
||||
if (!isset(Net_DNS2_Lookups::$algorithm_name_to_id[$mnemonic])) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->algorithm = Net_DNS2_Lookups::$algorithm_name_to_id[
|
||||
$mnemonic
|
||||
];
|
||||
} else {
|
||||
|
||||
if (!isset(Net_DNS2_Lookups::$algorithm_id_to_name[$this->algorithm])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// parse and base64 decode the certificate
|
||||
//
|
||||
// certificates MUST be provided base64 encoded, if not, everything will
|
||||
// be broken after this point, as we assume it's base64 encoded.
|
||||
//
|
||||
$this->certificate = base64_decode(implode(' ', $rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the format, keytag and algorithm
|
||||
//
|
||||
$x = unpack('nformat/nkeytag/Calgorithm', $this->rdata);
|
||||
|
||||
$this->format = $x['format'];
|
||||
$this->keytag = $x['keytag'];
|
||||
$this->algorithm = $x['algorithm'];
|
||||
|
||||
//
|
||||
// copy the certificate
|
||||
//
|
||||
$this->certificate = substr($this->rdata, 5, $this->rdlength - 5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->certificate) > 0) {
|
||||
|
||||
$data = pack('nnC', $this->format, $this->keytag, $this->algorithm) .
|
||||
$this->certificate;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* CNAME Resource Record - RFC1035 section 3.3.1
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / CNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_CNAME extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The canonical name
|
||||
*/
|
||||
public $cname;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->cname) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->cname = $this->cleanString(array_shift($rdata));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
$this->cname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->cname) > 0) {
|
||||
|
||||
return $packet->compress($this->cname, $packet->offset);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2015, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2015 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.4.1
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* CSYNC Resource Record - RFC 7477 seciond 2.1.1
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | SOA Serial |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | Flags |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / Type Bit Map /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_CSYNC extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* serial number
|
||||
*/
|
||||
public $serial;
|
||||
|
||||
/*
|
||||
* flags
|
||||
*/
|
||||
public $flags;
|
||||
|
||||
/*
|
||||
* array of RR type names
|
||||
*/
|
||||
public $type_bit_maps = array();
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->serial . ' ' . $this->flags;
|
||||
|
||||
//
|
||||
// show the RR's
|
||||
//
|
||||
foreach ($this->type_bit_maps as $rr) {
|
||||
|
||||
$out .= ' ' . strtoupper($rr);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->serial = array_shift($rdata);
|
||||
$this->flags = array_shift($rdata);
|
||||
|
||||
$this->type_bit_maps = $rdata;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the serial and flags values
|
||||
//
|
||||
$x = unpack('@' . $packet->offset . '/Nserial/nflags', $packet->rdata);
|
||||
|
||||
$this->serial = Net_DNS2::expandUint32($x['serial']);
|
||||
$this->flags = $x['flags'];
|
||||
|
||||
//
|
||||
// parse out the RR bitmap
|
||||
//
|
||||
$this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
|
||||
substr($this->rdata, 6)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// pack the serial and flags values
|
||||
//
|
||||
$data = pack('Nn', $this->serial, $this->flags);
|
||||
|
||||
//
|
||||
// convert the array of RR names to a type bitmap
|
||||
//
|
||||
$data .= Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
|
||||
|
||||
//
|
||||
// advance the offset
|
||||
//
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DHCID Resource Record - RFC4701 section 3.1
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ID Type Code |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | Digest Type | /
|
||||
* +--+--+--+--+--+--+--+--+ /
|
||||
* / /
|
||||
* / Digest /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_DHCID extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* Identifier type
|
||||
*/
|
||||
public $id_type;
|
||||
|
||||
/*
|
||||
* Digest Type
|
||||
*/
|
||||
public $digest_type;
|
||||
|
||||
/*
|
||||
* The digest
|
||||
*/
|
||||
public $digest;
|
||||
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = pack('nC', $this->id_type, $this->digest_type);
|
||||
$out .= base64_decode($this->digest);
|
||||
|
||||
return base64_encode($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$data = base64_decode(array_shift($rdata));
|
||||
if (strlen($data) > 0) {
|
||||
|
||||
//
|
||||
// unpack the id type and digest type
|
||||
//
|
||||
$x = unpack('nid_type/Cdigest_type', $data);
|
||||
|
||||
$this->id_type = $x['id_type'];
|
||||
$this->digest_type = $x['digest_type'];
|
||||
|
||||
//
|
||||
// copy out the digest
|
||||
//
|
||||
$this->digest = base64_encode(substr($data, 3, strlen($data) - 3));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the id type and digest type
|
||||
//
|
||||
$x = unpack('nid_type/Cdigest_type', $this->rdata);
|
||||
|
||||
$this->id_type = $x['id_type'];
|
||||
$this->digest_type = $x['digest_type'];
|
||||
|
||||
//
|
||||
// copy out the digest
|
||||
//
|
||||
$this->digest = base64_encode(
|
||||
substr($this->rdata, 3, $this->rdlength - 3)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->digest) > 0) {
|
||||
|
||||
$data = pack('nC', $this->id_type, $this->digest_type) .
|
||||
base64_decode($this->digest);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The DLV RR is implemented exactly like the DS RR; so we just extend that
|
||||
* class, and use all of it's methods
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_DLV extends Net_DNS2_RR_DS
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DNAME Resource Record - RFC2672 section 3
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / DNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_DNAME extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The target name
|
||||
*/
|
||||
public $dname;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->dname) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->dname = $this->cleanString(array_shift($rdata));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
$this->dname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->dname) > 0) {
|
||||
|
||||
return $packet->compress($this->dname, $packet->offset);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DNSKEY Resource Record - RFC4034 sction 2.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Flags | Protocol | Algorithm |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / /
|
||||
* / Public Key /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_DNSKEY extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* flags
|
||||
*/
|
||||
public $flags;
|
||||
|
||||
/*
|
||||
* protocol
|
||||
*/
|
||||
public $protocol;
|
||||
|
||||
/*
|
||||
* algorithm used
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* the public key
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->flags . ' ' . $this->protocol . ' ' .
|
||||
$this->algorithm . ' ' . $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->flags = array_shift($rdata);
|
||||
$this->protocol = array_shift($rdata);
|
||||
$this->algorithm = array_shift($rdata);
|
||||
$this->key = implode(' ', $rdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the flags, protocol and algorithm
|
||||
//
|
||||
$x = unpack('nflags/Cprotocol/Calgorithm', $this->rdata);
|
||||
|
||||
//
|
||||
// TODO: right now we're just displaying what's in DNS; we really
|
||||
// should be parsing bit 7 and bit 15 of the flags field, and store
|
||||
// those separately.
|
||||
//
|
||||
// right now the DNSSEC implementation is really just for display,
|
||||
// we don't validate or handle any of the keys
|
||||
//
|
||||
$this->flags = $x['flags'];
|
||||
$this->protocol = $x['protocol'];
|
||||
$this->algorithm = $x['algorithm'];
|
||||
|
||||
$this->key = base64_encode(substr($this->rdata, 4));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->key) > 0) {
|
||||
|
||||
$data = pack('nCC', $this->flags, $this->protocol, $this->algorithm);
|
||||
$data .= base64_decode($this->key);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DS Resource Record - RFC4034 sction 5.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Key Tag | Algorithm | Digest Type |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / /
|
||||
* / Digest /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_DS extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* key tag
|
||||
*/
|
||||
public $keytag;
|
||||
|
||||
/*
|
||||
* algorithm number
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* algorithm used to construct the digest
|
||||
*/
|
||||
public $digesttype;
|
||||
|
||||
/*
|
||||
* the digest data
|
||||
*/
|
||||
public $digest;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->keytag . ' ' . $this->algorithm . ' ' .
|
||||
$this->digesttype . ' ' . $this->digest;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->keytag = array_shift($rdata);
|
||||
$this->algorithm = array_shift($rdata);
|
||||
$this->digesttype = array_shift($rdata);
|
||||
$this->digest = implode('', $rdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the keytag, algorithm and digesttype
|
||||
//
|
||||
$x = unpack('nkeytag/Calgorithm/Cdigesttype', $this->rdata);
|
||||
|
||||
$this->keytag = $x['keytag'];
|
||||
$this->algorithm = $x['algorithm'];
|
||||
$this->digesttype = $x['digesttype'];
|
||||
|
||||
//
|
||||
// figure out the digest size
|
||||
//
|
||||
$digest_size = 0;
|
||||
if ($this->digesttype == 1) {
|
||||
|
||||
$digest_size = 20; // SHA1
|
||||
|
||||
} else if ($this->digesttype == 2) {
|
||||
|
||||
$digest_size = 32; // SHA256
|
||||
}
|
||||
|
||||
//
|
||||
// copy the digest
|
||||
//
|
||||
$x = unpack('H*', substr($this->rdata, 4, $digest_size));
|
||||
$this->digest = $x[1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->digest) > 0) {
|
||||
|
||||
$data = pack(
|
||||
'nCCH*',
|
||||
$this->keytag, $this->algorithm, $this->digesttype, $this->digest
|
||||
);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* EID Resource Record - undefined; the rdata is simply used as-is in it's
|
||||
* binary format, so not process has to be done.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_EID extends Net_DNS2_RR
|
||||
{
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
return $this->rdata;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2013, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2013 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.3.2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* EUI48 Resource Record - RFC7043 section 3.1
|
||||
*
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | EUI-48 Address |
|
||||
* | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_EUI48 extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The EUI48 address, in hex format
|
||||
*/
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$value = array_shift($rdata);
|
||||
|
||||
//
|
||||
// re: RFC 7043, the field must be represented as six two-digit hex numbers
|
||||
// separated by hyphens.
|
||||
//
|
||||
$a = explode('-', $value);
|
||||
if (count($a) != 6) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// make sure they're all hex values
|
||||
//
|
||||
foreach ($a as $i) {
|
||||
if (ctype_xdigit($i) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// store it
|
||||
//
|
||||
$this->address = strtolower($value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$x = unpack('C6', $this->rdata);
|
||||
if (count($x) == 6) {
|
||||
|
||||
$this->address = vsprintf('%02x-%02x-%02x-%02x-%02x-%02x', $x);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$a = explode('-', $this->address);
|
||||
foreach ($a as $b) {
|
||||
|
||||
$data .= chr(hexdec($b));
|
||||
}
|
||||
|
||||
$packet->offset += 6;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2013, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2013 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.3.2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* EUI64 Resource Record - RFC7043 section 4.1
|
||||
*
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | EUI-48 Address |
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_EUI64 extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The EUI64 address, in hex format
|
||||
*/
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$value = array_shift($rdata);
|
||||
|
||||
//
|
||||
// re: RFC 7043, the field must be represented as 8 two-digit hex numbers
|
||||
// separated by hyphens.
|
||||
//
|
||||
$a = explode('-', $value);
|
||||
if (count($a) != 8) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// make sure they're all hex values
|
||||
//
|
||||
foreach ($a as $i) {
|
||||
if (ctype_xdigit($i) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// store it
|
||||
//
|
||||
$this->address = strtolower($value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$x = unpack('C8', $this->rdata);
|
||||
if (count($x) == 8) {
|
||||
|
||||
$this->address = vsprintf(
|
||||
'%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x', $x
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$a = explode('-', $this->address);
|
||||
foreach ($a as $b) {
|
||||
|
||||
$data .= chr(hexdec($b));
|
||||
}
|
||||
|
||||
$packet->offset += 8;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* HINFO Resource Record - RFC1035 section 3.3.2
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / CPU /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / OS /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_HINFO extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* computer informatino
|
||||
*/
|
||||
public $cpu;
|
||||
|
||||
/*
|
||||
* operataing system
|
||||
*/
|
||||
public $os;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->formatString($this->cpu) . ' ' .
|
||||
$this->formatString($this->os);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$data = $this->buildString($rdata);
|
||||
if (count($data) == 2) {
|
||||
|
||||
$this->cpu = $data[0];
|
||||
$this->os = $data[1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->cpu = trim(Net_DNS2_Packet::label($packet, $offset), '"');
|
||||
$this->os = trim(Net_DNS2_Packet::label($packet, $offset), '"');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->cpu) > 0) {
|
||||
|
||||
$data = chr(strlen($this->cpu)) . $this->cpu;
|
||||
$data .= chr(strlen($this->os)) . $this->os;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.0.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* HIP Resource Record - RFC5205 section 5
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | HIT length | PK algorithm | PK length |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* ~ HIT ~
|
||||
* | |
|
||||
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+ +
|
||||
* | Public Key |
|
||||
* ~ ~
|
||||
* | |
|
||||
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
|
||||
* | |
|
||||
* ~ Rendezvous Servers ~
|
||||
* | |
|
||||
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_HIP extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The length of the HIT field
|
||||
*/
|
||||
public $hit_length;
|
||||
|
||||
/*
|
||||
* the public key cryptographic algorithm
|
||||
*/
|
||||
public $pk_algorithm;
|
||||
|
||||
/*
|
||||
* the length of the public key field
|
||||
*/
|
||||
public $pk_length;
|
||||
|
||||
/*
|
||||
* The HIT is stored as a binary value in network byte order.
|
||||
*/
|
||||
public $hit;
|
||||
|
||||
/*
|
||||
* The public key
|
||||
*/
|
||||
public $public_key;
|
||||
|
||||
/*
|
||||
* a list of rendezvous servers
|
||||
*/
|
||||
public $rendezvous_servers = array();
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->pk_algorithm . ' ' .
|
||||
$this->hit . ' ' . $this->public_key . ' ';
|
||||
|
||||
foreach ($this->rendezvous_servers as $index => $server) {
|
||||
|
||||
$out .= $server . '. ';
|
||||
}
|
||||
|
||||
return trim($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->pk_algorithm = array_shift($rdata);
|
||||
$this->hit = strtoupper(array_shift($rdata));
|
||||
$this->public_key = array_shift($rdata);
|
||||
|
||||
//
|
||||
// anything left on the array, must be one or more rendezevous servers. add
|
||||
// them and strip off the trailing dot
|
||||
//
|
||||
if (count($rdata) > 0) {
|
||||
|
||||
$this->rendezvous_servers = preg_replace('/\.$/', '', $rdata);
|
||||
}
|
||||
|
||||
//
|
||||
// store the lengths;
|
||||
//
|
||||
$this->hit_length = strlen(pack('H*', $this->hit));
|
||||
$this->pk_length = strlen(base64_decode($this->public_key));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the algorithm and length values
|
||||
//
|
||||
$x = unpack('Chit_length/Cpk_algorithm/npk_length', $this->rdata);
|
||||
|
||||
$this->hit_length = $x['hit_length'];
|
||||
$this->pk_algorithm = $x['pk_algorithm'];
|
||||
$this->pk_length = $x['pk_length'];
|
||||
|
||||
$offset = 4;
|
||||
|
||||
//
|
||||
// copy out the HIT value
|
||||
//
|
||||
$hit = unpack('H*', substr($this->rdata, $offset, $this->hit_length));
|
||||
|
||||
$this->hit = strtoupper($hit[1]);
|
||||
$offset += $this->hit_length;
|
||||
|
||||
//
|
||||
// copy out the public key
|
||||
//
|
||||
$this->public_key = base64_encode(
|
||||
substr($this->rdata, $offset, $this->pk_length)
|
||||
);
|
||||
$offset += $this->pk_length;
|
||||
|
||||
//
|
||||
// copy out any possible rendezvous servers
|
||||
//
|
||||
$offset = $packet->offset + $offset;
|
||||
|
||||
while ( ($offset - $packet->offset) < $this->rdlength) {
|
||||
|
||||
$this->rendezvous_servers[] = Net_DNS2_Packet::expand(
|
||||
$packet, $offset
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ( (strlen($this->hit) > 0) && (strlen($this->public_key) > 0) ) {
|
||||
|
||||
//
|
||||
// pack the length, algorithm and HIT values
|
||||
//
|
||||
$data = pack(
|
||||
'CCnH*',
|
||||
$this->hit_length,
|
||||
$this->pk_algorithm,
|
||||
$this->pk_length,
|
||||
$this->hit
|
||||
);
|
||||
|
||||
//
|
||||
// add the public key
|
||||
//
|
||||
$data .= base64_decode($this->public_key);
|
||||
|
||||
//
|
||||
// add the offset
|
||||
//
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
//
|
||||
// add each rendezvous server
|
||||
//
|
||||
foreach ($this->rendezvous_servers as $index => $server) {
|
||||
|
||||
$data .= $packet->compress($server, $packet->offset);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* IPSECKEY Resource Record - RFC4025 section 2.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | precedence | gateway type | algorithm | gateway |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------+ +
|
||||
* ~ gateway ~
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | /
|
||||
* / public key /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_IPSECKEY extends Net_DNS2_RR
|
||||
{
|
||||
const GATEWAY_TYPE_NONE = 0;
|
||||
const GATEWAY_TYPE_IPV4 = 1;
|
||||
const GATEWAY_TYPE_IPV6 = 2;
|
||||
const GATEWAY_TYPE_DOMAIN = 3;
|
||||
|
||||
const ALGORITHM_NONE = 0;
|
||||
const ALGORITHM_DSA = 1;
|
||||
const ALGORITHM_RSA = 2;
|
||||
|
||||
/*
|
||||
* Precedence (used the same was as a preference field)
|
||||
*/
|
||||
public $precedence;
|
||||
|
||||
/*
|
||||
* Gateway type - specifies the format of the gataway information
|
||||
* This can be either:
|
||||
*
|
||||
* 0 No Gateway
|
||||
* 1 IPv4 address
|
||||
* 2 IPV6 address
|
||||
* 3 wire-encoded domain name (not compressed)
|
||||
*
|
||||
*/
|
||||
public $gateway_type;
|
||||
|
||||
/*
|
||||
* The algorithm used
|
||||
*
|
||||
* This can be:
|
||||
*
|
||||
* 0 No key is present
|
||||
* 1 DSA key is present
|
||||
* 2 RSA key is present
|
||||
*
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* The gatway information
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/*
|
||||
* the public key
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->precedence . ' ' . $this->gateway_type . ' ' .
|
||||
$this->algorithm . ' ';
|
||||
|
||||
switch($this->gateway_type) {
|
||||
case self::GATEWAY_TYPE_NONE:
|
||||
$out .= '. ';
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_IPV4:
|
||||
case self::GATEWAY_TYPE_IPV6:
|
||||
$out .= $this->gateway . ' ';
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_DOMAIN:
|
||||
$out .= $this->gateway . '. ';
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= $this->key;
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// load the data
|
||||
//
|
||||
$precedence = array_shift($rdata);
|
||||
$gateway_type = array_shift($rdata);
|
||||
$algorithm = array_shift($rdata);
|
||||
$gateway = strtolower(trim(array_shift($rdata)));
|
||||
$key = array_shift($rdata);
|
||||
|
||||
//
|
||||
// validate it
|
||||
//
|
||||
switch($gateway_type) {
|
||||
case self::GATEWAY_TYPE_NONE:
|
||||
$gateway = '';
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_IPV4:
|
||||
if (Net_DNS2::isIPv4($gateway) == false) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_IPV6:
|
||||
if (Net_DNS2::isIPv6($gateway) == false) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_DOMAIN:
|
||||
; // do nothing
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// check the algorithm and key
|
||||
//
|
||||
switch($algorithm) {
|
||||
case self::ALGORITHM_NONE:
|
||||
$key = '';
|
||||
break;
|
||||
|
||||
case self::ALGORITHM_DSA:
|
||||
case self::ALGORITHM_RSA:
|
||||
; // do nothing
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// store the values
|
||||
//
|
||||
$this->precedence = $precedence;
|
||||
$this->gateway_type = $gateway_type;
|
||||
$this->algorithm = $algorithm;
|
||||
$this->gateway = $gateway;
|
||||
$this->key = $key;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// parse off the precedence, gateway type and algorithm
|
||||
//
|
||||
$x = unpack('Cprecedence/Cgateway_type/Calgorithm', $this->rdata);
|
||||
|
||||
$this->precedence = $x['precedence'];
|
||||
$this->gateway_type = $x['gateway_type'];
|
||||
$this->algorithm = $x['algorithm'];
|
||||
|
||||
$offset = 3;
|
||||
|
||||
//
|
||||
// extract the gatway based on the type
|
||||
//
|
||||
switch($this->gateway_type) {
|
||||
case self::GATEWAY_TYPE_NONE:
|
||||
$this->gateway = '';
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_IPV4:
|
||||
$this->gateway = inet_ntop(substr($this->rdata, $offset, 4));
|
||||
$offset += 4;
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_IPV6:
|
||||
$ip = unpack('n8', substr($this->rdata, $offset, 16));
|
||||
if (count($ip) == 8) {
|
||||
|
||||
$this->gateway = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $ip);
|
||||
$offset += 16;
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_DOMAIN:
|
||||
|
||||
$doffset = $offset + $packet->offset;
|
||||
$this->gateway = Net_DNS2_Packet::expand($packet, $doffset);
|
||||
$offset = ($doffset - $packet->offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// extract the key
|
||||
//
|
||||
switch($this->algorithm) {
|
||||
case self::ALGORITHM_NONE:
|
||||
$this->key = '';
|
||||
break;
|
||||
|
||||
case self::ALGORITHM_DSA:
|
||||
case self::ALGORITHM_RSA:
|
||||
$this->key = base64_encode(substr($this->rdata, $offset));
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// pack the precedence, gateway type and algorithm
|
||||
//
|
||||
$data = pack(
|
||||
'CCC', $this->precedence, $this->gateway_type, $this->algorithm
|
||||
);
|
||||
|
||||
//
|
||||
// add the gateway based on the type
|
||||
//
|
||||
switch($this->gateway_type) {
|
||||
case self::GATEWAY_TYPE_NONE:
|
||||
; // add nothing
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_IPV4:
|
||||
case self::GATEWAY_TYPE_IPV6:
|
||||
$data .= inet_pton($this->gateway);
|
||||
break;
|
||||
|
||||
case self::GATEWAY_TYPE_DOMAIN:
|
||||
$data .= chr(strlen($this->gateway)) . $this->gateway;
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// add the key if there's one specified
|
||||
//
|
||||
switch($this->algorithm) {
|
||||
case self::ALGORITHM_NONE:
|
||||
; // add nothing
|
||||
break;
|
||||
|
||||
case self::ALGORITHM_DSA:
|
||||
case self::ALGORITHM_RSA:
|
||||
$data .= base64_decode($this->key);
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* ISDN Resource Record - RFC1183 section 3.2
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / ISDN-address /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / SA /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_ISDN extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* ISDN Number
|
||||
*/
|
||||
public $isdnaddress;
|
||||
|
||||
/*
|
||||
* Sub-Address
|
||||
*/
|
||||
public $sa;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->formatString($this->isdnaddress) . ' ' .
|
||||
$this->formatString($this->sa);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$data = $this->buildString($rdata);
|
||||
if (count($data) >= 1) {
|
||||
|
||||
$this->isdnaddress = $data[0];
|
||||
if (isset($data[1])) {
|
||||
|
||||
$this->sa = $data[1];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$this->isdnaddress = Net_DNS2_Packet::label($packet, $packet->offset);
|
||||
|
||||
//
|
||||
// look for a SA (sub address) - it's optional
|
||||
//
|
||||
if ( (strlen($this->isdnaddress) + 1) < $this->rdlength) {
|
||||
|
||||
$this->sa = Net_DNS2_Packet::label($packet, $packet->offset);
|
||||
} else {
|
||||
|
||||
$this->sa = '';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->isdnaddress) > 0) {
|
||||
|
||||
$data = chr(strlen($this->isdnaddress)) . $this->isdnaddress;
|
||||
if (!empty($this->sa)) {
|
||||
|
||||
$data .= chr(strlen($this->sa));
|
||||
$data .= $this->sa;
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* the KEY RR is implemented the same as the DNSKEY RR, the only difference
|
||||
* is how the flags data is parsed.
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | A/C | Z | XT| Z | Z | NAMTYP| Z | Z | Z | Z | SIG |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
*
|
||||
* DNSKEY only uses bits 7 and 15
|
||||
*
|
||||
* We're not doing anything with these flags right now, so duplicating the
|
||||
* class like this is fine.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_KEY extends Net_DNS2_RR_DNSKEY
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* KX Resource Record - RFC2230 section 3.1
|
||||
*
|
||||
* This class is almost identical to MX, except that the the exchanger
|
||||
* domain is not compressed, it's added as a label
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PREFERENCE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / EXCHANGER /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_KX extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the preference for this mail exchanger
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* the hostname of the mail exchanger
|
||||
*/
|
||||
public $exchange;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->cleanString($this->exchange) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = array_shift($rdata);
|
||||
$this->exchange = $this->cleanString(array_shift($rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// parse the preference
|
||||
//
|
||||
$x = unpack('npreference', $this->rdata);
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
//
|
||||
// get the exchange entry server)
|
||||
//
|
||||
$offset = $packet->offset + 2;
|
||||
$this->exchange = Net_DNS2_Packet::label($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->exchange) > 0) {
|
||||
|
||||
$data = pack('nC', $this->preference, strlen($this->exchange)) .
|
||||
$this->exchange;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2013, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2013 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.3.1
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* L32 Resource Record - RFC6742 section 2.2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Preference | Locator32 (16 MSBs) |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Locator32 (16 LSBs) |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_L32 extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The preference
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* The locator32 field
|
||||
*/
|
||||
public $locator32;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->locator32;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = array_shift($rdata);
|
||||
$this->locator32 = array_shift($rdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the values
|
||||
//
|
||||
$x = unpack('npreference/C4locator', $this->rdata);
|
||||
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
//
|
||||
// build the locator value
|
||||
//
|
||||
$this->locator32 = $x['locator1'] . '.' . $x['locator2'] . '.' .
|
||||
$x['locator3'] . '.' . $x['locator4'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->locator32) > 0) {
|
||||
|
||||
//
|
||||
// break out the locator value
|
||||
//
|
||||
$n = explode('.', $this->locator32);
|
||||
|
||||
//
|
||||
// pack the data
|
||||
//
|
||||
return pack('nC4', $this->preference, $n[0], $n[1], $n[2], $n[3]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2013, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2013 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.3.1
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* L64 Resource Record - RFC6742 section 2.3
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Preference | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
|
||||
* | Locator64 |
|
||||
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_L64 extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The preference
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* The locator64 field
|
||||
*/
|
||||
public $locator64;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->locator64;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = array_shift($rdata);
|
||||
$this->locator64 = array_shift($rdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the values
|
||||
//
|
||||
$x = unpack('npreference/n4locator', $this->rdata);
|
||||
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
//
|
||||
// build the locator64
|
||||
//
|
||||
$this->locator64 = dechex($x['locator1']) . ':' .
|
||||
dechex($x['locator2']) . ':' .
|
||||
dechex($x['locator3']) . ':' .
|
||||
dechex($x['locator4']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->locator64) > 0) {
|
||||
|
||||
//
|
||||
// break out the locator64
|
||||
//
|
||||
$n = explode(':', $this->locator64);
|
||||
|
||||
//
|
||||
// pack the data
|
||||
//
|
||||
return pack(
|
||||
'n5', $this->preference, hexdec($n[0]), hexdec($n[1]),
|
||||
hexdec($n[2]), hexdec($n[3])
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,440 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* LOC Resource Record - RFC1876 section 2
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | VERSION | SIZE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | HORIZ PRE | VERT PRE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | LATITUDE |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | LONGITUDE |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ALTITUDE |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_LOC extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the LOC version- should only ever be 0
|
||||
*/
|
||||
public $version;
|
||||
|
||||
/*
|
||||
* The diameter of a sphere enclosing the described entity
|
||||
*/
|
||||
public $size;
|
||||
|
||||
/*
|
||||
* The horizontal precision of the data
|
||||
*/
|
||||
public $horiz_pre;
|
||||
|
||||
/*
|
||||
* The vertical precision of the data
|
||||
*/
|
||||
public $vert_pre;
|
||||
|
||||
/*
|
||||
* The latitude - stored in decimal degrees
|
||||
*/
|
||||
public $latitude;
|
||||
|
||||
/*
|
||||
* The longitude - stored in decimal degrees
|
||||
*/
|
||||
public $longitude;
|
||||
|
||||
/*
|
||||
* The altitude - stored in decimal
|
||||
*/
|
||||
public $altitude;
|
||||
|
||||
/*
|
||||
* used for quick power-of-ten lookups
|
||||
*/
|
||||
private $_powerOfTen = array(1, 10, 100, 1000, 10000, 100000,
|
||||
1000000,10000000,100000000,1000000000);
|
||||
|
||||
/*
|
||||
* some conversion values
|
||||
*/
|
||||
const CONV_SEC = 1000;
|
||||
const CONV_MIN = 60000;
|
||||
const CONV_DEG = 3600000;
|
||||
|
||||
const REFERENCE_ALT = 10000000;
|
||||
const REFERENCE_LATLON = 2147483648;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
if ($this->version == 0) {
|
||||
|
||||
return $this->_d2Dms($this->latitude, 'LAT') . ' ' .
|
||||
$this->_d2Dms($this->longitude, 'LNG') . ' ' .
|
||||
sprintf('%.2fm', $this->altitude) . ' ' .
|
||||
sprintf('%.2fm', $this->size) . ' ' .
|
||||
sprintf('%.2fm', $this->horiz_pre) . ' ' .
|
||||
sprintf('%.2fm', $this->vert_pre);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// format as defined by RFC1876 section 3
|
||||
//
|
||||
// d1 [m1 [s1]] {"N"|"S"} d2 [m2 [s2]] {"E"|"W"} alt["m"]
|
||||
// [siz["m"] [hp["m"] [vp["m"]]]]
|
||||
//
|
||||
$res = preg_match(
|
||||
'/^(\d+) \s+((\d+) \s+)?(([\d.]+) \s+)?(N|S) \s+(\d+) ' .
|
||||
'\s+((\d+) \s+)?(([\d.]+) \s+)?(E|W) \s+(-?[\d.]+) m?(\s+ ' .
|
||||
'([\d.]+) m?)?(\s+ ([\d.]+) m?)?(\s+ ([\d.]+) m?)?/ix',
|
||||
implode(' ', $rdata), $x
|
||||
);
|
||||
|
||||
if ($res) {
|
||||
|
||||
//
|
||||
// latitude
|
||||
//
|
||||
$latdeg = $x[1];
|
||||
$latmin = (isset($x[3])) ? $x[3] : 0;
|
||||
$latsec = (isset($x[5])) ? $x[5] : 0;
|
||||
$lathem = strtoupper($x[6]);
|
||||
|
||||
$this->latitude = $this->_dms2d($latdeg, $latmin, $latsec, $lathem);
|
||||
|
||||
//
|
||||
// longitude
|
||||
//
|
||||
$londeg = $x[7];
|
||||
$lonmin = (isset($x[9])) ? $x[9] : 0;
|
||||
$lonsec = (isset($x[11])) ? $x[11] : 0;
|
||||
$lonhem = strtoupper($x[12]);
|
||||
|
||||
$this->longitude = $this->_dms2d($londeg, $lonmin, $lonsec, $lonhem);
|
||||
|
||||
//
|
||||
// the rest of teh values
|
||||
//
|
||||
$version = 0;
|
||||
|
||||
$this->size = (isset($x[15])) ? $x[15] : 1;
|
||||
$this->horiz_pre = ((isset($x[17])) ? $x[17] : 10000);
|
||||
$this->vert_pre = ((isset($x[19])) ? $x[19] : 10);
|
||||
$this->altitude = $x[13];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack all the values
|
||||
//
|
||||
$x = unpack(
|
||||
'Cver/Csize/Choriz_pre/Cvert_pre/Nlatitude/Nlongitude/Naltitude',
|
||||
$this->rdata
|
||||
);
|
||||
|
||||
//
|
||||
// version must be 0 per RFC 1876 section 2
|
||||
//
|
||||
$this->version = $x['ver'];
|
||||
if ($this->version == 0) {
|
||||
|
||||
$this->size = $this->_precsizeNtoA($x['size']);
|
||||
$this->horiz_pre = $this->_precsizeNtoA($x['horiz_pre']);
|
||||
$this->vert_pre = $this->_precsizeNtoA($x['vert_pre']);
|
||||
|
||||
//
|
||||
// convert the latitude and longitude to degress in decimal
|
||||
//
|
||||
if ($x['latitude'] < 0) {
|
||||
|
||||
$this->latitude = ($x['latitude'] +
|
||||
self::REFERENCE_LATLON) / self::CONV_DEG;
|
||||
} else {
|
||||
|
||||
$this->latitude = ($x['latitude'] -
|
||||
self::REFERENCE_LATLON) / self::CONV_DEG;
|
||||
}
|
||||
|
||||
if ($x['longitude'] < 0) {
|
||||
|
||||
$this->longitude = ($x['longitude'] +
|
||||
self::REFERENCE_LATLON) / self::CONV_DEG;
|
||||
} else {
|
||||
|
||||
$this->longitude = ($x['longitude'] -
|
||||
self::REFERENCE_LATLON) / self::CONV_DEG;
|
||||
}
|
||||
|
||||
//
|
||||
// convert down the altitude
|
||||
//
|
||||
$this->altitude = ($x['altitude'] - self::REFERENCE_ALT) / 100;
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->version == 0) {
|
||||
|
||||
$lat = 0;
|
||||
$lng = 0;
|
||||
|
||||
if ($this->latitude < 0) {
|
||||
|
||||
$lat = ($this->latitude * self::CONV_DEG) - self::REFERENCE_LATLON;
|
||||
} else {
|
||||
|
||||
$lat = ($this->latitude * self::CONV_DEG) + self::REFERENCE_LATLON;
|
||||
}
|
||||
|
||||
if ($this->longitude < 0) {
|
||||
|
||||
$lng = ($this->longitude * self::CONV_DEG) - self::REFERENCE_LATLON;
|
||||
} else {
|
||||
|
||||
$lng = ($this->longitude * self::CONV_DEG) + self::REFERENCE_LATLON;
|
||||
}
|
||||
|
||||
$packet->offset += 16;
|
||||
|
||||
return pack(
|
||||
'CCCCNNN',
|
||||
$this->version,
|
||||
$this->_precsizeAtoN($this->size),
|
||||
$this->_precsizeAtoN($this->horiz_pre),
|
||||
$this->_precsizeAtoN($this->vert_pre),
|
||||
$lat, $lng,
|
||||
($this->altitude * 100) + self::REFERENCE_ALT
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* takes an XeY precision/size value, returns a string representation.
|
||||
* shamlessly stolen from RFC1876 Appendix A
|
||||
*
|
||||
* @param integer $prec the value to convert
|
||||
*
|
||||
* @return string
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
private function _precsizeNtoA($prec)
|
||||
{
|
||||
$mantissa = (($prec >> 4) & 0x0f) % 10;
|
||||
$exponent = (($prec >> 0) & 0x0f) % 10;
|
||||
|
||||
return $mantissa * $this->_powerOfTen[$exponent];
|
||||
}
|
||||
|
||||
/**
|
||||
* converts ascii size/precision X * 10**Y(cm) to 0xXY.
|
||||
* shamlessly stolen from RFC1876 Appendix A
|
||||
*
|
||||
* @param string $prec the value to convert
|
||||
*
|
||||
* @return integer
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
private function _precsizeAtoN($prec)
|
||||
{
|
||||
$exponent = 0;
|
||||
while ($prec >= 10) {
|
||||
|
||||
$prec /= 10;
|
||||
++$exponent;
|
||||
}
|
||||
|
||||
return ($prec << 4) | ($exponent & 0x0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert lat/lng in deg/min/sec/hem to decimal value
|
||||
*
|
||||
* @param integer $deg the degree value
|
||||
* @param integer $min the minutes value
|
||||
* @param integer $sec the seconds value
|
||||
* @param string $hem the hemisphere (N/E/S/W)
|
||||
*
|
||||
* @return float the decinmal value
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
private function _dms2d($deg, $min, $sec, $hem)
|
||||
{
|
||||
$deg = $deg - 0;
|
||||
$min = $min - 0;
|
||||
|
||||
$sign = ($hem == 'W' || $hem == 'S') ? -1 : 1;
|
||||
return ((($sec/60+$min)/60)+$deg) * $sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert lat/lng in decimal to deg/min/sec/hem
|
||||
*
|
||||
* @param float $data the decimal value
|
||||
* @param string $latlng either LAT or LNG so we can determine the HEM value
|
||||
*
|
||||
* @return string
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
private function _d2Dms($data, $latlng)
|
||||
{
|
||||
$deg = 0;
|
||||
$min = 0;
|
||||
$sec = 0;
|
||||
$msec = 0;
|
||||
$hem = '';
|
||||
|
||||
if ($latlng == 'LAT') {
|
||||
$hem = ($data > 0) ? 'N' : 'S';
|
||||
} else {
|
||||
$hem = ($data > 0) ? 'E' : 'W';
|
||||
}
|
||||
|
||||
$data = abs($data);
|
||||
|
||||
$deg = (int)$data;
|
||||
$min = (int)(($data - $deg) * 60);
|
||||
$sec = (int)(((($data - $deg) * 60) - $min) * 60);
|
||||
$msec = round((((((($data - $deg) * 60) - $min) * 60) - $sec) * 1000));
|
||||
|
||||
return sprintf('%d %02d %02d.%03d %s', $deg, $min, $sec, round($msec), $hem);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2013, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2013 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.3.1
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* LP Resource Record - RFC6742 section 2.4
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Preference | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
|
||||
* / /
|
||||
* / FQDN /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_LP extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The preference
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* The fdqn field
|
||||
*/
|
||||
public $fqdn;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->fqdn . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = array_shift($rdata);
|
||||
$this->fqdn = trim(array_shift($rdata), '.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// parse the preference
|
||||
//
|
||||
$x = unpack('npreference', $this->rdata);
|
||||
$this->preference = $x['preference'];
|
||||
$offset = $packet->offset + 2;
|
||||
|
||||
//
|
||||
// get the hostname
|
||||
//
|
||||
$this->fqdn = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->fqdn) > 0) {
|
||||
|
||||
$data = pack('n', $this->preference);
|
||||
$packet->offset += 2;
|
||||
|
||||
$data .= $packet->compress($this->fqdn, $packet->offset);
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* MX Resource Record - RFC1035 section 3.3.9
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PREFERENCE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / EXCHANGE /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_MX extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the preference for this mail exchanger
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* the hostname of the mail exchanger
|
||||
*/
|
||||
public $exchange;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->cleanString($this->exchange) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = array_shift($rdata);
|
||||
$this->exchange = $this->cleanString(array_shift($rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// parse the preference
|
||||
//
|
||||
$x = unpack('npreference', $this->rdata);
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
//
|
||||
// get the exchange entry server)
|
||||
//
|
||||
$offset = $packet->offset + 2;
|
||||
$this->exchange = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->exchange) > 0) {
|
||||
|
||||
$data = pack('n', $this->preference);
|
||||
$packet->offset += 2;
|
||||
|
||||
$data .= $packet->compress($this->exchange, $packet->offset);
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NAPTR Resource Record - RFC2915
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ORDER |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PREFERENCE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / FLAGS /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / SERVICES /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / REGEXP /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / REPLACEMENT /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NAPTR extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the order in which the NAPTR records MUST be processed
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/*
|
||||
* specifies the order in which NAPTR records with equal "order"
|
||||
* values SHOULD be processed
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* rewrite flags
|
||||
*/
|
||||
public $flags;
|
||||
|
||||
/*
|
||||
* Specifies the service(s) available down this rewrite path
|
||||
*/
|
||||
public $services;
|
||||
|
||||
/*
|
||||
* regular expression
|
||||
*/
|
||||
public $regexp;
|
||||
|
||||
/*
|
||||
* The next NAME to query for NAPTR, SRV, or address records
|
||||
* depending on the value of the flags field
|
||||
*/
|
||||
public $replacement;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->order . ' ' . $this->preference . ' ' .
|
||||
$this->formatString($this->flags) . ' ' .
|
||||
$this->formatString($this->services) . ' ' .
|
||||
$this->formatString($this->regexp) . ' ' .
|
||||
$this->cleanString($this->replacement) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->order = array_shift($rdata);
|
||||
$this->preference = array_shift($rdata);
|
||||
|
||||
$data = $this->buildString($rdata);
|
||||
if (count($data) == 4) {
|
||||
|
||||
$this->flags = $data[0];
|
||||
$this->services = $data[1];
|
||||
$this->regexp = $data[2];
|
||||
$this->replacement = $this->cleanString($data[3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the order and preference
|
||||
//
|
||||
$x = unpack('norder/npreference', $this->rdata);
|
||||
|
||||
$this->order = $x['order'];
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
$offset = $packet->offset + 4;
|
||||
|
||||
$this->flags = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->services = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->regexp = Net_DNS2_Packet::label($packet, $offset);
|
||||
|
||||
$this->replacement = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ( (isset($this->order)) && (strlen($this->services) > 0) ) {
|
||||
|
||||
$data = pack('nn', $this->order, $this->preference);
|
||||
|
||||
$data .= chr(strlen($this->flags)) . $this->flags;
|
||||
$data .= chr(strlen($this->services)) . $this->services;
|
||||
$data .= chr(strlen($this->regexp)) . $this->regexp;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
$data .= $packet->compress($this->replacement, $packet->offset);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2013, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2013 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.3.1
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NID Resource Record - RFC6742 section 2.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Preference | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
|
||||
* | NodeID |
|
||||
* + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NID extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The preference
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* The node ID field
|
||||
*/
|
||||
public $nodeid;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->nodeid;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = array_shift($rdata);
|
||||
$this->nodeid = array_shift($rdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the values
|
||||
//
|
||||
$x = unpack('npreference/n4nodeid', $this->rdata);
|
||||
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
//
|
||||
// build the node id
|
||||
//
|
||||
$this->nodeid = dechex($x['nodeid1']) . ':' .
|
||||
dechex($x['nodeid2']) . ':' .
|
||||
dechex($x['nodeid3']) . ':' .
|
||||
dechex($x['nodeid4']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->nodeid) > 0) {
|
||||
|
||||
//
|
||||
// break out the node id
|
||||
//
|
||||
$n = explode(':', $this->nodeid);
|
||||
|
||||
//
|
||||
// pack the data
|
||||
//
|
||||
return pack(
|
||||
'n5', $this->preference, hexdec($n[0]), hexdec($n[1]),
|
||||
hexdec($n[2]), hexdec($n[3])
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NIMLOCK Resource Record - undefined; the rdata is simply used as-is in it's
|
||||
* binary format, so not process has to be done.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NIMLOCK extends Net_DNS2_RR
|
||||
{
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
return $this->rdata;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NS Resource Record - RFC1035 section 3.3.11
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / NSDNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NS extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the hostname of the DNS server
|
||||
*/
|
||||
public $nsdname;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->nsdname) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->nsdname = $this->cleanString(array_shift($rdata));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
$this->nsdname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->nsdname) > 0) {
|
||||
|
||||
return $packet->compress($this->nsdname, $packet->offset);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NSAP Resource Record - RFC1706
|
||||
*
|
||||
* |--------------|
|
||||
* | <-- IDP --> |
|
||||
* |--------------|-------------------------------------|
|
||||
* | AFI | IDI | <-- DSP --> |
|
||||
* |-----|--------|-------------------------------------|
|
||||
* | 47 | 0005 | DFI | AA |Rsvd | RD |Area | ID |Sel |
|
||||
* |-----|--------|-----|----|-----|----|-----|----|----|
|
||||
* octets | 1 | 2 | 1 | 3 | 2 | 2 | 2 | 6 | 1 |
|
||||
* |-----|--------|-----|----|-----|----|-----|----|----|
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NSAP extends Net_DNS2_RR
|
||||
{
|
||||
public $afi;
|
||||
public $idi;
|
||||
public $dfi;
|
||||
public $aa;
|
||||
public $rsvd;
|
||||
public $rd;
|
||||
public $area;
|
||||
public $id;
|
||||
public $sel;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->afi) . '.' .
|
||||
$this->cleanString($this->idi) . '.' .
|
||||
$this->cleanString($this->dfi) . '.' .
|
||||
$this->cleanString($this->aa) . '.' .
|
||||
$this->cleanString($this->rsvd) . '.' .
|
||||
$this->cleanString($this->rd) . '.' .
|
||||
$this->cleanString($this->area) . '.' .
|
||||
$this->cleanString($this->id) . '.' .
|
||||
$this->sel;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$data = strtolower(trim(array_shift($rdata)));
|
||||
|
||||
//
|
||||
// there is no real standard for format, so we can't rely on the fact that
|
||||
// the value will come in with periods separating the values- so strip
|
||||
// them out if they're included, and parse without them.
|
||||
//
|
||||
$data = str_replace(array('.', '0x'), '', $data);
|
||||
|
||||
//
|
||||
// unpack it as ascii characters
|
||||
//
|
||||
$x = unpack('A2afi/A4idi/A2dfi/A6aa/A4rsvd/A4rd/A4area/A12id/A2sel', $data);
|
||||
|
||||
//
|
||||
// make sure the afi value is 47
|
||||
//
|
||||
if ($x['afi'] == '47') {
|
||||
|
||||
$this->afi = '0x' . $x['afi'];
|
||||
$this->idi = $x['idi'];
|
||||
$this->dfi = $x['dfi'];
|
||||
$this->aa = $x['aa'];
|
||||
$this->rsvd = $x['rsvd'];
|
||||
$this->rd = $x['rd'];
|
||||
$this->area = $x['area'];
|
||||
$this->id = $x['id'];
|
||||
$this->sel = $x['sel'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength == 20) {
|
||||
|
||||
//
|
||||
// get the AFI value
|
||||
//
|
||||
$this->afi = dechex(ord($this->rdata[0]));
|
||||
|
||||
//
|
||||
// we only support AFI 47- there arent' any others defined.
|
||||
//
|
||||
if ($this->afi == '47') {
|
||||
|
||||
//
|
||||
// unpack the rest of the values
|
||||
//
|
||||
$x = unpack(
|
||||
'Cafi/nidi/Cdfi/C3aa/nrsvd/nrd/narea/Nidh/nidl/Csel',
|
||||
$this->rdata
|
||||
);
|
||||
|
||||
$this->afi = sprintf('0x%02x', $x['afi']);
|
||||
$this->idi = sprintf('%04x', $x['idi']);
|
||||
$this->dfi = sprintf('%02x', $x['dfi']);
|
||||
$this->aa = sprintf(
|
||||
'%06x', $x['aa1'] << 16 | $x['aa2'] << 8 | $x['aa3']
|
||||
);
|
||||
$this->rsvd = sprintf('%04x', $x['rsvd']);
|
||||
$this->rd = sprintf('%04x', $x['rd']);
|
||||
$this->area = sprintf('%04x', $x['area']);
|
||||
$this->id = sprintf('%08x', $x['idh']) .
|
||||
sprintf('%04x', $x['idl']);
|
||||
$this->sel = sprintf('%02x', $x['sel']);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->afi == '0x47') {
|
||||
|
||||
//
|
||||
// build the aa field
|
||||
//
|
||||
$aa = unpack('A2x/A2y/A2z', $this->aa);
|
||||
|
||||
//
|
||||
// build the id field
|
||||
//
|
||||
$id = unpack('A8a/A4b', $this->id);
|
||||
|
||||
//
|
||||
$data = pack(
|
||||
'CnCCCCnnnNnC',
|
||||
hexdec($this->afi),
|
||||
hexdec($this->idi),
|
||||
hexdec($this->dfi),
|
||||
hexdec($aa['x']),
|
||||
hexdec($aa['y']),
|
||||
hexdec($aa['z']),
|
||||
hexdec($this->rsvd),
|
||||
hexdec($this->rd),
|
||||
hexdec($this->area),
|
||||
hexdec($id['a']),
|
||||
hexdec($id['b']),
|
||||
hexdec($this->sel)
|
||||
);
|
||||
|
||||
if (strlen($data) == 20) {
|
||||
|
||||
$packet->offset += 20;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NSEC Resource Record - RFC3845 section 2.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / Next Domain Name /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / List of Type Bit Map(s) /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NSEC extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The next owner name
|
||||
*/
|
||||
public $next_domain_name;
|
||||
|
||||
/*
|
||||
* identifies the RRset types that exist at the NSEC RR's owner name.
|
||||
*/
|
||||
public $type_bit_maps = array();
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$data = $this->cleanString($this->next_domain_name) . '.';
|
||||
|
||||
foreach ($this->type_bit_maps as $rr) {
|
||||
|
||||
$data .= ' ' . $rr;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->next_domain_name = $this->cleanString(array_shift($rdata));
|
||||
$this->type_bit_maps = $rdata;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// expand the next domain name
|
||||
//
|
||||
$offset = $packet->offset;
|
||||
$this->next_domain_name = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
//
|
||||
// parse out the RR's from the bitmap
|
||||
//
|
||||
$this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
|
||||
substr($this->rdata, $offset - $packet->offset)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->next_domain_name) > 0) {
|
||||
|
||||
$data = $packet->compress($this->next_domain_name, $packet->offset);
|
||||
$bitmap = Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
|
||||
|
||||
$packet->offset += strlen($bitmap);
|
||||
|
||||
return $data . $bitmap;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NSEC3 Resource Record - RFC5155 section 3.2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Hash Alg. | Flags | Iterations |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Salt Length | Salt /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Hash Length | Next Hashed Owner Name /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / Type Bit Maps /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NSEC3 extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* Algorithm to use
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* flags
|
||||
*/
|
||||
public $flags;
|
||||
|
||||
/*
|
||||
* defines the number of additional times the hash is performed.
|
||||
*/
|
||||
public $iterations;
|
||||
|
||||
/*
|
||||
* the length of the salt- not displayed
|
||||
*/
|
||||
public $salt_length;
|
||||
|
||||
/*
|
||||
* the salt
|
||||
*/
|
||||
public $salt;
|
||||
|
||||
/*
|
||||
* the length of the hash value
|
||||
*/
|
||||
public $hash_length;
|
||||
|
||||
/*
|
||||
* the hashed value of the owner name
|
||||
*/
|
||||
public $hashed_owner_name;
|
||||
|
||||
/*
|
||||
* array of RR type names
|
||||
*/
|
||||
public $type_bit_maps = array();
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->algorithm . ' ' . $this->flags . ' ' . $this->iterations . ' ';
|
||||
|
||||
//
|
||||
// per RFC5155, the salt_length value isn't displayed, and if the salt
|
||||
// is empty, the salt is displayed as '-'
|
||||
//
|
||||
if ($this->salt_length > 0) {
|
||||
|
||||
$out .= $this->salt;
|
||||
} else {
|
||||
|
||||
$out .= '-';
|
||||
}
|
||||
|
||||
//
|
||||
// per RFC5255 the hash length isn't shown
|
||||
//
|
||||
$out .= ' ' . $this->hashed_owner_name;
|
||||
|
||||
//
|
||||
// show the RR's
|
||||
//
|
||||
foreach ($this->type_bit_maps as $rr) {
|
||||
|
||||
$out .= ' ' . strtoupper($rr);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->algorithm = array_shift($rdata);
|
||||
$this->flags = array_shift($rdata);
|
||||
$this->iterations = array_shift($rdata);
|
||||
|
||||
//
|
||||
// an empty salt is represented as '-' per RFC5155 section 3.3
|
||||
//
|
||||
$salt = array_shift($rdata);
|
||||
if ($salt == '-') {
|
||||
|
||||
$this->salt_length = 0;
|
||||
$this->salt = '';
|
||||
} else {
|
||||
|
||||
$this->salt_length = strlen(pack('H*', $salt));
|
||||
$this->salt = strtoupper($salt);
|
||||
}
|
||||
|
||||
$this->hashed_owner_name = array_shift($rdata);
|
||||
$this->hash_length = strlen(base64_decode($this->hashed_owner_name));
|
||||
|
||||
$this->type_bit_maps = $rdata;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the first values
|
||||
//
|
||||
$x = unpack('Calgorithm/Cflags/niterations/Csalt_length', $this->rdata);
|
||||
|
||||
$this->algorithm = $x['algorithm'];
|
||||
$this->flags = $x['flags'];
|
||||
$this->iterations = $x['iterations'];
|
||||
$this->salt_length = $x['salt_length'];
|
||||
|
||||
$offset = 5;
|
||||
|
||||
if ($this->salt_length > 0) {
|
||||
|
||||
$x = unpack('H*', substr($this->rdata, $offset, $this->salt_length));
|
||||
$this->salt = strtoupper($x[1]);
|
||||
$offset += $this->salt_length;
|
||||
}
|
||||
|
||||
//
|
||||
// unpack the hash length
|
||||
//
|
||||
$x = unpack('@' . $offset . '/Chash_length', $this->rdata);
|
||||
$offset++;
|
||||
|
||||
//
|
||||
// copy out the hash
|
||||
//
|
||||
$this->hash_length = $x['hash_length'];
|
||||
if ($this->hash_length > 0) {
|
||||
|
||||
$this->hashed_owner_name = base64_encode(
|
||||
substr($this->rdata, $offset, $this->hash_length)
|
||||
);
|
||||
$offset += $this->hash_length;
|
||||
}
|
||||
|
||||
//
|
||||
// parse out the RR bitmap
|
||||
//
|
||||
$this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray(
|
||||
substr($this->rdata, $offset)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// pull the salt and build the length
|
||||
//
|
||||
$salt = pack('H*', $this->salt);
|
||||
$this->salt_length = strlen($salt);
|
||||
|
||||
//
|
||||
// pack the algorithm, flags, iterations and salt length
|
||||
//
|
||||
$data = pack(
|
||||
'CCnC',
|
||||
$this->algorithm, $this->flags, $this->iterations, $this->salt_length
|
||||
);
|
||||
$data .= $salt;
|
||||
|
||||
//
|
||||
// add the hash length and hash
|
||||
//
|
||||
$data .= chr($this->hash_length);
|
||||
if ($this->hash_length > 0) {
|
||||
|
||||
$data .= base64_decode($this->hashed_owner_name);
|
||||
}
|
||||
|
||||
//
|
||||
// conver the array of RR names to a type bitmap
|
||||
//
|
||||
$data .= Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* NSEC3PARAM Resource Record - RFC5155 section 4.2
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Hash Alg. | Flags | Iterations |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Salt Length | Salt /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_NSEC3PARAM extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* Algorithm to use
|
||||
*
|
||||
* TODO: same as the NSEC3
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* flags
|
||||
*/
|
||||
public $flags;
|
||||
|
||||
/*
|
||||
* defines the number of additional times the hash is performed.
|
||||
*/
|
||||
public $iterations;
|
||||
|
||||
/*
|
||||
* the length of the salt- not displayed
|
||||
*/
|
||||
public $salt_length;
|
||||
|
||||
/*
|
||||
* the salt
|
||||
*/
|
||||
public $salt;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->algorithm . ' ' . $this->flags . ' ' . $this->iterations . ' ';
|
||||
|
||||
//
|
||||
// per RFC5155, the salt_length value isn't displayed, and if the salt
|
||||
// is empty, the salt is displayed as "-"
|
||||
//
|
||||
if ($this->salt_length > 0) {
|
||||
|
||||
$out .= $this->salt;
|
||||
} else {
|
||||
|
||||
$out .= '-';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->algorithm = array_shift($rdata);
|
||||
$this->flags = array_shift($rdata);
|
||||
$this->iterations = array_shift($rdata);
|
||||
|
||||
$salt = array_shift($rdata);
|
||||
if ($salt == '-') {
|
||||
|
||||
$this->salt_length = 0;
|
||||
$this->salt = '';
|
||||
} else {
|
||||
|
||||
$this->salt_length = strlen(pack('H*', $salt));
|
||||
$this->salt = strtoupper($salt);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$x = unpack('Calgorithm/Cflags/niterations/Csalt_length', $this->rdata);
|
||||
|
||||
$this->algorithm = $x['algorithm'];
|
||||
$this->flags = $x['flags'];
|
||||
$this->iterations = $x['iterations'];
|
||||
$this->salt_length = $x['salt_length'];
|
||||
|
||||
if ($this->salt_length > 0) {
|
||||
|
||||
$x = unpack('H*', substr($this->rdata, 5, $this->salt_length));
|
||||
$this->salt = strtoupper($x[1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$salt = pack('H*', $this->salt);
|
||||
$this->salt_length = strlen($salt);
|
||||
|
||||
$data = pack(
|
||||
'CCnC',
|
||||
$this->algorithm, $this->flags, $this->iterations, $this->salt_length
|
||||
) . $salt;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2014, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2014 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.4.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* OPENPGPKEY Resource Record - https://tools.ietf.org/html/draft-ietf-dane-openpgpkey-01
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / /
|
||||
* / OpenPGP Public KeyRing /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_OPENPGPKEY extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the public key
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->key = array_shift($rdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$this->key = base64_encode(substr($this->rdata, 0, $this->rdlength));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->key) > 0) {
|
||||
|
||||
$data = base64_decode($this->key);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.0.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* OPT Resource Record - RFC2929 section 3.1
|
||||
*
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | OPTION-CODE |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | OPTION-LENGTH |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* | |
|
||||
* / OPTION-DATA /
|
||||
* / /
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_OPT extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* option code - assigned by IANA
|
||||
*/
|
||||
public $option_code;
|
||||
|
||||
/*
|
||||
* the length of the option data
|
||||
*/
|
||||
public $option_length;
|
||||
|
||||
/*
|
||||
* the option data
|
||||
*/
|
||||
public $option_data;
|
||||
|
||||
/*
|
||||
* the extended response code stored in the TTL
|
||||
*/
|
||||
public $extended_rcode;
|
||||
|
||||
/*
|
||||
* the implementation level
|
||||
*/
|
||||
public $version;
|
||||
|
||||
/*
|
||||
* the DO bit used for DNSSEC - RFC3225
|
||||
*/
|
||||
public $do;
|
||||
|
||||
/*
|
||||
* the extended flags
|
||||
*/
|
||||
public $z;
|
||||
|
||||
/**
|
||||
* Constructor - builds a new Net_DNS2_RR_OPT object; normally you wouldn't call
|
||||
* this directly, but OPT RR's are a little different
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet or null to create
|
||||
* an empty object
|
||||
* @param array $rr an array with RR parse values or null to
|
||||
* create an empty object
|
||||
*
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function __construct(Net_DNS2_Packet &$packet = null, array $rr = null)
|
||||
{
|
||||
//
|
||||
// this is for when we're manually building an OPT RR object; we aren't
|
||||
// passing in binary data to parse, we just want a clean/empty object.
|
||||
//
|
||||
$this->type = 'OPT';
|
||||
$this->rdlength = 0;
|
||||
|
||||
$this->option_length = 0;
|
||||
$this->extended_rcode = 0;
|
||||
$this->version = 0;
|
||||
$this->do = 0;
|
||||
$this->z = 0;
|
||||
|
||||
//
|
||||
// everthing else gets passed through to the parent.
|
||||
//
|
||||
if ( (!is_null($packet)) && (!is_null($rr)) ) {
|
||||
|
||||
parent::__construct($packet, $rr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string. There is no
|
||||
* defintion for returning an OPT RR by string- this is just here to validate
|
||||
* the binary parsing / building routines.
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->option_code . ' ' . $this->option_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line. There is no
|
||||
* definition for parsing a OPT RR by string- this is just here to validate
|
||||
* the binary parsing / building routines.
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->option_code = array_shift($rdata);
|
||||
$this->option_data = array_shift($rdata);
|
||||
$this->option_length = strlen($this->option_data);
|
||||
|
||||
$x = unpack('Cextended/Cversion/Cdo/Cz', pack('N', $this->ttl));
|
||||
|
||||
$this->extended_rcode = $x['extended'];
|
||||
$this->version = $x['version'];
|
||||
$this->do = ($x['do'] >> 7);
|
||||
$this->z = $x['z'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// parse out the TTL value
|
||||
//
|
||||
$x = unpack('Cextended/Cversion/Cdo/Cz', pack('N', $this->ttl));
|
||||
|
||||
$this->extended_rcode = $x['extended'];
|
||||
$this->version = $x['version'];
|
||||
$this->do = ($x['do'] >> 7);
|
||||
$this->z = $x['z'];
|
||||
|
||||
//
|
||||
// parse the data, if there is any
|
||||
//
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the code and length
|
||||
//
|
||||
$x = unpack('noption_code/noption_length', $this->rdata);
|
||||
|
||||
$this->option_code = $x['option_code'];
|
||||
$this->option_length = $x['option_length'];
|
||||
|
||||
//
|
||||
// copy out the data based on the length
|
||||
//
|
||||
$this->option_data = substr($this->rdata, 4);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* pre-builds the TTL value for this record; we needed to separate this out
|
||||
* from the rrGet() function, as the logic in the Net_DNS2_RR packs the TTL
|
||||
* value before it builds the rdata value.
|
||||
*
|
||||
* @return void
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function preBuild()
|
||||
{
|
||||
//
|
||||
// build the TTL value based on the local values
|
||||
//
|
||||
$ttl = unpack(
|
||||
'N',
|
||||
pack('CCCC', $this->extended_rcode, $this->version, ($this->do << 7), 0)
|
||||
);
|
||||
|
||||
$this->ttl = $ttl[1];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// if there is an option code, then pack that data too
|
||||
//
|
||||
if ($this->option_code) {
|
||||
|
||||
$data = pack('nn', $this->option_code, $this->option_length) .
|
||||
$this->option_data;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* PTR Resource Record - RFC1035 section 3.3.12
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / PTRDNAME /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_PTR extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the hostname of the PTR entry
|
||||
*/
|
||||
public $ptrdname;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return rtrim($this->ptrdname, '.') . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->ptrdname = rtrim(implode(' ', $rdata), '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
$this->ptrdname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->ptrdname) > 0) {
|
||||
|
||||
return $packet->compress($this->ptrdname, $packet->offset);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* PX Resource Record - RFC2163 section 4
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PREFERENCE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / MAP822 /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / MAPX400 /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_PX extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* preference
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* the RFC822 part of the MCGAM
|
||||
*/
|
||||
public $map822;
|
||||
|
||||
/*
|
||||
* the X.400 part of the MCGAM
|
||||
*/
|
||||
public $mapx400;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' . $this->cleanString($this->map822) . '. ' .
|
||||
$this->cleanString($this->mapx400) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = $rdata[0];
|
||||
$this->map822 = $this->cleanString($rdata[1]);
|
||||
$this->mapx400 = $this->cleanString($rdata[2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// parse the preference
|
||||
//
|
||||
$x = unpack('npreference', $this->rdata);
|
||||
$this->preference = $x['preference'];
|
||||
|
||||
$offset = $packet->offset + 2;
|
||||
|
||||
$this->map822 = Net_DNS2_Packet::expand($packet, $offset);
|
||||
$this->mapx400 = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->map822) > 0) {
|
||||
|
||||
$data = pack('n', $this->preference);
|
||||
$packet->offset += 2;
|
||||
|
||||
$data .= $packet->compress($this->map822, $packet->offset);
|
||||
$data .= $packet->compress($this->mapx400, $packet->offset);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* RP Resource Record - RFC1183 section 2.2
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / mboxdname /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / txtdname /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_RP extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* mailbox for the responsible person
|
||||
*/
|
||||
public $mboxdname;
|
||||
|
||||
/*
|
||||
* is a domain name for which TXT RR's exists
|
||||
*/
|
||||
public $txtdname;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->mboxdname) . '. ' .
|
||||
$this->cleanString($this->txtdname) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->mboxdname = $this->cleanString($rdata[0]);
|
||||
$this->txtdname = $this->cleanString($rdata[1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->mboxdname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
$this->txtdname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->mboxdname) > 0) {
|
||||
|
||||
return $packet->compress($this->mboxdname, $packet->offset) .
|
||||
$packet->compress($this->txtdname, $packet->offset);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
* This file contains code based off the Net::DNS::SEC Perl module by
|
||||
* Olaf M. Kolkman
|
||||
*
|
||||
* This is the copyright notice from the PERL Net::DNS::SEC module:
|
||||
*
|
||||
* Copyright (c) 2001 - 2005 RIPE NCC. Author Olaf M. Kolkman
|
||||
* Copyright (c) 2007 - 2008 NLnet Labs. Author Olaf M. Kolkman
|
||||
* <olaf@net-dns.org>
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of the author not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* RRSIG Resource Record - RFC4034 sction 3.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Type Covered | Algorithm | Labels |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Original TTL |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Signature Expiration |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Signature Inception |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Key Tag | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signer's Name /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / /
|
||||
* / Signature /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_RRSIG extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the RR type covered by this signature
|
||||
*/
|
||||
public $typecovered;
|
||||
|
||||
/*
|
||||
* the algorithm used for the signature
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* the number of labels in the name
|
||||
*/
|
||||
public $labels;
|
||||
|
||||
/*
|
||||
* the original TTL
|
||||
*/
|
||||
public $origttl;
|
||||
|
||||
/*
|
||||
* the signature expiration
|
||||
*/
|
||||
public $sigexp;
|
||||
|
||||
/*
|
||||
* the inception of the signature
|
||||
*/
|
||||
public $sigincep;
|
||||
|
||||
/*
|
||||
* the keytag used
|
||||
*/
|
||||
public $keytag;
|
||||
|
||||
/*
|
||||
* the signer's name
|
||||
*/
|
||||
public $signname;
|
||||
|
||||
/*
|
||||
* the signature
|
||||
*/
|
||||
public $signature;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->typecovered . ' ' . $this->algorithm . ' ' .
|
||||
$this->labels . ' ' . $this->origttl . ' ' .
|
||||
$this->sigexp . ' ' . $this->sigincep . ' ' .
|
||||
$this->keytag . ' ' . $this->cleanString($this->signname) . '. ' .
|
||||
$this->signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->typecovered = strtoupper(array_shift($rdata));
|
||||
$this->algorithm = array_shift($rdata);
|
||||
$this->labels = array_shift($rdata);
|
||||
$this->origttl = array_shift($rdata);
|
||||
$this->sigexp = array_shift($rdata);
|
||||
$this->sigincep = array_shift($rdata);
|
||||
$this->keytag = array_shift($rdata);
|
||||
$this->signname = $this->cleanString(array_shift($rdata));
|
||||
|
||||
foreach ($rdata as $line) {
|
||||
|
||||
$this->signature .= $line;
|
||||
}
|
||||
|
||||
$this->signature = trim($this->signature);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack
|
||||
//
|
||||
$x = unpack(
|
||||
'ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag',
|
||||
$this->rdata
|
||||
);
|
||||
|
||||
$this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']];
|
||||
$this->algorithm = $x['algorithm'];
|
||||
$this->labels = $x['labels'];
|
||||
$this->origttl = Net_DNS2::expandUint32($x['origttl']);
|
||||
|
||||
//
|
||||
// the dates are in GM time
|
||||
//
|
||||
$this->sigexp = gmdate('YmdHis', $x['sigexp']);
|
||||
$this->sigincep = gmdate('YmdHis', $x['sigincep']);
|
||||
|
||||
//
|
||||
// get the keytag
|
||||
//
|
||||
$this->keytag = $x['keytag'];
|
||||
|
||||
//
|
||||
// get teh signers name and signature
|
||||
//
|
||||
$offset = $packet->offset + 18;
|
||||
$sigoffset = $offset;
|
||||
|
||||
$this->signname = strtolower(
|
||||
Net_DNS2_Packet::expand($packet, $sigoffset)
|
||||
);
|
||||
$this->signature = base64_encode(
|
||||
substr($this->rdata, 18 + ($sigoffset - $offset))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->signature) > 0) {
|
||||
|
||||
//
|
||||
// parse the values out of the dates
|
||||
//
|
||||
preg_match(
|
||||
'/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigexp, $e
|
||||
);
|
||||
preg_match(
|
||||
'/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigincep, $i
|
||||
);
|
||||
|
||||
//
|
||||
// pack the value
|
||||
//
|
||||
$data = pack(
|
||||
'nCCNNNn',
|
||||
Net_DNS2_Lookups::$rr_types_by_name[$this->typecovered],
|
||||
$this->algorithm,
|
||||
$this->labels,
|
||||
$this->origttl,
|
||||
gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]),
|
||||
gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]),
|
||||
$this->keytag
|
||||
);
|
||||
|
||||
//
|
||||
// the signer name is special; it's not allowed to be compressed
|
||||
// (see section 3.1.7)
|
||||
//
|
||||
$names = explode('.', strtolower($this->signname));
|
||||
foreach ($names as $name) {
|
||||
|
||||
$data .= chr(strlen($name));
|
||||
$data .= $name;
|
||||
}
|
||||
$data .= "\0";
|
||||
|
||||
//
|
||||
// add the signature
|
||||
//
|
||||
$data .= base64_decode($this->signature);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* RT Resource Record - RFC1183 section 3.3
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | preference |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / intermediate-host /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_RT extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the preference of this route
|
||||
*/
|
||||
public $preference;
|
||||
|
||||
/*
|
||||
* host which will servce as an intermediate in reaching the owner host
|
||||
*/
|
||||
public $intermediatehost;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->preference . ' ' .
|
||||
$this->cleanString($this->intermediatehost) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->preference = $rdata[0];
|
||||
$this->intermediatehost = $this->cleanString($rdata[1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the preference
|
||||
//
|
||||
$x = unpack('npreference', $this->rdata);
|
||||
|
||||
$this->preference = $x['preference'];
|
||||
$offset = $packet->offset + 2;
|
||||
|
||||
$this->intermediatehost = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->intermediatehost) > 0) {
|
||||
|
||||
$data = pack('n', $this->preference);
|
||||
$packet->offset += 2;
|
||||
|
||||
$data .= $packet->compress($this->intermediatehost, $packet->offset);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,459 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
* This file contains code based off the Net::DNS::SEC Perl module by
|
||||
* Olaf M. Kolkman
|
||||
*
|
||||
* This is the copyright notice from the PERL Net::DNS::SEC module:
|
||||
*
|
||||
* Copyright (c) 2001 - 2005 RIPE NCC. Author Olaf M. Kolkman
|
||||
* Copyright (c) 2007 - 2008 NLnet Labs. Author Olaf M. Kolkman
|
||||
* <olaf@net-dns.org>
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and that
|
||||
* both that copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of the author not be
|
||||
* used in advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
|
||||
* AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SIG Resource Record - RFC2535 section 4.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Type Covered | Algorithm | Labels |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Original TTL |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Signature Expiration |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Signature Inception |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Key Tag | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signer's Name /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / /
|
||||
* / Signature /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_SIG extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* and instance of a Net_DNS2_PrivateKey object
|
||||
*/
|
||||
public $private_key = null;
|
||||
|
||||
/*
|
||||
* the RR type covered by this signature
|
||||
*/
|
||||
public $typecovered;
|
||||
|
||||
/*
|
||||
* the algorithm used for the signature
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* the number of labels in the name
|
||||
*/
|
||||
public $labels;
|
||||
|
||||
/*
|
||||
* the original TTL
|
||||
*/
|
||||
public $origttl;
|
||||
|
||||
/*
|
||||
* the signature expiration
|
||||
*/
|
||||
public $sigexp;
|
||||
|
||||
/*
|
||||
* the inception of the signature
|
||||
*/
|
||||
public $sigincep;
|
||||
|
||||
/*
|
||||
* the keytag used
|
||||
*/
|
||||
public $keytag;
|
||||
|
||||
/*
|
||||
* the signer's name
|
||||
*/
|
||||
public $signname;
|
||||
|
||||
/*
|
||||
* the signature
|
||||
*/
|
||||
public $signature;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->typecovered . ' ' . $this->algorithm . ' ' .
|
||||
$this->labels . ' ' . $this->origttl . ' ' .
|
||||
$this->sigexp . ' ' . $this->sigincep . ' ' .
|
||||
$this->keytag . ' ' . $this->cleanString($this->signname) . '. ' .
|
||||
$this->signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->typecovered = strtoupper(array_shift($rdata));
|
||||
$this->algorithm = array_shift($rdata);
|
||||
$this->labels = array_shift($rdata);
|
||||
$this->origttl = array_shift($rdata);
|
||||
$this->sigexp = array_shift($rdata);
|
||||
$this->sigincep = array_shift($rdata);
|
||||
$this->keytag = array_shift($rdata);
|
||||
$this->signname = $this->cleanString(array_shift($rdata));
|
||||
|
||||
foreach ($rdata as $line) {
|
||||
|
||||
$this->signature .= $line;
|
||||
}
|
||||
|
||||
$this->signature = trim($this->signature);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack
|
||||
//
|
||||
$x = unpack(
|
||||
'ntc/Calgorithm/Clabels/Norigttl/Nsigexp/Nsigincep/nkeytag',
|
||||
$this->rdata
|
||||
);
|
||||
|
||||
$this->typecovered = Net_DNS2_Lookups::$rr_types_by_id[$x['tc']];
|
||||
$this->algorithm = $x['algorithm'];
|
||||
$this->labels = $x['labels'];
|
||||
$this->origttl = Net_DNS2::expandUint32($x['origttl']);
|
||||
|
||||
//
|
||||
// the dates are in GM time
|
||||
//
|
||||
$this->sigexp = gmdate('YmdHis', $x['sigexp']);
|
||||
$this->sigincep = gmdate('YmdHis', $x['sigincep']);
|
||||
|
||||
//
|
||||
// get the keytag
|
||||
//
|
||||
$this->keytag = $x['keytag'];
|
||||
|
||||
//
|
||||
// get teh signers name and signature
|
||||
//
|
||||
$offset = $packet->offset + 18;
|
||||
$sigoffset = $offset;
|
||||
|
||||
$this->signname = strtolower(
|
||||
Net_DNS2_Packet::expand($packet, $sigoffset)
|
||||
);
|
||||
$this->signature = base64_encode(
|
||||
substr($this->rdata, 18 + ($sigoffset - $offset))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
//
|
||||
// parse the values out of the dates
|
||||
//
|
||||
preg_match(
|
||||
'/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigexp, $e
|
||||
);
|
||||
preg_match(
|
||||
'/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $this->sigincep, $i
|
||||
);
|
||||
|
||||
//
|
||||
// pack the value
|
||||
//
|
||||
$data = pack(
|
||||
'nCCNNNn',
|
||||
Net_DNS2_Lookups::$rr_types_by_name[$this->typecovered],
|
||||
$this->algorithm,
|
||||
$this->labels,
|
||||
$this->origttl,
|
||||
gmmktime($e[4], $e[5], $e[6], $e[2], $e[3], $e[1]),
|
||||
gmmktime($i[4], $i[5], $i[6], $i[2], $i[3], $i[1]),
|
||||
$this->keytag
|
||||
);
|
||||
|
||||
//
|
||||
// the signer name is special; it's not allowed to be compressed
|
||||
// (see section 3.1.7)
|
||||
//
|
||||
$names = explode('.', strtolower($this->signname));
|
||||
foreach ($names as $name) {
|
||||
|
||||
$data .= chr(strlen($name));
|
||||
$data .= $name;
|
||||
}
|
||||
|
||||
$data .= chr('0');
|
||||
|
||||
//
|
||||
// if the signature is empty, and $this->private_key is an instance of a
|
||||
// private key object, and we have access to openssl, then assume this
|
||||
// is a SIG(0), and generate a new signature
|
||||
//
|
||||
if ( (strlen($this->signature) == 0)
|
||||
&& ($this->private_key instanceof Net_DNS2_PrivateKey)
|
||||
&& (extension_loaded('openssl') === true)
|
||||
) {
|
||||
|
||||
//
|
||||
// create a new packet for the signature-
|
||||
//
|
||||
$new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN');
|
||||
|
||||
//
|
||||
// copy the packet data over
|
||||
//
|
||||
$new_packet->copy($packet);
|
||||
|
||||
//
|
||||
// remove the SIG object from the additional list
|
||||
//
|
||||
array_pop($new_packet->additional);
|
||||
$new_packet->header->arcount = count($new_packet->additional);
|
||||
|
||||
//
|
||||
// copy out the data
|
||||
//
|
||||
$sigdata = $data . $new_packet->get();
|
||||
|
||||
//
|
||||
// based on the algorithm
|
||||
//
|
||||
$algorithm = 0;
|
||||
|
||||
switch($this->algorithm) {
|
||||
|
||||
//
|
||||
// MD5
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
|
||||
|
||||
$algorithm = OPENSSL_ALGO_MD5;
|
||||
break;
|
||||
|
||||
//
|
||||
// SHA1
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
|
||||
|
||||
$algorithm = OPENSSL_ALGO_SHA1;
|
||||
break;
|
||||
|
||||
//
|
||||
// SHA256 (PHP 5.4.8 or higher)
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.4.8', '<') == true) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'SHA256 support is only available in PHP >= 5.4.8',
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
|
||||
);
|
||||
}
|
||||
|
||||
$algorithm = OPENSSL_ALGO_SHA256;
|
||||
break;
|
||||
|
||||
//
|
||||
// SHA512 (PHP 5.4.8 or higher)
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.4.8', '<') == true) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'SHA512 support is only available in PHP >= 5.4.8',
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
|
||||
);
|
||||
}
|
||||
|
||||
$algorithm = OPENSSL_ALGO_SHA512;
|
||||
break;
|
||||
|
||||
//
|
||||
// unsupported at the moment
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSA:
|
||||
case Net_DNS2_Lookups::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_DSANSEC3SHA1:
|
||||
default:
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid or unsupported algorithm',
|
||||
Net_DNS2_Lookups::E_OPENSSL_INV_ALGO
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// sign the data
|
||||
//
|
||||
if (openssl_sign($sigdata, $this->signature, $this->private_key->instance, $algorithm) == false) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
openssl_error_string(),
|
||||
Net_DNS2_Lookups::E_OPENSSL_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// build the signature value based
|
||||
//
|
||||
switch($this->algorithm) {
|
||||
|
||||
//
|
||||
// RSA- add it directly
|
||||
//
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSAMD5:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA1:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA256:
|
||||
case Net_DNS2_Lookups::DNSSEC_ALGORITHM_RSASHA512:
|
||||
|
||||
$this->signature = base64_encode($this->signature);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// add the signature
|
||||
//
|
||||
$data .= base64_decode($this->signature);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2016, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2016 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.4.2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The SMIMEA RR is implemented exactly like the TLSA record, so
|
||||
* for now we just extend the TLSA RR and use it.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_SMIMEA extends Net_DNS2_RR_TLSA
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SOA Resource Record - RFC1035 section 3.3.13
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / MNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / RNAME /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | SERIAL |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | REFRESH |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | RETRY |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | EXPIRE |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | MINIMUM |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_SOA extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The master DNS server
|
||||
*/
|
||||
public $mname;
|
||||
|
||||
/*
|
||||
* mailbox of the responsible person
|
||||
*/
|
||||
public $rname;
|
||||
|
||||
/*
|
||||
* serial number
|
||||
*/
|
||||
public $serial;
|
||||
|
||||
/*
|
||||
* refresh time
|
||||
*/
|
||||
public $refresh;
|
||||
|
||||
/*
|
||||
* retry interval
|
||||
*/
|
||||
public $retry;
|
||||
|
||||
/*
|
||||
* expire time
|
||||
*/
|
||||
public $expire;
|
||||
|
||||
/*
|
||||
* minimum TTL for any RR in this zone
|
||||
*/
|
||||
public $minimum;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->mname) . '. ' .
|
||||
$this->cleanString($this->rname) . '. ' .
|
||||
$this->serial . ' ' . $this->refresh . ' ' . $this->retry . ' ' .
|
||||
$this->expire . ' ' . $this->minimum;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->mname = $this->cleanString($rdata[0]);
|
||||
$this->rname = $this->cleanString($rdata[1]);
|
||||
|
||||
$this->serial = $rdata[2];
|
||||
$this->refresh = $rdata[3];
|
||||
$this->retry = $rdata[4];
|
||||
$this->expire = $rdata[5];
|
||||
$this->minimum = $rdata[6];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// parse the
|
||||
//
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->mname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
$this->rname = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
//
|
||||
// get the SOA values
|
||||
//
|
||||
$x = unpack(
|
||||
'@' . $offset . '/Nserial/Nrefresh/Nretry/Nexpire/Nminimum/',
|
||||
$packet->rdata
|
||||
);
|
||||
|
||||
$this->serial = Net_DNS2::expandUint32($x['serial']);
|
||||
$this->refresh = Net_DNS2::expandUint32($x['refresh']);
|
||||
$this->retry = Net_DNS2::expandUint32($x['retry']);
|
||||
$this->expire = Net_DNS2::expandUint32($x['expire']);
|
||||
$this->minimum = Net_DNS2::expandUint32($x['minimum']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->mname) > 0) {
|
||||
|
||||
$data = $packet->compress($this->mname, $packet->offset);
|
||||
$data .= $packet->compress($this->rname, $packet->offset);
|
||||
|
||||
$data .= pack(
|
||||
'N5', $this->serial, $this->refresh, $this->retry,
|
||||
$this->expire, $this->minimum
|
||||
);
|
||||
|
||||
$packet->offset += 20;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The SPF RR is implemented exactly like the TXT record, so
|
||||
* for now we just extend the TXT RR and use it.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_SPF extends Net_DNS2_RR_TXT
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SRV Resource Record - RFC2782
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PRIORITY |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | WEIGHT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PORT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / TARGET /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_SRV extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The priority of this target host.
|
||||
*/
|
||||
public $priority;
|
||||
|
||||
/*
|
||||
* a relative weight for entries with the same priority
|
||||
*/
|
||||
public $weight;
|
||||
|
||||
/*
|
||||
* The port on this target host of this service.
|
||||
*/
|
||||
public $port;
|
||||
|
||||
/*
|
||||
* The domain name of the target host
|
||||
*/
|
||||
public $target;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->priority . ' ' . $this->weight . ' ' .
|
||||
$this->port . ' ' . $this->cleanString($this->target) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->priority = $rdata[0];
|
||||
$this->weight = $rdata[1];
|
||||
$this->port = $rdata[2];
|
||||
|
||||
$this->target = $this->cleanString($rdata[3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the priority, weight and port
|
||||
//
|
||||
$x = unpack('npriority/nweight/nport', $this->rdata);
|
||||
|
||||
$this->priority = $x['priority'];
|
||||
$this->weight = $x['weight'];
|
||||
$this->port = $x['port'];
|
||||
|
||||
$offset = $packet->offset + 6;
|
||||
$this->target = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->target) > 0) {
|
||||
|
||||
$data = pack('nnn', $this->priority, $this->weight, $this->port);
|
||||
$packet->offset += 6;
|
||||
|
||||
$data .= $packet->compress($this->target, $packet->offset);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SSHFP Resource Record - RFC4255 section 3.1
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | algorithm | fp type | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
|
||||
* / /
|
||||
* / fingerprint /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_SSHFP extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the algorithm used
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* The finger print type
|
||||
*/
|
||||
public $fp_type;
|
||||
|
||||
/*
|
||||
* the finger print data
|
||||
*/
|
||||
public $fingerprint;
|
||||
|
||||
/*
|
||||
* Algorithms
|
||||
*/
|
||||
const SSHFP_ALGORITHM_RES = 0;
|
||||
const SSHFP_ALGORITHM_RSA = 1;
|
||||
const SSHFP_ALGORITHM_DSS = 2;
|
||||
const SSHFP_ALGORITHM_ECDSA = 3;
|
||||
|
||||
/*
|
||||
* Fingerprint Types
|
||||
*/
|
||||
const SSHFP_FPTYPE_RES = 0;
|
||||
const SSHFP_FPTYPE_SHA1 = 1;
|
||||
const SSHFP_FPTYPE_SHA256 = 2;
|
||||
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->algorithm . ' ' . $this->fp_type . ' ' . $this->fingerprint;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// "The use of mnemonics instead of numbers is not allowed."
|
||||
//
|
||||
// RFC4255 section 3.2
|
||||
//
|
||||
$algorithm = array_shift($rdata);
|
||||
$fp_type = array_shift($rdata);
|
||||
$fingerprint = strtolower(implode('', $rdata));
|
||||
|
||||
//
|
||||
// There are only two algorithm's defined
|
||||
//
|
||||
if ( ($algorithm != self::SSHFP_ALGORITHM_RSA)
|
||||
&& ($algorithm != self::SSHFP_ALGORITHM_DSS)
|
||||
&& ($algorithm != self::SSHFP_ALGORITHM_ECDSA)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// there are only two fingerprints defined
|
||||
//
|
||||
if ( ($fp_type != self::SSHFP_FPTYPE_SHA1)
|
||||
&& ($fp_type != self::SSHFP_FPTYPE_SHA256)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->algorithm = $algorithm;
|
||||
$this->fp_type = $fp_type;
|
||||
$this->fingerprint = $fingerprint;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the algorithm and finger print type
|
||||
//
|
||||
$x = unpack('Calgorithm/Cfp_type', $this->rdata);
|
||||
|
||||
$this->algorithm = $x['algorithm'];
|
||||
$this->fp_type = $x['fp_type'];
|
||||
|
||||
//
|
||||
// There are only three algorithm's defined
|
||||
//
|
||||
if ( ($this->algorithm != self::SSHFP_ALGORITHM_RSA)
|
||||
&& ($this->algorithm != self::SSHFP_ALGORITHM_DSS)
|
||||
&& ($this->algorithm != self::SSHFP_ALGORITHM_ECDSA)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// there are only two fingerprints defined
|
||||
//
|
||||
if ( ($this->fp_type != self::SSHFP_FPTYPE_SHA1)
|
||||
&& ($this->fp_type != self::SSHFP_FPTYPE_SHA256)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// parse the finger print; this assumes SHA-1
|
||||
//
|
||||
$fp = unpack('H*a', substr($this->rdata, 2));
|
||||
$this->fingerprint = strtolower($fp['a']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->fingerprint) > 0) {
|
||||
|
||||
$data = pack(
|
||||
'CCH*', $this->algorithm, $this->fp_type, $this->fingerprint
|
||||
);
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2011, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.2.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The TA RR is implemented exactly like the DS record, so
|
||||
* for now we just extend the DS RR and use it.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_TA extends Net_DNS2_RR_DS
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2011, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.2.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TALINK Resource Record - DNSSEC Trust Anchor
|
||||
*
|
||||
* http://tools.ietf.org/id/draft-ietf-dnsop-dnssec-trust-history-00.txt
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / PREVIOUS /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / NEXT /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_TALINK extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* the previous domain name
|
||||
*/
|
||||
public $previous;
|
||||
|
||||
/*
|
||||
* the next domain name
|
||||
*/
|
||||
public $next;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cleanString($this->previous) . '. ' .
|
||||
$this->cleanString($this->next) . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->previous = $this->cleanString($rdata[0]);
|
||||
$this->next = $this->cleanString($rdata[1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$offset = $packet->offset;
|
||||
|
||||
$this->previous = Net_DNS2_Packet::label($packet, $offset);
|
||||
$this->next = Net_DNS2_Packet::label($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ( (strlen($this->previous) > 0) || (strlen($this->next) > 0) ) {
|
||||
|
||||
$data = chr(strlen($this->previous)) . $this->previous .
|
||||
chr(strlen($this->next)) . $this->next;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TKEY Resource Record - RFC 2930 section 2
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / ALGORITHM /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | INCEPTION |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | EXPIRATION |
|
||||
* | |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | MODE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ERROR |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | KEY SIZE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / KEY DATA /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | OTHER SIZE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / OTHER DATA /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_TKEY extends Net_DNS2_RR
|
||||
{
|
||||
public $algorithm;
|
||||
public $inception;
|
||||
public $expiration;
|
||||
public $mode;
|
||||
public $error;
|
||||
public $key_size;
|
||||
public $key_data;
|
||||
public $other_size;
|
||||
public $other_data;
|
||||
|
||||
/*
|
||||
* TSIG Modes
|
||||
*/
|
||||
const TSIG_MODE_RES = 0;
|
||||
const TSIG_MODE_SERV_ASSIGN = 1;
|
||||
const TSIG_MODE_DH = 2;
|
||||
const TSIG_MODE_GSS_API = 3;
|
||||
const TSIG_MODE_RESV_ASSIGN = 4;
|
||||
const TSIG_MODE_KEY_DELE = 5;
|
||||
|
||||
/*
|
||||
* map the mod id's to names so we can validate
|
||||
*/
|
||||
public $tsgi_mode_id_to_name = array(
|
||||
|
||||
self::TSIG_MODE_RES => 'Reserved',
|
||||
self::TSIG_MODE_SERV_ASSIGN => 'Server Assignment',
|
||||
self::TSIG_MODE_DH => 'Diffie-Hellman',
|
||||
self::TSIG_MODE_GSS_API => 'GSS-API',
|
||||
self::TSIG_MODE_RESV_ASSIGN => 'Resolver Assignment',
|
||||
self::TSIG_MODE_KEY_DELE => 'Key Deletion'
|
||||
);
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->cleanString($this->algorithm) . '. ' . $this->mode;
|
||||
if ($this->key_size > 0) {
|
||||
|
||||
$out .= ' ' . trim($this->key_data, '.') . '.';
|
||||
} else {
|
||||
|
||||
$out .= ' .';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// data passed in is assumed: <algorithm> <mode> <key>
|
||||
//
|
||||
$this->algorithm = $this->cleanString(array_shift($rdata));
|
||||
$this->mode = array_shift($rdata);
|
||||
$this->key_data = trim(array_shift($rdata), '.');
|
||||
|
||||
//
|
||||
// the rest of the data is set manually
|
||||
//
|
||||
$this->inception = time();
|
||||
$this->expiration = time() + 86400; // 1 day
|
||||
$this->error = 0;
|
||||
$this->key_size = strlen($this->key_data);
|
||||
$this->other_size = 0;
|
||||
$this->other_data = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// expand the algorithm
|
||||
//
|
||||
$offset = $packet->offset;
|
||||
$this->algorithm = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
//
|
||||
// unpack inception, expiration, mode, error and key size
|
||||
//
|
||||
$x = unpack(
|
||||
'@' . $offset . '/Ninception/Nexpiration/nmode/nerror/nkey_size',
|
||||
$packet->rdata
|
||||
);
|
||||
|
||||
$this->inception = Net_DNS2::expandUint32($x['inception']);
|
||||
$this->expiration = Net_DNS2::expandUint32($x['expiration']);
|
||||
$this->mode = $x['mode'];
|
||||
$this->error = $x['error'];
|
||||
$this->key_size = $x['key_size'];
|
||||
|
||||
$offset += 14;
|
||||
|
||||
//
|
||||
// if key_size > 0, then copy out the key
|
||||
//
|
||||
if ($this->key_size > 0) {
|
||||
|
||||
$this->key_data = substr($packet->rdata, $offset, $this->key_size);
|
||||
$offset += $this->key_size;
|
||||
}
|
||||
|
||||
//
|
||||
// unpack the other length
|
||||
//
|
||||
$x = unpack('@' . $offset . '/nother_size', $packet->rdata);
|
||||
|
||||
$this->other_size = $x['other_size'];
|
||||
$offset += 2;
|
||||
|
||||
//
|
||||
// if other_size > 0, then copy out the data
|
||||
//
|
||||
if ($this->other_size > 0) {
|
||||
|
||||
$this->other_data = substr(
|
||||
$packet->rdata, $offset, $this->other_size
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->algorithm) > 0) {
|
||||
|
||||
//
|
||||
// make sure the size values are correct
|
||||
//
|
||||
$this->key_size = strlen($this->key_data);
|
||||
$this->other_size = strlen($this->other_data);
|
||||
|
||||
//
|
||||
// add the algorithm without compression
|
||||
//
|
||||
$data = Net_DNS2_Packet::pack($this->algorithm);
|
||||
|
||||
//
|
||||
// pack in the inception, expiration, mode, error and key size
|
||||
//
|
||||
$data .= pack(
|
||||
'NNnnn', $this->inception, $this->expiration,
|
||||
$this->mode, 0, $this->key_size
|
||||
);
|
||||
|
||||
//
|
||||
// if the key_size > 0, then add the key
|
||||
//
|
||||
if ($this->key_size > 0) {
|
||||
|
||||
$data .= $this->key_data;
|
||||
}
|
||||
|
||||
//
|
||||
// pack in the other size
|
||||
//
|
||||
$data .= pack('n', $this->other_size);
|
||||
if ($this->other_size > 0) {
|
||||
|
||||
$data .= $this->other_data;
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2012, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2012 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.2.5
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TLSA Resource Record - RFC 6698
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Cert. Usage | Selector | Matching Type | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
|
||||
* / /
|
||||
* / Certificate Association Data /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_TLSA extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The Certificate Usage Field
|
||||
*/
|
||||
public $cert_usage;
|
||||
|
||||
/*
|
||||
* The Selector Field
|
||||
*/
|
||||
public $selector;
|
||||
|
||||
/*
|
||||
* The Matching Type Field
|
||||
*/
|
||||
public $matching_type;
|
||||
|
||||
/*
|
||||
* The Certificate Association Data Field
|
||||
*/
|
||||
public $certificate;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
return $this->cert_usage . ' ' . $this->selector . ' ' .
|
||||
$this->matching_type . ' ' . base64_encode($this->certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->cert_usage = array_shift($rdata);
|
||||
$this->selector = array_shift($rdata);
|
||||
$this->matching_type = array_shift($rdata);
|
||||
$this->certificate = base64_decode(implode('', $rdata));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the format, keytag and algorithm
|
||||
//
|
||||
$x = unpack('Cusage/Cselector/Ctype', $this->rdata);
|
||||
|
||||
$this->cert_usage = $x['usage'];
|
||||
$this->selector = $x['selector'];
|
||||
$this->matching_type = $x['type'];
|
||||
|
||||
//
|
||||
// copy the certificate
|
||||
//
|
||||
$this->certificate = substr($this->rdata, 3, $this->rdlength - 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->certificate) > 0) {
|
||||
|
||||
$data = pack(
|
||||
'CCC', $this->cert_usage, $this->selector, $this->matching_type
|
||||
) . $this->certificate;
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TSIG Resource Record - RFC 2845
|
||||
*
|
||||
* 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* / algorithm /
|
||||
* / /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | time signed |
|
||||
* | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | | fudge |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | mac size | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
|
||||
* / mac /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | original id | error |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | other length | /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /
|
||||
* / other data /
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_TSIG extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* TSIG Algorithm Identifiers
|
||||
*/
|
||||
const HMAC_MD5 = 'hmac-md5.sig-alg.reg.int'; // RFC 2845, required
|
||||
const GSS_TSIG = 'gss-tsig'; // unsupported, optional
|
||||
const HMAC_SHA1 = 'hmac-sha1'; // RFC 4635, required
|
||||
const HMAC_SHA224 = 'hmac-sha224'; // RFC 4635, optional
|
||||
const HMAC_SHA256 = 'hmac-sha256'; // RFC 4635, required
|
||||
const HMAC_SHA384 = 'hmac-sha384'; // RFC 4635, optional
|
||||
const HMAC_SHA512 = 'hmac-sha512'; // RFC 4635, optional
|
||||
|
||||
/*
|
||||
* the map of hash values to names
|
||||
*/
|
||||
public static $hash_algorithms = array(
|
||||
|
||||
self::HMAC_MD5 => 'md5',
|
||||
self::HMAC_SHA1 => 'sha1',
|
||||
self::HMAC_SHA224 => 'sha224',
|
||||
self::HMAC_SHA256 => 'sha256',
|
||||
self::HMAC_SHA384 => 'sha384',
|
||||
self::HMAC_SHA512 => 'sha512'
|
||||
);
|
||||
|
||||
/*
|
||||
* algorithm used; only supports HMAC-MD5
|
||||
*/
|
||||
public $algorithm;
|
||||
|
||||
/*
|
||||
* The time it was signed
|
||||
*/
|
||||
public $time_signed;
|
||||
|
||||
/*
|
||||
* fudge- allowed offset from the time signed
|
||||
*/
|
||||
public $fudge;
|
||||
|
||||
/*
|
||||
* size of the digest
|
||||
*/
|
||||
public $mac_size;
|
||||
|
||||
/*
|
||||
* the digest data
|
||||
*/
|
||||
public $mac;
|
||||
|
||||
/*
|
||||
* the original id of the request
|
||||
*/
|
||||
public $original_id;
|
||||
|
||||
/*
|
||||
* additional error code
|
||||
*/
|
||||
public $error;
|
||||
|
||||
/*
|
||||
* length of the "other" data, should only ever be 0 when there is
|
||||
* no error, or 6 when there is the error RCODE_BADTIME
|
||||
*/
|
||||
public $other_length;
|
||||
|
||||
/*
|
||||
* the other data; should only ever be a timestamp when there is the
|
||||
* error RCODE_BADTIME
|
||||
*/
|
||||
public $other_data;
|
||||
|
||||
/*
|
||||
* the key to use for signing - passed in, not included in the rdata
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
$out = $this->cleanString($this->algorithm) . '. ' .
|
||||
$this->time_signed . ' ' .
|
||||
$this->fudge . ' ' . $this->mac_size . ' ' .
|
||||
base64_encode($this->mac) . ' ' . $this->original_id . ' ' .
|
||||
$this->error . ' '. $this->other_length;
|
||||
|
||||
if ($this->other_length > 0) {
|
||||
|
||||
$out .= ' ' . $this->other_data;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
//
|
||||
// the only value passed in is the key-
|
||||
//
|
||||
// this assumes it's passed in base64 encoded.
|
||||
//
|
||||
$this->key = preg_replace('/\s+/', '', array_shift($rdata));
|
||||
|
||||
//
|
||||
// the rest of the data is set to default
|
||||
//
|
||||
$this->algorithm = self::HMAC_MD5;
|
||||
$this->time_signed = time();
|
||||
$this->fudge = 300;
|
||||
$this->mac_size = 0;
|
||||
$this->mac = '';
|
||||
$this->original_id = 0;
|
||||
$this->error = 0;
|
||||
$this->other_length = 0;
|
||||
$this->other_data = '';
|
||||
|
||||
//
|
||||
// per RFC 2845 section 2.3
|
||||
//
|
||||
$this->class = 'ANY';
|
||||
$this->ttl = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// expand the algorithm
|
||||
//
|
||||
$newoffset = $packet->offset;
|
||||
$this->algorithm = Net_DNS2_Packet::expand($packet, $newoffset);
|
||||
$offset = $newoffset - $packet->offset;
|
||||
|
||||
//
|
||||
// unpack time, fudge and mac_size
|
||||
//
|
||||
$x = unpack(
|
||||
'@' . $offset . '/ntime_high/Ntime_low/nfudge/nmac_size',
|
||||
$this->rdata
|
||||
);
|
||||
|
||||
$this->time_signed = Net_DNS2::expandUint32($x['time_low']);
|
||||
$this->fudge = $x['fudge'];
|
||||
$this->mac_size = $x['mac_size'];
|
||||
|
||||
$offset += 10;
|
||||
|
||||
//
|
||||
// copy out the mac
|
||||
//
|
||||
if ($this->mac_size > 0) {
|
||||
|
||||
$this->mac = substr($this->rdata, $offset, $this->mac_size);
|
||||
$offset += $this->mac_size;
|
||||
}
|
||||
|
||||
//
|
||||
// unpack the original id, error, and other_length values
|
||||
//
|
||||
$x = unpack(
|
||||
'@' . $offset . '/noriginal_id/nerror/nother_length',
|
||||
$this->rdata
|
||||
);
|
||||
|
||||
$this->original_id = $x['original_id'];
|
||||
$this->error = $x['error'];
|
||||
$this->other_length = $x['other_length'];
|
||||
|
||||
//
|
||||
// the only time there is actually any "other data", is when there's
|
||||
// a BADTIME error code.
|
||||
//
|
||||
// The other length should be 6, and the other data field includes the
|
||||
// servers current time - per RFC 2845 section 4.5.2
|
||||
//
|
||||
if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) {
|
||||
|
||||
if ($this->other_length != 6) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// other data is a 48bit timestamp
|
||||
//
|
||||
$x = unpack(
|
||||
'nhigh/nlow',
|
||||
substr($this->rdata, $offset + 6, $this->other_length)
|
||||
);
|
||||
$this->other_data = $x['low'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->key) > 0) {
|
||||
|
||||
//
|
||||
// create a new packet for the signature-
|
||||
//
|
||||
$new_packet = new Net_DNS2_Packet_Request('example.com', 'SOA', 'IN');
|
||||
|
||||
//
|
||||
// copy the packet data over
|
||||
//
|
||||
$new_packet->copy($packet);
|
||||
|
||||
//
|
||||
// remove the TSIG object from the additional list
|
||||
//
|
||||
array_pop($new_packet->additional);
|
||||
$new_packet->header->arcount = count($new_packet->additional);
|
||||
|
||||
//
|
||||
// copy out the data
|
||||
//
|
||||
$sig_data = $new_packet->get();
|
||||
|
||||
//
|
||||
// add the name without compressing
|
||||
//
|
||||
$sig_data .= Net_DNS2_Packet::pack($this->name);
|
||||
|
||||
//
|
||||
// add the class and TTL
|
||||
//
|
||||
$sig_data .= pack(
|
||||
'nN', Net_DNS2_Lookups::$classes_by_name[$this->class], $this->ttl
|
||||
);
|
||||
|
||||
//
|
||||
// add the algorithm name without compression
|
||||
//
|
||||
$sig_data .= Net_DNS2_Packet::pack(strtolower($this->algorithm));
|
||||
|
||||
//
|
||||
// add the rest of the values
|
||||
//
|
||||
$sig_data .= pack(
|
||||
'nNnnn', 0, $this->time_signed, $this->fudge,
|
||||
$this->error, $this->other_length
|
||||
);
|
||||
if ($this->other_length > 0) {
|
||||
|
||||
$sig_data .= pack('nN', 0, $this->other_data);
|
||||
}
|
||||
|
||||
//
|
||||
// sign the data
|
||||
//
|
||||
$this->mac = $this->_signHMAC(
|
||||
$sig_data, base64_decode($this->key), $this->algorithm
|
||||
);
|
||||
$this->mac_size = strlen($this->mac);
|
||||
|
||||
//
|
||||
// compress the algorithm
|
||||
//
|
||||
$data = Net_DNS2_Packet::pack(strtolower($this->algorithm));
|
||||
|
||||
//
|
||||
// pack the time, fudge and mac size
|
||||
//
|
||||
$data .= pack(
|
||||
'nNnn', 0, $this->time_signed, $this->fudge, $this->mac_size
|
||||
);
|
||||
$data .= $this->mac;
|
||||
|
||||
//
|
||||
// check the error and other_length
|
||||
//
|
||||
if ($this->error == Net_DNS2_Lookups::RCODE_BADTIME) {
|
||||
|
||||
$this->other_length = strlen($this->other_data);
|
||||
if ($this->other_length != 6) {
|
||||
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
$this->other_length = 0;
|
||||
$this->other_data = '';
|
||||
}
|
||||
|
||||
//
|
||||
// pack the id, error and other_length
|
||||
//
|
||||
$data .= pack(
|
||||
'nnn', $packet->header->id, $this->error, $this->other_length
|
||||
);
|
||||
if ($this->other_length > 0) {
|
||||
|
||||
$data .= pack('nN', 0, $this->other_data);
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* signs the given data with the given key, and returns the result
|
||||
*
|
||||
* @param string $data the data to sign
|
||||
* @param string $key key to use for signing
|
||||
* @param string $algorithm the algorithm to use; defaults to MD5
|
||||
*
|
||||
* @return string the signed digest
|
||||
* @throws Net_DNS2_Exception
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
private function _signHMAC($data, $key = null, $algorithm = self::HMAC_MD5)
|
||||
{
|
||||
//
|
||||
// use the hash extension; this is included by default in >= 5.1.2 which
|
||||
// is our dependent version anyway- so it's easy to switch to it.
|
||||
//
|
||||
if (extension_loaded('hash')) {
|
||||
|
||||
if (!isset(self::$hash_algorithms[$algorithm])) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'invalid or unsupported algorithm',
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
return hash_hmac(self::$hash_algorithms[$algorithm], $data, $key, true);
|
||||
}
|
||||
|
||||
//
|
||||
// if the hash extension isn't loaded, and they selected something other
|
||||
// than MD5, throw an exception
|
||||
//
|
||||
if ($algorithm != self::HMAC_MD5) {
|
||||
|
||||
throw new Net_DNS2_Exception(
|
||||
'only HMAC-MD5 supported. please install the php-extension ' .
|
||||
'"hash" in order to use the sha-family',
|
||||
Net_DNS2_Lookups::E_PARSE_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// otherwise, do it ourselves
|
||||
//
|
||||
if (is_null($key)) {
|
||||
|
||||
return pack('H*', md5($data));
|
||||
}
|
||||
|
||||
$key = str_pad($key, 64, chr(0x00));
|
||||
if (strlen($key) > 64) {
|
||||
|
||||
$key = pack('H*', md5($key));
|
||||
}
|
||||
|
||||
$k_ipad = $key ^ str_repeat(chr(0x36), 64);
|
||||
$k_opad = $key ^ str_repeat(chr(0x5c), 64);
|
||||
|
||||
return $this->_signHMAC(
|
||||
$k_opad . pack('H*', md5($k_ipad . $data)), null, $algorithm
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2010 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 0.6.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TXT Resource Record - RFC1035 section 3.3.14
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / TXT-DATA /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_TXT extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* an array of the text strings
|
||||
*/
|
||||
public $text = array();
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
if (count($this->text) == 0) {
|
||||
return '""';
|
||||
}
|
||||
|
||||
$data = '';
|
||||
|
||||
foreach ($this->text as $t) {
|
||||
|
||||
$data .= $this->formatString($t) . ' ';
|
||||
}
|
||||
|
||||
return trim($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$data = $this->buildString($rdata);
|
||||
if (count($data) > 0) {
|
||||
|
||||
$this->text = $data;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
$length = $packet->offset + $this->rdlength;
|
||||
$offset = $packet->offset;
|
||||
|
||||
while ($length > $offset) {
|
||||
|
||||
$this->text[] = Net_DNS2_Packet::label($packet, $offset);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
$data = null;
|
||||
|
||||
foreach ($this->text as $t) {
|
||||
|
||||
$data .= chr(strlen($t)) . $t;
|
||||
}
|
||||
|
||||
$packet->offset += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* c-hanging-comment-ender-p: nil
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* DNS Library for handling lookups and updates.
|
||||
*
|
||||
* PHP Version 5
|
||||
*
|
||||
* Copyright (c) 2011, Mike Pultz <mike@mikepultz.com>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* * Neither the name of Mike Pultz nor the names of his contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @copyright 2011 Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @version SVN: $Id$
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @since File available since Release 1.2.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* URI Resource Record - http://tools.ietf.org/html/draft-faltstrom-uri-06
|
||||
*
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | PRIORITY |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | WEIGHT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* / TARGET /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* @category Networking
|
||||
* @package Net_DNS2
|
||||
* @author Mike Pultz <mike@mikepultz.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
||||
* @link http://pear.php.net/package/Net_DNS2
|
||||
* @see Net_DNS2_RR
|
||||
*
|
||||
*/
|
||||
class Net_DNS2_RR_URI extends Net_DNS2_RR
|
||||
{
|
||||
/*
|
||||
* The priority of this target host.
|
||||
*/
|
||||
public $priority;
|
||||
|
||||
/*
|
||||
* a relative weight for entries with the same priority
|
||||
*/
|
||||
public $weight;
|
||||
|
||||
/*
|
||||
* The domain name of the target host
|
||||
*/
|
||||
public $target;
|
||||
|
||||
/**
|
||||
* method to return the rdata portion of the packet as a string
|
||||
*
|
||||
* @return string
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrToString()
|
||||
{
|
||||
//
|
||||
// presentation format has double quotes (") around the target.
|
||||
//
|
||||
return $this->priority . ' ' . $this->weight . ' "' .
|
||||
$this->cleanString($this->target) . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata portion from a standard DNS config line
|
||||
*
|
||||
* @param array $rdata a string split line of values for the rdata
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrFromString(array $rdata)
|
||||
{
|
||||
$this->priority = $rdata[0];
|
||||
$this->weight = $rdata[1];
|
||||
|
||||
//
|
||||
// make sure to trim the lead/trailing double quote if it's there.
|
||||
//
|
||||
$this->target = trim($this->cleanString($rdata[2]), '"');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the rdata of the Net_DNS2_Packet object
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrSet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if ($this->rdlength > 0) {
|
||||
|
||||
//
|
||||
// unpack the priority and weight
|
||||
//
|
||||
$x = unpack('npriority/nweight', $this->rdata);
|
||||
|
||||
$this->priority = $x['priority'];
|
||||
$this->weight = $x['weight'];
|
||||
|
||||
$offset = $packet->offset + 4;
|
||||
$this->target = Net_DNS2_Packet::expand($packet, $offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the rdata portion of the DNS packet
|
||||
*
|
||||
* @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
|
||||
* compressed names
|
||||
*
|
||||
* @return mixed either returns a binary packed
|
||||
* string or null on failure
|
||||
* @access protected
|
||||
*
|
||||
*/
|
||||
protected function rrGet(Net_DNS2_Packet &$packet)
|
||||
{
|
||||
if (strlen($this->target) > 0) {
|
||||
|
||||
$data = pack('nn', $this->priority, $this->weight);
|
||||
$packet->offset += 4;
|
||||
|
||||
$data .= $packet->compress(trim($this->target, '"'), $packet->offset);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user