Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
551c1b59
Commit
551c1b59
authored
27 years ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
Now scans through all nameservers and not only the last one.
Rev: lib/modules/Protocols.pmod/DNS.pmod:1.7
parent
9b56207f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Protocols.pmod/DNS.pmod
+31
-16
31 additions, 16 deletions
lib/modules/Protocols.pmod/DNS.pmod
with
31 additions
and
16 deletions
lib/modules/Protocols.pmod/DNS.pmod
+
31
−
16
View file @
551c1b59
...
...
@@ -211,14 +211,21 @@ class protocol
class client {
inherit protocol;
string nameserver;
array(
string
)
nameserver
s = ({})
;
array domains = ({});
void create(void|string server)
{
if(!server)
{
string domain;
foreach(Stdio.read_file("/etc/resolv.conf")/"\n", string line)
string resolv_conf = Stdio.read_file("/etc/resolv.conf");
if (!resolv_conf) {
throw(({ "Protocols.DNS.client(): No /etc/resolv.conf!\n",
backtrace() }));
}
foreach(resolv_conf/"\n", string line)
{
string rest;
sscanf(line,"%s#",line);
...
...
@@ -240,14 +247,17 @@ class client {
break;
case "nameserver":
nameserver
=
rest;
nameserver
s += ({
rest
})
;
break;
}
}
if (!sizeof(nameservers)) {
nameservers = ({ "127.0.0.1" });
}
if(domain)
domains = ({ domain }) + domains;
} else {
nameserver
=
server;
nameserver
s= ({
server
})
;
}
}
...
...
@@ -257,12 +267,12 @@ class client {
{
object udp=spider.dumUDP();
udp->bind(0);
udp->send(nameserver,53,s);
udp->send(nameserver
s[0]
,53,s);
mapping m;
do {
m=udp->read();
} while (m->port != 53 ||
m->ip != nameserver ||
m->ip != nameserver
s[0]
||
m->data[0..1]!=s[0..1]);
return decode_res(m->data);
}
...
...
@@ -391,16 +401,21 @@ class async_client
destruct(r);
}
void retry(object(Request) r)
void retry(object(Request) r
, void|int nsno
)
{
if(!r) return;
if(r->retries++ > 12)
{
call_out(remove,120,r);
}else{
call_out(retry,5,r);
send(nameserver,53,r->req);
if (nsno >= sizeof(nameservers)) {
if(r->retries++ > 12)
{
call_out(remove,120,r);
return;
} else {
nsno = 0;
}
}
send(nameservers[nsno],53,r->req);
call_out(retry,5,r,nsno+1);
}
void do_query(string domain, int cl, int type,
...
...
@@ -419,14 +434,14 @@ class async_client
r->callback=callback;
r->args=args;
requests[id]=r;
call_out(retry
,5,r);
udp::send(nameserver
,5
3
,r
->req
);
udp::send(nameservers[0]
,5
3
,r
->req
);
call_out(retry
,5,r
,1
);
}
static private void rec_data()
{
mapping m=udp::read();
if(m->port != 53 ||
m->ip !=
nameserver) return;
if(m->port != 53 ||
search(
nameserver
s, m->ip) == -1
) return;
sscanf(m->data,"%2c",int id);
object r=requests[id];
if(!r) return;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment