getServerIP
Server
Returns the machine's public IPv4 address, read from its network interfaces at start.
string|false getServerIP([bool withPort = false])
Parameters
| Name | Type | Description |
|---|---|---|
| withPort | bool | If true, :port is appended.default false |
Returns
The address, such as "203.0.113.7" or "203.0.113.7:27015". false if the machine has no public address, as behind NAT or in a container.
Example
local address = getServerIP(true)
if address then
print("connect to " .. address)
end