IP Range Limit function

Source: Internet
Author: User
Tags exit range split
Function Everyone if there are good suggestions algorithm, contact me!! :)

'******************************
' Function Checkip (CINPUT_IP,CBOUND_IP)
' Created by Qqdao, Qqdao@263.net 2001/11/28
' Description: First you need to be based on the number loop, and then determine if there is a "-", if there is a split processing, and finally determine whether in the scope
' Parameters: Cinput_ip, Ip on behalf of check
' Cbound_ip, given a range of formats, a single IP, and range IP, the range IP last used "-" split, if it is "*" must be put to the last
' After each range add ': ALLOW ' indicates permission to login, add ": Refuse" indicates refusal to log in. multiple ranges with ";" Separated
' such as 192.168.1*.*:allow;192.168.1.1:allow;192.168.1.1-10:refuse '
' Return value: True/false
' Update: 2001/12/05 support Allow,refuse Support ' * ', do not want to? Support, because and * almost
'******************************
function Checkip (CINPUT_IP,CBOUND_IP)
Dim csingle_ip,ctemp_ip,cstart_ip,cend_ip
Checkip = False
Csingle_ip=split (Cbound_ip, ";")

For i=0 to UBound (CSINGLE_IP)
If Instr (Csingle_ip (i), "refuse") <> 0 Then ' is rejected
Ctemp_ip = Left (Csingle_ip (i), InStr (Csingle_ip (i), ":")-1)

If Instr (ctemp_ip, "*") <> 0 Then ' is wide range
Cstart_ip = Left (Ctemp_ip,instr (CTEMP_IP, "*")-1)
If left (Cinput_ip,len (CSTART_IP)) =cstart_ip Then
Checkip = False
Exit function
End If
End If

If Instr (Ctemp_ip, "-") = 0 Then
CSTART_IP = Ctemp_ip
CEND_IP = Ctemp_ip
Else
Cstart_ip = Left (Ctemp_ip,instr (Ctemp_ip, "-")-1)
Cend_ip = Left (Cstart_ip,instrrev (Cstart_ip, ".") -1) + "." +mid (Ctemp_ip,instr (Ctemp_ip, "-") +1)
End If

If Ip2str (cinput_ip) >=ip2str (CSTART_IP) and Ip2str (CINPUT_IP) <=ip2str (CEND_IP) Then
Checkip = False
Exit function
End If

ElseIf Instr (Csingle_ip (i), "ALLOW") <> 0 Then ' Allow

Ctemp_ip = Left (Csingle_ip (i), InStr (Csingle_ip (i), ":")-1)

If Instr (ctemp_ip, "*") <> 0 Then ' is wide range
Cstart_ip = Left (Ctemp_ip,instr (CTEMP_IP, "*")-1)
&



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.