Skip to content

Commit

Permalink
0.3.rc2 first clean compile
Browse files Browse the repository at this point in the history
  • Loading branch information
8bitgeek committed Mar 2, 2012
1 parent 00f60ea commit 82d50dc
Show file tree
Hide file tree
Showing 20 changed files with 652 additions and 191 deletions.
2 changes: 1 addition & 1 deletion client/opennic.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <QTcpSocket>
#include <QAbstractButton>

#define VERSION_STRING "0.3.rc1"
#define VERSION_STRING "0.3.rc2"

namespace Ui
{
Expand Down
2 changes: 1 addition & 1 deletion opennic.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define MyAppName "OpenNIC Wizard"
#define MyAppServiceName "OpenNIC Service"
#define MyAppVersion "0.3.rc1"
#define MyAppVersion "0.3.rc2"
#define MyAppPublisher "The OpenNIC Project"
#define MyAppURL "http://www.opennicproject.org"
#define MyAppExeName "OpenNIC.exe"
Expand Down
23 changes: 14 additions & 9 deletions server/bootstrap.domains
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
dns.opennic.glue
register.bbs
grep.geek
register.ing
google.com
yahoo.com
wikipedia.org
www.abs.gov.au
opennic.glue
icann;wikipedia.org
icann;www.abs.gov.au
icann;yahoo.com
icann;google.com
icann;360.cn
icann;canada.ca
opennic;dns.opennic.glue
opennic;grep.geek
opennic;opennic.glue
opennic;reg.for.free
opennic;register.bbs
opennic;register.fur
opennic;register.gopher
opennic;register.ing
18 changes: 5 additions & 13 deletions server/opennicdnsclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void OpenNICDnsClient::fetch(const quint8 *pkt, const quint8 *s, int pktsiz, cha
* @brief Process the datagram
* @param datagram The raw datagram octets
*/
void OpenNICDnsClient::processDatagram(QByteArray datagram)
void OpenNICDnsClient::processDatagram(QByteArray& datagram)
{
quint8* pkt = (quint8*)datagram.data();
int len = datagram.length();
Expand Down Expand Up @@ -303,7 +303,7 @@ void OpenNICDnsClient::processDatagram(QByteArray datagram)
* @param port the port address at the resolver
* @return Resultes are emitted by the reply() signal.
*/
void OpenNICDnsClient::lookup(QHostAddress resolverAddress, QString name, dns_query_type type, quint16 port)
void OpenNICDnsClient::lookup(QHostAddress resolverAddress, OpenNICDomainName name, dns_query_type type, quint16 port)
{
setResolver(resolverAddress);
lookup(name,type,port);
Expand All @@ -316,7 +316,7 @@ void OpenNICDnsClient::lookup(QHostAddress resolverAddress, QString name, dns_qu
* @param port the port address at the resolver
* @return Results are emitted by the reply() signal.
*/
void OpenNICDnsClient::lookup(QString name, dns_query_type qtype, quint16 port)
void OpenNICDnsClient::lookup(OpenNICDomainName name, dns_query_type qtype, quint16 port)
{
dns_query* q;

Expand All @@ -337,7 +337,7 @@ void OpenNICDnsClient::lookup(QString name, dns_query_type qtype, quint16 port)
q->query_type = qtype;
q->tid = ++m_tid;
q->expire = now.addSecs(DNS_QUERY_TIMEOUT);
q->name = name.toLower();
q->name = name;

/* Prepare DNS packet header */
pkt_hdr = (header*)pkt;
Expand All @@ -351,7 +351,7 @@ void OpenNICDnsClient::lookup(QString name, dns_query_type qtype, quint16 port)
/* Encode DNS name */

char sname[2048];
strcpy(sname,name.toAscii().data());
strcpy(sname,name.domainName().toAscii().data());
char* pname = &sname[0];
name_len = strlen(pname);
p = (char *) &pkt_hdr->data; /* For encoding host name into packet */
Expand Down Expand Up @@ -403,12 +403,4 @@ void OpenNICDnsClient::lookup(QString name, dns_query_type qtype, quint16 port)
}
}

/**
* @brief get here on dns callback data
*/
void OpenNICDnsClient::reply(dns_query& data)
{
/* NOP */
}


25 changes: 20 additions & 5 deletions server/opennicdnsclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <QMutex>
#include <QTimerEvent>

#include "opennicdomainname.h"

#define DNS_QUERY_TIMEOUT 30 /* Query timeout, seconds */
#define DNS_MAX 1025 /* Maximum host name */
#define DNS_PACKET_LEN 2048 /* Buffer size for DNS packet */
Expand Down Expand Up @@ -76,9 +78,9 @@ class OpenNICDnsClient : public QObject
bool isOpen() {return mClientSocket != NULL; }
bool open();
void close();
virtual void lookup(QHostAddress resolverAddress, QString name, dns_query_type qtype, quint16 port=DEFAULT_DNS_PORT);
virtual void lookup(QString name, dns_query_type qtype, quint16 port=DEFAULT_DNS_PORT);
virtual void reply(dns_query& data);
virtual void lookup(QHostAddress resolverAddress, OpenNICDomainName name, dns_query_type qtype, quint16 port=DEFAULT_DNS_PORT);
virtual void lookup(OpenNICDomainName name, dns_query_type qtype, quint16 port=DEFAULT_DNS_PORT);
virtual void reply(dns_query& data) {}

private slots:
void readPendingDatagrams();
Expand All @@ -89,7 +91,7 @@ class OpenNICDnsClient : public QObject
void disposeQuery(dns_query* q);
void fetch(const quint8 *pkt, const quint8 *s, int pktsiz, char *dst, int dstlen);
void doReply(dns_query* q, dns_error error);
void processDatagram(QByteArray datagram);
void processDatagram(QByteArray& datagram);
bool mActive;
quint16 m_tid; /* Latest tid used */
QHostAddress mResolverAddress; /* The resolver address */
Expand All @@ -109,14 +111,27 @@ class dns_query {
, query_type(OpenNICDnsClient::DNS_A_RECORD)
, tid(0)
{}
dns_query(const dns_query& other)
{
latency = other.latency;
error = other.error;
query_type = other.query_type;
tid = other.tid;
start = other.start;
expire = other.expire;
name = other.name;
addr = other.addr;
mxName = other.mxName;
}
~dns_query() {}
QDateTime end() {return start.addMSecs(latency);}
quint64 latency; /* latency in milliseconds */
OpenNICDnsClient::dns_error error; /* Result code */
OpenNICDnsClient::dns_query_type query_type; /* Query type */
quint16 tid; /* UDP DNS transaction ID */
QDateTime start; /* The start of the query */
QDateTime expire; /* Time when this query expire */
QString name; /* Host name */
OpenNICDomainName name; /* Host name */
QHostAddress addr; /* Host address */
QString mxName; /* MX record host name. */
};
Expand Down
96 changes: 94 additions & 2 deletions server/opennicdomainname.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,98 @@
/*
* Copyright (c) 2012 Mike Sharkey <[email protected]>
*
* "THE BEER-WARE LICENSE" (Revision 42):
* Mike Sharkey wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return.
*/
#include "opennicdomainname.h"

OpenNICDomainName::OpenNICDomainName(QObject *parent) :
QObject(parent)
#include <QString>
#include <QStringList>

#define ANNONYMOUS_SERVICE "{annon}"

#define inherited QObject

OpenNICDomainName::OpenNICDomainName(QObject *parent)
: inherited(parent)
, mDnsService(ANNONYMOUS_SERVICE)
{
}

OpenNICDomainName::OpenNICDomainName(QString text, QObject *parent)
: inherited(parent)
{
fromString(text);
}

OpenNICDomainName::OpenNICDomainName(const OpenNICDomainName& other)
{
copy(other);
}

OpenNICDomainName::~OpenNICDomainName()
{
}

/**
* @brief assignment operator
*/
OpenNICDomainName& OpenNICDomainName::operator=(const OpenNICDomainName& other)
{
return copy(other);
}

/**
* @brief equality operator
*/
bool OpenNICDomainName::operator==(OpenNICDomainName &other)
{
return toString() == other.toString();
}

/**
* @brief unequality operator
*/
bool OpenNICDomainName::operator!=(OpenNICDomainName &other)
{
return toString() != other.toString();
}

/**
* @brief Copy from another.
*/
OpenNICDomainName& OpenNICDomainName::copy(const OpenNICDomainName& other)
{
mDnsService = other.mDnsService;
mDomainName = other.mDomainName;
return *this;
}

/**
* @brief convert from text.
*/
void OpenNICDomainName::fromString(QString text)
{
QStringList parts = text.split(";");
if (parts.count()>=2)
{
mDnsService = parts[0].trimmed();
mDomainName = parts[1].trimmed();
}
else
{
mDnsService = ANNONYMOUS_SERVICE;
mDomainName = text;
}
}

/**
* @brief convert to text
*/
QString OpenNICDomainName::toString()
{
return mDnsService.trimmed()+";"+mDomainName.trimmed();
}

40 changes: 35 additions & 5 deletions server/opennicdomainname.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
/*
* Copyright (c) 2012 Mike Sharkey <[email protected]>
*
* "THE BEER-WARE LICENSE" (Revision 42):
* Mike Sharkey wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return.
*/
#ifndef OPENNICDOMAINNAME_H
#define OPENNICDOMAINNAME_H

#include <QObject>
#include <QString>

/**
* @brief input text is <DNS Service>;<domain name> example: "opennic;www.opennic.glue"
*/
class OpenNICDomainName : public QObject
{
Q_OBJECT
public:
explicit OpenNICDomainName(QObject *parent = 0);
Q_OBJECT
public:
OpenNICDomainName(QObject *parent = 0);
OpenNICDomainName(QString text, QObject *parent = 0);
OpenNICDomainName(const OpenNICDomainName& other);
virtual ~OpenNICDomainName();

signals:
OpenNICDomainName& copy(const OpenNICDomainName& other);

public slots:
OpenNICDomainName& operator=(const OpenNICDomainName& other);
bool operator==(OpenNICDomainName &other);
bool operator!=(OpenNICDomainName &other);

void fromString(QString text);
QString toString();

void setDnsService(QString dnsService) {mDnsService=dnsService;}
void setDomainName(QString domainName) {mDomainName=domainName;}

QString& dnsService() {return mDnsService;}
QString& domainName() {return mDomainName;}

private:
QString mDnsService;
QString mDomainName;

};

Expand Down
Loading

0 comments on commit 82d50dc

Please sign in to comment.