diff --git a/README.md b/README.md index da379a29e62daf8f0e937609cb1b9b45dcb976e8..c51c1b313294a2f250739dfad6620fcc44a2b7f2 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,11 @@ DHTNet depends on the following libraries: ## Packaging and release -In `extras/packaging`, you will find a `build_packages.sh` script which will build packages for supported plateform. You must provide as argument the OS for which you want to build. You can't specify the plateform (arm64, x86, ...) as you can compile only for the same plateform as the one you are running on. +In `extras/packaging`, you will find a `build_packages.sh` script which will build packages for supported platform. You must provide as argument the OS for which you want to build. You are unable to specify the platform (arm64, x86, ...) as you can compile only for the same platform as the one you are running on. **Usage:** ```bash -extras/packaging/build_packages.sh -a # -a or --all will build all plateform which are known to be supported +extras/packaging/build_packages.sh -a # -a or --all will build all platform which are known to be supported extras/packaging/build_packages.sh -u # -u or --ubuntu will build for all supported versions of Ubuntu extras/packaging/build_packages.sh -u22 -d11 # -u22 will build for ubuntu 22.04 and -d11 will build for Debian 11 ``` diff --git a/include/compat/msvc/windirent.h b/include/compat/msvc/windirent.h index ee9f5528537b23828dea59dd0d34f819e29fc597..a87d0b9bf0c6b016f5949fdac0b3b3ea22add352 100644 --- a/include/compat/msvc/windirent.h +++ b/include/compat/msvc/windirent.h @@ -145,7 +145,7 @@ #define S_IXOTH 0 #endif -/* Maximum length of file name */ +/* Maximum length of filename */ #if !defined(PATH_MAX) #define PATH_MAX MAX_PATH #endif @@ -171,7 +171,7 @@ #define DTTOIF(type) (type) /* - * File type macros. Note that block devices, sockets and links cannot be + * File type macros. Note that block devices, sockets and links are unable to be * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are * only defined for compatibility. These macros should always return false * on Windows. @@ -223,7 +223,7 @@ struct _wdirent /* File type */ int d_type; - /* File name */ + /* Filename */ wchar_t d_name[PATH_MAX]; }; typedef struct _wdirent _wdirent; @@ -275,7 +275,7 @@ struct dirent /* File type */ int d_type; - /* File name */ + /* Filename */ char d_name[PATH_MAX]; }; typedef struct dirent dirent; @@ -385,24 +385,24 @@ _wopendir(const wchar_t* dirname) /* Directory stream opened successfully */ error = 0; } else { - /* Cannot retrieve first entry */ + /* Unable to retrieve first entry */ error = 1; dirent_set_errno(ENOENT); } } else { - /* Cannot retrieve full path name */ + /* Unable to retrieve full path name */ dirent_set_errno(ENOENT); error = 1; } } else { - /* Cannot allocate memory for search pattern */ + /* Unable to allocate memory for search pattern */ error = 1; } } else { - /* Cannot allocate _WDIR structure */ + /* Unable to allocate _WDIR structure */ error = 1; } @@ -437,8 +437,8 @@ _wreaddir(_WDIR* dirp) entp = &dirp->ent; /* - * Copy file name as wide-character string. If the file name is too - * long to fit in to the destination buffer, then truncate file name + * Copy filename as wide-character string. If the filename is too + * long to fit in to the destination buffer, then truncate filename * to PATH_MAX characters and zero-terminate the buffer. */ n = 0; @@ -448,7 +448,7 @@ _wreaddir(_WDIR* dirp) } dirp->ent.d_name[n] = 0; - /* Length of file name excluding zero terminator */ + /* Length of filename excluding zero terminator */ entp->d_namlen = n; /* File type */ @@ -509,7 +509,7 @@ _wclosedir(_WDIR* dirp) /* * Rewind directory stream such that _wreaddir() returns the very first - * file name again. + * filename again. */ static void _wrewinddir(_WDIR* dirp) @@ -619,7 +619,7 @@ opendir(const char* dirname) } else { /* - * Cannot convert file name to wide-character string. This + * Unable to convert filename to wide-character string. This * occurs if the string contains invalid multi-byte sequences or * the output buffer is too small to contain the resulting * string. @@ -628,7 +628,7 @@ opendir(const char* dirname) } } else { - /* Cannot allocate DIR structure */ + /* Unable to allocate DIR structure */ error = 1; } @@ -644,10 +644,10 @@ opendir(const char* dirname) /* * Read next directory entry. * - * When working with text consoles, please note that file names returned by + * When working with text consoles, please note that filenames returned by * readdir() are represented in the default ANSI code page while any output to * console is typically formatted on another code page. Thus, non-ASCII - * characters in file names will not usually display correctly on console. The + * characters in filenames will not usually display correctly on console. The * problem can be fixed in two ways: (1) change the character set of console * to 1252 using chcp utility and use Lucida Console font, or (2) use * _cprintf function when writing to console. The _cprinf() will re-encode @@ -666,16 +666,16 @@ readdir(DIR* dirp) size_t n; int error; - /* Attempt to convert file name to multi-byte string */ + /* Attempt to convert filename to multi-byte string */ error = dirent_wcstombs_s(&n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX); /* - * If the file name cannot be represented by a multi-byte string, - * then attempt to use old 8+3 file name. This allows traditional - * Unix-code to access some file names despite of unicode - * characters, although file names may seem unfamiliar to the user. + * If the filename is unable to be represented by a multi-byte string, + * then attempt to use old 8.3 filename. This allows traditional + * Unix-code to access some filenames despite of unicode + * characters, although filenames may seem unfamiliar to the user. * - * Be ware that the code below cannot come up with a short file + * Beware that the code below is unable to come up with a short file * name unless the file system provides one. At least * VirtualBox shared folders fail to do this. */ @@ -693,7 +693,7 @@ readdir(DIR* dirp) /* Initialize directory entry for return */ entp = &dirp->ent; - /* Length of file name excluding zero terminator */ + /* Length of filename excluding zero terminator */ entp->d_namlen = n - 1; /* File attributes */ @@ -712,9 +712,9 @@ readdir(DIR* dirp) } else { /* - * Cannot convert file name to multi-byte string so construct + * Unable to convert filename to multi-byte string so construct * an errornous directory entry and return that. Note that - * we cannot return NULL as that would stop the processing + * we are unable to return NULL as that would stop the processing * of directory entries completely. */ entp = &dirp->ent; @@ -804,7 +804,7 @@ dirent_mbstowcs_s( error = 0; } else { - /* Could not convert string */ + /* Unable to convert string */ error = 1; } @@ -853,7 +853,7 @@ dirent_wcstombs_s(size_t* pReturnValue, error = 0; } else { - /* Cannot convert string */ + /* Unable to convert string */ error = 1; } diff --git a/include/connectionmanager.h b/include/connectionmanager.h index 6cd3b56e76ae773b145441428e8a32202bc9b6c4..e4ea21288b62b2a895c9860e8c4a2479f424f897 100644 --- a/include/connectionmanager.h +++ b/include/connectionmanager.h @@ -190,7 +190,7 @@ public: std::size_t activeSockets() const; /** - * Log informations for all sockets + * Log information for all sockets */ void monitor() const; diff --git a/include/ice_transport.h b/include/ice_transport.h index a13ebdd71004133affb4dbf6a81181a0f97fe3f6..c48a7628cb7473177ee4ebddb7813eb65a4ff21b 100644 --- a/include/ice_transport.h +++ b/include/ice_transport.h @@ -101,7 +101,7 @@ public: * to find the right candidate pair. * This function doesn't block, the callback on_negodone_cb will be called * with the negotiation result when operation is really done. - * Return false if negotiation cannot be started else true. + * Return false if negotiation is unable to be started else true. */ bool startIce(const Attribute& rem_attrs, std::vector<IceCandidate>&& rem_candidates); bool startIce(const SDP& sdp); diff --git a/include/multiplexed_socket.h b/include/multiplexed_socket.h index 2079df5e0249c9f9d2985d95ee21b4105ef2e5f5..480932cd701ffd9b3d3d36681d3b2b722b054d41 100644 --- a/include/multiplexed_socket.h +++ b/include/multiplexed_socket.h @@ -135,7 +135,7 @@ public: void onShutdown(OnShutdownCb&& cb); /** - * Get informations from socket (channels opened) + * Get information from socket (channels opened) */ void monitor() const; diff --git a/include/pj_init_lock.h b/include/pj_init_lock.h index c521a8a7527541c19c01908a30c4ec30b3640b37..b1b675c6ebf5b4d165987a9cdfeddabfa8b9c0a4 100644 --- a/include/pj_init_lock.h +++ b/include/pj_init_lock.h @@ -29,7 +29,7 @@ namespace dhtnet { // - The first call to pj_init actually initializes the library; subsequent calls do nothing. // - All calls to pj_shutdown do nothing, except the last one which actually performs the shutdown. // Unfortunately, the way this logic is implemented in PJSIP is not thread-safe, so we're -// responsible for making sure that these functions can't be called by two threads at the same time. +// responsible for making sure that these functions are unable to be called by two threads at the same time. class PjInitLock { private: diff --git a/include/string_utils.h b/include/string_utils.h index 587cfb66b37b5139e69d1bf069596fb889fabf41..92e54e8ede9b350c394aa4b0a04306f0f6d52670 100644 --- a/include/string_utils.h +++ b/include/string_utils.h @@ -71,9 +71,9 @@ to_int(std::string_view str) if (ec == std::errc()) return result; if (ec == std::errc::invalid_argument) - throw std::invalid_argument("Can't parse integer: invalid_argument"); + throw std::invalid_argument("Unable to parse integer: invalid_argument"); else if (ec == std::errc::result_out_of_range) - throw std::out_of_range("Can't parse integer: out of range"); + throw std::out_of_range("Unable to parse integer: out of range"); throw std::system_error(std::make_error_code(ec)); } diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp index da5897ee8c599610aba863ada87f9c5d4db97354..652a10565c0aaec044716f8db4eb8075c6ec61f5 100644 --- a/src/connectionmanager.cpp +++ b/src/connectionmanager.cpp @@ -949,7 +949,7 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif connType, ok] { auto sthis = w.lock(); if (!ok && sthis && sthis->config_->logger) - sthis->config_->logger->error("[device {}] Cannot initialize ICE session.", devicePk->getLongId()); + sthis->config_->logger->error("[device {}] Unable to initialize ICE session.", devicePk->getLongId()); if (!sthis || !ok) { eraseInfo(); return; @@ -997,7 +997,7 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif info->ice_ = sthis->config_->factory->createUTransport(""); if (!info->ice_) { if (sthis->config_->logger) - sthis->config_->logger->error("[device {}] Cannot initialize ICE session.", deviceId); + sthis->config_->logger->error("[device {}] Unable to initialize ICE session.", deviceId); eraseInfo(); return; } @@ -1027,7 +1027,7 @@ ConnectionManager::Impl::sendChannelRequest(const std::weak_ptr<DeviceInfo>& din auto channelSock = sock->addChannel(name); if (!channelSock) { if (config_->logger) - config_->logger->error("sendChannelRequest failed - cannot create channel"); + config_->logger->error("sendChannelRequest failed - unable to create channel"); if (auto info = dinfow.lock()) info->executePendingOperations(vid, nullptr); return; @@ -1088,7 +1088,7 @@ ConnectionManager::Impl::onPeerResponse(PeerConnectionRequest&& req) req.id)); } else { if (config_->logger) - config_->logger->warn("[device {}] Respond received, but cannot find request", device); + config_->logger->warn("[device {}] Response received, but unable to find request", device); } } @@ -1397,7 +1397,7 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req, return; if (!ok) { if (shared->config_->logger) - shared->config_->logger->error("[device {}] Cannot initialize ICE session.", req.owner->getLongId()); + shared->config_->logger->error("[device {}] Unable to initialize ICE session.", req.owner->getLongId()); dht::ThreadPool::io().run([eraseInfo = std::move(eraseInfo)] { eraseInfo(); }); return; } @@ -1442,7 +1442,7 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req, info->ice_ = shared->config_->factory->createUTransport(""); if (not info->ice_) { if (shared->config_->logger) - shared->config_->logger->error("[device {}] Cannot initialize ICE session", deviceId); + shared->config_->logger->error("[device {}] Unable to initialize ICE session", deviceId); eraseInfo(); return; } @@ -1663,7 +1663,7 @@ ConnectionManager::Impl::foundPeerDevice(const std::shared_ptr<dht::crypto::Cert while (top_issuer->issuer) top_issuer = top_issuer->issuer; - // Device certificate can't be self-signed + // Unable to self-signed device certificate if (top_issuer == crt) { if (logger) logger->warn("Found invalid (self-signed) peer device: {}", crt->getLongId()); diff --git a/src/fileutils.cpp b/src/fileutils.cpp index 9e2352773dca34bf3eeebe40a89b04cafb656821..335da58034c5bd883f565c938e628d7ddda08e18 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -124,7 +124,7 @@ createSymlink(const std::string& linkFile, const std::string& target) try { std::filesystem::create_symlink(target, linkFile); } catch (const std::exception& e) { - //JAMI_ERR("Couldn't create soft link: %s", e.what()); + //JAMI_ERR("Unable to create soft link: %s", e.what()); return false; } return true; @@ -136,7 +136,7 @@ createHardlink(const std::string& linkFile, const std::string& target) try { std::filesystem::create_hard_link(target, linkFile); } catch (const std::exception& e) { - //JAMI_ERR("Couldn't create hard link: %s", e.what()); + //JAMI_ERR("Unable to create hard link: %s", e.what()); return false; } return true; @@ -155,7 +155,7 @@ loadFile(const std::filesystem::path& path) std::vector<uint8_t> buffer; std::ifstream file(path, std::ios::binary); if (!file) - throw std::runtime_error("Can't read file: " + path.string()); + throw std::runtime_error("Unable to read file: " + path.string()); file.seekg(0, std::ios::end); auto size = file.tellg(); if (size > std::numeric_limits<unsigned>::max()) @@ -163,7 +163,7 @@ loadFile(const std::filesystem::path& path) buffer.resize(size); file.seekg(0, std::ios::beg); if (!file.read((char*) buffer.data(), size)) - throw std::runtime_error("Can't load file: " + path.string()); + throw std::runtime_error("Unable to load file: " + path.string()); return buffer; } @@ -172,7 +172,7 @@ saveFile(const std::filesystem::path& path, const uint8_t* data, size_t data_siz { std::ofstream file(path, std::ios::trunc | std::ios::binary); if (!file.is_open()) { - //JAMI_ERR("Could not write data to %s", path.c_str()); + //JAMI_ERR("Unable to write data to %s", path.c_str()); return; } file.write((char*) data, data_size); @@ -208,13 +208,13 @@ eraseFile_win32(const std::string& path, bool dosync) HANDLE h = CreateFileA(path.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (h == INVALID_HANDLE_VALUE) { - // JAMI_WARN("Can not open file %s for erasing.", path.c_str()); + // JAMI_WARN("Unable to open file %s for erasing.", path.c_str()); return false; } LARGE_INTEGER size; if (!GetFileSizeEx(h, &size)) { - // JAMI_WARN("Can not erase file %s: GetFileSizeEx() failed.", path.c_str()); + // JAMI_WARN("Unable to erase file %s: GetFileSizeEx() failed.", path.c_str()); CloseHandle(h); return false; } @@ -231,7 +231,7 @@ eraseFile_win32(const std::string& path, bool dosync) try { buffer = new char[ERASE_BLOCK]; } catch (std::bad_alloc& ba) { - // JAMI_WARN("Can not allocate buffer for erasing %s.", path.c_str()); + // JAMI_WARN("Unable to allocate buffer for erasing %s.", path.c_str()); CloseHandle(h); return false; } @@ -267,7 +267,7 @@ eraseFile_posix(const std::string& path, bool dosync) { struct stat st; if (stat(path.c_str(), &st) == -1) { - //JAMI_WARN("Can not erase file %s: fstat() failed.", path.c_str()); + //JAMI_WARN("Unable to erase file %s: fstat() failed.", path.c_str()); return false; } // Remove read-only flag if possible @@ -275,7 +275,7 @@ eraseFile_posix(const std::string& path, bool dosync) int fd = open(path.c_str(), O_WRONLY); if (fd == -1) { - //JAMI_WARN("Can not open file %s for erasing.", path.c_str()); + //JAMI_WARN("Unable to open file %s for erasing.", path.c_str()); return false; } diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index a860ec3c34acfd5d48c3e253bcca2c3f90021aa3..16e9fb7fe52db88966e3f58a20938e718e93a357 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -253,7 +253,7 @@ add_stun_server(pj_pool_t& pool, pj_ice_strans_cfg& cfg, const StunServerInfo& i IpAddr ip {info.uri}; - // Given URI cannot be DNS resolved or not IPv4 or IPv6? + // Given URI is unable to be DNS resolved or not IPv4 or IPv6? // This prevents a crash into PJSIP when ip.toString() is called. if (ip.getFamily() == AF_UNSPEC) { /*JAMI_DBG("[ice (%s)] STUN server '%s' not used, unresolvable address", @@ -902,7 +902,7 @@ IceTransport::Impl::addStunConfig(int af) if (af != pj_AF_INET() and af != pj_AF_INET6()) { if (logger_) - logger_->error("Invalid address familly ({})", af); + logger_->error("Invalid address family ({})", af); return false; } @@ -1722,7 +1722,7 @@ IceTransport::send(unsigned compId, const unsigned char* buf, size_t len) if (!remote) { if (pimpl_->logger_) - pimpl_->logger_->error("[ice:{}] can't find remote address for component {:d}", fmt::ptr(pimpl_), compId); + pimpl_->logger_->error("[ice:{}] Unable to find remote address for component {:d}", fmt::ptr(pimpl_), compId); errno = EINVAL; return -1; } diff --git a/src/ip_utils.cpp b/src/ip_utils.cpp index 25e1f406d97ba9d75eee7d1dd32d5ec3fa931ca5..42d2230dc9f8731ca28640f2c37f0261c70b4618 100644 --- a/src/ip_utils.cpp +++ b/src/ip_utils.cpp @@ -100,7 +100,7 @@ ip_utils::getHostName() // Cycle through available interfaces. for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { // Skip loopback, point-to-point and down interfaces. - // except don't skip down interfaces if we're trying to get + // except don't skip down interfaces if we're attempting to get // a list of configurable interfaces. if ((ifa->ifa_flags & IFF_LOOPBACK) || (!(ifa->ifa_flags & IFF_UP))) { continue; @@ -155,7 +155,7 @@ ip_utils::getHostName() strncpy(ifReq.ifr_name, pifReq->ifr_name, sizeof(ifReq.ifr_name)); ioctl(localSock, SIOCGIFFLAGS, &ifReq); // Skip loopback, point-to-point and down interfaces. - // except don't skip down interfaces if we're trying to get + // except don't skip down interfaces if we're attempting to get // a list of configurable interfaces. if ((ifReq.ifr_flags & IFF_LOOPBACK) || (!(ifReq.ifr_flags & IFF_UP))) { continue; @@ -205,7 +205,7 @@ ip_utils::getLocalGateway() char localHostBuf[INET_ADDRSTRLEN]; auto hostInfo = ip_utils::getHostName(); if (hostInfo.address.empty()) { - // JAMI_WARN("Couldn't find local host"); + // JAMI_WARN("Unable to find local host"); return {}; } else { return IpAddr(ip_utils::getGateway(hostInfo.address, ip_utils::subnet_mask::prefix_24bit)); @@ -270,14 +270,14 @@ ip_utils::getLocalAddr(pj_uint16_t family) if (status == PJ_SUCCESS) { return ip_addr; } - // JAMI_WARN("Could not get preferred address familly (%s)", + // JAMI_WARN("Unable to get preferred address family (%s)", // (family == pj_AF_INET6()) ? "IPv6" : "IPv4"); family = (family == pj_AF_INET()) ? pj_AF_INET6() : pj_AF_INET(); status = pj_gethostip(family, ip_addr.pjPtr()); if (status == PJ_SUCCESS) { return ip_addr; } - // JAMI_ERR("Could not get local IP"); + // JAMI_ERR("Unable to get local IP"); return ip_addr; } @@ -294,14 +294,14 @@ ip_utils::getInterfaceAddr(const std::string& interface, pj_uint16_t family) int fd = socket(unix_family, SOCK_DGRAM, 0); if (fd < 0) { - // JAMI_ERR("Could not open socket: %m"); + // JAMI_ERR("Unable to open socket: %m"); return addr; } if (unix_family == AF_INET6) { int val = family != pj_AF_UNSPEC(); if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void*) &val, sizeof(val)) < 0) { - // JAMI_ERR("Could not setsockopt: %m"); + // JAMI_ERR("Unable to setsockopt: %m"); close(fd); return addr; } diff --git a/src/security/certstore.cpp b/src/security/certstore.cpp index b78d63f793fecf56d045f727cc593775862d6290..629f4c780db7d9783ec4d0053d191ae4b8e61074 100644 --- a/src/security/certstore.cpp +++ b/src/security/certstore.cpp @@ -98,7 +98,7 @@ CertificateStore::loadRevocations(crypto::Certificate& crt) const fileutils::loadFile(crl))); } catch (const std::exception& e) { if (logger_) - logger_->warn("Can't load revocation list: %s", e.what()); + logger_->warn("Unable to load revocation list: %s", e.what()); } } @@ -126,7 +126,7 @@ CertificateStore::loadRevocations(crypto::Certificate& crt) const } } catch (const std::exception& e) { if (logger_) - logger_->warn("Can't load OCSP revocation status: {:s}", e.what()); + logger_->warn("Unable to load OCSP revocation status: {:s}", e.what()); } } } @@ -183,7 +183,7 @@ CertificateStore::getCertificateLegacy(const std::string& dataDir, const std::st } } catch (const std::exception& e) { if (logger_) - logger_->warn("Can't load certificate: {:s}", e.what()); + logger_->warn("Unable to load certificate: {:s}", e.what()); } return {}; } @@ -296,7 +296,7 @@ CertificateStore::pinCertificatePath(const std::string& path, ids.emplace_back(e.first->first); } catch (const std::exception& e) { if (logger_) - logger_->warn("Can't load certificate: {:s}", e.what()); + logger_->warn("Unable to load certificate: {:s}", e.what()); } } paths_.emplace(path, std::move(scerts)); @@ -432,7 +432,7 @@ CertificateStore::pinRevocationList(const std::string& id, pinRevocationList(id, *crl); } catch (...) { if (logger_) - logger_->warn("Can't add revocation list"); + logger_->warn("Unable to add revocation list"); } } @@ -576,7 +576,7 @@ TrustStore::setCertificateStatus(std::shared_ptr<crypto::Certificate> cert, crt_status.second.allowed = allowed; setStoreCertStatus(*cert, allowed); } else { - // Can't find certificate + // Unable to find certificate unknownCertStatus_[cert_id].allowed = allowed; } } else { diff --git a/src/security/diffie-hellman.cpp b/src/security/diffie-hellman.cpp index 9c69f8bba4aac22b19e88347cf2424ffd722441f..cfba7209f72313c07ab75a9e5c43b64b34ebc4c2 100644 --- a/src/security/diffie-hellman.cpp +++ b/src/security/diffie-hellman.cpp @@ -127,7 +127,7 @@ DhParams::loadDhParams(const std::filesystem::path& path) } return params; } - // JAMI_ERR("Can't generate DH params."); + // JAMI_ERR("Unable to generate DH params."); return {}; } } diff --git a/src/security/threadloop.h b/src/security/threadloop.h index 67b43ff432c722f5e7ea407d7f6fb1583cb1be50..b1cfdeffb9c7cd2d6e4e7856574c97d12bceb8e5 100644 --- a/src/security/threadloop.h +++ b/src/security/threadloop.h @@ -95,7 +95,7 @@ public: void wait_for(const std::chrono::duration<Rep, Period>& rel_time) { if (std::this_thread::get_id() != get_id()) - throw std::runtime_error("can not call wait_for outside thread context"); + throw std::runtime_error("Unable to call wait_for outside thread context"); std::unique_lock lk(mutex_); cv_.wait_for(lk, rel_time, [this]() { return isStopping(); }); @@ -105,7 +105,7 @@ public: bool wait_for(const std::chrono::duration<Rep, Period>& rel_time, Pred&& pred) { if (std::this_thread::get_id() != get_id()) - throw std::runtime_error("can not call wait_for outside thread context"); + throw std::runtime_error("Unable to call wait_for outside thread context"); std::unique_lock lk(mutex_); return cv_.wait_for(lk, rel_time, [this, pred] { return isStopping() || pred(); }); @@ -115,7 +115,7 @@ public: void wait(Pred&& pred) { if (std::this_thread::get_id() != get_id()) - throw std::runtime_error("Can not call wait outside thread context"); + throw std::runtime_error("Unable to call wait outside thread context"); std::unique_lock lk(mutex_); cv_.wait(lk, [this, p = std::forward<Pred>(pred)] { return isStopping() || p(); }); diff --git a/src/security/tls_session.cpp b/src/security/tls_session.cpp index 8d3539ae89404470f64480ae9f85fabc969bd52c..4e6952e439bdb873d1637c36e203b1d6ecfa9231 100644 --- a/src/security/tls_session.cpp +++ b/src/security/tls_session.cpp @@ -496,7 +496,7 @@ TlsSession::TlsSessionImpl::initCredentials() params_.ca_list.c_str(), GNUTLS_X509_FMT_DER); if (ret < 0) - throw std::runtime_error("can't load CA " + params_.ca_list + ": " + throw std::runtime_error("Unable to load CA " + params_.ca_list + ": " + std::string(gnutls_strerror(ret))); if (params_.logger) @@ -531,7 +531,7 @@ TlsSession::TlsSessionImpl::initCredentials() certs.size(), params_.cert_key->x509_key); if (ret < 0) - throw std::runtime_error("can't load certificate: " + std::string(gnutls_strerror(ret))); + throw std::runtime_error("Unable to load certificate: " + std::string(gnutls_strerror(ret))); if (params_.logger) params_.logger->d("[TLS] User identity loaded"); diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 1c94abcb408ea33296eda6746bd7c392b485201a..56533d160197b8561c9fde4b3e01705cfd5fd34d 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -44,11 +44,11 @@ to_wstring(const std::string& str, int codePage) int srcLength = (int) str.length(); int requiredSize = MultiByteToWideChar(codePage, 0, str.c_str(), srcLength, nullptr, 0); if (!requiredSize) { - throw std::runtime_error("Can't convert string to wstring"); + throw std::runtime_error("Unable to convert string to wstring"); } std::wstring result((size_t) requiredSize, 0); if (!MultiByteToWideChar(codePage, 0, str.c_str(), srcLength, &(*result.begin()), requiredSize)) { - throw std::runtime_error("Can't convert string to wstring"); + throw std::runtime_error("Unable to convert string to wstring"); } return result; } @@ -59,12 +59,12 @@ to_string(const std::wstring& wstr, int codePage) int srcLength = (int) wstr.length(); int requiredSize = WideCharToMultiByte(codePage, 0, wstr.c_str(), srcLength, nullptr, 0, 0, 0); if (!requiredSize) { - throw std::runtime_error("Can't convert wstring to string"); + throw std::runtime_error("Unable to convert wstring to string"); } std::string result((size_t) requiredSize, 0); if (!WideCharToMultiByte( codePage, 0, wstr.c_str(), srcLength, &(*result.begin()), requiredSize, 0, 0)) { - throw std::runtime_error("Can't convert wstring to string"); + throw std::runtime_error("Unable to convert wstring to string"); } return result; } @@ -76,7 +76,7 @@ to_string(double value) char buf[64]; int len = snprintf(buf, sizeof(buf), "%-.*G", 16, value); if (len <= 0) - throw std::invalid_argument {"can't parse double"}; + throw std::invalid_argument {"Unable to parse double"}; return {buf, (size_t) len}; } @@ -91,7 +91,7 @@ from_hex_string(const std::string& str) { uint64_t id; if (auto [p, ec] = std::from_chars(str.data(), str.data()+str.size(), id, 16); ec != std::errc()) { - throw std::invalid_argument("Can't parse id: " + str); + throw std::invalid_argument("Unable to parse id: " + str); } return id; } diff --git a/src/upnp/protocol/natpmp/nat_pmp.cpp b/src/upnp/protocol/natpmp/nat_pmp.cpp index 60d6bf5f2a824999b6db3fa86da64171b720fe23..c7e3d6f96c197a852a8a48fd3cbf30689c9e7de8 100644 --- a/src/upnp/protocol/natpmp/nat_pmp.cpp +++ b/src/upnp/protocol/natpmp/nat_pmp.cpp @@ -74,7 +74,7 @@ NatPmp::initNatPmp() igd_->setPublicIp(IpAddr()); igd_->setUID(""); - if (logger_) logger_->debug("NAT-PMP: Trying to initialize IGD"); + if (logger_) logger_->debug("NAT-PMP: Attempting to initialize IGD"); int err = initnatpmp(&natpmpHdl_, 0, 0); @@ -82,10 +82,10 @@ NatPmp::initNatPmp() if (logger_) logger_->warn("NAT-PMP: Initializing IGD using default gateway failed!"); const auto& localGw = ip_utils::getLocalGateway(); if (not localGw) { - if (logger_) logger_->warn("NAT-PMP: Couldn't find valid gateway on local host"); + if (logger_) logger_->warn("NAT-PMP: Unable to find valid gateway on local host"); err = NATPMP_ERR_CANNOTGETGATEWAY; } else { - if (logger_) logger_->warn("NAT-PMP: Trying to initialize using detected gateway {}", + if (logger_) logger_->warn("NAT-PMP: Attempting to initialize using detected gateway {}", localGw.toString()); struct in_addr inaddr; inet_pton(AF_INET, localGw.toString().c_str(), &inaddr); @@ -94,7 +94,7 @@ NatPmp::initNatPmp() } if (err < 0) { - if (logger_) logger_->error("NAT-PMP: Can't initialize libnatpmp -> {}", getNatPmpErrorStr(err)); + if (logger_) logger_->error("NAT-PMP: Unable to initialize libnatpmp -> {}", getNatPmpErrorStr(err)); return; } @@ -206,7 +206,7 @@ NatPmp::searchForIgd() } }); } else { - if (logger_) logger_->warn("NAT-PMP: Setup failed after {} trials. NAT-PMP will be disabled!", + if (logger_) logger_->warn("NAT-PMP: Setup failed after {} attempts. NAT-PMP will be disabled!", MAX_RESTART_SEARCH_RETRIES); } } @@ -440,7 +440,7 @@ NatPmp::sendMappingRequest(Mapping& mapping, uint32_t& lifetime) if (!responseValid) { // Unfortunately, libnatpmp only allows reading one response per request sent; calling // readResponse again at this point would result in a NATPMP_ERR_NOPENDINGREQ error. - // Since we can't know whether the mapping was actually created or not, we return an + // Since it is unable to known whether the mapping was actually created or not, we return an // error to ensure the caller won't attempt to use a port mapping that doesn't exist. return NATPMP_ERR_INVALIDARGS; } diff --git a/src/upnp/protocol/pupnp/pupnp.cpp b/src/upnp/protocol/pupnp/pupnp.cpp index afb110a8778731d9bea7803cb76ed16d485143e1..b49a43a6bdf38ae2d550a745e7b5c92622ec3f15 100644 --- a/src/upnp/protocol/pupnp/pupnp.cpp +++ b/src/upnp/protocol/pupnp/pupnp.cpp @@ -29,7 +29,7 @@ constexpr static const char* ACTION_GET_GENERIC_PORT_MAPPING_ENTRY {"GetGenericP constexpr static const char* ACTION_GET_STATUS_INFO {"GetStatusInfo"}; constexpr static const char* ACTION_GET_EXTERNAL_IP_ADDRESS {"GetExternalIPAddress"}; -// Error codes returned by router when trying to remove ports. +// Error codes returned by router when attempting to remove ports. constexpr static int ARRAY_IDX_INVALID = 713; constexpr static int CONFLICT_IN_MAPPING = 718; @@ -119,21 +119,21 @@ PUPnP::initUpnpLib() initialized_ = true; return; }else { - if (logger_) logger_->error("PUPnP: Can't initialize libupnp: {}", UpnpGetErrorMessage(upnp_err)); + if (logger_) logger_->error("PUPnP: Unable to initialize libupnp: {}", UpnpGetErrorMessage(upnp_err)); UpnpFinish(); initialized_ = false; return; } } - // Disable embedded WebServer if any. + // Disable embedded Web server if any. if (UpnpIsWebserverEnabled() == 1) { - if (logger_) logger_->warn("PUPnP: Web-server is enabled. Disabling"); + if (logger_) logger_->warn("PUPnP: Web server is enabled. Disabling"); UpnpEnableWebserver(0); if (UpnpIsWebserverEnabled() == 1) { - if (logger_) logger_->error("PUPnP: Could not disable Web-server!"); + if (logger_) logger_->error("PUPnP: Unable to disable Web server!"); } else { - if (logger_) logger_->debug("PUPnP: Web-server successfully disabled"); + if (logger_) logger_->debug("PUPnP: Web server successfully disabled"); } } @@ -173,7 +173,7 @@ PUPnP::registerClient() // Register Upnp control point. int upnp_err = UpnpRegisterClient(ctrlPtCallback, this, &ctrlptHandle_); if (upnp_err != UPNP_E_SUCCESS) { - if (logger_) logger_->error("PUPnP: Can't register client: {}", UpnpGetErrorMessage(upnp_err)); + if (logger_) logger_->error("PUPnP: Unable to register client: {}", UpnpGetErrorMessage(upnp_err)); } else { if (logger_) logger_->debug("PUPnP: Successfully registered client"); clientRegistered_ = true; @@ -321,7 +321,7 @@ PUPnP::searchForIgd() } if (igdSearchCounter_++ >= PUPNP_MAX_RESTART_SEARCH_RETRIES) { - if (logger_) logger_->warn("PUPnP: Setup failed after {:d} trials. PUPnP will be disabled!", + if (logger_) logger_->warn("PUPnP: Setup failed after {:d} attempts. PUPnP will be disabled!", PUPNP_MAX_RESTART_SEARCH_RETRIES); return; } @@ -492,7 +492,7 @@ PUPnP::validateIgd(const std::string& location, IXML_Document* doc_container_ptr if (const auto& localGw = ip_utils::getLocalGateway()) { igd_candidate->setLocalIp(localGw); } else { - if (logger_) logger_->warn("PUPnP: Could not set internal address for IGD candidate {}", + if (logger_) logger_->warn("PUPnP: Unable to set internal address for IGD candidate {}", igd_candidate->getUID().c_str()); return false; } @@ -856,7 +856,7 @@ PUPnP::downLoadIgdDescription(const std::string& locationUrl) int upnp_err = UpnpDownloadXmlDoc(locationUrl.c_str(), &doc_container_ptr); std::lock_guard lk(ongoingOpsMtx_); - // Trying to use libupnp functions after UpnpFinish has been called (which may + // Attempting to use libupnp functions after UpnpFinish has been called (which may // be the case if destroying_ is true) can cause errors. It's probably not a // problem here, but return early just in case. if (destroying_) @@ -1029,7 +1029,7 @@ PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event) auto actionRequest = UpnpActionComplete_get_ActionRequest(a_event); // Abort if there is no action to process. if (actionRequest == nullptr) { - if (logger_) logger_->warn("PUPnP: Can't get the Action Request data from the event"); + if (logger_) logger_->warn("PUPnP: Unable to get the Action Request data from the event"); break; } @@ -1089,7 +1089,7 @@ PUPnP::parseIgd(IXML_Document* doc, std::string locationUrl) // Check the UDN to see if its already in our device list. std::string UDN(getFirstDocItem(doc, "UDN")); if (UDN.empty()) { - if (logger_) logger_->warn("PUPnP: could not find UDN in description document of device"); + if (logger_) logger_->warn("PUPnP: Unable to find UDN in description document of device"); return nullptr; } else { std::lock_guard lk(pupnpMutex_); diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp index b7ec7c99fa633c77f564f3787fed1716b030cc94..5a3d8a284bcc7e4df746229236c3fba6dd79a421 100644 --- a/src/upnp/upnp_context.cpp +++ b/src/upnp/upnp_context.cpp @@ -395,7 +395,7 @@ UPnPContext::releaseMapping(const Mapping& map) } if (mapPtr->isAvailable()) { - if (logger_) logger_->warn("Trying to release an unused mapping {}", mapPtr->toString()); + if (logger_) logger_->warn("Attempting to release an unused mapping {}", mapPtr->toString()); return; } @@ -488,7 +488,7 @@ UPnPContext::getAvailablePortNumber(PortType type) } // Very unlikely to get here. - if (logger_) logger_->error("Could not find an available port after {} trials", MAX_REQUEST_RETRIES); + if (logger_) logger_->error("Unable to find an available port after {} attempts", MAX_REQUEST_RETRIES); return 0; } @@ -534,7 +534,7 @@ UPnPContext::provisionNewMappings(PortType type, int portCount) registerMapping(map); } else { // Very unlikely to get here! - if (logger_) logger_->error("Cannot provision port: no available port number"); + if (logger_) logger_->error("Unable to provision port: no available port number"); return; } } @@ -609,7 +609,7 @@ UPnPContext::updateCurrentIgd() currentIgd_->getUID(), currentIgd_->toString()); } else { - if (logger_) logger_->warn("Couldn't update current IGD: no valid IGD was found"); + if (logger_) logger_->warn("Unable to update current IGD: no valid IGD was found"); } } @@ -680,7 +680,7 @@ UPnPContext::renewMappings() const auto& igd = getCurrentIgd(); if (!igd) { - if (logger_) logger_->debug("Cannot renew mappings: no valid IGD available"); + if (logger_) logger_->debug("Unable to renew mappings: no valid IGD available"); return; } @@ -1223,7 +1223,7 @@ UPnPContext::unregisterMapping(const Mapping::sharedPtr_t& map) if (logger_) logger_->debug("Unregistered mapping {}", map->toString()); } else { // The mapping may already be un-registered. Just ignore it. - if (logger_) logger_->debug("Can't unregister mapping {} [{}] since it doesn't have a local match", + if (logger_) logger_->debug("Unable to unregister mapping {} [{}] since it doesn't have a local match", map->toString(), map->getProtocolName()); } diff --git a/tools/dhtnet_crtmgr/main.cpp b/tools/dhtnet_crtmgr/main.cpp index 4705e94492be65111a9ea51adf6effcfb14ec6ad..34e9ab259c7e159566a91b35f672f8069e456938 100644 --- a/tools/dhtnet_crtmgr/main.cpp +++ b/tools/dhtnet_crtmgr/main.cpp @@ -153,7 +153,7 @@ int create_yaml_config(std::filesystem::path file, std::filesystem::path certifi yaml_file.close(); Log("Configuration file created in {}\n", file); } else { - fmt::print(stderr, "Error: Could not create configuration file {}.\n", file); + fmt::print(stderr, "Error: Unable to create configuration file {}.\n", file); return 1; } return 0; @@ -163,7 +163,7 @@ int configure_ssh_config(std::filesystem::path yaml_config) { std::filesystem::path home_dir = getenv("HOME"); if (home_dir.empty()) { - fmt::print(stderr, "Error: HOME environment variable is not set. Cannot configure SSH.\n"); + fmt::print(stderr, "Error: HOME environment variable is not set. Unable to configure SSH.\n"); return 1; } std::filesystem::path ssh_dir = home_dir / ".ssh"; @@ -189,7 +189,7 @@ int configure_ssh_config(std::filesystem::path yaml_config) ssh_file.close(); Log("SSH configuration added to {}\n", ssh_config); } else { - fmt::print(stderr, "Error: Could not open ssh config file.\n"); + fmt::print(stderr, "Error: Unable to open ssh config file.\n"); return 1; } return 0; @@ -287,7 +287,7 @@ main(int argc, char** argv) std::error_code e; std::filesystem::create_directories(folder, e); if (e) { - fmt::print(stderr, "Error: Could not create directory {}. {}\n", folder, e.message()); + fmt::print(stderr, "Error: Unable to create directory {}. {}\n", folder, e.message()); return EXIT_FAILURE; } @@ -303,13 +303,13 @@ main(int argc, char** argv) } } catch (const std::exception& e) { - fmt::print(stderr, "Error: Could not load server CA. Please generate server CA first.\n"); + fmt::print(stderr, "Error: Unable to load server CA. Please generate server CA first.\n"); return EXIT_FAILURE; } } else { ca = dhtnet::generateIdentity(folder, "ca"); if (!ca.first || !ca.second) { - fmt::print(stderr, "Error: Could not generate CA.\n"); + fmt::print(stderr, "Error: Unable to generate CA.\n"); return EXIT_FAILURE; } Log("Generated CA in {}: {} {}\n", folder, "ca", ca.second->getId()); @@ -318,7 +318,7 @@ main(int argc, char** argv) // Generate client certificate auto id = dhtnet::generateIdentity(folder, "certificate", ca); if (!id.first || !id.second) { - fmt::print(stderr, "Error: Could not generate certificate.\n"); + fmt::print(stderr, "Error: Unable to generate certificate.\n"); return EXIT_FAILURE; } Log("Generated certificate in {}: {} {}\n", folder, "certificate", id.second->getId()); @@ -379,7 +379,7 @@ main(int argc, char** argv) std::filesystem::path path_ca = params.output / "CA"; auto ca = dhtnet::generateIdentity(path_ca, "ca-server"); if (!ca.first || !ca.second) { - fmt::print(stderr, "Error: Could not generate CA.\n"); + fmt::print(stderr, "Error: Unable to generate CA.\n"); return EXIT_FAILURE; } Log("Generated CA in {}: {} {}\n", path_ca, "ca-server", ca.second->getId()); @@ -387,7 +387,7 @@ main(int argc, char** argv) std::filesystem::path path_id = params.output / "id"; auto identity = dhtnet::generateIdentity(path_id, "id-server", ca); if (!identity.first || !identity.second) { - fmt::print(stderr, "Error: Could not generate certificate.\n"); + fmt::print(stderr, "Error: Unable to generate certificate.\n"); return EXIT_FAILURE; } Log("Generated certificate in {}: {} {}\n", path_id,"id-server", identity.second->getId()); @@ -398,14 +398,14 @@ main(int argc, char** argv) if (params.name.empty()) { auto ca = dhtnet::generateIdentity(params.output, "ca"); if (!ca.first || !ca.second) { - fmt::print(stderr, "Error: Could not generate CA.\n"); + fmt::print(stderr, "Error: Unable to generate CA.\n"); return EXIT_FAILURE; } Log("Generated certificate in {}: {} {}\n", params.output, "ca", ca.second->getId()); }else{ auto ca = dhtnet::generateIdentity(params.output, params.name); if (!ca.first || !ca.second) { - fmt::print(stderr, "Error: Could not generate CA.\n"); + fmt::print(stderr, "Error: Unable to generate CA.\n"); return EXIT_FAILURE; } Log("Generated certificate in {}: {} {}\n", params.output, params.name, ca.second->getId()); @@ -415,14 +415,14 @@ main(int argc, char** argv) if (params.name.empty()) { auto id = dhtnet::generateIdentity(params.output, "certificate", ca); if (!id.first || !id.second) { - fmt::print(stderr, "Error: Could not generate certificate.\n"); + fmt::print(stderr, "Error: Unable to generate certificate.\n"); return EXIT_FAILURE; } Log("Generated certificate in {}: {} {}\n", params.output, "certificate", id.second->getId()); }else{ auto id = dhtnet::generateIdentity(params.output, params.name, ca); if (!id.first || !id.second) { - fmt::print(stderr, "Error: Could not generate certificate.\n"); + fmt::print(stderr, "Error: Unable to generate certificate.\n"); return EXIT_FAILURE; } Log("Generated certificate in {}: {} {}\n", params.output, params.name, id.second->getId()); diff --git a/tools/dnc/main.cpp b/tools/dnc/main.cpp index f759ff5087c369c6b688d4e04f505b6b572070dc..9ff8c2cc244b3757acff6a7346ed362bed85f897 100644 --- a/tools/dnc/main.cpp +++ b/tools/dnc/main.cpp @@ -149,7 +149,7 @@ parse_args(int argc, char** argv) Log("Read configuration file: {}\n", params.configuration.c_str()); std::ifstream config_file(params.configuration); if (!config_file.is_open()) { - std::cerr << "Error: Could not open configuration file.\n"; + std::cerr << "Error: Unable to open configuration file.\n"; } else { YAML::Node config = YAML::Load(config_file); if (config["bootstrap"] && params.bootstrap.empty()) { diff --git a/tools/dsh/main.cpp b/tools/dsh/main.cpp index 4859ab139b28c4f22113304aa9337929073057ce..4c5d4c12b0172832473fe5e06f5222cbdb56ea29 100644 --- a/tools/dsh/main.cpp +++ b/tools/dsh/main.cpp @@ -135,7 +135,7 @@ parse_args(int argc, char** argv) printf("read configuration file: %s\n", params.configuration.c_str()); std::ifstream config_file(params.configuration); if (!config_file.is_open()) { - std::cerr << "Error: Could not open configuration file.\n"; + std::cerr << "Error: Unable to open configuration file.\n"; } else { YAML::Node config = YAML::Load(config_file); if (config["bootstrap"] && params.bootstrap.empty()) { diff --git a/tools/dvpn/main.cpp b/tools/dvpn/main.cpp index 1cf3ec9467e99cfecb862104ba32fb60aa904440..67537393aebc86fd5297a919e9a593f6b4970f4f 100644 --- a/tools/dvpn/main.cpp +++ b/tools/dvpn/main.cpp @@ -122,7 +122,7 @@ parse_args(int argc, char** argv) printf("read configuration file: %s\n", params.configuration.c_str()); std::ifstream config_file(params.configuration); if (!config_file.is_open()) { - std::cerr << "Error: Could not open configuration file.\n"; + std::cerr << "Error: Unable to open configuration file.\n"; } else { YAML::Node config = YAML::Load(config_file); if (config["bootstrap"] && params.bootstrap.empty()) {