This repository has been archived by the owner on May 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DnsUpdater.h
116 lines (100 loc) · 2.3 KB
/
DnsUpdater.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// DnsUpdater.h
//
#pragma once
class DomainInfo : public IAuthInfo {
public:
// for query string
tstring hostname;
tstring tld;
tstring myip;
tstring mx;
tstring backmx;
tstring wildcard;
// provider info
tstring easydnsurl;
DWORD httpTimeout;
// auth
tstring username;
tstring password;
tstring domain;
// proxy
tstring proxy;
DWORD proxyPort;
DomainInfo()
{
easydnsurl = _T("http:https://members.easydns.com/dyn/dyndns.php");
domain = _T("");
myip = _T("1.1.1.1");
httpTimeout = 0;
proxyPort = 0;
}
DomainInfo(const DomainInfo& info)
{
// query string
hostname = info.hostname;
tld = info.tld;
myip = info.myip;
mx = info.mx;
backmx = info.backmx;
wildcard = info.wildcard;
// provider info
easydnsurl = info.easydnsurl;
httpTimeout = info.httpTimeout;
// auth
username = info.username;
password = info.password;
domain = info.domain;
// proxy
proxy = info.proxy;
proxyPort = info.proxyPort;
}
DomainInfo& operator = (const DomainInfo& info)
{
// query string
hostname = info.hostname;
tld = info.tld;
myip = info.myip;
mx = info.mx;
backmx = info.backmx;
wildcard = info.wildcard;
// provider info
easydnsurl = info.easydnsurl;
httpTimeout = info.httpTimeout;
// auth
username = info.username;
password = info.password;
domain = info.domain;
// proxy
proxy = info.proxy;
proxyPort = info.proxyPort;
return *this;
}
BOOL UpdateDNS(const TCHAR* addr, EventLog* plog);
HRESULT GetPassword(LPTSTR szPwd, DWORD* dwBuffSize);
HRESULT GetUsername(LPTSTR szUid, DWORD* dwBuffSize);
HRESULT GetDomain(LPTSTR szDomain, DWORD* dwBuffSize);
};
typedef std::vector<DomainInfo> DomainInfoVect;
typedef std::vector<DomainInfo>::iterator DomainInfoVectIter;
const int FP_MAXWAIT = MAXIMUM_WAIT_OBJECTS - 1;
class DnsUpdater {
private:
DomainInfoVect domainInfo;
// wait array
HANDLE waitArray[1];
DWORD waitObjects;
DWORD timeout;
WSADATA wsadata;
public:
EventLog* evLog;
void CloseHandles(bool includeEvent = false);
DnsUpdater();
~DnsUpdater();
// config
void Add(const DomainInfo& info);
void SetTimeout(DWORD timeoutMs) { timeout = timeoutMs; }
// run
bool RunOnce();
void Run();
void Stop();
};