1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

fix previous commit

This commit is contained in:
Jeff Becker 2019-11-29 21:57:40 -05:00
parent 19835ce501
commit 1f83fdb190
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
3 changed files with 21 additions and 22 deletions

View file

@ -843,17 +843,12 @@ namespace libuv
{
if(m_Run)
{
#ifdef LOKINET_DEBUG
if((uv_now(&m_Impl) - last_time) > 1000)
{
llarp::LogInfo("UV EVENT LOOP TICKS LAST SECOND: ", loop_run_count,
", LOGIC THREAD JOBS: ", m_Logic->numPendingJobs());
loop_run_count = 0;
last_time = uv_now(&m_Impl);
}
loop_run_count++;
#endif
uv_timer_start(&m_TickTimer, &OnTickTimeout, ms, 0);
uv_run(&m_Impl, UV_RUN_ONCE);
}

View file

@ -23,11 +23,11 @@ namespace llarp
OutboundMessage::XMIT() const
{
size_t extra = 0;
if(m_Data.size() < FragmentSize)
if(m_Data.size() <= FragmentSize)
{
extra = m_Data.size();
}
auto xmit = CreatePacket(Command::eXMIT, 10 + 32 + extra);
auto xmit = CreatePacket(Command::eXMIT, 10 + 32 + extra, 0, 0);
htobe16buf(xmit.data() + CommandOverhead + PacketOverhead, m_Data.size());
htobe64buf(xmit.data() + 2 + CommandOverhead + PacketOverhead, m_MsgID);
std::copy_n(m_Digest.begin(), m_Digest.size(),
@ -68,7 +68,7 @@ namespace llarp
{
/// overhead for a data packet in plaintext
static constexpr size_t Overhead = 10;
uint16_t idx = FragmentSize;
uint16_t idx = 0;
const auto datasz = m_Data.size();
while(idx < datasz)
{
@ -121,7 +121,7 @@ namespace llarp
llarp_time_t now)
: m_Data(size_t{sz})
, m_Digset{std::move(h)}
, m_MsgID{msgid}
, m_MsgID(msgid)
, m_LastActiveAt{now}
{
}
@ -199,6 +199,5 @@ namespace llarp
CryptoManager::instance()->shorthash(gotten, buf);
return gotten == m_Digset;
}
} // namespace iwp
} // namespace llarp

View file

@ -191,7 +191,10 @@ namespace llarp
OutboundMessage{msgid, std::move(buf), now, completed})
.first->second;
EncryptAndSend(msg.XMIT());
msg.FlushUnAcked(util::memFn(&Session::EncryptAndSend, this), now);
if(buf.size() > FragmentSize)
{
msg.FlushUnAcked(util::memFn(&Session::EncryptAndSend, this), now);
}
LogDebug("send message ", msgid);
return true;
}
@ -697,19 +700,21 @@ namespace llarp
rxid,
InboundMessage{rxid, sz, std::move(h), m_Parent->Now()})
.first;
size_t _sz =
std::min(data.size()
- (CommandOverhead + sizeof(uint16_t)
+ sizeof(uint64_t) + PacketOverhead + 32),
size_t{sz});
const llarp_buffer_t buf(data.data() + (data.size() - _sz), _sz);
itr->second.HandleData(0, buf, now);
if(_sz <= FragmentSize)
auto _sz = data.size()
- (CommandOverhead + sizeof(uint16_t) + sizeof(uint64_t)
+ PacketOverhead + 32);
if(sz <= FragmentSize && _sz == 0)
{
if(not itr->second.Verify())
{
LogError("bad short xmit hash from ", m_RemoteAddr);
return;
const llarp_buffer_t buf(data.data() + (data.size() - sz), sz);
LogInfo(_sz);
itr->second.HandleData(0, buf, now);
if(not itr->second.Verify())
{
LogError("bad short xmit hash from ", m_RemoteAddr);
return;
}
}
auto msg = std::move(itr->second);
const llarp_buffer_t buf(msg.m_Data);