IP commands
IP commands can be used in HTTP and TCP events.
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.
Example
when HTTP_REQUEST {
local version = IP:version()
debug("ip version is %s", version)
}