Getting back to this, forgot about posting the header info, etc.....
This is not the code as that would relate to a rather large project ATM. This shows the header request and the format of the server's response.
In my code I have added a couple more error codes of no connect and invalid response(invalid format of response from server IE: got something I wasn't expecting.)
I have a VB app written as well but there are a few steps here that are taken care of in the control so a bit more info here.
You must of course connect a socket to dynupdate.no-ip.com first.
Not really code but wanted to break it out from the text.......
[code:1:1ec31d3ef1]
' Send the following header to dynupdate.no-ip.com server(all lines terminate with CRLF):
' GET /dns?username=%username%&password=%password%&hostname=%hostname%&ip=%ip% HTTP/1.1
' User-Agent: ATmega 2560 Ardunio/EthernetShield via BASCOM/v1.0
' Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
' Accept-Language: en-US,en;q=0.5
' Accept-Encoding: none
' Connection: keep-alive
' Cache-Control: max-age=0
' terminate request header with empty line
'
' Where : %username% = NO-IP username account
' %password% = NO-IP username's account password
' %hostname% = NO-IP username's dynamic host name to update
' %ip% = Current public IP address
'
' The server will then respond with a server response(all lines terminate with CRLF) of :
' HTTP/1.1 200 OK
' Date: Tue, 11 Feb 2014 23:55:50 GMT
' Server: Apache/2
' Content-Location: dns.php
' Vary: negotiate
' TCN: choice
' Content-Length: 1
' Content-Type: text/plain; charset=UTF-8
' Connection: keep-alive
' <note this is a BLANK line = CRLF>
' %hostname%:0 = correct response, no update.
' OR
' 5 = too many attempts in a hour for example
'
' Where as the number following the : is coded as follows:
' 0 = Success - IP address is current, no update performed
' 1 = Success - DNS hostname update successful
' 2 = Error - Hostname supplied does not exist
' 3 = Error - Invalid username
' 4 = Error - Invalid password
' 5 = Error - Too many updates sent. Updates are blocked until 1 hour passes since last status of 5 returned
' 6 = Error - Account disabled due to violation of No-IP terms of service. Our terms of service can be viewed at http://www.no-ip.com/legal/tos
' 7 = Error - Invalid IP. Invalid IP submitted is improperly formated, is a private LAN RFC 1918 address, or an abuse blacklisted address
' 8 = Error - Disabled / Locked hostname
' 9 = Host updated is configured as a web redirect and no update was performed
' 10 = Error - Group supplied does not exist
' 11 = Success - DNS group update is successful
' 12 = Success - DNS group is current, no update performed
' 13 = Error - Update client support not available for supplied hostname or group
' 14 = Error - Hostname supplied does not have offline settings configured. Returned if sending offline=YES on a host that does not have any offline actions configured
' 99 = Error - Client disabled. Client should exit and not perform any more updates without user intervention
' 100 = Error - User input error usually returned if missing required request parameters
[/code:1:1ec31d3ef1]
Enjoy, works VERY well as long as you follow the server rules and understand sockets, buffer reads/writes, disconnects, etc... you can meld into your code. In debug you can get a error code of 5 often. :oops:
Mark
↧