mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
Merge pull request #951 from majestrate/fix-ip-rewrite-on-snode-2019-12-06
use ipv6 only with ipv6 packets
This commit is contained in:
commit
9c7355ff9c
@ -154,7 +154,12 @@ namespace llarp
|
||||
src = m_Parent->GetIfAddr();
|
||||
else
|
||||
src = pkt.srcv6();
|
||||
if(pkt.IsV6())
|
||||
pkt.UpdateIPv6Address(src, m_IP);
|
||||
else
|
||||
pkt.UpdateIPv4Address(xhtonl(net::IPPacket::TruncateV6(src)),
|
||||
xhtonl(net::IPPacket::TruncateV6(m_IP)));
|
||||
|
||||
const auto _pktbuf = pkt.Buffer();
|
||||
const llarp_buffer_t& pktbuf = _pktbuf.underlying;
|
||||
const uint8_t queue_idx = pktbuf.sz / llarp::routing::ExitPadSize;
|
||||
|
@ -479,7 +479,11 @@ namespace llarp
|
||||
if(!pkt.Load(buf))
|
||||
return false;
|
||||
// rewrite ip
|
||||
if(m_UseV6)
|
||||
pkt.UpdateIPv6Address(from, m_IfAddr);
|
||||
else
|
||||
pkt.UpdateIPv4Address(xhtonl(net::IPPacket::TruncateV6(from)),
|
||||
xhtonl(net::IPPacket::TruncateV6(m_IfAddr)));
|
||||
return llarp_ev_tun_async_write(&m_Tun, pkt.Buffer());
|
||||
}
|
||||
|
||||
@ -579,6 +583,7 @@ namespace llarp
|
||||
m_HigestAddr = m_OurRange.HighestAddr();
|
||||
LogInfo(Name(), " set ifaddr range to ", m_Tun.ifaddr, "/",
|
||||
m_Tun.netmask, " lo=", m_IfAddr, " hi=", m_HigestAddr);
|
||||
m_UseV6 = false;
|
||||
}
|
||||
if(k == "ifname")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user