'From Squeak 3.2 of 11 July 2002 [latest update: #4917] on 15 December 2002 at 1:23:31 pm'! Object subclass: #DtDNSClient instanceVariableNames: 'id password ip host path client interval lastAccessedTime background stopFlag ' classVariableNames: '' poolDictionaries: '' category: 'Tools-Web'! !DtDNSClient commentStamp: 'tf 12/15/2002 13:23' prior: 0! DtDNSClient is a client for Dynamic DNS auto update server at DtDNS(http://www.dtdns.com). It will connect their auto-update-ip server every 60 minutes by default. when using router, I don't have neat idea to get the current global IP. So it will connect the server without checking the change of IPs. The connection will be running in the background, it should be useful to Swiki. ex. open workspace and enter... dtDns _ DtDNSClient new initialize. dtDns start. "<- set the information to connect, and run connection in background" dtDns stop. "<- terminate the background" dtDns resume. "<- resume the background" open transcript to see the status. settings: 'Change your DtDNS server if necessary' (host) - server for DtDNS auto-ip-update. Default should be OK. 'Enter your host name (ex. xxx.dtdns.net)' (id) - domain address you enter at DtDNS service. 'Enter your interval time(minutes) to connect' (interval) - connection interval in minutes. prohibit less than 10. 'Enter your IP. none for auto' (ip) - none or cancel for determin by DtDNS server. None should be OK. 'Enter your password' (password) - password to entry your current IP to DtDNS server. 'Change your DtDNS server path, if necessary' (path) - path of DtDNS auto-ip-update at their server. Default should be OK. ! !DtDNSClient methodsFor: 'initialize' stamp: 'tf 12/14/2002 16:37'! initialize ip _ nil. "for receiver determine the IP" host _ self defaultServerName. path _ self defaultServerPath. lastAccessedTime _ nil. interval _ 60. client _ 'Squeak%20DtDNSClient'. ! ! !DtDNSClient methodsFor: 'start/stop' stamp: 'tf 12/15/2002 13:08'! resume | block | background ifNotNil:[ self stop. ]. block _ [ self background. ]. stopFlag _ false. background _ block newProcess. background priority:(background priority - 10). background resume. ! ! !DtDNSClient methodsFor: 'start/stop' stamp: 'tf 12/15/2002 13:09'! start (self hostFromUser) ifNil:[ ^nil ]. (self pathFromUser) ifNil:[ ^nil ]. (self idFromUser) ifNil:[ ^nil ]. (self passwordFromUser) ifNil:[ ^nil ]. (self intervalFromUser) ifNil:[ ^nil ]. (self ipFromUser) ifNil:[ ^nil ]. self resume.! ! !DtDNSClient methodsFor: 'start/stop' stamp: 'tf 12/14/2002 16:07'! stop background ifNotNil:[ stopFlag _ true. background terminate. background _ nil. ]. ! ! !DtDNSClient methodsFor: 'defaults' stamp: 'tf 12/14/2002 17:50'! defaultServerName ^'http://www.dtdns.com' ! ! !DtDNSClient methodsFor: 'defaults' stamp: 'tf 12/14/2002 17:50'! defaultServerPath ^'/api/autodns.cfm?' ! ! !DtDNSClient methodsFor: 'background' stamp: 'tf 12/14/2002 18:57'! background | shouldConnect | [stopFlag] whileFalse:[ (lastAccessedTime isNil) ifTrue:[ shouldConnect _ true. ] ifFalse:[ (Time totalSeconds > (lastAccessedTime + (interval * 60))) ifTrue:[ shouldConnect _ true. ] ifFalse:[ shouldConnect _ false. ]. ]. shouldConnect ifTrue:[ self connect. ]. (Delay forSeconds:60) wait. ]. Transcript show:(self class printString, ' background terminated.'); cr. ! ! !DtDNSClient methodsFor: 'background' stamp: 'tf 12/14/2002 18:00'! connect | url src | url _ host, path, 'id=', id, '&', 'pw=', password, '&', 'client=', client. ip ifNotNil:[ url _ url, '&ip=', ip. ]. src _ HTTPSocket httpGetDocument:url. Transcript show:(self class printString, ' result:', src contents printString); cr. Transcript show:(Date today printString,' ', Time now printString, ' ', self class printString, ' background connect.'); cr. lastAccessedTime _ Time totalSeconds. ! ! !DtDNSClient methodsFor: 'private' stamp: 'tf 12/14/2002 17:53'! hostFromUser host ifNil:[ host _ ''. ]. host _ FillInTheBlank request:'Change your DtDNS server if necessary' initialAnswer:host. (host = '') ifTrue:[ ^nil. ]. ! ! !DtDNSClient methodsFor: 'private' stamp: 'tf 12/14/2002 17:54'! idFromUser id ifNil:[ id _ ''. ]. id _ FillInTheBlank request:'Enter your host name (ex. xxx.dtdns.net)' initialAnswer:id. (id = '') ifTrue:[ ^nil. ]. ! ! !DtDNSClient methodsFor: 'private' stamp: 'tf 12/14/2002 17:54'! intervalFromUser | ans | interval ifNil:[ interval _ ''. ]. ans _ FillInTheBlank request:'Enter your interval time(minutes) to connect' initialAnswer:(interval printString). (ans = '') ifTrue:[ ^nil. ]. interval _ ans asNumber. (interval < 10) ifTrue:[ interval _ 10. ]. ! ! !DtDNSClient methodsFor: 'private' stamp: 'tf 12/14/2002 15:51'! ipFromUser ip ifNil:[ ip _ ''. ]. ip _ FillInTheBlank request:'Enter your IP. none for auto' initialAnswer:ip. (ip = '') ifTrue:[ ip _ nil. ]. ^self! ! !DtDNSClient methodsFor: 'private' stamp: 'tf 12/14/2002 17:54'! passwordFromUser password ifNil:[ password _ ''. ]. password _ FillInTheBlank request:'Enter your password' initialAnswer:password. (password = '') ifTrue:[ ^nil. ]. ! ! !DtDNSClient methodsFor: 'private' stamp: 'tf 12/14/2002 17:55'! pathFromUser path ifNil:[ path _ ''. ]. path _ FillInTheBlank request:'Change your DtDNS server path, if necessary' initialAnswer:path. (path = '') ifTrue:[ ^nil. ]. ! !