Merge remote-tracking branch 'origin/master' into debian/sid

This commit is contained in:
Jason Rhinelander 2019-07-26 18:21:27 -03:00
commit e82a219252
3 changed files with 48 additions and 14 deletions

View File

@ -25,7 +25,9 @@ namespace llarp
return false;
}
Message message{buf.sz, callback};
Message message;
message.first.resize(buf.sz);
message.second = callback;
std::copy_n(buf.base, buf.sz, message.first.data());

View File

@ -728,10 +728,13 @@ namespace llarp
[=](const RouterID &id, const RouterContact *const rc,
const RCRequestResult result) {
(void)id;
std::vector< RouterContact > routers;
if(result == RCRequestResult::Success && rc != nullptr)
if(resultHandler)
{
routers.push_back(*rc);
std::vector< RouterContact > routers;
if(result == RCRequestResult::Success && rc != nullptr)
{
routers.push_back(*rc);
}
resultHandler(routers);
}
});

View File

@ -6,27 +6,56 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
set -e
helpme=
default_url="https://i2p.rocks/i2procks.signed"
default_dest="$HOME/.lokinet/bootstrap.signed"
if [ "$#" -gt 2 ]; then
helpme=y
fi
if [ -z "$1" ]
then
url="https://i2p.rocks/i2procks.signed"
url="$default_url"
elif [[ "$1" = -* ]]; then
helpme=y
else
url="$1"
fi
echo "downloading $url"
if [ ! -d "$HOME/.lokinet" ]
then
mkdir $HOME/.lokinet
if [[ "$2" = -* ]]; then
helpme=y
elif [ -n "$2" ]; then
dest="$2"
else
dest="$default_dest"
fi
if [ -n "$helpme" ]; then
echo "Usage: $0 [URL [DEST]] -- download bootstrap file from URL (default: $default_url) and save to DEST (default: $default_dest)."
exit 1
fi
destdir="$(dirname $dest)"
if [ ! -d "$destdir" ]; then
mkdir "$destdir"
fi
echo "downloading $url"
# use temp file to not overrwrite existing bootstrap file on fail
#tmp=mktemp
tmp=/tmp/bootstrap.tmp
# MacOS does not have wget without homebrew but does have curl
# Rick also had indicated most BSDs have curl too
curl -o "$tmp" "$url" && \
(mv "$tmp" "$HOME/.lokinet/bootstrap.signed" && echo -e "${GREEN}lokinet successfully bootstrapped${NC}" ) \
|| echo -e "${RED}failed to download bootstrap from $url${NC}"
rm -f "$tmp"
if curl -L "$url" >"$tmp"; then
mv "$tmp" "$dest"
echo -e "${GREEN}lokinet successfully bootstrapped${NC}"
else
echo -e "${RED}failed to download bootstrap from $url${NC}"
rm -f "$tmp"
exit 1
fi