NetworkInterface.getInetAddresses

Better version (won't crash most apps) of the same hook by A200K. Local network IP address restriction (using java network interface).

CollectionFif
GroupRead.Network
NameNetworkInterface.getInetAddresses
AuthorFif_
Version1
Updated (UTC)2018-03-14 23:07:38
Created (UTC)2018-03-14 23:07:38
Downloads1513
Class namejava.net.NetworkInterface
Method namegetInetAddresses
Parameter types
Return type-
Min SDK5
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
Settings-
-- Fif.NetworkInterface.getInetAddresses is a Lua hooks designed to work with XPrivacyLua.
-- Copyright (C) 2018 Philippe Troin (Fif_ on XDA)

-- Fif.NetworkInterface.getInetAddresses is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.

-- Fif.NetworkInterface.getInetAddresses is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.

-- You should have received a copy of the GNU General Public License
-- along with XPrivacyLua.  If not, see <http://www.gnu.org/licenses/>.

function after(hook, param)
    local res = param:getResult()
    if res == nil or not res:hasMoreElements() then
        return false
    end

    local inetAddressClass = luajava.bindClass('java.net.InetAddress')
    local loopback = inetAddressClass:getLoopbackAddress()
    local arrayListCls = luajava.bindClass('java.util.ArrayList')
    local aList = luajava.new(arrayListCls)
    aList:add(loopback)
    local collectionsCls = luajava.bindClass('java.util.Collections')
    local fake = collectionsCls:enumeration(aList)

    local old = res:nextElement()

    param:setResult(fake)
    return true, old:toString(), loopback:toString()
end