Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/merge_maser…
Browse files Browse the repository at this point in the history
…_into_dev-2.1

# Conflicts:
#	CHANGELOG.md
#	net/socket_factory.cpp
#	platform/windows/capi/src/ag_dns_h_hash.inc
#	platform/windows/cs/Adguard.Dns/Adguard.Dns/AGDnsApi.cs
#	proxy/dnsproxy.cpp
#	upstream/upstream_dot.cpp
  • Loading branch information
ngorskikh committed Dec 16, 2022
2 parents 6a874fc + 4da4183 commit 80a7e7f
Show file tree
Hide file tree
Showing 51 changed files with 452 additions and 292 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* [Apple] See `AGDnsProxyError`
* [Android] See `ag_dnsproxy_init_result`

## V2.0

* [Feature] Add an option to strip Encrypted Client Hello parameters from responses, effectively blocking ECH.
* [C API] See `ag_dnsproxy_settings::block_ech`
* [Apple] See `AGDnsProxyConfig.blockEch`
Expand Down
4 changes: 2 additions & 2 deletions bamboo-specs/android-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DL - Android build and deploy:
key: JOB1
description: Builds and deploy libraries
docker:
image: adguard/core-libs:1.5
image: adguard/core-libs:1.11
volumes:
${bamboo.working.directory}: ${bamboo.working.directory}
${bamboo.tmp.directory}: ${bamboo.tmp.directory}
Expand Down Expand Up @@ -66,7 +66,7 @@ DL - Android build and deploy:
esac
if [ "${current_branch}" = "master" ]; then
conan export ../../.. AdguardTeam/NativeLibsCommon
conan export ../../.. /777@AdguardTeam/NativeLibsCommon
fi
working-dir: dns-libs/platform/android/dnsproxy
description: Publishes or assembles libraries
Expand Down
2 changes: 2 additions & 0 deletions bamboo-specs/bamboo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
!include 'run-tests.yaml'
---
!include 'increment-version.yaml'
---
!include 'upload-conan-recipes.yaml'
10 changes: 8 additions & 2 deletions bamboo-specs/increment-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stages:
DL - Increment version:
key: JOB1
docker:
image: adguard/core-libs:latest
image: adguard/core-libs:1.11
volumes:
${bamboo.working.directory}: ${bamboo.working.directory}
${bamboo.tmp.directory}: ${bamboo.tmp.directory}
Expand Down Expand Up @@ -61,12 +61,18 @@ DL - Increment version:
case "${bamboo_repository_branch_name}" in
master|stable-*)
cd scripts
./increment_conan_version.sh ${bamboo_custom_version} || exit 1
git add conandata.yml
git add ../conandata.yml
git commit -m "skipci: Automatic version increment by Bamboo"
git push
BAMBOO_URL=$(echo ${bamboo_resultsUrl} | sed -ne 's|\(https://[^/]\+\)/.*|\1|p')
curl -H "Authorization: Bearer ${bamboo.bambooTriggerTokenSecret}" \
"${BAMBOO_URL}/rest/api/latest/queue/CL-DNSUCR" -X POST -d "executeAllStages=1"
;;
esac
working-dir: dns-libs
description: Increment version
Expand Down
2 changes: 1 addition & 1 deletion bamboo-specs/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Run C++ tests:
key: JOB1
description: Runs C++ tests
docker:
image: adguard/core-libs:latest
image: adguard/core-libs:1.11
volumes:
${bamboo.working.directory}: ${bamboo.working.directory}
${bamboo.tmp.directory}: ${bamboo.tmp.directory}
Expand Down
68 changes: 68 additions & 0 deletions bamboo-specs/upload-conan-recipes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
version: 2
plan:
project-key: CL
key: DNSUCR
name: DnsLibs - Upload conan recipes
stages:
- Default Stage:
manual: false
final: false
jobs:
- Default Job
Default Job:
key: JOB1
docker:
image: adguard/core-libs:1.11
volumes:
${bamboo.git.cache.directory}: ${bamboo.git.cache.directory}
${system.HOME}/.ssh: /root/.ssh
docker-run-arguments: []
tasks:
- !include docker-clean.yaml
- checkout:
force-clean-build: 'true'
description: Checkout
- script:
interpreter: SHELL
scripts:
- |-
# Clean up local cache
conan remove -f '*'
conan remote add -i 0 art ${bamboo.conanRepoUrl} || true
# Export packages
cd scripts
python3 -m pip install -r requirements.txt
./export_conan.py
conan user -p "${bamboo_artifactoryPassword}" -r art "${bamboo_artifactoryUser}" > upload.txt 2>&1
# Upload packages
conan upload -r art --all -c '*' >> upload.txt 2>&1
echo conan upload finished with status $?
final-tasks:
- script:
interpreter: SHELL
scripts:
- |-
# Clean up
conan remove -f '*'
conan remove --locks
description: Clean up
requirements:
- adg-privileged-docker
artifact-subscriptions: []
repositories:
- dns-libs:
scope: global
branches:
create: manually
delete: never
link-to-jira: true
triggers: []
notifications: []
labels: []
other:
concurrent-build-plugin: system-default
1 change: 0 additions & 1 deletion cmake/conan_bootstrap.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
function(conan_bootstrap)
cmake_parse_arguments(BS "" "SRCROOT;CONANFILE;SCOPE_NAME" "" ${ARGN})
set(CONAN_EXPORTED OFF)
include("${BS_SRCROOT}/cmake/conan.cmake")
if (NOT TARGET CONAN_DONE::${BS_SCOPE_NAME})
# Profile settings
Expand Down
2 changes: 1 addition & 1 deletion common/include/dns/common/version.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#pragma once
#define AG_DNSLIBS_VERSION "2.0.43"
#define AG_DNSLIBS_VERSION "2.0.66"
80 changes: 34 additions & 46 deletions conandata.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
commit_hash:
"2.0.20":
hash: "e0ebc461e0441a528a3d3332d7e974f4470d273e"
"2.0.21":
hash: "bc040d0fa6c8bf9d933bff420a599ea355050234"
"2.0.22":
hash: "b7fb942e1a7a51153d3439276b014019d1bd27b3"
"2.0.23":
hash: "cc6a989ff9566d4863f088c8ab23d0ec91e6d580"
"2.0.24":
hash: "39d916ec922bdc3a1c2412554a69f898e74be0b7"
"2.0.25":
hash: "484b41433a28eab4ebf6501f53853072256b9986"
"2.0.26":
hash: "7b32666c18b4876756236547c3060d9f925c504c"
"2.0.28":
hash: "46aecd61ca4341b37f23c8e0e6c447336865f2d7"
"2.0.29":
hash: "f8ac9215e5d63006fdd7c1143f7b0acb06d91637"
"2.0.30":
hash: "d3698b3e8626acccbb8082d573a6d2f6110dfa06"
"2.0.31":
hash: "049a5f3f2752032b4498c60b8a072a8f6d4053bb"
"2.0.32":
hash: "566a6843ec184bd19956b65805ecc2c0e63755d3"
"2.0.33":
hash: "6fe0dd48e6d58e2d4c64dd97563d75cd858aefa5"
"2.0.34":
hash: "35bbe1dcd366b4ceabaf9327617a8a33f52ae9e7"
"2.0.35":
hash: "17f5aa90ffdc4d5dac77a1dcd2ccf4d6dad63d10"
"2.0.36":
hash: "a3531efe50623b77d0d060c3ff85290558da5a02"
"2.0.37":
hash: "072446cc2fc8cb5a59e5570a74f830c8a9269450"
"2.0.38":
hash: "1dc211e8b259a27e3c0a8eb94d7488676224f7b9"
"2.0.39":
hash: "cf5872f821de02c1faaccde0c8bc0ec49ccfe6aa"
"2.0.40":
hash: "23b55676e684b766563fa6b6937ff5e66704ef77"
"2.0.41":
hash: "71e3b1eed6d89ff61f29904a96f8891c0e0f9412"
"2.0.42":
hash: "80da7d6b76d7962d869764afb4b7edf8191fe745"
"2.0.43":
hash: "8499ee8fd1df7dee796a118d90db091eff29900c"
"2.0.50":
hash: "84d3dc526067eebb01d9d4030a833e5c466f7d6e"
"2.0.51":
hash: "fe08b51738e029abc151d3e9e17e8850f4c0d78f"
"2.0.52":
hash: "a523561ed6482629128c5336ca0744261bc8602f"
"2.0.53":
hash: "5b54a9143031cd7ae7ac29ed4395ff08af42088d"
"2.0.54":
hash: "b830de744fe2f3dbaebb7fa05c3676dc01eb4832"
"2.0.55":
hash: "75662502b9165b074259942e49ffb536fcc80c86"
"2.0.56":
hash: "dd68d129a2449083e0d99fc06cc040ddf7fd23de"
"2.0.57":
hash: "fe4097c4b9372d9d30386ca4b84abef93e88e4ac"
"2.0.58":
hash: "f768655158108551549221d041865dcfd26aec93"
"2.0.59":
hash: "0e0b97aea8adbc6cc5f28c70818988e17ba9c40a"
"2.0.60":
hash: "a1448ab3165aaed99f5ffb183988d455e5dc9f26"
"2.0.61":
hash: "1273e47a36fc338dd517c08a265bec9475763f9b"
"2.0.62":
hash: "193c9be47355c2e5cd8421e2061ed8f3038a2766"
"2.0.63":
hash: "df9d906eb4768c0196f9ec6749f7d3574ea74b13"
"2.0.64":
hash: "c492b594a99d0a774619c97f6051914d3ef37d71"
"2.0.65":
hash: "0add627ee717867dfdc1f8bdf6f6dc5317d1159b"
"2.0.66":
hash: "b94494f6f2af4e3cc183a964ca76bbf0f2eecfd0"
15 changes: 9 additions & 6 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

class DnsLibsConan(ConanFile):
name = "dns-libs"
version = "777" # use the `commit_hash` option to select the desired library version
license = "Apache-2.0"
author = "AdguardTeam"
url = "https://github.com/AdguardTeam/DnsLibs"
Expand Down Expand Up @@ -49,10 +48,14 @@ def config_options(self):
del self.options.fPIC

def source(self):
self.run("git clone https://github.com/AdguardTeam/DnsLibs.git source_subfolder")
self.run("git init . && git remote add origin https://github.com/AdguardTeam/DnsLibs.git && git fetch")

if self.options.commit_hash:
self.run("cd source_subfolder && git checkout %s" % self.options.commit_hash)
if self.version == "777":
if self.options.commit_hash:
self.run("git checkout -f %s" % self.options.commit_hash)
else:
version_hash = self.conan_data["commit_hash"][self.version]["hash"]
self.run("git checkout -f %s" % version_hash)

def build(self):
cmake = CMake(self)
Expand All @@ -62,7 +65,7 @@ def build(self):
cmake.definitions["CMAKE_CXX_FLAGS"] = "-stdlib=%s" % self.settings.compiler.libcxx
if self.settings.compiler.version:
cmake.definitions["CMAKE_CXX_COMPILER_VERSION"] = self.settings.compiler.version
cmake.configure(source_folder="source_subfolder/proxy")
cmake.configure(source_folder="proxy")
cmake.build(target="dnsproxy")

def package(self):
Expand All @@ -77,7 +80,7 @@ def package(self):
]

for m in MODULES:
self.copy("*.h", dst="include", src="source_subfolder/%s/include" % m)
self.copy("*.h", dst="include", src="%s/include" % m)

self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
Expand Down
5 changes: 5 additions & 0 deletions net/include/dns/net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class SocketFactory {

SocketFactory &operator=(const SocketFactory &) = delete;

/**
* Deinitialize the factory
*/
void deinit();

/**
* Create a socket basing on the factory and provided parameters
* @param parameters the socket parameters
Expand Down
52 changes: 11 additions & 41 deletions net/outbound_direct_proxy.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <tuple>

#include "outbound_direct_proxy.h"

namespace ag::dns {
Expand All @@ -7,62 +9,39 @@ DirectOProxy::DirectOProxy(Parameters parameters)
}

void DirectOProxy::reset_connections() {
std::scoped_lock l(m_guard);

for (auto &[conn_id, conn] : m_connections) {
[[maybe_unused]] auto e = conn.socket->set_callbacks({});
conn.parameters.loop->submit([this, conn_id = conn_id]() {
std::optional<Callbacks> cbx;

{
std::scoped_lock l(m_guard);
auto it = m_connections.find(conn_id);
if (it == m_connections.end()) {
return;
}

cbx = it->second.parameters.callbacks;
if (cbx->on_close == nullptr) {
m_connections.erase(it);
}
}

if (cbx.has_value() && cbx->on_close != nullptr) {
auto err = make_error(SocketError::AE_OUTBOUND_PROXY_ERROR, "Reset re-routed directly connection");
cbx->on_close(cbx->arg, err);
}
});
for (auto &[conn_id, conn] : std::exchange(m_connections, {})) {
if (conn.parameters.callbacks.on_close != nullptr) {
auto err = make_error(SocketError::AE_OUTBOUND_PROXY_ERROR, "Reset re-routed directly connection");
conn.parameters.callbacks.on_close(conn.parameters.callbacks.arg, err);
}
}
}

void DirectOProxy::deinit_impl() {
}

OutboundProxy::ProtocolsSet DirectOProxy::get_supported_protocols() const {
return (1u << utils::TP_TCP) | (1u << utils::TP_UDP);
}

std::optional<evutil_socket_t> DirectOProxy::get_fd(uint32_t conn_id) const {
std::scoped_lock l(m_guard);
auto it = m_connections.find(conn_id);
return (it != m_connections.end()) ? it->second.socket->get_fd() : std::nullopt;
}

Error<SocketError> DirectOProxy::send(uint32_t conn_id, Uint8View data) {
std::scoped_lock l(m_guard);
auto it = m_connections.find(conn_id);
return (it != m_connections.end())
? it->second.socket->send(data)
: make_error(SocketError::AE_CONNECTION_ID_NOT_FOUND, fmt::to_string(conn_id));
}

bool DirectOProxy::set_timeout(uint32_t conn_id, Micros timeout) {
std::scoped_lock l(m_guard);
auto it = m_connections.find(conn_id);
return (it != m_connections.end())
? it->second.socket->set_timeout(timeout)
: false;
return (it != m_connections.end()) && it->second.socket->set_timeout(timeout);
}

Error<SocketError> DirectOProxy::set_callbacks_impl(uint32_t conn_id, Callbacks cbx) {
std::scoped_lock l(m_guard);
auto it = m_connections.find(conn_id);
if (it == m_connections.end()) {
return make_error(SocketError::AE_CONNECTION_ID_NOT_FOUND, fmt::to_string(conn_id));
Expand All @@ -79,21 +58,13 @@ Error<SocketError> DirectOProxy::set_callbacks_impl(uint32_t conn_id, Callbacks
}

void DirectOProxy::close_connection_impl(uint32_t conn_id) {
std::scoped_lock l(m_guard);
auto node = m_connections.extract(conn_id);
if (node.empty()) {
return;
}

Connection &conn = node.mapped();
m_closing_connections.insert(std::move(node));

[[maybe_unused]] auto e = conn.socket->set_callbacks({});
conn.parameters.callbacks = {};
conn.parameters.loop->submit([this, conn_id]() {
std::scoped_lock l(m_guard);
m_closing_connections.erase(conn_id);
});
}

Error<SocketError> DirectOProxy::connect_to_proxy(uint32_t conn_id, const ConnectParameters &parameters) {
Expand All @@ -102,7 +73,6 @@ Error<SocketError> DirectOProxy::connect_to_proxy(uint32_t conn_id, const Connec

Error<SocketError> DirectOProxy::connect_through_proxy(
uint32_t conn_id, const ConnectParameters &parameters) {
std::scoped_lock l(m_guard);
Connection &conn = m_connections
.emplace(conn_id,
Connection{
Expand Down
Loading

0 comments on commit 80a7e7f

Please sign in to comment.