Skip to content

Commit

Permalink
v2.1.3 Ready for next release
Browse files Browse the repository at this point in the history
  • Loading branch information
softwareengineer1 committed May 27, 2018
1 parent 322f170 commit f2723e1
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 40 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -4,15 +4,18 @@ A really awesome multi-platform (lin,win,mac,android) local caching and proxying
GET LATEST VERSION HERE (v2.1.1):
https://github.com/softwareengineer1/YourFriendlyDNS/releases
![YourFriendlyDNS v2.0](YFD-v2.1.1-macOS.png)
{Version 2.1.3}
1. Timeout state improved (intermediary state to confirm timeout)


![YourFriendlyDNS Auto Sourcer and Stamp Converter](YFD-autosourcer-stampconverter.png)
{Version 2.1.2}
1. Added a disconnected / no response timeout state, so if no responses are received (maybe disconnected/offline) the message queue shouldn’t drown in unhandled requests.

2. Added Auto Sourcer + Stamp Converter!
-> Already has the main three available and known sources so far (and a source with my providers during testing) by default, and you can easily add further sources if/when they’re available or change locations.
-> Auto Sourcer, already has the main three available and known sources preloaded by default (and a source with my providers during testing, demonstrating the ease of adding or making/using your own provider sources resources), and you can easily add further sources if/when they’re available or change web locations. HTTPS (port 443) and HTTP (port 80) sources locations supported.

Now you don’t need to copy and paste stamps from those lists into the application, you can instead load (from saved) or update source lists that are in the standard simple format, see what server info is actually contained, and click “ADD IT!” button to add to your dns providers / dns servers list!
Much more user-friendly! Now you don’t need to manually look at provider sources and pick and choose which ones to then copy and paste one by one into the application… You can instead load (from saved once retrieved recently) or download/update source lists from their urls that are in the standard simple format, select them to decode and see what server info is actually contained, change server parameter to re-encode the server info back to stamp form and finally click “ADD IT!” button to add to your dns providers / dns servers list!

The stamp converter supports protocols v1,v2,v3 (v0 is just plain dns, it can read them but won’t use them if DNSCrypt is enabled)

Expand Down
Binary file modified Source/.DS_Store
Binary file not shown.
7 changes: 3 additions & 4 deletions Source/YourFriendlyDNS/YourFriendlyDNS.pro
Expand Up @@ -13,21 +13,20 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = YourFriendlyDNS
TEMPLATE = app

VERSION = 2.1.2
VERSION = 2.1.3
QMAKE_TARGET_COMPANY = freedom based software co.
QMAKE_TARGET_PRODUCT = YourFriendlyDNS
QMAKE_TARGET_DESCRIPTION = A local encrypting, caching and proxying dns proxy
QMAKE_TARGET_COPYRIGHT = 2018

#DEFINES += APP_VERSION=\\\"$$VERSION\\\"
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
#comment this next line out if you need to debug it if somethings not quite right (you'll get the qDebug() output then [and on macOS it has to be a debug build too for some reason])
#DEFINES += QT_NO_DEBUG_OUTPUT
DEFINES += QT_NO_DEBUG_OUTPUT

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
Expand Down
2 changes: 1 addition & 1 deletion Source/YourFriendlyDNS/android/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="org.freedombasedsoftware.YourFriendlyDNS" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.1" android:versionCode="2" android:installLocation="auto">
<manifest package="org.freedombasedsoftware.YourFriendlyDNS" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.1.3" android:versionCode="2" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
Expand Down
45 changes: 29 additions & 16 deletions Source/YourFriendlyDNS/dnscrypt.h
Expand Up @@ -281,11 +281,12 @@ class ProviderSource : public QObject
Q_OBJECT
public:
QSslSocket tls;
QByteArray data, hash, downloadRequest;
QByteArray data, hash, oldhash, downloadRequest;
QString url, userAgent, sourcesDir, sourcesName, filePath;
QDateTime lastUpdated;
QVector<ProviderFromSource> providers;
int offset;
bool fileWasLoaded;

ProviderSource()
{
Expand All @@ -294,11 +295,10 @@ class ProviderSource : public QObject
}
ProviderSource(const QString &url, const QByteArray &hash = "", const QDateTime lastUpdated = QDateTime())
{
init();
this->url = url;
this->hash = hash;
this->lastUpdated = lastUpdated;
this->userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Firefox/60.0";
this->offset = 0;

sourcesDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
sourcesDir += QDir::separator();
Expand All @@ -313,7 +313,7 @@ class ProviderSource : public QObject

connectUp();
}
ProviderSource(const ProviderSource &src)
ProviderSource(const ProviderSource &src) : QObject(nullptr)
{
copyFrom(src);
connectUp();
Expand All @@ -336,6 +336,7 @@ class ProviderSource : public QObject
{
lastUpdated = QDateTime();
offset = 0;
fileWasLoaded = false;
this->userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Firefox/60.0";
}
void connectUp()
Expand Down Expand Up @@ -376,11 +377,14 @@ class ProviderSource : public QObject
download();
return;
}
interpretData();
interpretData(data);
displayProviders(providers);

f.close();
fileWasLoaded = true;
}
else
download();
}

void download()
Expand Down Expand Up @@ -436,7 +440,7 @@ Cache-Control: max-age=0)";

QByteArray extractFromTo(int startingFrom, int to)
{
if(startingFrom <= data.size() && to <= data.size())
if(startingFrom < data.size() && to < data.size())
{
QByteArray extracted;
extracted.resize(to - startingFrom);
Expand All @@ -447,7 +451,7 @@ Cache-Control: max-age=0)";
return "";
}

void interpretData()
void interpretData(const QByteArray &data)
{
if(data.startsWith("# "))
{
Expand All @@ -473,19 +477,22 @@ Cache-Control: max-age=0)";
providers.append(ProviderFromSource(listedName, description, stamp));
}

entryFound = data.indexOf("## ", entryFound + 3);
entryFound = data.indexOf("## ", entryFound + offset);
offset = 0;
}

oldhash = hash;
hash = QCryptographicHash::hash(data, QCryptographicHash::Sha256);
}
}

QFile f(filePath);
if(f.open(QFile::WriteOnly))
{
f.write(data);
f.close();
}
lastUpdated = QDateTime::currentDateTime();
void saveData()
{
QFile f(filePath);
if(f.open(QFile::WriteOnly))
{
f.write(data);
f.close();
}
}

Expand All @@ -507,7 +514,13 @@ private slots:
}
data += response;

interpretData();
interpretData(data);
if(hash != oldhash || !fileWasLoaded)
{
lastUpdated = QDateTime::currentDateTime();
saveData();
qDebug() << "Saved updated sources list!" << sourcesName << "New hash:" << hash << "old hash:" << oldhash;
}
emit displayProviders(providers);
}

Expand Down
8 changes: 4 additions & 4 deletions Source/YourFriendlyDNS/dnsserverwindow.cpp
Expand Up @@ -165,7 +165,7 @@ void DNSServerWindow::listeningIPsUpdate()
if(listeningips == "")
{
listeningips = "No non-loopback listening network addresses detected...\
Check network connection and click here to refresh (Note: Doesn't effect the actual working of it)";
Check network connection!";
}

ui->listeningIPs->setText(listeningips);
Expand Down Expand Up @@ -542,7 +542,6 @@ bool DNSServerWindow::settingsLoad()
if(json.contains("dnscrypt_provider_sources") && json["dnscrypt_provider_sources"].isArray())
{
emit clearSources();
QString first;
QJsonArray sourcesarray = json["dnscrypt_provider_sources"].toArray();
for(int i = 0; i < sourcesarray.size(); i++)
{
Expand All @@ -553,7 +552,6 @@ bool DNSServerWindow::settingsLoad()
if(source.contains("url") && source["url"].isString())
{
url = source["url"].toString();
if(i == 0) first = url;
}
if(source.contains("hash") && source["hash"].isString())
hash = QByteArray::fromHex(source["hash"].toString().toUtf8());
Expand All @@ -563,7 +561,9 @@ bool DNSServerWindow::settingsLoad()
qDebug() << "Provider source loaded:" << url << hash << lastUpdated;
emit loadSource(url, false, hash, lastUpdated);
}
emit loadSource(first);
QJsonObject source = sourcesarray[0].toObject();
if(sourcesarray.size() > 0 && source.contains("url") && source["url"].isString())
emit loadSource(source["url"].toString());
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Source/YourFriendlyDNS/providersourcerstampconverter.cpp
Expand Up @@ -206,7 +206,7 @@ void providerSourcerStampConverter::on_autosourcesTree_currentItemChanged(QTreeW
Q_UNUSED(previous);
if(current)
{
if(current->columnCount() > 0)
if(current->columnCount() > 1)
decodeStamp(current->text(1));
}
}
Expand Down
16 changes: 13 additions & 3 deletions Source/YourFriendlyDNS/providersourcerstampconverter.ui
Expand Up @@ -92,7 +92,11 @@
</font>
</property>
<property name="text">
<string>+</string>
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/plus.png</normaloff>:/images/plus.png</iconset>
</property>
</widget>
</item>
Expand Down Expand Up @@ -145,7 +149,11 @@
</font>
</property>
<property name="text">
<string>-</string>
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/minus.png</normaloff>:/images/minus.png</iconset>
</property>
</widget>
</item>
Expand Down Expand Up @@ -376,6 +384,8 @@
<tabstop>pathEdit</tabstop>
<tabstop>autosourcesTree</tabstop>
</tabstops>
<resources/>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>
18 changes: 13 additions & 5 deletions Source/YourFriendlyDNS/smalldnsserver.cpp
Expand Up @@ -195,21 +195,29 @@ bool SmallDNSServer::weDoStillHaveAConnection()
{
if(!sendrecvFlag && responseLastReceivedTime.secsTo(requestLastSentTime) > 30)
{
qDebug() << "Haven't received responses for the last 30 seconds... Let's slow down... Taking a two minute timeout.";
timeoutEnd = QDateTime::currentDateTime().addSecs(120);
timeoutInferencePeriod = QDateTime::currentDateTime().addSecs(30);
inTimeout = 1;
}
}
else if(inTimeout == 1)
else if(inTimeout > 0)
{
if(QDateTime::currentDateTime() > timeoutEnd || sendrecvFlag)
if(inTimeout == 1)
{
if(QDateTime::currentDateTime() > timeoutInferencePeriod && !sendrecvFlag && responseLastReceivedTime.secsTo(requestLastSentTime) > 60)
{
timeoutEnd = QDateTime::currentDateTime().addSecs(120);
qDebug() << "Haven't received responses for the last 60 seconds... Let's slow down... Taking a two minute timeout.";
inTimeout = 2;
//Now firmly in a timeout
}
}
if(QDateTime::currentDateTime() > timeoutEnd || sendrecvFlag) //Only unless a response comes in of one already sent while waiting it out
{
responseLastReceivedTime = requestLastSentTime = QDateTime::currentDateTime();
inTimeout = 0;
emit deleteObjectsTheresNoResponseFor();
return true;
}

return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions Source/YourFriendlyDNS/smalldnsserver.h
Expand Up @@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <QProcess>
#include "androidsuop.h"
#include "initialresponse.h"
#include "dnscrypt.h" //Including my DNSCrypt class and helpers, giving us DNSCrypt protocol version 1,2,3 support!
#include "dnscrypt.h" //Including our DNSCrypt class and helpers, giving us DNSCrypt protocol version 1,2,3 support!

/* YourFriendlyDNS - A really awesome multi-platform (lin,win,mac,android) local caching and proxying dns server!
Copyright (C) 2018 softwareengineer1 @ github.com/softwareengineer1
Expand Down Expand Up @@ -84,7 +84,7 @@ class SmallDNSServer : public QObject
void determineDoHDoTLSProviders();

bool whitelistmode, blockmode_returnlocalhost, initialMode, autoTTL, dnscryptEnabled, sendrecvFlag;
QDateTime requestLastSentTime, responseLastReceivedTime, timeoutEnd;
QDateTime requestLastSentTime, responseLastReceivedTime, timeoutInferencePeriod, timeoutEnd;
Q_IPV6ADDR ipv6ToRespondWith;
quint32 ipToRespondWith, cachedMinutesValid, dnsTTL, inTimeout;
quint64 numSentRequests, numReceivedResponses;
Expand Down
4 changes: 2 additions & 2 deletions TestProviders.md
@@ -1,6 +1,6 @@
# Test Providers

These were providers I was testing, making sure it interprets all stamps properly.
These were providers I was testing, making sure it interprets all stamps properly, and just making sure everything working properly.

--

Expand Down Expand Up @@ -28,6 +28,6 @@ sdns://AgcAAAAAAAAABzEuMC4wLjGgENk8mGSlIfMGXMOlIlCcKvq7AVgcrZxtjon911-ep0cg63Ul-
opendns v1 DNSCrypt
sdns://AQAAAAAAAAAADjIwOC42Ny4yMjAuMjIwILc1EUAgbyJdPivYItf9aR6hwzzI1maNDL4Ev6vKQ_t5GzIuZG5zY3J5cHQtY2VydC5vcGVuZG5zLmNvbQ

## opendns DNSCrypt
## opendns DNSCrypt ipv6
opendns v1 DNSCrypt ipv6
sdns://AQAAAAAAAAAAD1syNjIwOjA6Y2NjOjoyXSC3NRFAIG8iXT4r2CLX_WkeocM8yNZmjQy-BL-rykP7eRsyLmRuc2NyeXB0LWNlcnQub3BlbmRucy5jb20

0 comments on commit f2723e1

Please sign in to comment.