make format

pull/1250/head
Jason Rhinelander 4 years ago
parent 1697bf90fe
commit 5cf2126bb9

@ -103,8 +103,7 @@ namespace abyss
bool bool
ShouldProcessHeader(std::string_view name) const ShouldProcessHeader(std::string_view name) const
{ {
return name == "content-length"sv return name == "content-length"sv || name == "content-type"sv
|| name == "content-type"sv
|| name == "www-authenticate"sv; || name == "www-authenticate"sv;
} }

@ -164,10 +164,11 @@ namespace llarp
"network", "strict-connect", false, "", AssignmentAcceptor(m_strictConnect)); "network", "strict-connect", false, "", AssignmentAcceptor(m_strictConnect));
// TODO: make sure this is documented... what does it mean though? // TODO: make sure this is documented... what does it mean though?
conf.addUndeclaredHandler("network", [&](std::string_view, std::string_view name, std::string_view value) { conf.addUndeclaredHandler(
m_options.emplace(name, value); "network", [&](std::string_view, std::string_view name, std::string_view value) {
return true; m_options.emplace(name, value);
}); return true;
});
} }
void void
@ -236,16 +237,18 @@ namespace llarp
m_OutboundLink = LinkInfoFromINIValues("*", arg); m_OutboundLink = LinkInfoFromINIValues("*", arg);
}); });
conf.addUndeclaredHandler("bind", [&](std::string_view, std::string_view name, std::string_view value) { conf.addUndeclaredHandler(
LinkInfo info = LinkInfoFromINIValues(name, value); "bind", [&](std::string_view, std::string_view name, std::string_view value) {
LinkInfo info = LinkInfoFromINIValues(name, value);
if (info.port <= 0) if (info.port <= 0)
throw std::invalid_argument(stringify("Invalid [bind] port specified on interface", name)); throw std::invalid_argument(
stringify("Invalid [bind] port specified on interface", name));
assert(name != "*"); // handled by defineOption("bind", "*", ...) above assert(name != "*"); // handled by defineOption("bind", "*", ...) above
m_InboundLinks.emplace_back(std::move(info)); m_InboundLinks.emplace_back(std::move(info));
}); });
} }
void void
@ -277,7 +280,8 @@ namespace llarp
(void)params; (void)params;
conf.addUndeclaredHandler( conf.addUndeclaredHandler(
"services", [this](std::string_view section, std::string_view name, std::string_view value) { "services",
[this](std::string_view section, std::string_view name, std::string_view value) {
(void)section; (void)section;
services.emplace_back(name, value); services.emplace_back(name, value);
return true; return true;
@ -422,15 +426,16 @@ namespace llarp
m_mapAddr = arg; m_mapAddr = arg;
}); });
conf.addUndeclaredHandler("snapp", [&](std::string_view, std::string_view name, std::string_view value) { conf.addUndeclaredHandler(
if (name == "blacklist-snode") "snapp", [&](std::string_view, std::string_view name, std::string_view value) {
{ if (name == "blacklist-snode")
m_snodeBlacklist.push_back(str(value)); {
return true; m_snodeBlacklist.push_back(str(value));
} return true;
}
return false; return false;
}); });
} }
bool bool

@ -48,7 +48,8 @@ namespace llarp
} }
ConfigDefinition& ConfigDefinition&
ConfigDefinition::addConfigValue(std::string_view section, std::string_view name, std::string_view value) ConfigDefinition::addConfigValue(
std::string_view section, std::string_view name, std::string_view value)
{ {
// see if we have an undeclared handler to fall back to in case section or section:name is // see if we have an undeclared handler to fall back to in case section or section:name is
// absent // absent

@ -82,7 +82,7 @@ win32_tun_io::add_ev(llarp_ev_loop* loop)
// we're already non-blocking // we're already non-blocking
// add to list // add to list
tun_listeners.push_back(this); tun_listeners.push_back(this);
byte_t* readbuf = (byte_t*)malloc(1500); byte_t* readbuf = (byte_t*)malloc(1500);
read(readbuf, 1500); read(readbuf, 1500);
return true; return true;
@ -91,16 +91,16 @@ win32_tun_io::add_ev(llarp_ev_loop* loop)
// places data in event queue for kernel to process // places data in event queue for kernel to process
bool bool
win32_tun_io::do_write(void* data, size_t sz) win32_tun_io::do_write(void* data, size_t sz)
{ {
DWORD code; DWORD code;
asio_evt_pkt* pkt = new asio_evt_pkt; asio_evt_pkt* pkt = new asio_evt_pkt;
pkt->buf = data; pkt->buf = data;
pkt->sz = sz; pkt->sz = sz;
pkt->write = true; pkt->write = true;
memset(&pkt->pkt, '\0', sizeof(pkt->pkt)); memset(&pkt->pkt, '\0', sizeof(pkt->pkt));
WriteFile(tunif->tun_fd, data, sz, nullptr, &pkt->pkt); WriteFile(tunif->tun_fd, data, sz, nullptr, &pkt->pkt);
code = GetLastError(); code = GetLastError();
//llarp::LogInfo("wrote data, error ", code); // llarp::LogInfo("wrote data, error ", code);
return (code == 0 || code == 997); return (code == 0 || code == 997);
} }
@ -115,7 +115,7 @@ win32_tun_io::flush_write()
void void
win32_tun_io::read(byte_t* buf, size_t sz) win32_tun_io::read(byte_t* buf, size_t sz)
{ {
DWORD code; DWORD code;
asio_evt_pkt* pkt = new asio_evt_pkt; asio_evt_pkt* pkt = new asio_evt_pkt;
pkt->buf = buf; pkt->buf = buf;
@ -148,7 +148,7 @@ tun_ev_loop(void* u)
// of the tun logic // of the tun logic
for (const auto& tun : tun_listeners) for (const auto& tun : tun_listeners)
{ {
logic->call_soon([tun]() { logic->call_soon([tun]() {
tun->flush_write(); tun->flush_write();
if (tun->t->tick) if (tun->t->tick)
tun->t->tick(tun->t); tun->t->tick(tun->t);
@ -166,22 +166,22 @@ tun_ev_loop(void* u)
// llarp::LogInfo("read tun ", size, " bytes, pass to handler"); // llarp::LogInfo("read tun ", size, " bytes, pass to handler");
logic->call_soon([pkt, size, ev]() { logic->call_soon([pkt, size, ev]() {
if (ev->t->recvpkt) if (ev->t->recvpkt)
ev->t->recvpkt(ev->t, llarp_buffer_t(pkt->buf, size)); ev->t->recvpkt(ev->t, llarp_buffer_t(pkt->buf, size));
free(pkt->buf); free(pkt->buf);
delete pkt; delete pkt;
}); });
byte_t* readbuf = (byte_t*)malloc(1500); byte_t* readbuf = (byte_t*)malloc(1500);
ev->read(readbuf, 1500); ev->read(readbuf, 1500);
} }
else else
{ {
// ok let's queue another read! // ok let's queue another read!
byte_t* readbuf = (byte_t*)malloc(1500); byte_t* readbuf = (byte_t*)malloc(1500);
ev->read(readbuf, 1500); ev->read(readbuf, 1500);
} }
logic->call_soon([ev]() { logic->call_soon([ev]() {
ev->flush_write(); ev->flush_write();
if(ev->t->tick) if (ev->t->tick)
ev->t->tick(ev->t); ev->t->tick(ev->t);
}); });
} }

@ -400,10 +400,7 @@ namespace llarp
HandleVerifyGotRouter(dht::GotRouterMessage_constptr msg, llarp_async_verify_rc* j); HandleVerifyGotRouter(dht::GotRouterMessage_constptr msg, llarp_async_verify_rc* j);
bool bool
OnLookup( OnLookup(const service::Address& addr, std::optional<IntroSet> i, const RouterID& endpoint);
const service::Address& addr,
std::optional<IntroSet> i,
const RouterID& endpoint); /* */
bool bool
DoNetworkIsolation(bool failed); DoNetworkIsolation(bool failed);

@ -45,7 +45,9 @@ namespace llarp
// Shortcut for explicitly casting a string_view to a string. Saves 8 characters compared to // Shortcut for explicitly casting a string_view to a string. Saves 8 characters compared to
// `std::string(view)`. // `std::string(view)`.
inline std::string str(std::string_view s) { inline std::string
str(std::string_view s)
{
return std::string{s}; return std::string{s};
} }

Loading…
Cancel
Save