| |
| /pliant/protocol/common/misc.pli |
| |
| 1 |
abstract | |
| 2 |
[A few entry level function used by servers that I found no better place for.] | |
| 3 |
| |
| 4 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 5 |
# | |
| 6 |
# This program is free software; you can redistribute it and/or | |
| 7 |
# modify it under the terms of the GNU General Public License version 2 | |
| 8 |
# as published by the Free Software Foundation. | |
| 9 |
# | |
| 10 |
# This program is distributed in the hope that it will be useful, | |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 |
# GNU General Public License for more details. | |
| 14 |
# | |
| 15 |
# You should have received a copy of the GNU General Public License | |
| 16 |
# version 2 along with this program; if not, write to the Free Software | |
| 17 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 18 |
| |
| 19 |
| |
| 20 |
method ip is_inside_ip_domain domain -> inside | |
| 21 |
arg Str ip domain ; arg CBool inside | |
| 22 |
if domain="" | |
| 23 |
return true | |
| 24 |
eif (domain parse any:(var Str domain1) _ any:(var Str domain2)) | |
| 25 |
return (ip is_inside_ip_domain domain1) or (ip is_inside_ip_domain domain2) | |
| 26 |
eif not (ip eparse (var Int ip1) "." (var Int ip2) "." (var Int ip3) "." (var Int ip4)) | |
| 27 |
return false | |
| 28 |
if (domain eparse (var Int d1) "." (var Int d2) "." (var Int d3) "." (var Int d4) "/" (var Int m1) "." (var Int m2) "." (var Int m3) "." (var Int m4)) | |
| 29 |
inside := (ip1 .and. m1)=d1 and (ip2 .and. m2)=d2 and (ip3 .and. m3)=d3 and (ip4 .and. m4)=d4 | |
| 30 |
eif (domain eparse (var Int d1) "." (var Int d2) "." (var Int d3) "." (var Int d4)) | |
| 31 |
inside := ip1=d1 and ip2=d2 and ip3=d3 and ip4=d4 | |
| 32 |
else | |
| 33 |
inside := false | |
| 34 |
| |
| 35 |
| |
| 36 |
export '. is_inside_ip_domain' | |
| |