mirror of https://github.com/oxen-io/lokinet
add bootstrap list functionality and utility
parent
51fae100ee
commit
0afb3b320b
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
echo -n 'l'
|
||||||
|
for arg in $@ ; do cat "$arg" ; done
|
||||||
|
echo -n 'e'
|
@ -0,0 +1,3 @@
|
|||||||
|
usage:
|
||||||
|
|
||||||
|
./make-bootstrap-list.sh $(find $HOME/.lokinet/netdb | grep \\.signed$) > bootstrap.signed
|
@ -0,0 +1,34 @@
|
|||||||
|
#include <bootstrap.hpp>
|
||||||
|
#include <util/bencode.hpp>
|
||||||
|
|
||||||
|
namespace llarp
|
||||||
|
{
|
||||||
|
void
|
||||||
|
BootstrapList::Clear()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BootstrapList::BDecode(llarp_buffer_t* buf)
|
||||||
|
{
|
||||||
|
return bencode_read_list(
|
||||||
|
[&](llarp_buffer_t* b, bool more) -> bool {
|
||||||
|
if(more)
|
||||||
|
{
|
||||||
|
RouterContact rc;
|
||||||
|
if(not rc.BDecode(b))
|
||||||
|
return false;
|
||||||
|
emplace(std::move(rc));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BootstrapList::BEncode(llarp_buffer_t* buf) const
|
||||||
|
{
|
||||||
|
return BEncodeWriteList(begin(), end(), buf);
|
||||||
|
}
|
||||||
|
} // namespace llarp
|
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef LLARP_BOOTSTRAP_HPP
|
||||||
|
#define LLARP_BOOTSTRAP_HPP
|
||||||
|
|
||||||
|
#include <router_contact.hpp>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace llarp
|
||||||
|
{
|
||||||
|
struct BootstrapList final : public std::set< RouterContact >
|
||||||
|
{
|
||||||
|
bool
|
||||||
|
BDecode(llarp_buffer_t* buf);
|
||||||
|
|
||||||
|
bool
|
||||||
|
BEncode(llarp_buffer_t* buf) const;
|
||||||
|
|
||||||
|
void
|
||||||
|
Clear();
|
||||||
|
};
|
||||||
|
} // namespace llarp
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue