@@ -31,8 +31,10 @@ import {
31
31
export default class DNSAddOverride extends React . Component {
32
32
state = {
33
33
Type : '' ,
34
+ ReturnType : 'IP' ,
34
35
Domain : '' ,
35
- ResultIP : '0.0.0.0' ,
36
+ ResultIP : '' ,
37
+ ResultCNAME : '' ,
36
38
ClientIP : '*' ,
37
39
Expiration : 0 ,
38
40
check : { }
@@ -53,11 +55,13 @@ export default class DNSAddOverride extends React.Component {
53
55
this . state . Type = props . type
54
56
this . state . Domain = props . domain || ''
55
57
this . state . ResultIP = props . ResultIP || ''
58
+ this . state . ResultCNAME = props . ResultCNAME || ''
56
59
this . state . ClientIP = props . clientip || '*'
57
60
this . state . check = {
58
61
Type : '' ,
59
62
Domain : '' ,
60
63
ResultIP : '' ,
64
+ ResultCNAME : '' ,
61
65
ClientIP : ''
62
66
}
63
67
@@ -67,7 +71,7 @@ export default class DNSAddOverride extends React.Component {
67
71
}
68
72
69
73
validateField ( name , value ) {
70
- let check = { Type : '' , Domain : '' , ResultIP : '' , ClientIP : '' }
74
+ let check = { Type : '' , Domain : '' , ResultIP : '' , ResultCNAME : '' , ClientIP : '' }
71
75
72
76
if ( name == 'Type' && ! [ 'block' , 'permit' ] . includes ( value ) ) {
73
77
check . Type = 'has-danger'
@@ -103,10 +107,21 @@ export default class DNSAddOverride extends React.Component {
103
107
return
104
108
}
105
109
110
+ if ( this . state . ReturnType == 'CNAME' ) {
111
+ if ( this . state . ResultCNAME != '' && ! this . state . ResultCNAME . endsWith ( '.' ) ) {
112
+ this . state . ResultCNAME += '.'
113
+ }
114
+ this . state . ResultIP = ''
115
+ } else if ( this . state . ReturnType == 'IP' ) {
116
+ this . state . ResultCNAME = ''
117
+ }
118
+
119
+
106
120
let override = {
107
121
Type : this . state . Type ,
108
122
Domain : this . state . Domain ,
109
123
ResultIP : this . state . ResultIP ,
124
+ ResultCNAME : this . state . ResultCNAME ,
110
125
ClientIP : this . state . ClientIP ,
111
126
Expiration : this . state . Expiration
112
127
}
@@ -203,36 +218,66 @@ export default class DNSAddOverride extends React.Component {
203
218
) }
204
219
</ FormControl >
205
220
206
- < FormControl isInvalid = { this . state . check . ResultIP == 'has-danger' } >
221
+
222
+ < FormControl
223
+ isInvalid = { this . state . check . ResultIP == 'has-danger' || this . state . check . ReturnCNAME == 'has-danger' }
224
+ >
207
225
< FormControlLabel >
208
- < FormControlLabelText > Result IP </ FormControlLabelText >
226
+ < FormControlLabelText > Result Type </ FormControlLabelText >
209
227
</ FormControlLabel >
210
228
211
- < Input >
229
+ < RadioGroup
230
+ flex = { 1 }
231
+ defaultValue = { this . state . ReturnType }
232
+ accessibilityLabel = "Select Return Type"
233
+ onChange = { ( type ) => {
234
+ this . handleChange ( 'ReturnType' , type )
235
+ } }
236
+ >
237
+ < HStack py = "1" space = "md" >
238
+ < Radio key = "block" value = "IP" size = "md" >
239
+ < RadioIndicator mr = "$2" >
240
+ < RadioIcon as = { CircleIcon } strokeWidth = { 1 } />
241
+ </ RadioIndicator >
242
+ < RadioLabel > IP</ RadioLabel >
243
+ </ Radio >
244
+
245
+ < Radio key = "permit" value = "CNAME" size = "md" >
246
+ < RadioIndicator mr = "$2" >
247
+ < RadioIcon as = { CircleIcon } strokeWidth = { 1 } />
248
+ </ RadioIndicator >
249
+ < RadioLabel > CNAME</ RadioLabel >
250
+ </ Radio >
251
+ </ HStack >
252
+ </ RadioGroup >
253
+
254
+
255
+ < Input py = "1" >
212
256
< InputField
213
257
type = "text"
214
258
name = "ResultIP"
215
- value = { this . state . ResultIP }
216
- onChangeText = { ( value ) => this . handleChange ( 'ResultIP' , value ) }
259
+ value = { this . state . ReturnType == 'IP' ? this . state . ResultIP : this . state . ResultCNAME }
260
+ onChangeText = { ( value ) => this . handleChange ( 'Result' + this . state . ReturnType , value ) }
217
261
/>
218
262
</ Input >
219
263
220
- { this . state . check . ResultIP == 'has-danger' ? (
264
+ { ( this . state . check . ResultIP == 'has-danger' || this . state . check . ResultCNAME == 'has-danger' ) ? (
221
265
< FormControlError >
222
266
< FormControlErrorText >
223
- Please enter a valid IP or leave empty
267
+ Please enter a valid { this . state . ReturnType } or leave empty
224
268
</ FormControlErrorText >
225
269
</ FormControlError >
226
270
) : (
227
271
< FormControlHelper >
228
272
< FormControlHelperText >
229
- Optional. Set a custom IP address to return for domain name
273
+ Optional. Set a custom { this . state . ReturnType } address to return for domain name
230
274
lookup
231
275
</ FormControlHelperText >
232
276
</ FormControlHelper >
233
277
) }
234
278
</ FormControl >
235
279
280
+
236
281
< FormControl isInvalid = { this . state . check . ClientIP == 'has-danger' } >
237
282
< FormControlLabel >
238
283
< FormControlLabelText > Client IP</ FormControlLabelText >
0 commit comments