Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
47
Task/DNS-query/R/dns-query-1.r
Normal file
47
Task/DNS-query/R/dns-query-1.r
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include <Rcpp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace Rcpp ;
|
||||
|
||||
// [[Rcpp::export]]
|
||||
CharacterVector getNameInfo(std::string fqdn) {
|
||||
|
||||
struct addrinfo hints, *res, *res0;
|
||||
int error;
|
||||
char host[NI_MAXHOST];
|
||||
|
||||
memset(&hints, 0, sizeof hints);
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
|
||||
error = getaddrinfo(fqdn.c_str(), NULL, &hints, &res0);
|
||||
if (error) { return(NA_STRING); }
|
||||
|
||||
int i = 0 ;
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
error = getnameinfo(res->ai_addr, res->ai_addrlen,
|
||||
host, sizeof host, NULL, 0, NI_NUMERICHOST);
|
||||
if (!error) { i++ ; }
|
||||
}
|
||||
|
||||
CharacterVector results(i) ;
|
||||
|
||||
i = 0;
|
||||
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
error = getnameinfo(res->ai_addr, res->ai_addrlen,
|
||||
host, sizeof host, NULL, 0, NI_NUMERICHOST);
|
||||
if (!error) { results[i++] = host ; }
|
||||
}
|
||||
|
||||
freeaddrinfo(res0);
|
||||
|
||||
return(results) ;
|
||||
|
||||
}
|
||||
5
Task/DNS-query/R/dns-query-2.r
Normal file
5
Task/DNS-query/R/dns-query-2.r
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
library(Rcpp)
|
||||
sourceCpp("dns.cpp")
|
||||
getNameInfo("www.kame.net")
|
||||
## [1] "203.178.141.194"
|
||||
## [2] "2001:200:dff:fff1:216:3eff:feb1:44d7"
|
||||
Loading…
Add table
Add a link
Reference in a new issue