Jump to content

Modem Ip Alma


turkoglu98
 Share

Recommended Posts

arkadaşlar bir programıma istatistik bölümü yapıyordum ve doğru olması için modemin ip adresi alınması gerekiyor. ama bir türlü alamadım. 

aslında sitelerden veri çekerek yapılabiliyor ama programı çok kasıyor bazen yanıt vermiyor. bunun daha kolay bir yolunu bilen var mı?

 

192.168 gibi olan ip adresini değil direk modemin adresi lazım 

Link to comment
Share on other sites

HTTP.Download("http://www.ipchicken.com/", _TempFolder .. "\\tempfile", MODE_TEXT);
error = Application.GetLastError();
if (error == 0) then
    page = TextFile.ReadToString(_TempFolder .. "\\tempfile");
    File.Delete(_TempFolder .. "\\tempfile", false, false, true);
    ip = string.sub(page, string.find(page, '%d+%.%d+%.%d+%.%d+'));
    if (ip ~= nil) then
        error = 0;
  Dialog.Message("", "Ip adresim: "..ip..")
 end
end

Link to comment
Share on other sites

  • Editor
function WMIDateStringToDate(dtmDate)
    if dtmDate then
        dtmDate = tostring(dtmDate);
        return (String.Mid (dtmDate, 7, 2)  .. "/" ..
                String.Mid (dtmDate, 5, 2)  .. "/" ..
                String.Left(dtmDate, 4)     .. " " ..
                String.Mid (dtmDate, 9, 2)  .. ":" .. 
                String.Mid (dtmDate, 11, 2) .. ":" .. 
                String.Mid (dtmDate, 13, 2)
               );
    else
        return "";
    end
end

function Escape(v)
    if (v == nil) then return ""; end
    if (type(v) == "table") then return Table.Concat(v, ", "); end
    if (type(v) == "boolean") then
        if (v == true) then return "Yes"; else return "No"; end
    end
    return v;
end

local sOutput      = "";
local oWMIService  = luacom.GetObject("winmgmts:\\\\localhost\\root\\CIMV2");
local oColItems    = oWMIService:ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 48);
if oColItems then
    local oEnum   = luacom.GetEnumerator(oColItems);
    local oItem = oEnum:Next();
    while oItem do
        if Escape(oItem:DefaultIPGateway()) ~= "" then
        sOutput = Escape(oItem:DefaultIPGateway());
        end
        oItem = oEnum:Next();
    end
    Dialog.Message("WMI (Windows Kütüphanesi) Çıktısı",sOutput);
else
    Dialog.Message("WMI (Windows Kütüphanesi) Çıktısı", "");
end

Bu kod sana varsayılan ağ geçidin yani ney üzerinden internete çıkıyorsun modemse modemin ip si. onu verir.Kullana bilmen için LUA pluginini aktif etmen lazım.

Link to comment
Share on other sites

arkadaşlar benim istediğim 192.168 li olan değil 

ipchicken.com sitesinde görüntülen ip adresi;

mesela: 78.174.72.100  

HTTP.Download("http://www.ipchicken.com/", _TempFolder .. "\\tempfile", MODE_TEXT);
error = Application.GetLastError();
if (error == 0) then
    page = TextFile.ReadToString(_TempFolder .. "\\tempfile");
    File.Delete(_TempFolder .. "\\tempfile", false, false, true);
    ip = string.sub(page, string.find(page, '%d+%.%d+%.%d+%.%d+'));
    if (ip ~= nil) then
        error = 0;
  Dialog.Message("", "Ip adresim: "..ip..")
 end
end

bu kod işe yarıyor ama programı çok kasıyor bunun alternatif bir yolu yokmu

Link to comment
Share on other sites

  • Editor

Bu şekilde aldım arkadaşlar IP yi işini görürmü bilemem.

tblA = CommandLine.Execute("ping google.com", 0);
str = "";
for j,k in pairs(tblA) do
str = k;
end
ilk = String.Find(str, "[", 1, false);
son = String.Find(str, "]", 1, false);
result = String.Mid(str, ilk + 1,(son - ilk) -1);
Dialog.Message("",result);

Projede CommandLine pluginini aktif etmen lazım.

Link to comment
Share on other sites

 

http://myexternalip.com/raw sayfada sadece dış ip'yi gösteriyor.
veya icanhazip.com
Cmd için curl vasıtasıyla yine aynı site üzerinden ip çekilebiliyor.
http://curl.haxx.se/download.html


bkz:



curl "http://myexternalip.com/raw"

 Kardeş güzel bilgi vermişsin tşk ederim cmd ile bulmak gerçekten merak ettiğim bir konuydu peki extra curl vs bir paket kullanmadan bulma imkanımız varmı wan ip yi ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...