"rustls-pki-types",
"serde",
"serde_yaml",
- "time",
"tokio",
"tokio-rustls",
]
name = "recrust"
crate-type = ["staticlib"]
+[features]
+# default = []
+pkcs12 = ["p12-keystore"]
+
[dependencies]
cxx = "1.0.181" # issue #16101
serde = { version = "1.0", features = ["derive"] }
tokio-rustls = { version = "0.26", default-features = false }
# time pinned to avoid too high rustc version dependency (1.88), remove at some point!
-time = { version = "=0.3.45" }
+# Handled in a different way: the pkcs12 feature is now optional, can be enabled is rust version >= 1.88
+#time = { version = "=0.3.45" }
-p12-keystore = { version = "0.2.0" }
+p12-keystore = { version = "0.2.0", optional = true }
[build-dependencies]
cxx-build = "1.0"
fi
fi
-$CARGO build ${CARGO_PROFILE} $RUST_TARGET --target-dir=$builddir/target --manifest-path $srcdir/Cargo.toml
+$CARGO build ${CARGO_PROFILE} $RUST_TARGET --target-dir=$builddir/target --manifest-path $srcdir/Cargo.toml $features
if [ -n "${CARGO_USE_DEV}" ]; then
cp -p target/$RUSTC_TARGET_ARCH/debug/librecrust.a $builddir/rec-rust-lib/rust/librecrust.a
env.append('RUST_TARGET', '', separator: '')
env.append('RUSTC_TARGET_ARCH', '', separator: '')
+if cargo.version().version_compare('>=1.88')
+env.set('features', '--features pkcs12')
+endif
+
lib_recrust = custom_target('librecrust.a',
output: [outfile, 'cxx.h', 'lib.rs.h', 'misc.rs.h', 'web.rs.h'],
input: infile,
);
fn getUUID() -> String;
}
+ extern "Rust" {
+ fn rust_features() ->String;
+ }
+}
+
+pub fn rust_features() -> String {
+ #![allow(unused_mut)]
+ let mut ret = String::from("");
+ #[cfg(feature = "pkcs12")]
+ ret.push_str(" pkcs12");
+ ret
}
// Load private key and certs from pkcs12 (pfx) file.
+#[cfg(feature = "pkcs12")]
fn load_pkcs12_key_and_certs(
filename: &str,
password: &str,
}
}
+#[cfg(not(feature = "pkcs12"))]
+fn load_pkcs12_key_and_certs(
+ filename: &str,
+ _password: &str,
+ ctx: &Arc<Context>,
+) -> std::io::Result<(pki_types::PrivateKeyDer<'static>, Vec<pki_types::CertificateDer<'static>>)> {
+ let msg = "PKCS12 feature is not enabled";
+ rustmisc::log(
+ &ctx.logger,
+ rustmisc::Priority::Error,
+ msg,
+ &vec![rustmisc::KeyValue {
+ key: "filename".to_string(),
+ value: filename.to_string(),
+ }]);
+ Err(std::io::Error::other(msg))
+}
+
+
+
// impl below needed because the classes are used in the Context, which gets passed around.
unsafe impl Send for rustweb::CredentialsHolder {}
unsafe impl Sync for rustweb::CredentialsHolder {}
#include <sstream>
#include <boost/algorithm/string/join.hpp>
+#ifdef RECURSOR
+#include "rust/misc.rs.h"
+#endif
+
static ProductType productType;
string compilerVersion()
#endif
#ifdef HAVE_LIBCAP
<< " libcap"
+#endif
+#ifdef RECURSOR
+ << pdns::rust::misc::rust_features()
#endif
<< endl;
#ifdef PDNS_MODULES
except subprocess.CalledProcessError as e:
raise AssertionError('%s failed (%d): %s' % (rec_controlCmd, e.returncode, e.output))
+ @classmethod
+ def recFeatures(cls):
+ rec_versionCmd = [os.environ['PDNSRECURSOR'],
+ '--version']
+ try:
+ full = subprocess.check_output(rec_versionCmd, text=True, stderr=subprocess.STDOUT)
+ for line in full.splitlines():
+ if line.startswith("Features: "):
+ return line
+ except subprocess.CalledProcessError as e:
+ raise AssertionError('%s failed (%d): %s' % (rec_versionCmd, e.returncode, e.output))
+
@classmethod
def setUpSockets(cls):
print("Setting up UDP socket..")
set -x
fi
-if ! "$PDNSRECURSOR" --version 2>&1 | grep Features | grep -q dnstap-framestream; then
- export NODNSTAPTESTS=1
-fi
-
# Run with -m 'not external' to skip test that require external connectivity
# Run with -m 'not unreliable_on_gh' to skip tests that are unreliable on GitHUb
# Run with -m 'not (external or unreliable_on_gh)' to skip both categories
import requests
import subprocess
-
+import pytest
from recursortests import RecursorTest
class RecPrometheusTest(RecursorTest):
def generateRecursorConfig(cls, confdir):
super(HttpsPKCS12PrometheusTest, cls).generateRecursorYamlConfig(confdir)
+ @pytest.mark.skipif('pkcs12' not in RecursorTest.recFeatures(), reason='pkcs12 feature not available')
def testPrometheus(self):
self.waitForTCPSocket("127.0.0.1", self._wsPort)
url = 'https://user:' + self._wsPassword + '@127.0.0.1:' + str(self._wsPort) + '/metrics'
import time
import dns
import dnstap_pb2
+import pytest
from unittest import SkipTest
from recursortests import RecursorTest
sock.close()
@classmethod
+ @pytest.mark.skipif('dnstap-framestream' not in RecursorTest.recFeatures(), reason='dnstap feature not available')
def setUpClass(cls):
- if os.environ.get("NODNSTAPTESTS") == "1":
- raise SkipTest("Not Yet Supported")
-
cls.setUpSockets()
-
cls.startResponders()
listener = threading.Thread(name='DNSTap Listener', target=cls.FrameStreamUnixListenerMain, args=[DNSTapServerParameters])