Fortinet white logo
Fortinet white logo
8.0.0

IP address classes

IP address classes

__eq()

Support use “==” to compare two IP address classes.

__tostring()

Support use tostring(IP-class) to convert IP address class to IP string.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:local_addr())
}

IP:local_addr()

Return IP address class, which is the local address of the connection.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:local_addr())
    if ip == "10.10.10.10" then
	debug("local addr equals to 10.10.10.10")
    end
}

IP:remote_addr()

Return IP address class, which is the remote address of the connection.

Example
when HTTP_REQUEST { 
    local ip = tostring(IP:remote_addr())
    if ip == "10.10.10.10" then
	debug("remote addr equals to 10.10.10.10")
    end
}

IP:client_addr()

Return IP address class, which is the client IP address of the stream.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:client_addr())
    if ip == "10.10.10.10" then
	debug("client addr equals to 10.10.10.10")
    end
}

IP:server_addr()

Return IP address class, which is the server IP address of the stream. If server is not connected, return nil.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:server_addr())
    if ip == "10.10.10.10" then
	debug("server addr equals to 10.10.10.10")
    end
}

IP:version()

Return the IP version of the connection, either 4 or 6.

Example
when HTTP_REQUEST {
    local version = IP:version()
    if version == 4 then
        debug("ip version is 4")
    end
}

IP address classes

IP address classes

__eq()

Support use “==” to compare two IP address classes.

__tostring()

Support use tostring(IP-class) to convert IP address class to IP string.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:local_addr())
}

IP:local_addr()

Return IP address class, which is the local address of the connection.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:local_addr())
    if ip == "10.10.10.10" then
	debug("local addr equals to 10.10.10.10")
    end
}

IP:remote_addr()

Return IP address class, which is the remote address of the connection.

Example
when HTTP_REQUEST { 
    local ip = tostring(IP:remote_addr())
    if ip == "10.10.10.10" then
	debug("remote addr equals to 10.10.10.10")
    end
}

IP:client_addr()

Return IP address class, which is the client IP address of the stream.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:client_addr())
    if ip == "10.10.10.10" then
	debug("client addr equals to 10.10.10.10")
    end
}

IP:server_addr()

Return IP address class, which is the server IP address of the stream. If server is not connected, return nil.

Example
when HTTP_REQUEST {
    local ip = tostring(IP:server_addr())
    if ip == "10.10.10.10" then
	debug("server addr equals to 10.10.10.10")
    end
}

IP:version()

Return the IP version of the connection, either 4 or 6.

Example
when HTTP_REQUEST {
    local version = IP:version()
    if version == 4 then
        debug("ip version is 4")
    end
}