Code: Select all
Function DynDns( cHostName )
Local cIp := AllTrim( PublicIP() ) // PublicIP() es una funcion que esta en foro
Local Encode := hb_Base64Encode( "<usuario>:<clave>" ) // Usuario y Clave de acceso a DynDns
Local cBuffer, cRequest, cResponse, nBytes, pSocket
INetInit()
pSocket := INetConnect( "members.dyndns.org", 80 )
IF INetErrorCode( pSocket ) <> 0
INetCleanUp()
Return( "0.0.0.0" )
ENDIF
nBytes := INetSend( pSocket, "GET /nic/update?hostname=" + Alltrim( lower( cHostName ) ) + "&myip=" + cIp + "&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG HTTP/1.1" + CRLF + "Host: members.dyndns.org" + CRLF + "Authorization: Basic " + Encode + CRLF + "User-Agent: lotenet" + CRLF + CRLF )
cBuffer := Space(512)
cResponse:= ""
WHILE ( nBytes > 0 )
nBytes := INetRecv( pSocket, @cBuffer )
cResponse += Left( cBuffer, nBytes )
cBuffer := Space(512)
ENDDO
INetClose( pSocket )
INetCleanUp()
Alert( cResponse )
Return Nil