@@ -75,20 +75,50 @@ struct DNSQuestion
75
75
class DNSServer
76
76
{
77
77
public:
78
+ /* *
79
+ * @brief Construct a new DNSServer object
80
+ * by default server is configured to run in "Captive-portal" mode
81
+ * it must be started with start() call to establish a listening socket
82
+ *
83
+ */
78
84
DNSServer ();
85
+
79
86
/* *
80
87
* @brief Construct a new DNSServer object
81
88
* builds DNS server with default parameters
82
89
* @param domainName - domain name to serve
83
90
*/
84
91
DNSServer (const String &domainName);
85
92
~DNSServer (){}; // default d-tor
86
- void processNextRequest (){}; // stub, left for compatibility with an old version
93
+
94
+ // Copy semantics not implemented (won't run on same UDP port anyway)
95
+ DNSServer (const DNSServer&) = delete ;
96
+ DNSServer& operator =(const DNSServer&) = delete ;
97
+
98
+
99
+ /* *
100
+ * @brief stub, left for compatibility with an old version
101
+ * does nothing actually
102
+ *
103
+ */
104
+ void processNextRequest (){};
105
+
106
+ /* *
107
+ * @brief Set the Error Reply Code for all req's not matching predifined domain
108
+ *
109
+ * @param replyCode
110
+ */
87
111
void setErrorReplyCode (const DNSReplyCode &replyCode);
112
+
113
+ /* *
114
+ * @brief set TTL for successfull replies
115
+ *
116
+ * @param ttl in seconds
117
+ */
88
118
void setTTL (const uint32_t &ttl);
89
119
90
120
/* *
91
- * @brief Starts a server with current configuration or with default parameters
121
+ * @brief (re) Starts a server with current configuration or with default parameters
92
122
* if it's the first call.
93
123
* Defaults are:
94
124
* port: 53
@@ -100,13 +130,39 @@ class DNSServer
100
130
*/
101
131
bool start ();
102
132
103
- // Returns true if successful, false if there are no sockets available
104
- bool start (const uint16_t &port,
133
+ /* *
134
+ * @brief (re)Starts a server with provided configuration
135
+ *
136
+ * @return true on success
137
+ * @return false if IP or socket error
138
+ */
139
+ bool start (uint16_t port,
105
140
const String &domainName,
106
141
const IPAddress &resolvedIP);
107
- // stops the DNS server
142
+
143
+ /* *
144
+ * @brief stops the server and close UDP socket
145
+ *
146
+ */
108
147
void stop ();
109
148
149
+ /* *
150
+ * @brief returns true if DNS server runs in captive-portal mode
151
+ * i.e. all requests are served with AP's ip address
152
+ *
153
+ * @return true if catch-all mode active
154
+ * @return false otherwise
155
+ */
156
+ inline bool isCaptive () const { return _domainName.isEmpty (); };
157
+
158
+ /* *
159
+ * @brief returns 'true' if server is up and UDP socket is listening for UDP req's
160
+ *
161
+ * @return true if server is up
162
+ * @return false otherwise
163
+ */
164
+ inline bool isUp () { return _udp.connected (); };
165
+
110
166
private:
111
167
AsyncUDP _udp;
112
168
uint16_t _port;
0 commit comments