| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Email::Received::Constants; | 
| 2 | 2 |  |  | 2 |  | 11 | use base qw( Exporter ); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 1879 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | @IP_VARS = qw( | 
| 5 |  |  |  |  |  |  | LOCALHOST IPV4_ADDRESS IP_ADDRESS | 
| 6 |  |  |  |  |  |  | ); | 
| 7 |  |  |  |  |  |  | our @EXPORT = @IP_VARS; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 2 |  |  |  |  | 300 | use constant LOCALHOST => qr/ | 
| 10 |  |  |  |  |  |  | (?: | 
| 11 |  |  |  |  |  |  | # as a string | 
| 12 |  |  |  |  |  |  | localhost(?:\.localdomain)? | 
| 13 |  |  |  |  |  |  | | | 
| 14 |  |  |  |  |  |  | \b(? | 
| 15 |  |  |  |  |  |  | # plain IPv4 | 
| 16 |  |  |  |  |  |  | 127\.0\.0\.1 \b | 
| 17 |  |  |  |  |  |  | | | 
| 18 |  |  |  |  |  |  | # IPv6 addresses | 
| 19 |  |  |  |  |  |  | # don't use \b here, it hits on :'s | 
| 20 |  |  |  |  |  |  | (?:IPv6:    # with optional prefix | 
| 21 |  |  |  |  |  |  | | (? | 
| 22 |  |  |  |  |  |  | ) | 
| 23 |  |  |  |  |  |  | (?: | 
| 24 |  |  |  |  |  |  | # IPv4 mapped in IPv6 | 
| 25 |  |  |  |  |  |  | # note the colon after the 12th byte in each here | 
| 26 |  |  |  |  |  |  | (?: | 
| 27 |  |  |  |  |  |  | # first 6 (12 bytes) non-zero | 
| 28 |  |  |  |  |  |  | (?:0{1,4}:){5}		ffff: | 
| 29 |  |  |  |  |  |  | | | 
| 30 |  |  |  |  |  |  | # leading zeros omitted (note {0,5} not {1,5}) | 
| 31 |  |  |  |  |  |  | ::(?:0{1,4}:){0,4}		ffff: | 
| 32 |  |  |  |  |  |  | | | 
| 33 |  |  |  |  |  |  | # trailing zeros (in the first 6) omitted | 
| 34 |  |  |  |  |  |  | (?:0{1,4}:){1,4}:		ffff: | 
| 35 |  |  |  |  |  |  | | | 
| 36 |  |  |  |  |  |  | # 0000 in second up to (including) fifth omitted | 
| 37 |  |  |  |  |  |  | 0{1,4}::(?:0{1,4}:){1,3}	ffff: | 
| 38 |  |  |  |  |  |  | | | 
| 39 |  |  |  |  |  |  | # 0000 in third up to (including) fifth omitted | 
| 40 |  |  |  |  |  |  | (?:0{1,4}:){2}:0{1,2}:	ffff: | 
| 41 |  |  |  |  |  |  | | | 
| 42 |  |  |  |  |  |  | # 0000 in fourth up to (including) fifth omitted | 
| 43 |  |  |  |  |  |  | (?:0{1,4}:){3}:0:		ffff: | 
| 44 |  |  |  |  |  |  | | | 
| 45 |  |  |  |  |  |  | # 0000 in fifth omitted | 
| 46 |  |  |  |  |  |  | (?:0{1,4}:){4}:		ffff: | 
| 47 |  |  |  |  |  |  | ) | 
| 48 |  |  |  |  |  |  | # and the IPv4 address appended to all of the 12 bytes above | 
| 49 |  |  |  |  |  |  | 127\.0\.0\.1	# no \b, we check later | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | | # or (separately) a pure IPv6 address | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | # all 8 (16 bytes) of them present | 
| 54 |  |  |  |  |  |  | (?:0{1,4}:){7}			0{0,3}1 | 
| 55 |  |  |  |  |  |  | | | 
| 56 |  |  |  |  |  |  | # leading zeros omitted | 
| 57 |  |  |  |  |  |  | :(?::0{1,4}){0,6}:		0{0,3}1 | 
| 58 |  |  |  |  |  |  | | | 
| 59 |  |  |  |  |  |  | # 0000 in second up to (including) seventh omitted | 
| 60 |  |  |  |  |  |  | 0{1,4}:(?::0{1,4}){0,5}:	0{0,3}1 | 
| 61 |  |  |  |  |  |  | | | 
| 62 |  |  |  |  |  |  | # 0000 in third up to (including) seventh omitted | 
| 63 |  |  |  |  |  |  | (?:0{1,4}:){2}(?::0{1,4}){0,4}:	0{0,3}1 | 
| 64 |  |  |  |  |  |  | | | 
| 65 |  |  |  |  |  |  | # 0000 in fouth up to (including) seventh omiited | 
| 66 |  |  |  |  |  |  | (?:0{1,4}:){3}(?::0{1,4}){0,3}:	0{0,3}1 | 
| 67 |  |  |  |  |  |  | | | 
| 68 |  |  |  |  |  |  | # 0000 in fifth up to (including) seventh omitted | 
| 69 |  |  |  |  |  |  | (?:0{1,4}:){4}(?::0{1,4}){0,2}:	0{0,3}1 | 
| 70 |  |  |  |  |  |  | | | 
| 71 |  |  |  |  |  |  | # 0000 in sixth up to (including) seventh omitted | 
| 72 |  |  |  |  |  |  | (?:0{1,4}:){5}(?::0{1,4}){0,1}:	0{0,3}1 | 
| 73 |  |  |  |  |  |  | | | 
| 74 |  |  |  |  |  |  | # 0000 in seventh omitted | 
| 75 |  |  |  |  |  |  | (?:0{1,4}:){6}:			0{0,3}1 | 
| 76 |  |  |  |  |  |  | ) | 
| 77 |  |  |  |  |  |  | (?![a-f0-9:]) | 
| 78 |  |  |  |  |  |  | ) | 
| 79 | 2 |  |  | 2 |  | 15 | /oxi; | 
|  | 2 |  |  |  |  | 4 |  | 
| 80 |  |  |  |  |  |  |  | 
| 81 | 2 |  |  |  |  | 1135 | use constant IPV4_ADDRESS => qr/\b | 
| 82 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 83 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 84 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 85 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d) | 
| 86 | 2 |  |  | 2 |  | 12 | \b/ox; | 
|  | 2 |  |  |  |  | 3 |  | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 2 |  |  |  |  | 135 | use constant IP_ADDRESS => qr/ | 
| 89 |  |  |  |  |  |  | (?: | 
| 90 |  |  |  |  |  |  | \b(? | 
| 91 |  |  |  |  |  |  | # plain IPv4, as above | 
| 92 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 93 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 94 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 95 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\b | 
| 96 |  |  |  |  |  |  | | | 
| 97 |  |  |  |  |  |  | # IPv6 addresses | 
| 98 |  |  |  |  |  |  | # don't use \b here, it hits on :'s | 
| 99 |  |  |  |  |  |  | (?:IPv6:    # with optional prefix | 
| 100 |  |  |  |  |  |  | | (? | 
| 101 |  |  |  |  |  |  | ) | 
| 102 |  |  |  |  |  |  | (?: | 
| 103 |  |  |  |  |  |  | # IPv4 mapped in IPv6 | 
| 104 |  |  |  |  |  |  | # note the colon after the 12th byte in each here | 
| 105 |  |  |  |  |  |  | (?: | 
| 106 |  |  |  |  |  |  | # first 6 (12 bytes) non-zero | 
| 107 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){6} | 
| 108 |  |  |  |  |  |  | | | 
| 109 |  |  |  |  |  |  | # leading zeros omitted (note {0,5} not {1,5}) | 
| 110 |  |  |  |  |  |  | ::(?:[a-f0-9]{1,4}:){0,5} | 
| 111 |  |  |  |  |  |  | | | 
| 112 |  |  |  |  |  |  | # trailing zeros (in the first 6) omitted | 
| 113 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){1,5}: | 
| 114 |  |  |  |  |  |  | | | 
| 115 |  |  |  |  |  |  | # 0000 in second up to (including) fifth omitted | 
| 116 |  |  |  |  |  |  | [a-f0-9]{1,4}::(?:[a-f0-9]{1,4}:){1,4} | 
| 117 |  |  |  |  |  |  | | | 
| 118 |  |  |  |  |  |  | # 0000 in third up to (including) fifth omitted | 
| 119 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){2}:(?:[a-f0-9]{1,4}:){1,3} | 
| 120 |  |  |  |  |  |  | | | 
| 121 |  |  |  |  |  |  | # 0000 in fourth up to (including) fifth omitted | 
| 122 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){3}:(?:[a-f0-9]{1,4}:){1,2} | 
| 123 |  |  |  |  |  |  | | | 
| 124 |  |  |  |  |  |  | # 0000 in fifth omitted | 
| 125 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){4}:[a-f0-9]{1,4}: | 
| 126 |  |  |  |  |  |  | ) | 
| 127 |  |  |  |  |  |  | # and the IPv4 address appended to all of the 12 bytes above | 
| 128 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 129 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 130 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. | 
| 131 |  |  |  |  |  |  | (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)   # no \b, we check later | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | | # or (separately) a pure IPv6 address | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | # all 8 (16 bytes) of them present | 
| 136 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4} | 
| 137 |  |  |  |  |  |  | | | 
| 138 |  |  |  |  |  |  | # leading zeros omitted | 
| 139 |  |  |  |  |  |  | :(?::[a-f0-9]{1,4}){1,7} | 
| 140 |  |  |  |  |  |  | | | 
| 141 |  |  |  |  |  |  | # trailing zeros omitted | 
| 142 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){1,7}: | 
| 143 |  |  |  |  |  |  | | | 
| 144 |  |  |  |  |  |  | # 0000 in second up to (including) seventh omitted | 
| 145 |  |  |  |  |  |  | [a-f0-9]{1,4}:(?::[a-f0-9]{1,4}){1,6} | 
| 146 |  |  |  |  |  |  | | | 
| 147 |  |  |  |  |  |  | # 0000 in third up to (including) seventh omitted | 
| 148 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5} | 
| 149 |  |  |  |  |  |  | | | 
| 150 |  |  |  |  |  |  | # 0000 in fouth up to (including) seventh omiited | 
| 151 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4} | 
| 152 |  |  |  |  |  |  | | | 
| 153 |  |  |  |  |  |  | # 0000 in fifth up to (including) seventh omitted | 
| 154 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3} | 
| 155 |  |  |  |  |  |  | | | 
| 156 |  |  |  |  |  |  | # 0000 in sixth up to (including) seventh omitted | 
| 157 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2} | 
| 158 |  |  |  |  |  |  | | | 
| 159 |  |  |  |  |  |  | # 0000 in seventh omitted | 
| 160 |  |  |  |  |  |  | (?:[a-f0-9]{1,4}:){6}:[a-f0-9]{1,4} | 
| 161 |  |  |  |  |  |  | | | 
| 162 |  |  |  |  |  |  | # :: (the unspecified addreess 0:0:0:0:0:0:0:0) | 
| 163 |  |  |  |  |  |  | # dos: I don't expect to see this address in a header, and | 
| 164 |  |  |  |  |  |  | # it may cause non-address strings to match, but we'll | 
| 165 |  |  |  |  |  |  | # include it for now since it is valid | 
| 166 |  |  |  |  |  |  | :: | 
| 167 |  |  |  |  |  |  | ) | 
| 168 |  |  |  |  |  |  | (?![a-f0-9:]) | 
| 169 |  |  |  |  |  |  | ) | 
| 170 | 2 |  |  | 2 |  | 13 | /oxi; | 
|  | 2 |  |  |  |  | 5 |  | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | 1; |