mIRC Home    About    Download    Register    News    Help

Print Thread
$homeip/$lanip/$localip #263552 17/08/18 05:56 PM
Joined: Nov 2004
Posts: 804
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Nov 2004
Posts: 804
Some kind of identifier for returning your LAN/WLAN IP would be nice.

At the minute I have to use some PHP code bytecode compiled as an exe to do this.


What do you do at the end of the world? Are you busy? Will you save us?
Re: $homeip/$lanip/$localip [Re: Jigsy] #263553 17/08/18 10:02 PM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
Code:
alias localip {
  .comopen a wbemScripting.swbemLocator | .comclose a $com(a,connectserver,3,bstr,.,bstr,root\cimv2,dispatch* b)
  .comclose b $com(b,execquery,3,bstr,SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True ,dispatch* c)
  var %b $comval(c,0),%r
  while (%b) {
    if ($comval(c,%b,DHCPEnabled)) %r = %r $comval(c,%b,DHCPServer)
    else %r = %r $comval(c,%b,IPAddress)
    dec %b
  }
  .comclose c
  return %r
}
You can try this, I might write something for the external ip later

Not a bad suggestion but it can be done without using 'php byte code'


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $homeip/$lanip/$localip [Re: Wims] #263555 18/08/18 12:19 PM
Joined: Nov 2004
Posts: 804
Jigsy Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Nov 2004
Posts: 804
Interesting.

This seems to return 192.168.0.1 instead of my current ip which is 192.168.0.3, though.


What do you do at the end of the world? Are you busy? Will you save us?
Re: $homeip/$lanip/$localip [Re: Jigsy] #263557 19/08/18 12:22 PM
Joined: Mar 2008
Posts: 90
B
BhaaL Offline
Babel fish
Offline
Babel fish
B
Joined: Mar 2008
Posts: 90
Not sure, but DHCPServer sounds wrong in the if-part.

Re: $homeip/$lanip/$localip [Re: BhaaL] #267184 15/04/20 03:44 AM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
Yes, that was not really correct. Before it wasn't possible to handle such result from mIRC's COM implementation, now with the latest beta it's possible:
Code
alias myips {
  .comopen loc WbemScripting.SWbemLocator
  .comclose loc $com(loc, ConnectServer, 3, dispatch* query)
  noop $com(query, ExecQuery, 3, bstr, Select * from Win32_NetworkAdapter WHERE NetConnectionStatus = 2, dispatch* adapter)
  var %a $comval(adapter,0)
  while (%a) {
    hadd -m getips $comval(adapter,%a,Index) $comval(adapter,%a,NetConnectionID)
    dec %a 
  }
  noop $com(query, ExecQuery, 3, bstr, Select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = True, dispatch* ips)
  var %cv $comval(ips,0)
  while (%cv) {
    if ($hget(getips,$comval(ips, %cv, Index)) != $null) {
      noop $comval(ips, %cv, IPAddress,&test).result
      breplace &test 0 32
      echo -s $bvar(&test,1-).text
    }
    dec %cv
 
  }
  :error
  if ($error || %err) {
    echo -a /myips: $v1
    reseterror
  }
  hfree getips
  .comclose query
  .comclose adapter
  .comclose ips
}
This finds the network adapter which are connected (status = 2) and then find the ip addresses belonging to them.

Note that when the value returned is an array like this, $comval(name,N,IPAddress) would return $null, but it now returns the first element in the array (while you can access the full array using a binvar and splitting on byte 0)


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net