/ipaddr
Posted by Psycho
Tuesday, September 28, 2004
Description: Simple snippet to get your external IP

Are you on a router?
Can't see your IP?

This can help

/ipaddr to start



dialog ip_address {
  title "IP Address - dyndns.org"
  size -1 -1 112 52
  option dbu
  edit "", 1, 46 10 58 10, disable
  text "Internal IP:", 2, 6 12 35 8, right
  box "IP Address", 3, 2 2 108 48
  edit "", 4, 46 24 58 10, disable
  text "External IP:", 5, 6 26 35 8, right
  button "Get IP", 6, 6 38 31 8
  button "Close", 7, 74 38 31 8, ok
  button "Clipboard", 8, 40 38 31 8
}
alias ipaddr {
  dialog -dmo ip_address ip_address
}
on *:dialog:ip_address:init:*:{
  did -a ip_address 1 $ip
  did -a ip_address 4 $ip
}
on *:dialog:ip_address:sclick:6:{
  did -r ip_address 4 | did -a ip_address 4 Waiting...
  sockopen ipaddr checkip.dyndns.org 80
}
on *:dialog:ip_address:sclick:8:{
  clipboard $did(ip_address,4)
}
on *:sockopen:ipaddr:{
  sockwrite -n $sockname GET /index.htm
  sockwrite -n $sockname Host: checkip.dyndns.org $+ $crlf $+ $crlf
}
on *:sockread:ipaddr:{
  if ($sockerr) { halt }
  else {
    var %temptext
    sockread %temptext
    if (<body> isin %temptext) { did -r ip_address 4 | did -a ip_address 4 $diehtml($gettok(%temptext,2,58)) }
  }
  else { return }
}
alias -l diehtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
  return %x
}
you dont need
Posted by variant
Tuesday, September 28, 2004 08:42pm PDT
the $crlf $crlf on

sockwrite -n $sockname Host: checkip.dyndns.org $+ $crlf $+ $crlf

just add another sockwrite -n $sockname under it and get rid of the $+ $crlf $+ $crlf
Subject line
Posted by Ghost2-b
Wednesday, September 29, 2004 01:45am PDT
/localinfo -u
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world