SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DynDNS.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
20
21
22 #include "NativeFeatureIncludes.h"
23 #if _RAKNET_SUPPORT_DynDNS==1 && _RAKNET_SUPPORT_TCPInterface==1
24
25 #ifndef __DYN_DNS_H
26 #define __DYN_DNS_H
27
28 #include "string.h"
29
30 namespace SLNet
31 {
32
33 class TCPInterface;
34
35 enum DynDnsResultCode
36 {
37 // ----- Success -----
38 RC_SUCCESS,
39 RC_DNS_ALREADY_SET, // RakNet detects no action is needed
40
41 // ----- Ignorable failure (treat same as success) -----
42 RC_NO_CHANGE, // DynDNS detects no action is needed (treated as abuse though)
43
44 // ----- User error -----
45 RC_NOT_DONATOR, // You have to pay to do this
46 RC_NO_HOST, // This host does not exist at all
47 RC_BAD_AUTH, // You set the wrong password
48 RC_NOT_YOURS, // This is not your host
49
50 // ----- Permanent failure -----
51 RC_ABUSE, // Your host has been blocked, too many failures disable your account
52 RC_TCP_FAILED_TO_START, // TCP port already in use
53 RC_TCP_DID_NOT_CONNECT, // DynDNS down?
54 RC_UNKNOWN_RESULT, // DynDNS returned a result code that was not documented as of 12/4/2010 on http://www.dyndns.com/developers/specs/flow.pdf
55 RC_PARSING_FAILURE, // Can't read the result returned, format change?
56 RC_CONNECTION_LOST_WITHOUT_RESPONSE, // Lost the connection to DynDNS while communicating
57 RC_BAD_AGENT, // ???
58 RC_BAD_SYS, // ???
59 RC_DNS_ERROR, // ???
60 RC_NOT_FQDN, // ???
61 RC_NUM_HOST, // ???
62 RC_911, // ???
63 RC_DYNDNS_TIMEOUT // DynDNS did not respond
64 };
65
66 // Can only process one at a time with the current implementation
67 class RAK_DLL_EXPORT DynDNS
68 {
69 public:
70 DynDNS();
71 ~DynDNS();
72
73 // Pass 0 for newIPAddress to autodetect whatever you are uploading from
74 // usernameAndPassword should be in the format username:password
75 void UpdateHostIPAsynch(const char *dnsHost, const char *newIPAddress, const char *usernameAndPassword );
76 void Update(void);
77
78 // Output
79 bool IsRunning(void) const {return connectPhase!=CP_IDLE;}
80 bool IsCompleted(void) const {return connectPhase==CP_IDLE;}
81 SLNet::DynDnsResultCode GetCompletedResultCode(void) {return result;}
82 const char *GetCompletedDescription(void) const {return resultDescription;}
83 bool WasResultSuccessful(void) const {return result==RC_SUCCESS || result==RC_DNS_ALREADY_SET || result==RC_NO_CHANGE;}
84 char *GetMyPublicIP(void) const {return (char*) myIPStr;} // We get our public IP as part of the process. This is valid once completed
85
86 protected:
87 void Stop(void);
88 void SetCompleted(SLNet::DynDnsResultCode _result, const char *_resultDescription) {Stop(); result=_result; resultDescription=_resultDescription;}
89
90 enum ConnectPhase
91 {
92 CP_CONNECTING_TO_CHECKIP,
93 CP_WAITING_FOR_CHECKIP_RESPONSE,
94 CP_CONNECTING_TO_DYNDNS,
95 CP_WAITING_FOR_DYNDNS_RESPONSE,
96 CP_IDLE
97 };
98
99 TCPInterface *tcp;
100 SLNet::RakString getString;
101 SystemAddress serverAddress;
102 ConnectPhase connectPhase;
103 SLNet::RakString host;
104 SLNet::Time phaseTimeout;
105 SystemAddress checkIpAddress;
106 const char *resultDescription;
107 SLNet::DynDnsResultCode result;
108 char myIPStr[32];
109 };
110
111 } // namespace SLNet
112
113 #endif // __DYN_DNS_H
114
115 #endif // _RAKNET_SUPPORT_DynDNS