Fixed windows
This commit is contained in:
parent
6e2d901bf6
commit
1c448ed41c
@ -138,8 +138,6 @@ set(SOURCE_FILES
|
||||
src/protocol/ringbuffer.cpp
|
||||
src/protocol/AcknowledgeManager.cpp
|
||||
src/protocol/PacketLossCalculator.cpp
|
||||
|
||||
src/lookup/ip.cpp
|
||||
)
|
||||
|
||||
set(HEADER_FILES
|
||||
@ -219,6 +217,7 @@ if (TEASPEAK_SERVER)
|
||||
|
||||
set(SOURCE_FILES ${SOURCE_FILES}
|
||||
src/BasicChannel.cpp
|
||||
src/lookup/ip.cpp
|
||||
)
|
||||
|
||||
set(HEADER_FILES ${HEADER_FILES}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "misc/spin_mutex.h"
|
||||
#include "Definitions.h"
|
||||
#include "Variable.h"
|
||||
#include "spdlog/fmt/ostr.h" // must be included
|
||||
|
||||
#define permNotGranted (-2)
|
||||
#define PERM_ID_GRANT ((ts::permission::PermissionType) (1U << 15U))
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <utility>
|
||||
#include "misc/memtracker.h"
|
||||
#include <ThreadPool/Mutex.h>
|
||||
#include "Variable.h"
|
||||
#include <map>
|
||||
#include <deque>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "bbcodes.h"
|
||||
|
||||
using namespace std;
|
||||
@ -7,8 +8,9 @@ using namespace bbcode;
|
||||
|
||||
bool bbcode::sloppy::has_tag(std::string message, std::deque<std::string> tag) {
|
||||
std::transform(message.begin(), message.end(), message.begin(), ::tolower);
|
||||
for(auto& entry : tag)
|
||||
for(auto& entry : tag) {
|
||||
std::transform(entry.begin(), entry.end(), entry.begin(), ::tolower);
|
||||
}
|
||||
|
||||
std::deque<std::string> begins;
|
||||
size_t index = 0, found, length = 0;
|
||||
@ -17,17 +19,23 @@ bool bbcode::sloppy::has_tag(std::string message, std::deque<std::string> tag) {
|
||||
for(auto it = tag.begin(); it != tag.end() && found == string::npos; it++) {
|
||||
found = message.find(*it, index);
|
||||
length = it->length();
|
||||
};
|
||||
}
|
||||
|
||||
if(found > 0 && found + length < message.length()) {
|
||||
if(message[found + length] == ']' || (message[found + length] == '=' && message.find(']', found + length) != string::npos)) {
|
||||
if(message[found - 1] == '/') {
|
||||
auto found_tag = message.substr(found, length);
|
||||
for(const auto& entry : begins)
|
||||
if(entry == found_tag) return true;
|
||||
} else if(message[found - 1] == '[' && (found < 2 || message[found - 2] != '\\'))
|
||||
for(const auto& entry : begins) {
|
||||
if(entry == found_tag) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if(message[found - 1] == '[' && (found < 2 || message[found - 2] != '\\')) {
|
||||
begins.push_back(message.substr(found, length));
|
||||
if(message[found + length] != ']')
|
||||
}
|
||||
if(message[found + length] != ']') {
|
||||
found = message.find(']', found + length);
|
||||
}
|
||||
}
|
||||
}
|
||||
index = found + 1;
|
||||
|
@ -3,44 +3,32 @@
|
||||
#include <netinet/in.h>
|
||||
#include "./ip.h"
|
||||
|
||||
namespace lookup {
|
||||
namespace ipv4_impl {
|
||||
union uaddress_t {
|
||||
struct {
|
||||
uint32_t address{0};
|
||||
uint16_t port{0};
|
||||
};
|
||||
|
||||
uint64_t value;
|
||||
namespace lookup::ipv4_impl {
|
||||
union uaddress_t {
|
||||
struct {
|
||||
uint32_t address;
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
struct converter {
|
||||
constexpr inline void operator()(uaddress_t& result, const sockaddr_in& addr) {
|
||||
result.address = addr.sin_addr.s_addr;
|
||||
result.port = addr.sin_port;
|
||||
}
|
||||
};
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
struct comparator {
|
||||
constexpr inline bool operator()(const uaddress_t& a, const uaddress_t& b) {
|
||||
return a.value == b.value;
|
||||
}
|
||||
};
|
||||
struct converter {
|
||||
constexpr inline void operator()(uaddress_t& result, const sockaddr_in& addr) {
|
||||
result.address = addr.sin_addr.s_addr;
|
||||
result.port = addr.sin_port;
|
||||
}
|
||||
};
|
||||
|
||||
struct hash {
|
||||
constexpr inline uint8_t operator()(const sockaddr_in& address) {
|
||||
return (address.sin_addr.s_addr & 0xFFU) ^ (address.sin_port);
|
||||
}
|
||||
};
|
||||
}
|
||||
struct comparator {
|
||||
constexpr inline bool operator()(const uaddress_t& a, const uaddress_t& b) {
|
||||
return a.value == b.value;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using ip_v4 = ip_vx<
|
||||
T,
|
||||
sockaddr_in,
|
||||
ipv4_impl::uaddress_t,
|
||||
ipv4_impl::converter,
|
||||
ipv4_impl::comparator,
|
||||
ipv4_impl::hash
|
||||
>;
|
||||
struct hash {
|
||||
constexpr inline uint8_t operator()(const sockaddr_in& address) {
|
||||
return (address.sin_addr.s_addr & 0xFFU) ^ (address.sin_port);
|
||||
}
|
||||
};
|
||||
}
|
@ -1,53 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "./ip.h"
|
||||
|
||||
namespace lookup {
|
||||
namespace ipv6_impl {
|
||||
struct address_t {
|
||||
union {
|
||||
uint64_t address_u64[ 2];
|
||||
};
|
||||
|
||||
uint16_t port;
|
||||
namespace lookup::ipv6_impl {
|
||||
struct address_t {
|
||||
union {
|
||||
uint64_t address_u64[ 2];
|
||||
};
|
||||
|
||||
struct converter {
|
||||
constexpr inline void operator()(address_t& result, const sockaddr_in6& addr) {
|
||||
auto addr_ptr = (uint64_t*) &addr.sin6_addr;
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
result.address_u64[0] = addr_ptr[0];
|
||||
result.address_u64[1] = addr_ptr[1];
|
||||
struct converter {
|
||||
constexpr inline void operator()(address_t& result, const sockaddr_in6& addr) {
|
||||
auto addr_ptr = (uint64_t*) &addr.sin6_addr;
|
||||
|
||||
result.port = addr.sin6_port;
|
||||
}
|
||||
};
|
||||
result.address_u64[0] = addr_ptr[0];
|
||||
result.address_u64[1] = addr_ptr[1];
|
||||
|
||||
struct comparator {
|
||||
constexpr inline bool operator()(const address_t& a, const address_t& b) {
|
||||
return a.address_u64[0] == b.address_u64[0] && a.address_u64[1] == b.address_u64[1] && a.port == b.port;
|
||||
}
|
||||
};
|
||||
result.port = addr.sin6_port;
|
||||
}
|
||||
};
|
||||
|
||||
struct hash {
|
||||
constexpr inline uint8_t operator()(const sockaddr_in6& address) {
|
||||
auto addr_ptr = (uint8_t*) &address.sin6_addr;
|
||||
struct comparator {
|
||||
constexpr inline bool operator()(const address_t& a, const address_t& b) {
|
||||
return a.address_u64[0] == b.address_u64[0] && a.address_u64[1] == b.address_u64[1] && a.port == b.port;
|
||||
}
|
||||
};
|
||||
|
||||
return (uint8_t) (addr_ptr[8] ^ addr_ptr[9]) ^ (uint8_t) (addr_ptr[15] ^ address.sin6_port);
|
||||
}
|
||||
};
|
||||
}
|
||||
struct hash {
|
||||
constexpr inline uint8_t operator()(const sockaddr_in6& address) {
|
||||
auto addr_ptr = (uint8_t*) &address.sin6_addr;
|
||||
|
||||
template <typename T>
|
||||
using ip_v6 = ip_vx<
|
||||
T,
|
||||
sockaddr_in6,
|
||||
ipv6_impl::address_t,
|
||||
ipv6_impl::converter,
|
||||
ipv6_impl::comparator,
|
||||
ipv6_impl::hash
|
||||
>;
|
||||
return (uint8_t) (addr_ptr[8] ^ addr_ptr[9]) ^ (uint8_t) (addr_ptr[15] ^ address.sin6_port);
|
||||
}
|
||||
};
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
//#define NO_OPEN_SSL /* because we're lazy and dont want to build this lib extra for the TeaClient */
|
||||
#define FIXEDINT_H_INCLUDED /* else it will be included by ge */
|
||||
|
||||
#include "misc/endianness.h"
|
||||
#include <ed25519/ed25519.h>
|
||||
#include <stdint.h>
|
||||
#include <ed25519/ge.h>
|
||||
#include <log/LogUtils.h>
|
||||
#include "misc/memtracker.h"
|
||||
#include "misc/digest.h"
|
||||
#include "CryptHandler.h"
|
||||
#include <ed25519/ed25519.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "./CryptHandler.h"
|
||||
#include "../misc/endianness.h"
|
||||
#include "../misc/memtracker.h"
|
||||
#include "../misc/digest.h"
|
||||
#include "../misc/sassert.h"
|
||||
|
||||
using namespace std;
|
||||
@ -69,7 +70,7 @@ bool CryptHandler::setupSharedSecret(const std::string& alpha, const std::string
|
||||
}
|
||||
|
||||
{
|
||||
lock_guard lock(this->cache_key_lock);
|
||||
std::lock_guard lock(this->cache_key_lock);
|
||||
memcpy(this->iv_struct, iv_buffer, SHA_DIGEST_LENGTH);
|
||||
this->iv_struct_length = SHA_DIGEST_LENGTH;
|
||||
|
||||
@ -171,7 +172,9 @@ bool CryptHandler::generate_key_nonce(
|
||||
) {
|
||||
auto& key_cache_array = to_server ? this->cache_key_client : this->cache_key_server;
|
||||
if(type < 0 || type >= key_cache_array.max_size()) {
|
||||
#if 0
|
||||
logError(0, "Tried to generate a crypt key with invalid type ({})!", type);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -180,7 +183,7 @@ bool CryptHandler::generate_key_nonce(
|
||||
auto& key_cache = key_cache_array[type];
|
||||
if(key_cache.generation != generation) {
|
||||
const size_t buffer_length = 6 + this->iv_struct_length;
|
||||
sassert(buffer_length < GENERATE_BUFFER_LENGTH);
|
||||
assert(buffer_length < GENERATE_BUFFER_LENGTH);
|
||||
|
||||
char buffer[GENERATE_BUFFER_LENGTH];
|
||||
memset(buffer, 0, buffer_length);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <array>
|
||||
#include <pipes/buffer.h>
|
||||
#include "../query/Command.h"
|
||||
|
||||
|
@ -11,10 +11,6 @@
|
||||
#include "./Packet.h"
|
||||
#include "../misc/queue.h"
|
||||
|
||||
#ifndef NO_LOG
|
||||
#include <log/LogUtils.h>
|
||||
#endif
|
||||
|
||||
namespace ts::buffer {
|
||||
struct RawBuffer {
|
||||
public:
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef byte
|
||||
#define byte asdd
|
||||
#ifndef WIN32
|
||||
#warning The byte macro is already defined! Undefining it!
|
||||
#endif
|
||||
@ -18,17 +17,18 @@
|
||||
#include "../Variable.h"
|
||||
|
||||
namespace ts {
|
||||
#define PARM_TYPE(type, fromString, toString) \
|
||||
BaseCommandParm(std::string key, type value) : BaseCommandParm(std::pair<std::string, std::string>(key, "")) {\
|
||||
toString; \
|
||||
} \
|
||||
BaseCommandParm& operator=(type value){ \
|
||||
toString; \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
operator type(){ \
|
||||
fromString; \
|
||||
#define PARM_TYPE(type, fromString, toString) \
|
||||
BaseCommandParm(std::string key, type value) : BaseCommandParm(std::pair<std::string, std::string>(key, "")) { \
|
||||
toString; \
|
||||
} \
|
||||
\
|
||||
BaseCommandParm& operator=(type value){ \
|
||||
toString; \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
operator type() { \
|
||||
fromString; \
|
||||
}
|
||||
|
||||
class Command;
|
||||
@ -43,7 +43,6 @@ operator type(){ \
|
||||
public:
|
||||
ParameterBulk(const ParameterBulk& ref) : parms(ref.parms) {}
|
||||
|
||||
|
||||
variable operator[](size_t index){
|
||||
if(parms.size() > index) return parms[index];
|
||||
return variable{"", "", VARTYPE_NULL};
|
||||
|
Loading…
x
Reference in New Issue
Block a user