Merge pull request #323 from despair86/dev

fix windows build
pull/330/head
Ryan Tharp 5 years ago committed by GitHub
commit 411ea072c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,14 +97,15 @@ namespace abyss
bool bool
ShouldProcessHeader(const llarp::string_view& name) const ShouldProcessHeader(const llarp::string_view& name) const
{ {
return name == "content-length" || name == "content-type"; return name == llarp::string_view("content-length")
|| name == llarp::string_view("content-type");
} }
/// return true if we get a 200 status code /// return true if we get a 200 status code
bool bool
HandleStatusCode(string_view code) const HandleStatusCode(string_view code) const
{ {
return code == "200"; return code == string_view("200");
} }
bool bool

@ -103,7 +103,8 @@ namespace abyss
ShouldProcessHeader(const string_view& name) const ShouldProcessHeader(const string_view& name) const
{ {
// TODO: header whitelist // TODO: header whitelist
return name == "content-type" || name == "content-length"; return name == string_view("content-type")
|| name == string_view("content-length");
} }
bool bool
@ -143,7 +144,7 @@ namespace abyss
"text/plain", "text/plain",
"no content type provided"); "no content type provided");
} }
else if(itr->second != "application/json") else if(itr->second != string_view("application/json"))
{ {
return WriteResponseSimple(415, "Unsupported Media Type", return WriteResponseSimple(415, "Unsupported Media Type",
"text/plain", "text/plain",

@ -215,9 +215,17 @@ endif()
if(WITH_SHARED) if(WITH_SHARED)
add_library(${SHARED_LIB} SHARED ${LIB_SRC}) add_library(${SHARED_LIB} SHARED ${LIB_SRC})
if (WIN32) if (WIN32)
if(USE_LIBABYSS)
target_link_libraries(${SHARED_LIB} ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
else()
target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads) target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi Threads::Threads)
endif()
else()
if(USE_LIBABYSS)
target_link_libraries(${SHARED_LIB} ${ABYSS_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads)
else() else()
target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads) target_link_libraries(${SHARED_LIB} ${CRYPTOGRAPHY_LIB} ${LIBS} ${UTIL_LIB} libutp ${PLATFORM_LIB} Threads::Threads)
endif()
install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib) install(TARGETS ${SHARED_LIB} LIBRARY DESTINATION lib)
endif() endif()
add_log_tag(${SHARED_LIB}) add_log_tag(${SHARED_LIB})

@ -173,24 +173,25 @@ namespace llarp
util::StatusObject util::StatusObject
ILinkLayer::ExtractStatus() const ILinkLayer::ExtractStatus() const
{ {
std::vector<util::StatusObject> pending, established; std::vector< util::StatusObject > pending, established;
std::transform(m_Pending.begin(), m_Pending.end(), std::back_inserter(pending), [](const auto & item) -> util::StatusObject { std::transform(m_Pending.begin(), m_Pending.end(),
std::back_inserter(pending),
[](const auto& item) -> util::StatusObject {
return item.second->ExtractStatus(); return item.second->ExtractStatus();
}); });
std::transform(m_AuthedLinks.begin(), m_AuthedLinks.end(), std::back_inserter(established), [](const auto & item) -> util::StatusObject { std::transform(m_AuthedLinks.begin(), m_AuthedLinks.end(),
std::back_inserter(established),
[](const auto& item) -> util::StatusObject {
return item.second->ExtractStatus(); return item.second->ExtractStatus();
}); });
return { return {{"name", Name()},
{"name", Name()},
{"rank", uint64_t(Rank())}, {"rank", uint64_t(Rank())},
{"addr", m_ourAddr.ToString()}, {"addr", m_ourAddr.ToString()},
{"sessions", util::StatusObject{ {"sessions",
{"pending", pending}, util::StatusObject{{"pending", pending},
{"established", established} {"established", established}}}};
}}
};
} }
bool bool

@ -180,7 +180,8 @@ namespace llarp
bool bool
MapAddr(const RouterID& pk, ILinkSession* s); MapAddr(const RouterID& pk, ILinkSession* s);
void Tick(llarp_time_t now); void
Tick(llarp_time_t now);
LinkMessageHandler HandleMessage; LinkMessageHandler HandleMessage;
TimeoutHandler HandleTimeout; TimeoutHandler HandleTimeout;

@ -160,8 +160,7 @@ namespace llarp
IHopHandler* IHopHandler*
PathContext::GetByUpstream(const RouterID& remote, const PathID_t& id) PathContext::GetByUpstream(const RouterID& remote, const PathID_t& id)
{ {
auto own = MapGet( auto own = MapGet(m_OurPaths, id,
m_OurPaths, id,
[](__attribute__((unused)) const PathSet* s) -> bool { [](__attribute__((unused)) const PathSet* s) -> bool {
// TODO: is this right? // TODO: is this right?
return true; return true;
@ -172,8 +171,7 @@ namespace llarp
if(own) if(own)
return own; return own;
return MapGet( return MapGet(m_TransitPaths, id,
m_TransitPaths, id,
[remote](const std::shared_ptr< TransitHop >& hop) -> bool { [remote](const std::shared_ptr< TransitHop >& hop) -> bool {
return hop->info.upstream == remote; return hop->info.upstream == remote;
}, },
@ -196,8 +194,7 @@ namespace llarp
IHopHandler* IHopHandler*
PathContext::GetByDownstream(const RouterID& remote, const PathID_t& id) PathContext::GetByDownstream(const RouterID& remote, const PathID_t& id)
{ {
return MapGet( return MapGet(m_TransitPaths, id,
m_TransitPaths, id,
[remote](const std::shared_ptr< TransitHop >& hop) -> bool { [remote](const std::shared_ptr< TransitHop >& hop) -> bool {
return hop->info.downstream == remote; return hop->info.downstream == remote;
}, },

@ -2,5 +2,4 @@
namespace llarp namespace llarp
{ {
} // namespace llarp } // namespace llarp

@ -41,7 +41,6 @@ namespace llarp
struct AbstractRouter : public util::IStateful struct AbstractRouter : public util::IStateful
{ {
virtual void virtual void
OnSessionEstablished(RouterContact rc) = 0; OnSessionEstablished(RouterContact rc) = 0;
@ -140,11 +139,12 @@ namespace llarp
/// set router's service node whitelist /// set router's service node whitelist
virtual void virtual void
SetRouterWhitelist(const std::vector<RouterID> & routers) =0 ; SetRouterWhitelist(const std::vector< RouterID > &routers) = 0;
/// visit each connected link session /// visit each connected link session
virtual void virtual void
ForEachPeer(std::function<void(const ILinkSession*, bool)> visit) const = 0; ForEachPeer(
std::function< void(const ILinkSession *, bool) > visit) const = 0;
}; };
} // namespace llarp } // namespace llarp

@ -679,9 +679,7 @@ namespace llarp
Router::NumberOfConnectedRouters() const Router::NumberOfConnectedRouters() const
{ {
size_t s = 0; size_t s = 0;
ForEachPeer([&s](const auto *, bool) { ForEachPeer([&s](const auto *, bool) { ++s; });
++s;
});
return s; return s;
} }

@ -141,7 +141,7 @@ namespace llarp
} }
void void
SetRouterWhitelist(const std::vector<RouterID> & routers) override; SetRouterWhitelist(const std::vector< RouterID > &routers) override;
exit::Context & exit::Context &
exitContext() override exitContext() override
@ -430,7 +430,8 @@ namespace llarp
RouterID remote, const std::vector< RouterContact > &results) override; RouterID remote, const std::vector< RouterContact > &results) override;
void void
ForEachPeer(std::function< void(const ILinkSession *, bool) > visit) const override; ForEachPeer(
std::function< void(const ILinkSession *, bool) > visit) const override;
void void
ForEachPeer(std::function< void(ILinkSession *) > visit); ForEachPeer(std::function< void(ILinkSession *) > visit);

@ -266,9 +266,7 @@ namespace llarp
auto itr = m_PrefetchedTags.find(tag); auto itr = m_PrefetchedTags.find(tag);
if(itr == m_PrefetchedTags.end()) if(itr == m_PrefetchedTags.end())
{ {
itr = m_PrefetchedTags itr = m_PrefetchedTags.emplace(tag, CachedTagResult(tag, this)).first;
.emplace(tag, CachedTagResult(tag, this))
.first;
} }
for(const auto& introset : itr->second.result) for(const auto& introset : itr->second.result)
{ {
@ -1310,8 +1308,7 @@ namespace llarp
} }
} }
// no converstation // no converstation
return EnsurePathToService( return EnsurePathToService(remote,
remote,
[](Address, OutboundContext* c) { [](Address, OutboundContext* c) {
if(c) if(c)
c->UpdateIntroSet(true); c->UpdateIntroSet(true);

@ -134,7 +134,8 @@ namespace llarp
Verify(Crypto* c, const ServiceInfo& from) const; Verify(Crypto* c, const ServiceInfo& from) const;
bool bool
HandleMessage(routing::IMessageHandler* h, AbstractRouter* r) const override; HandleMessage(routing::IMessageHandler* h,
AbstractRouter* r) const override;
}; };
} // namespace service } // namespace service
} // namespace llarp } // namespace llarp

@ -1,7 +1,5 @@
#include <util/bencode.h> #include <util/bencode.h>
#include <util/logger.hpp> #include <util/logger.hpp>
#include <cstdlib> #include <cstdlib>
bool bool
@ -75,10 +73,10 @@ bencode_write_bytestring(llarp_buffer_t* buff, const void* data, size_t sz)
bool bool
bencode_write_uint64(llarp_buffer_t* buff, uint64_t i) bencode_write_uint64(llarp_buffer_t* buff, uint64_t i)
{ {
#if (__APPLE__ && __MACH__) #ifndef __LP64__
if(!buff->writef("i%llu", i)) if(!buff->writef("i%llu", i))
#else #else
if(!buff->writef("i%lu", i)) if(!buff->write("i%lu", i))
#endif #endif
{ {
return false; return false;

@ -120,9 +120,16 @@ struct llarp_buffer_t
bool bool
write(InputIt begin, InputIt end); write(InputIt begin, InputIt end);
#ifndef _WIN32
bool bool
writef(const char *fmt, ...) __attribute__((format(printf, 2, 3))); writef(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
; ;
#else
bool
writef(const char *fmt, ...)
__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3)));
;
#endif
bool bool
put_uint16(uint16_t i); put_uint16(uint16_t i);

@ -71,7 +71,7 @@ namespace llarp
/// an entity that has a status that can be extracted /// an entity that has a status that can be extracted
struct IStateful struct IStateful
{ {
virtual ~IStateful() {}; virtual ~IStateful(){};
virtual StatusObject virtual StatusObject
ExtractStatus() const = 0; ExtractStatus() const = 0;

@ -16,8 +16,8 @@ struct llarp_threadpool
std::queue< std::function< void(void) > > jobs; std::queue< std::function< void(void) > > jobs;
llarp_threadpool(int workers, const char *name) llarp_threadpool(int workers, const char *name)
: impl( : impl(std::make_unique< llarp::thread::ThreadPool >(workers,
std::make_unique< llarp::thread::ThreadPool >(workers, workers * 128)) workers * 128))
{ {
(void)name; (void)name;
} }

Loading…
Cancel
Save