Exemple #1
0
DNSUpdate::DNSUpdate(string dns_address, string zonename, string hostname,
		     string hostip, DnsUpdateMode updateMode,
		     DnsUpdateProtocol proto /* = DNSUPDATE_TCP */)
    :_hostname(NULL) { 
    message= NULL;
    memset(&server, 0, sizeof(server));

    server.ss_family = AF_INET6;


#ifndef WIN32	
	// LINUX, BSD
	server.ss_family = AF_INET6;
#else
	// WINDOWS
	server.sa_family = AF_INET6;
#endif

    
    if (updateMode==DNSUPDATE_AAAA || updateMode==DNSUPDATE_AAAA_CLEANUP) {
	splitHostDomain(hostname);
    } else {

	_hostname=new char[hostname.length()+1];
	strcpy(_hostname,hostname.c_str());

        int len = hostname.length()+1;
        _hostname=new char[len];
        strncpy(_hostname,hostname.c_str(), len-1);

	zoneroot = new domainname(zonename.c_str());
    }
    
    txt_to_addr(&server,dns_address.c_str());

    this->hostip = new char[hostip.length()+1];
    strcpy(this->hostip,hostip.c_str());
    this->ttl=new char[strlen(DNSUPDATE_DEFAULT_TTL)+1];
    strcpy(this->ttl,DNSUPDATE_DEFAULT_TTL);

    int len = hostip.length()+1;
    this->hostip = new char[len];
    strncpy(this->hostip,hostip.c_str(), len-1);
    hostip[len-1] = 0;
    
    len = strlen(DNSUPDATE_DEFAULT_TTL)+1;
    this->ttl=new char[len];
    strncpy(this->ttl,DNSUPDATE_DEFAULT_TTL, len-1);
    ttl[len-1]=0;

    this->updateMode = updateMode;
    _proto = proto;
}
Exemple #2
0
int main(int argc, char **argv) {
    _addr a;

    try {
        /* get command-line arguments */
        if (argc != 2 ) {
            printf( "Usage: %s [domainname]\n", argv[0] );
            return 1;
        } else {
            dyndomain = argv[1];
            txt_to_addr(&a, "any");
        }

        poslib_config_init();

        /* bring up posadis */
        servers.push_front(ServerSocket(ss_udp, udpcreateserver(&a)));

        // use the posadis logging system
        pos_log(context_none, log_info, "Proof of concept DNS server starting up...");

        // set signal handlers
        signal(SIGINT, cleanup);
        signal(SIGTERM, cleanup);

        // set query function
        handle_query = my_handle_query;

        // run server
        posserver_run();
    } catch (PException p) {
        printf("Fatal exception: %s\n", p.message);
        return 1;
    }

    return 0;
}