Skip to content

Commit 44ad8ad

Browse files
authored
Merge pull request #1694 from oxen-io/dev
0.9.5
2 parents 4723b53 + 75b4758 commit 44ad8ad

19 files changed

+237
-193
lines changed

CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if(CCACHE_PROGRAM)
1616
endif()
1717

1818
project(lokinet
19-
VERSION 0.9.4
19+
VERSION 0.9.5
2020
DESCRIPTION "lokinet - IP packet onion router"
2121
LANGUAGES C CXX)
2222

@@ -141,7 +141,7 @@ if(LIBUV_FOUND AND NOT BUILD_STATIC_DEPS)
141141
target_link_libraries(libuv INTERFACE PkgConfig::LIBUV)
142142
else()
143143
if(NOT BUILD_STATIC_DEPS)
144-
message(FATAL_ERROR "Could not find libu >= 1.28.0; install it on your system or use -DBUILD_STATIC_DEPS=ON")
144+
message(FATAL_ERROR "Could not find libuv >= 1.28.0; install it on your system or use -DBUILD_STATIC_DEPS=ON")
145145
endif()
146146
endif()
147147

@@ -302,6 +302,19 @@ endif()
302302
add_subdirectory(external)
303303
include_directories(SYSTEM external/sqlite_orm/include)
304304

305+
option(USE_JEMALLOC "Link to jemalloc for memory allocations, if found" ON)
306+
if(USE_JEMALLOC AND NOT STATIC_LINK)
307+
pkg_check_modules(JEMALLOC jemalloc IMPORTED_TARGET)
308+
if(JEMALLOC_FOUND)
309+
target_link_libraries(base_libs INTERFACE PkgConfig::JEMALLOC)
310+
else()
311+
message(STATUS "jemalloc not found, not linking to jemalloc")
312+
endif()
313+
else()
314+
message(STATUS "jemalloc support disabled")
315+
endif()
316+
317+
305318
if(ANDROID)
306319
target_link_libraries(base_libs INTERFACE log)
307320
target_compile_definitions(base_libs INTERFACE ANDROID)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM node:14.16.1
2+
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
3+
RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q update && apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y && apt-get -o=Dpkg::Use-Pty=0 -q install -y eatmydata gdb cmake git ninja-build pkg-config ccache g++ wine'

contrib/ci/docker/rebuild-docker-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ test "x$registry" != "x" || exit 1
88
for file in ${@:2} ; do
99
name="$(echo $file | cut -d'.' -f1)"
1010
echo "rebuild $name"
11-
docker build -f $file -t $registry/lokinet-ci-$name --pull --no-cache --quiet .
11+
docker build -f $file -t $registry/lokinet-ci-$name .
1212
docker push $registry/lokinet-ci-$name
1313
done

contrib/py/admin/lokinetmon

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import sys
66
import time
77
import platform
88
import os
9+
import re
910
from argparse import ArgumentParser as AP
1011

1112
is_windows = lambda : platform.system().lower() == 'windows'
@@ -40,12 +41,13 @@ except ImportError:
4041
print("for other linuxs do:")
4142
print("\tpip3 install --user geoip")
4243
print("for other linuxs you are responsible for obtaining your owen geoip databases, glhf")
44+
time.sleep(1)
4345
else:
4446
print("install it with:")
4547
print("\tpip3 install --user geoip")
46-
print("")
47-
print("press enter to continue without geoip")
48-
sys.stdin.read(1)
48+
print()
49+
print("press enter to continue without geoip")
50+
sys.stdin.read(1)
4951
else:
5052
try:
5153
geoip_env_var = 'GEOIP_DB_FILE'
@@ -86,6 +88,7 @@ def ip_to_flag(ip):
8688
class Monitor:
8789

8890
_sample_size = 12
91+
filter = lambda x : True
8992

9093
def __init__(self, url, introsetMode=False):
9194
self.txrate = 0
@@ -144,7 +147,7 @@ class Monitor:
144147
self.win.addstr(" {} ->".format(hopstr))
145148

146149
self.win.addstr(" [{} ms latency]".format(path["intro"]["latency"]))
147-
self.win.addstr(" [{} until expire]".format(self.time_to(path["expiresAt"])))
150+
self.win.addstr(" [expires: {}]".format(self.time_to(path["expiresAt"])))
148151
if path["expiresSoon"]:
149152
self.win.addstr("(expiring)")
150153
elif path["expired"]:
@@ -153,13 +156,17 @@ class Monitor:
153156

154157
@staticmethod
155158
def time_to(timestamp):
156-
""" return time until timestamp in seconds formatted"""
159+
""" return time until timestamp formatted"""
157160
if timestamp:
161+
unit = 'seconds'
158162
val = (timestamp - now()) / 1000.0
163+
if abs(val) > 60.0:
164+
val /= 60.0
165+
unit = 'minutes'
159166
if val < 0:
160-
return "{} seconds ago".format(0-val)
167+
return "{:.2f} {} ago".format(0-val, unit)
161168
else:
162-
return "{} seconds".format(val)
169+
return "in {:.2f} {}".format(val, unit)
163170
else:
164171
return 'never'
165172

@@ -201,15 +208,18 @@ class Monitor:
201208
paths = status["paths"]
202209
self.win.addstr("paths: {}".format(len(paths)))
203210
for path in paths:
204-
y_pos = self._render_path(y_pos, path, "inbound")
211+
if self.filter('localhost.loki'):
212+
y_pos = self._render_path(y_pos, path, "localhost.loki")
205213
for session in (status["remoteSessions"] or []):
206214
for path in session["paths"]:
207-
y_pos = self._render_path(
208-
y_pos, path, "[active] {}".format(session["currentConvoTag"])
209-
)
215+
if self.filter(session["remoteIdentity"]):
216+
y_pos = self._render_path(
217+
y_pos, path, "[active] {}".format(session["currentConvoTag"])
218+
)
210219
for session in (status["snodeSessions"] or []):
211220
for path in session["paths"]:
212-
y_pos = self._render_path(y_pos, path, "[snode]")
221+
if self.filter(session["endpoint"]):
222+
y_pos = self._render_path(y_pos, path, "[snode]")
213223
return y_pos
214224

215225
def display_links(self, y_pos, data):
@@ -407,18 +417,20 @@ class Monitor:
407417
"""
408418
y_pos += 1
409419
self.win.move(y_pos, 1)
410-
self.win.addstr("localhost.loki")
411-
y_pos = self._display_our_introset(y_pos, service)
412-
y_pos += 1
420+
if self.filter("localhost.loki"):
421+
self.win.addstr("localhost.loki")
422+
y_pos = self._display_our_introset(y_pos, service)
423+
y_pos += 1
413424
remotes = service['remoteSessions'] or []
414425
for session in remotes:
415-
y_pos = self._display_session_introset(y_pos, session)
426+
if self.filter(session['remoteIdentity']):
427+
y_pos = self._display_session_introset(y_pos, session)
416428

417429
def _display_intro(self, y_pos, intro, label, paths):
418430
y_pos += 1
419431
self.win.move(y_pos, 1)
420432
path = 'path' in intro and intro['path'][:4] or '????'
421-
self.win.addstr('{}: ({}|{}) [expires in: {}] [{} paths]'.format(label, intro['router'][:8], path, self.time_to(intro['expiresAt']), self.count_endpoints_in_path(paths, intro['router'])))
433+
self.win.addstr('{}: ({}|{}) [expires: {}] [{} paths]'.format(label, intro['router'][:8], path, self.time_to(intro['expiresAt']), self.count_endpoints_in_path(paths, intro['router'])))
422434
return y_pos
423435

424436
@staticmethod
@@ -457,10 +469,13 @@ class Monitor:
457469
#print(context.keys())
458470
y_pos += 1
459471
self.win.move(y_pos, 1)
460-
readyState = context['readyToSend'] and '✔️' or '❌'
472+
readyState = context['readyToSend'] and '️✅' or '❌'
461473
self.win.addstr('{} ({}) [{}]'.format(context['remoteIdentity'], context['currentConvoTag'], readyState))
462474
y_pos += 1
463475
self.win.move(y_pos, 1)
476+
self.win.addstr('created: {}'.format(self.time_to(context['sessionCreatedAt'])))
477+
y_pos += 1
478+
self.win.move(y_pos, 1)
464479
self.win.addstr('last good send: {}'.format(self.time_to(context['lastGoodSend'])))
465480
y_pos += 1
466481
self.win.move(y_pos, 1)
@@ -544,13 +559,19 @@ def main():
544559

545560
ap.add_argument("--introset", action='store_const', const=True, default=False, help="run in introset inspection mode")
546561
ap.add_argument("--url", default='tcp://127.0.0.1:1190', type=str, help='url to lokinet rpc')
562+
ap.add_argument('--filter', default='.+', type=str, help="regex to filter entries")
563+
ap.add_argument('--invert-filter', const=True, default=False, action='store_const', help='invert regex filter matching')
547564

548565
args = ap.parse_args()
549566

550567
mon = Monitor(
551568
args.url,
552569
args.introset
553570
)
571+
mon.filter = lambda x : re.match(args.filter, x) is not None
572+
if args.invert_filter:
573+
old_filter = mon.filter
574+
mon.filter = lambda x : not old_filter(x)
554575
mon.run()
555576

556577
if __name__ == "__main__":

docs/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if (NOT DOXYGEN)
44
return()
55
endif()
66
find_program(SPHINX_BUILD sphinx-build)
7-
if (NOT DOXYGEN)
7+
if (NOT SPHINX_BUILD)
88
message(STATUS "Documentation generation disabled (sphinx-build not found)")
99
return()
1010
endif()
@@ -22,7 +22,7 @@ add_custom_command(
2222

2323
add_custom_command(
2424
OUTPUT html/index.html
25-
COMMAND ${SPHINX_BUILD}
25+
COMMAND ${SPHINX_BUILD} -j auto
2626
-Dbreathe_projects.lokinet=${CMAKE_CURRENT_BINARY_DIR}/doxyxml
2727
-Dversion=${lokinet_VERSION} -Drelease=${lokinet_VERSION}
2828
-Aversion=${lokinet_VERSION} -Aversions=${lokinet_VERSION_MAJOR},${lokinet_VERSION_MINOR},${lokinet_VERSION_PATCH}

llarp/exit/session.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace llarp
4646
obj["lastExitUse"] = to_json(m_LastUse);
4747
auto pub = m_ExitIdentity.toPublic();
4848
obj["exitIdentity"] = pub.ToString();
49+
obj["endpoint"] = m_ExitRouter.ToString();
4950
return obj;
5051
}
5152

llarp/iwp/linklayer.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace llarp::iwp
2424
keyManager, getrc, h, sign, before, est, reneg, timeout, closed, pumpDone, worker)
2525
, m_Wakeup{ev->make_waker([this]() { HandleWakeupPlaintext(); })}
2626
, m_PlaintextRecv{1024}
27-
, permitInbound{allowInbound}
27+
, m_Inbound{allowInbound}
2828

2929
{}
3030

@@ -34,6 +34,15 @@ namespace llarp::iwp
3434
return "iwp";
3535
}
3636

37+
std::string
38+
LinkLayer::PrintableName() const
39+
{
40+
if (m_Inbound)
41+
return "inbound iwp link";
42+
else
43+
return "outbound iwp link";
44+
}
45+
3746
uint16_t
3847
LinkLayer::Rank() const
3948
{
@@ -48,10 +57,10 @@ namespace llarp::iwp
4857
bool isNewSession = false;
4958
if (itr == m_AuthedAddrs.end())
5059
{
51-
Lock_t lock(m_PendingMutex);
60+
Lock_t lock{m_PendingMutex};
5261
if (m_Pending.count(from) == 0)
5362
{
54-
if (not permitInbound)
63+
if (not m_Inbound)
5564
return;
5665
isNewSession = true;
5766
m_Pending.insert({from, std::make_shared<Session>(this, from)});
@@ -60,14 +69,13 @@ namespace llarp::iwp
6069
}
6170
else
6271
{
63-
Lock_t lock(m_AuthedLinksMutex);
64-
auto range = m_AuthedLinks.equal_range(itr->second);
65-
session = range.first->second;
72+
if (auto s_itr = m_AuthedLinks.find(itr->second); s_itr != m_AuthedLinks.end())
73+
session = s_itr->second;
6674
}
6775
if (session)
6876
{
6977
bool success = session->Recv_LL(std::move(pkt));
70-
if (!success and isNewSession)
78+
if (not success and isNewSession)
7179
{
7280
LogWarn("Brand new session failed; removing from pending sessions list");
7381
m_Pending.erase(m_Pending.find(from));
@@ -78,7 +86,7 @@ namespace llarp::iwp
7886
bool
7987
LinkLayer::MapAddr(const RouterID& r, ILinkSession* s)
8088
{
81-
if (!ILinkLayer::MapAddr(r, s))
89+
if (not ILinkLayer::MapAddr(r, s))
8290
return false;
8391
m_AuthedAddrs.emplace(s->GetRemoteEndpoint(), r);
8492
return true;
@@ -93,6 +101,8 @@ namespace llarp::iwp
93101
std::shared_ptr<ILinkSession>
94102
LinkLayer::NewOutboundSession(const RouterContact& rc, const AddressInfo& ai)
95103
{
104+
if (m_Inbound)
105+
throw std::logic_error{"inbound link cannot make outbound sessions"};
96106
return std::make_shared<Session>(this, rc, ai);
97107
}
98108

llarp/iwp/linklayer.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ namespace llarp::iwp
5656
void
5757
AddWakeup(std::weak_ptr<Session> peer);
5858

59+
std::string
60+
PrintableName() const;
61+
5962
private:
6063
void
6164
HandleWakeupPlaintext();
6265

6366
const std::shared_ptr<EventLoopWakeup> m_Wakeup;
6467
std::unordered_map<SockAddr, std::weak_ptr<Session>> m_PlaintextRecv;
6568
std::unordered_map<SockAddr, RouterID> m_AuthedAddrs;
66-
const bool permitInbound;
69+
const bool m_Inbound;
6770
};
6871

6972
using LinkLayer_ptr = std::shared_ptr<LinkLayer>;

0 commit comments

Comments
 (0)