| 106 | |
| 107 | |
| 108 | bool LUAIPAddress::Read(Exception& ex, lua_State *pState, int index, IPAddress& address,bool withDNS) { |
| 109 | |
| 110 | if (lua_type(pState, index)==LUA_TSTRING) // lua_type because can be encapsulated in a lua_next |
| 111 | return withDNS ? address.setWithDNS(ex, lua_tostring(pState,index)) : address.set(ex, lua_tostring(pState,index)); |
| 112 | |
| 113 | if(lua_istable(pState,index)) { |
| 114 | bool isConst; |
| 115 | |
| 116 | IPAddress* pOther = Script::ToObject<IPAddress>(pState, isConst, index); |
| 117 | if (pOther) { |
| 118 | address.set(*pOther); |
| 119 | return true; |
| 120 | } |
| 121 | |
| 122 | SocketAddress* pAddress = Script::ToObject<SocketAddress>(pState, isConst, index); |
| 123 | if (pAddress) { |
| 124 | address.set(pAddress->host()); |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | ServerConnection* pServer = Script::ToObject<ServerConnection>(pState, isConst, index); |
| 129 | if (pServer) { |
| 130 | address.set(pServer->address.host()); |
| 131 | return true; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | ex.set(Exception::NETIP, "No valid IPAddress available to read"); |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | int LUAIPAddress::Set(lua_State *pState) { |
| 140 | SCRIPT_CALLBACK(IPAddress, address) |
nothing calls this directly
no test coverage detected