handle ip modes & add compilation flags for windows build

This commit is contained in:
Aryan Arora
2024-04-24 15:41:40 +05:30
committed by Kelson
parent a6cf161341
commit b7eadf95bf
8 changed files with 44 additions and 57 deletions

View File

@ -16,6 +16,7 @@
namespace kiwix {
enum class IpMode { ipv4, ipv6, all };
typedef zim::size_type size_type;
typedef zim::offset_type offset_type;

View File

@ -22,6 +22,7 @@
#include <string>
#include <memory>
#include "common.h"
namespace kiwix
{
@ -62,10 +63,10 @@ namespace kiwix
{ m_withTaskbar = withTaskbar; m_withLibraryButton = withLibraryButton; }
void setBlockExternalLinks(bool blockExternalLinks)
{ m_blockExternalLinks = blockExternalLinks; }
void setIPv6(bool ipv6) { m_ipv6 = ipv6; }
void setIpMode(IpMode mode) { m_ipMode = mode; }
int getPort();
std::string getAddress();
bool isAddressIPv6();
IpMode getIpMode() const;
protected:
std::shared_ptr<Library> mp_library;
@ -80,7 +81,7 @@ namespace kiwix
bool m_withTaskbar = true;
bool m_withLibraryButton = true;
bool m_blockExternalLinks = false;
bool m_ipv6 = false;
IpMode m_ipMode = IpMode::ipv4;
int m_ipConnectionLimit = 0;
std::unique_ptr<InternalServer> mp_server;
};

View File

@ -25,12 +25,12 @@
#include <map>
#include <cstdint>
struct ip_addr{
namespace kiwix {
struct IpAddress{
std::string addr;
std::string addr6;
};
namespace kiwix {
typedef std::pair<std::string, std::string> LangNameCodePair;
typedef std::vector<LangNameCodePair> FeedLanguages;
typedef std::vector<std::string> FeedCategories;
@ -220,23 +220,11 @@ bool fileReadable(const std::string& path);
*/
std::string getMimeTypeForFile(const std::string& filename);
/** Provides all available network interfaces on Windows
*
* This function provides the available IPv4 and IPv6 network interfaces
*/
std::map<std::string,ip_addr> getNetworkInterfacesWin();
/** Provides all available network interfaces on Posix
*
* This function provides the available IPv4 and IPv6 network interfaces
*/
std::map<std::string,ip_addr> getNetworkInterfacesPosix();
/** Provides all available network interfaces
*
* This function provides the available IPv4 and IPv6 network interfaces
*/
std::map<std::string,ip_addr> getNetworkInterfaces();
std::map<std::string,IpAddress> getNetworkInterfaces();
/** Provides the best IP address
* This function provides the best IP address from the list given by getNetworkInterfaces