20i Domains

Nominet EPP & DAC Guides

Discussion in 'Domain Tools' started by danielcoates, Jan 23, 2016.

  1. PoshTiger United Kingdom

    PoshTiger Well-Known Member

    Joined:
    Jun 2011
    Posts:
    1,503
    Likes Received:
    74
    Round one to Rob :D


    Sent from my iPhone using Tapatalk
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
    articles.co.uk
     
  3. monaghan United Kingdom

    monaghan Moderator Staff Member

    Joined:
    May 2007
    Posts:
    2,103
    Likes Received:
    71
    Too much other paying work on at the moment :)
     
  4. DomainAngel

    DomainAngel Retired Member

    Joined:
    Sep 2006
    Posts:
    1,329
    Likes Received:
    49
    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;
    //}
    }
    };
     
  5. RobM

    RobM Retired Member

    Joined:
    Mar 2012
    Posts:
    3,289
    Likes Received:
    470
    :eek: This thread lost me at some point. I wasn't disagreeing with anyone lol
     
  6. PoshTiger United Kingdom

    PoshTiger Well-Known Member

    Joined:
    Jun 2011
    Posts:
    1,503
    Likes Received:
    74
    Round 2 to Alex!
     
  7. monaghan United Kingdom

    monaghan Moderator Staff Member

    Joined:
    May 2007
    Posts:
    2,103
    Likes Received:
    71
    Perhaps if we are on equal points we can both get on with some real work now :)
     
  8. newbie United Kingdom

    newbie Active Member

    Joined:
    Oct 2005
    Posts:
    441
    Likes Received:
    4
    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 :)
     
  9. monaghan United Kingdom

    monaghan Moderator Staff Member

    Joined:
    May 2007
    Posts:
    2,103
    Likes Received:
    71
    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.
     
  10. danielcoates

    danielcoates Active Member

    Joined:
    Apr 2013
    Posts:
    138
    Likes Received:
    5
    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.

    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.
     
  11. newbie United Kingdom

    newbie Active Member

    Joined:
    Oct 2005
    Posts:
    441
    Likes Received:
    4
    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: Feb 2, 2016
  12. monaghan United Kingdom

    monaghan Moderator Staff Member

    Joined:
    May 2007
    Posts:
    2,103
    Likes Received:
    71
    You can engineer some of that luck, but at the end of the day hitting a random target when you have to sit on your hands waiting for a restricted poll time does need a good helping of luck :)