Compare commits

..

4 Commits

Author SHA1 Message Date
sgourdas
528a532b27 fixup! Get ipv4 working on dual stack 2024-10-06 13:24:52 +03:00
sgourdas
fa410f739c Fix Server::setAddress 2024-10-05 15:24:21 +03:00
sgourdas
5f1f37bd2a kiwix-serve: Error message reword 2024-10-05 12:04:45 +03:00
sgourdas
5855791899 kiwix-serve: Disable IPV6_ONLY on Windows 2024-10-05 12:01:40 +03:00
5 changed files with 36 additions and 15 deletions

View File

@@ -38,6 +38,9 @@ jobs:
- name: Install packages
run: |
brew update
brew unlink python3
# upgrade from python@3.12 to python@3.12.2 fails to overwrite those
rm -f /usr/local/bin/2to3 /usr/local/bin/2to3-3.12 /usr/local/bin/idle3 /usr/local/bin/idle3.12 /usr/local/bin/pydoc3 /usr/local/bin/pydoc3.12 /usr/local/bin/python3 /usr/local/bin/python3-config /usr/local/bin/python3.12 /usr/local/bin/python3.12-config
brew install pkg-config ninja meson
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1

View File

@@ -515,7 +515,28 @@ bool InternalServer::start() {
struct sockaddr* sockaddr = (m_ipMode==IpMode::ALL || m_ipMode==IpMode::IPV6)
? (struct sockaddr*)&sockAddr6
: (struct sockaddr*)&sockAddr4;
#ifdef _WIN32
SOCKET sock = INVALID_SOCKET;
if (m_ipMode == IpMode::ALL || m_ipMode == IpMode::IPV6) {
if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) == INVALID_SOCKET) {
std::cerr << "ERROR: Failed to create IPv6 socket" << std::endl;
return false;
}
int opt = 0;
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&opt, sizeof(opt)) != 0) {
std::cerr << "ERROR: Failed to set IPV6_V6ONLY option" << std::endl;
closesocket(sock);
return false;
}
if (::bind(sock, (struct sockaddr*)&sockAddr6, sizeof(sockAddr6)) == SOCKET_ERROR) {
std::cerr << "ERROR: Failed to bind IPv6 socket" << std::endl;
closesocket(sock);
return false;
}
}
#endif
mp_daemon = MHD_start_daemon(flags,
m_port,
NULL,
@@ -523,14 +544,21 @@ bool InternalServer::start() {
&staticHandlerCallback,
this,
MHD_OPTION_SOCK_ADDR, sockaddr,
#ifdef _WIN32
(sock == INVALID_SOCKET) ? MHD_OPTION_END : MHD_OPTION_LISTEN_SOCKET, sock,
#endif
MHD_OPTION_THREAD_POOL_SIZE, m_nbThreads,
MHD_OPTION_PER_IP_CONNECTION_LIMIT, m_ipConnectionLimit,
MHD_OPTION_END);
if (mp_daemon == nullptr) {
std::cerr << "Unable to instantiate the HTTP daemon. The port " << m_port
<< " is maybe already occupied or need more permissions to be open. "
std::cerr << "ERROR: Unable to instantiate the HTTP daemon. The port " << m_port
<< " may already be in use, or more permissions are required to open it. "
"Please try as root or with a port number higher or equal to 1024."
<< std::endl;
#ifdef _WIN32
if (sock != INVALID_SOCKET) closesocket(sock);
#endif
return false;
}
auto server_start_time = std::chrono::system_clock::now().time_since_epoch();

View File

@@ -229,7 +229,7 @@ IpAddress getBestPublicIps() {
}
}
#endif
const char* const v4prefixes[] = { "192.168", "172.16", "10.0" };
const char* const v4prefixes[] = { "192.168", "172.16", "10.0", "169.254" };
for (const auto& prefix : v4prefixes) {
for (const auto& kv : interfaces) {
const auto& interfaceIps = kv.second;

View File

@@ -60,15 +60,5 @@
"download-links-heading": "Discargar ligamines pro <b><i>{{BOOK_TITLE}}</i></b>",
"download-links-title": "Discargar libro",
"preview-book": "Previsualisation",
"unknown-error": "Error incognite",
"book-category.wikibooks": "Wikilibros",
"book-category.wikinews": "Wikinovas",
"book-category.wikipedia": "Wikipedia",
"book-category.wikiquote": "Wikiquote",
"book-category.wikisource": "Wikisource",
"book-category.wikispecies": "Wikispecies",
"book-category.wikiversity": "Wikiversitate",
"book-category.wikivoyage": "Wikiviage",
"book-category.wiktionary": "Wiktionario",
"book-category.other": "Altere"
"unknown-error": "Error incognite"
}

View File

@@ -17,7 +17,7 @@
"no-book-found": "没有符合搜索要求的图书",
"url-not-found": "在此服务器上找不到请求的 URL{{url}}",
"suggest-search": "对<a href=\"{{{SEARCH_URL}}}\">{{PATTERN}}</a>进行全文搜索",
"random-article-failure": "抱歉! 随机条目失败了 (⁠〒⁠﹏⁠〒⁠)",
"random-article-failure": "抱歉! 随机条目失败了 (⁠〒⁠﹏⁠〒⁠) 【好生草的表情(】",
"invalid-raw-data-type": "{{DATATYPE}} 对原请求无效。",
"invalid-request": "请求的URL无效{{{url}}}",
"no-value-for-arg": "参数{{ARGUMENT}}无值",