1026
1031
js_destroy(starwhitis);
1027
1032
goto old_udpany_code_disabled;
1034
use_old_udpany_code:
1036
/* The old udpany code is still used by the recursive half of
1037
* MaraDNS, so we have to keep it for the time being */
1039
/* Look for an A record with the same name as the query */
1040
if(change_rtype(query,RR_A) == JS_ERROR)
1042
spot_data = mhash_get(bighash,query);
1043
/* If found, add the data to our records */
1044
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1046
where = spot_data.value;
1047
authoritative = where->authoritative;
1048
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1049
&(header.nscount),&(header.arcount),1,
1050
spot_data.point,0,0) == JS_ERROR)
1053
/* Look for MX record with the same name as the query */
1054
if(change_rtype(query,RR_MX) == JS_ERROR)
1056
spot_data = mhash_get(bighash,query);
1057
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1059
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1060
&(header.nscount),&(header.arcount),0,
1061
spot_data.point,0,0) == JS_ERROR)
1065
where = spot_data.value;
1066
authoritative = where->authoritative;
1067
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1068
&(header.nscount),&(header.arcount),1,
1069
spot_data.point,0,0) == JS_ERROR)
1075
/* We optionally look for NS and SOA on an RR_ANY query */
1077
/* Look for NS record with the same name as the query */
1078
if(change_rtype(query,RR_NS) == JS_ERROR)
1080
spot_data = mhash_get(bighash,query);
1081
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1083
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1084
&(header.nscount),&(header.arcount),0,
1085
spot_data.point,0,0) == JS_ERROR)
1089
where = spot_data.value;
1090
authoritative = where->authoritative;
1091
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1092
&(header.nscount),&(header.arcount),1,
1093
spot_data.point,0,0) == JS_ERROR)
1098
/* Look for SOA record with the same name as the query */
1099
if(change_rtype(query,RR_SOA) == JS_ERROR)
1101
spot_data = mhash_get(bighash,query);
1102
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1104
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1105
&(header.nscount),&(header.arcount),0,
1106
spot_data.point,0,0) == JS_ERROR)
1110
where = spot_data.value;
1111
authoritative = where->authoritative;
1112
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1113
&(header.nscount),&(header.arcount),1,
1114
spot_data.point,0,0) == JS_ERROR)
1121
/* If not found, look for lower-case version of the same query */
1123
found = fold_case(query);
1124
if(found == JS_ERROR)
1126
if(found == 1) /* Case folded */ {
1128
/* Look for lower case version of A record */
1129
if(change_rtype(query,RR_A) == JS_ERROR)
1131
spot_data = mhash_get(bighash,query);
1132
/* If A record of lower-case found... */
1133
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1135
where = spot_data.value;
1136
authoritative = where->authoritative;
1137
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1138
&(header.nscount),&(header.arcount),1,
1139
spot_data.point,0,0) == JS_ERROR)
1142
if(change_rtype(query,RR_MX) == JS_ERROR)
1144
spot_data = mhash_get(bighash,query);
1145
/* If MX record of lower-case found... */
1146
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1148
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1149
&(header.nscount),&(header.arcount),0,
1150
spot_data.point,0,0) == JS_ERROR)
1154
where = spot_data.value;
1155
authoritative = where->authoritative;
1156
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1157
&(header.nscount),&(header.arcount),1,
1158
spot_data.point,0,0) == JS_ERROR)
1162
/* Optionally look for SOA and NS records */
1164
if(change_rtype(query,RR_NS) == JS_ERROR)
1166
spot_data = mhash_get(bighash,query);
1167
/* If NS record of lower-case found... */
1168
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1170
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1171
&(header.nscount),&(header.arcount),0,
1172
spot_data.point,0,0) == JS_ERROR)
1176
where = spot_data.value;
1177
authoritative = where->authoritative;
1178
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1179
&(header.nscount),&(header.arcount),1,
1180
spot_data.point,0,0) == JS_ERROR)
1184
if(change_rtype(query,RR_SOA) == JS_ERROR)
1186
spot_data = mhash_get(bighash,query);
1187
/* If SOA record of lower-case found... */
1188
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1190
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1191
&(header.nscount),&(header.arcount),0,
1192
spot_data.point,0,0) == JS_ERROR)
1196
where = spot_data.value;
1197
authoritative = where->authoritative;
1198
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1199
&(header.nscount),&(header.arcount),1,
1200
spot_data.point,0,0) == JS_ERROR)
1206
if(found == 0) { /* If not found, do star record search */
1207
found = starwhitis_seek_any(query,RR_A,0,&header,&where,
1208
&authoritative,most,ns,ar);
1209
found = starwhitis_seek_any(query,RR_MX,found,&header,
1210
&where,&authoritative,most,ns,ar);
1212
found = starwhitis_seek_any(query,RR_NS,found,
1213
&header,&where,&authoritative,most,
1215
found = starwhitis_seek_any(query,RR_SOA,found,
1216
&header,&where,&authoritative,most,
1219
if(found == JS_ERROR) {
1225
/* If nothing found, look for a CNAME record with the same name as
1228
if(change_rtype(query,RR_CNAME) == JS_ERROR)
1230
spot_data = mhash_get(bighash,query);
1231
/* If found, add the data to our records */
1232
if(spot_data.value != 0 && spot_data.datatype == MARA_DNSRR) {
1234
if(add_answer(spot_data.value,most,ns,ar,&(header.ancount),
1235
&(header.nscount),&(header.arcount),1,
1236
spot_data.point,0,0) == JS_ERROR)
1241
/* If nothing found, look for DDIP notation */
1243
if(change_rtype(query,RR_ANY) == JS_ERROR)
1245
found = ddip_check(id,sock,ect,query);
1246
if(found == JS_ERROR)
1248
if(found == JS_SUCCESS) {
1029
1256
old_udpany_code_disabled:
1031
1258
/* Return with exit code of 0 if no answer was found */