Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Nominet EPP & DAC Guides

Anyone recognise this?

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>

#include "util.h"
using namespace std;

enum DAC_Registered{
R_YES=0,// - Registered
R_NO=1,// - Not registered
R_BLOCK=2,// - Quota limit block
R_COUNT=3
};


class dacCheckResult{
public:
char domain[255],
tag[255]; //??
char regDate[10], //YYYY-MM-DD
expDate[10]; //YYYY-MM-DD
DAC_Registered registered; //Y | N | B
bool detagged; //Y | N
int delay;

dacCheckResult(){};
void parse(char * content){ //\r\n
char * saveptr;
char * tok = trim(strtok_r(content, ",", &saveptr));
strncpy(domain, tok, 255);

tok = trim(strtok_r(NULL,",", &saveptr));
switch(tok[0]){
case 'Y': registered = R_YES;
tok = trim(strtok_r(NULL,",", &saveptr));
detagged = (tok[0] == 'Y');

strncpy(regDate, trim(strtok_r(NULL,",", &saveptr)), 10);
strncpy(expDate, trim(strtok_r(NULL,",", &saveptr)), 10);
strncpy(tag, trim(strtok_r(NULL,",", &saveptr)), 255); //TODO: check what values are hold in tag
break;
case 'N': registered = R_NO; break;
case 'B': registered = R_BLOCK;
delay = atoi(strtok_r(NULL,",", &saveptr));
break;
default: registered = R_COUNT;
cerr << "Error: Unknown register[0]=%s" << tok[0] << endl;
break;
}
}
};

class dacClient{
private:
int skt; //connection socket
fd_set skt_set;
char *rx;
char *tx;

int rxResponce(){
struct timeval tv_tout; //timeout

fd_set skt_set;
FD_ZERO(&skt_set);
FD_SET(skt, &skt_set);

tv_tout.tv_sec = 3;
tv_tout.tv_usec = 0;

int rc = select(skt+1, &skt_set, NULL, NULL, &tv_tout);
if(rc < 0){
close(skt);
cerr << "DAC: Error on socket" << endl;
return 0;
}else if(rc == 0){
close(skt);
cerr << "DAC: Timeout on socket " << endl;
return 0;
}

int size = 0;
do{
int bytes = recv(skt, &rx[size], (4096-size), 0);
if( bytes == -1){
perror("recv");
return 0;
}
if(bytes == 0){
fprintf(stderr, "DAC: Socket was closed by DAC!\n");
return 0;
}
size += bytes;
}while((rx[size-1] != '\n') && (size < 4096));
rx[size-2] = '\0';
return size;
}

int disconnect(){
static const char msgDisconnect[] = "#exit\r\n";
if (send(skt, msgDisconnect, sizeof(msgDisconnect)-1, 0) == -1){
perror("send");
return 1;
}
close(skt);
return 0;
}

public:
unsigned int limits_minute;
unsigned int limits_day;

unsigned int usage_minute;
unsigned int usage_day;


dacClient(const char * host, const unsigned short port, const unsigned int timeout) throw(int){
skt = connect_me(host, port, timeout);
if(skt == -1){
cerr << "Error creating socket to " << host << ":" << port << endl;
throw 1;
}

try{
rx = new char[4096+1];
tx = new char[1000];
}catch(bad_alloc e){ throw 1; }

memset(rx, 0, 4096+1);
memset(tx, 0, 1000);

limits_minute = limits_day =
usage_minute = usage_day = 0;

}

~dacClient(){
disconnect();

delete [] rx;
delete [] tx;

}

bool limits(){
static const char msgLimits[] = "#limits\r\n";
if (send(skt, msgLimits, sizeof(msgLimits)-1, 0) == -1){
perror("send");
return false;
}

if(rxResponce() == 0)//Response: #limits,C,60,Limits60,86400,Limits24
return false;

sscanf(rx, "#limits,C,%*d,%d,%*d,%d", &limits_minute,&limits_day);
return true;
}

int usage(){
static const char msgUsage[] = "#usage\r\n";
if (send(skt, msgUsage, sizeof(msgUsage)-1, 0) == -1){
perror("send");
return false;
}
if(rxResponce() ==0) //Response: #usage,C,60,Usage60,86400,Usage24
return false;
sscanf(rx, "#usage,C,%*d,%d,%*d,%d", &usage_minute,&usage_day);
return true;
}

//TODO: preparecheck() and recheck() to avoid snprintf() on each call ?
bool check(const char * domain, dacCheckResult * chkRes) {
//if (trim(domain) <> "") {
static char msg[255+2]={0};
int len = snprintf(msg, sizeof(msg), "%s\r\n", domain);
if (send(skt, msg, len, 0) == -1) {
return NULL; //"error";
}

if(rxResponce() == 0)
return false;

chkRes->parse(rx);
return true;
//}
}
};
 
I'm just using PHP and BASH. Simple script, took me a day to knock it up.

It catches ok. I'm sure there's a large element of luck involved though :)
 
I'm just using PHP and BASH. Simple script, took me a day to knock it up.

It catches ok. I'm sure there's a large element of luck involved though :)

PHP gets a lot of slagging off in some quarters, however, the newer versions can be quite fast. With catching you need to spend a lot of time in a delay loop waiting for the next poll cycle so you don't hit the DAC limits, so I guess it doesn't make that much difference which language you sit idle in.
 
I'm just using PHP and BASH. Simple script, took me a day to knock it up.

It catches ok. I'm sure there's a large element of luck involved though :)

That was my plan, for catching, though I still have a lot of working out to do, and a simple PHP site for managing domains.

A preview of which can be found here.

PHP gets a lot of slagging off in some quarters, however, the newer versions can be quite fast. With catching you need to spend a lot of time in a delay loop waiting for the next poll cycle so you don't hit the DAC limits, so I guess it doesn't make that much difference which language you sit idle in.

I think your right, given the delay's that you have to implement, so as not to get blocked, the language of choice is really down to personal preference, and I prefer PHP, even if it doesn't get me any really good catches, It's still worth a try.
 
I prefer PHP, even if it doesn't get me any really good catches, It's still worth a try.

My current PHP script caught PublicSpeaking.co.uk the other day, it's at £250 on DomainLore already :)

https://domainlore.uk/PublicSpeaking.co.uk

Other catches this week include:

Felines.UK
Snogs.co.uk
KidsScooter.co.uk
LumbarSupports.co.uk
OffRoadDriving.co.uk
BuyVan.co.uk

It works well and it was fun making it. I simply add my desired catches to the script each Sunday and it does it's thing for the following week.

When it comes to catching I think luck plays a part.
 
Last edited:

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

Sponsors

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel

Sponsors

Acorn Domains Merch
MariaBuy Marketplace

Shiny Nuts

Perfect
Service
Laskos
URL Shortener
*the exceptional businesses of our esteemed moderators
Top Bottom