Compare commits

...

951 Commits
v0.9.3 ... dev

Author SHA1 Message Date
Jason Rhinelander 178ac1757b
Merge pull request #2199 from dr7ana/oxen-logging-bump
Oxen-logging version bump
2023-08-11 19:05:23 -03:00
dr7ana 9acac2c33e CI fixes
- oxen-logging updated to bump fmt version
- version bump oxen-logging to fix fmt version
- version bump oxen-mq to solve uniform distribution error
- misc errors introduced by above version bumps
- clang-format 14 -> 15
2023-08-11 14:01:07 -07:00
Jason Rhinelander e11f5018c2
Fix negative integer parsing 2023-06-02 00:11:28 -03:00
Jason Rhinelander a17753fddb
Merge pull request #2180 from majestrate/fix-2179-ipv6-upstream-dns-2023-05-20
libunbound ipv6 upstream dns syntax error
2023-05-31 18:04:15 -03:00
Jason Rhinelander ab606c48d4
Rename `add_braces` -> `ipv6_brackets`
"Braces" seemed misleading as usually that terms refers to `{}` rather
than `[]`, and also this only affects ipv6 addresses.
2023-05-30 17:42:56 -03:00
Jason Rhinelander 7f9b425332
Merge pull request #2182 from dr7ana/incomplete-issues
Added workflow to remove stale, incomplete issues
2023-05-30 17:33:05 -03:00
dan 0a98fb943d added workflow to remove stale issues 2023-05-25 07:16:22 -07:00
Jeff Becker fc050b3a09
fix issue #2179
when setting libunbound's upstream dns, we need to not pass in the square braces of an ipv6 address.
we also net udp handles have ipv6 address for the local ip.
2023-05-20 18:21:20 -04:00
Jason Rhinelander 559fa8aec4
Merge pull request #2173 from longyap/dev
add #include <cstdint>
2023-05-11 10:12:01 -03:00
GNU/LongYap 89c5c73be4
add #include <cstdint>
add #include <cstdint> to fix build error
2023-05-11 20:47:00 +08:00
Jason Rhinelander a294c81f0d
Python <3.11 compat fix 2023-05-03 21:12:19 -03:00
Jason Rhinelander b48e8b23ea
Merge pull request #2106 from majestrate/fix-config-comment-typo-2023-01-05
fix typo in config comments
2023-03-01 12:31:18 -04:00
majestrate 24bfbd5bc6
Merge pull request #2142 from jagerman/bencode-hex
Add automatic hex decoding to bencode-dump.py
2023-02-28 12:50:10 -05:00
Jason Rhinelander e255b87992
Add automatic hex decoding to bencode-dump.py
This allows bencode-dump.py autodetect hex input and decode it on the
fly, which is quite convenient when working with binary-containing
bencoded data strings.
2023-02-28 12:34:17 -04:00
majestrate 7d2ad5621b
Merge pull request #2139 from majestrate/fix-issue-2138-with-loop-call-2023-02-15
fix issue #2138
2023-02-16 12:22:51 -05:00
Jeff Becker d7d3a4e774
fix issue #2138
in rpc client, contention on a null lock happened.
fix this by making the sending of pings always done in the logic
thread. this is done by wrapping the lambda we made with EventLoop::make_caller()
2023-02-15 17:31:14 -05:00
Jason Rhinelander 366d0c1be9
Merge pull request #2128 from majestrate/oxend-defer-ping-2023-01-29
ping oxend after getting identity keys
2023-02-06 12:44:43 -04:00
majestrate 3de23c3eba
Merge pull request #2130 from XutaxKamay/dev
fix openwrt mips32 static build
2023-02-05 15:56:26 -05:00
Kamay Xutax 742b66c300 fix openwrt mips32 static build
libunbound needs to link against libatomic because of openssl
crypto (says EVP_sha256 missing otherwise in libunbound during build)
2023-02-05 18:31:33 +01:00
Jason Rhinelander 7fb36782dc
Merge pull request #2121 from drouhana/rpc-refactor
RPC refactor
2023-02-01 19:55:18 -04:00
dan 9bfe881a35 OMQ_Request handling logic change 2023-02-01 15:52:37 -08:00
dan b2e8cde64b working new endpoints
- added hotswap functionality
- map_exit and unmap_exit working
2023-02-01 15:52:37 -08:00
dan 0632e88de0 Make new header for json type conversions 2023-02-01 15:52:37 -08:00
Jeff Becker 02b392881b add llarp::service::Endpoint::map_exit 2023-02-01 15:52:30 -08:00
Jeff Becker 031e173f1a
ping oxend after getting identity keys
fixes #2125
2023-01-29 18:25:49 -05:00
dan d3e69fe3c5 added unmapexit and listexit endpoints 2023-01-24 09:44:02 -08:00
dan d37398a915 review comments 2023-01-24 07:23:01 -08:00
drouhana f6aa58482a
Merge branch 'dev' into rpc-refactor 2023-01-24 06:54:36 -08:00
dan 13b01c86a6 Updated RpcServer Initialization and Logic
-- Moved all RPCServer initialization logic to rpcserver constructor
    -- Fixed config logic, fxn binding to rpc address, fxn adding rpc cats
    -- router hive failed CI/CD resulting from outdated reference to rpcBindAddr
    -- ipc socket as default hidden from windows (for now)
refactored config endpoint
    - added rpc call script (contrib/omq-rpc.py)
    - added new fxns to .ini config stuff
    - added delete .ini file functionality to config endpoint
    - added edge case control for config endpoint

add commented out line in clang-form for header reorg later
2023-01-24 06:50:46 -08:00
Jeff Becker c682247f87
fix typo in config comments
lokinetN -> lokitunN
2023-01-23 09:24:21 -05:00
majestrate 7ae1a1a83b
Merge pull request #2108 from majestrate/service-refactor-2023-01-08
[internals refactor] docs and reorganize compilation units
2023-01-21 09:53:34 -05:00
Jeff Becker cd8316e287
add commented out line in clang-form for header reorg later 2023-01-20 15:58:07 -05:00
Jeff Becker 2498a085db
rearrange cmake libraries
define relations and document them.
make responsibilies clear and consice.
2023-01-20 15:58:07 -05:00
Jeff Becker 4508c59cd3
redo includes to be consistent 2023-01-20 13:26:22 -05:00
Jeff Becker 0ab050647f
overview of refactor plan and new component structure. 2023-01-20 13:26:22 -05:00
drouhana 0edfe8ff83
IPC Socket Fixes (#2111)
* Updated RpcServer Initialization and Logic

-- Moved all RPCServer initialization logic to rpcserver constructor
-- Fixed config logic, fxn binding to rpc address, fxn adding rpc cats
-- router hive failed CI/CD resulting from outdated reference to rpcBindAddr
-- ipc socket as default hidden from windows (for now)
2023-01-20 14:15:18 -04:00
majestrate 245f968d33
Merge pull request #2120 from tewinget/fix_syslog_target_arg
Fix incorrect usage of oxen-logging syslog
2023-01-17 19:20:37 -05:00
Thomas Winget fbfd70a35a Fix incorrect usage of oxen-logging syslog
Previously oxen-logging was erroneously hard-coded to use the target
"lokinet" for system logs.  Obviously this is wrong for anything else
which uses oxen-logging and the system log.  This changes our call to
add_sink to pass "lokinet" as the target rather than the config
filename, and updates oxen-logging to use that argument correctly.
2023-01-17 17:04:53 -05:00
majestrate ae9fd9a739
Merge pull request #2113 from drouhana/cli-refactor
testnet fixes
2023-01-11 09:37:06 -05:00
dan b31a266be8 testnet fixes
-- add ability to pass .ini path without --config flag
-- -r flag runs lokinet in router mode
2023-01-10 14:03:41 -08:00
drouhana a6b2172e54
Fix accepting config file as positional argument
re-add ability to pass .ini path without --config flag
2023-01-10 16:37:18 -04:00
Jason Rhinelander d1b6ccfbc3
Merge pull request #2109 from drouhana/cli-refactor
CLI Fixes
2023-01-10 15:51:00 -04:00
dan ea740ffd79 options.overwrite and options.force are redundant given refactor. they are now combined 2023-01-10 06:35:41 -08:00
dan 26beebca97 logic fix, commit to be stashed 2023-01-09 11:43:25 -08:00
dan b6991bb59a lokinet.cpp CLI and logic fixes
- added single dash to one letter flags to fix CLI incorrectconstruction error
- fixed generate file error
2023-01-09 11:28:25 -08:00
Jason Rhinelander 96c7f13744
Merge pull request #2107 from drouhana/cli-refactor
Command Line Interface Refactor
2023-01-06 19:08:14 -04:00
Jason Rhinelander 3d0fe8ecb7 Rename 'package' target on macos to 'dmg' to avoid cpack conflict
CLI11 uses cpack, which makes us fail to configure on macos because of
the 'package' target.  Renaming it to 'dmg' should avoid the conflict.
2023-01-06 15:07:26 -08:00
dan dc7f3cee22 Replace cxxopts with CLI11
- Simiplifies CLI code for future modification
- filesystem library linked in cmake check_for_std_filesystem file
2023-01-06 15:04:14 -08:00
Jason Rhinelander bf0dc52df7
Merge pull request #2104 from majestrate/openwrt-aarch64-fix-2023-01-03
add case for openwrt aarch64 in static deps
2023-01-05 12:02:53 -04:00
Jeff Becker dcd4623d2e
[win32 ci pipeline]
bookworm has no need for alternatives for mingw.

remove update-alternatives from the pipeline
2023-01-03 09:28:28 -05:00
Jeff Becker 1d84d630ea
add case for openwrt aarch64 in static deps
fixes #2103
2023-01-03 08:56:54 -05:00
Jason Rhinelander 9929445970
Fix poll_block_hash being set in the wrong place 2022-12-21 18:43:44 -04:00
Jason Rhinelander 8959e84595
Merge pull request #2079 from jagerman/bump-deps
Version bump for new release
2022-11-29 13:58:58 -04:00
Jason Rhinelander d9d3041dce
Bump version for fix release
In retrospect the last release really should have been called 0.10.0 and
this should be 0.10.1, but too late now.
2022-11-29 12:42:40 -04:00
Jason Rhinelander c3d212054a
Update deps to latest versions 2022-11-29 12:42:40 -04:00
majestrate e1f1b8b1c7
Merge pull request #2066 from jagerman/another-obsolete-bs
Remove another obsolete bootstrap
2022-11-27 13:27:38 -05:00
majestrate 9edda9f101
Merge pull request #2055 from jagerman/fix-option-names
Fix missing option names, make [lokid]:rpc required
2022-11-27 13:27:32 -05:00
majestrate 2c6e2e9472
Merge pull request #2076 from tewinget/more-verbose-logging
Fix Windows DNS issues
2022-11-24 09:38:13 -05:00
Thomas Winget 1e29465237 fix missing namespace 2022-11-22 18:39:22 -05:00
Thomas Winget c4c81cc9f8 I hate clang-format sometimes 2022-11-22 18:33:12 -05:00
Thomas Winget 3d71bbd1e4 log func should return a string instead 2022-11-22 17:59:54 -05:00
Thomas Winget d44ad497fd rvalue ref -> value 2022-11-22 17:48:03 -05:00
Thomas Winget 548ce5c3a2 invert packet direction on WINDIVERT_ADDRESS
We simply keep the WINDIVERT_ADDRESS struct given on recv, so when
using it for send we need to invert the direction (the Output bit)
2022-11-22 16:36:33 -05:00
Thomas Winget 5238c3f1a0 force windivert to recalc IP checksum 2022-11-22 16:36:33 -05:00
Thomas Winget 133cee0fd9 Remove obsolete/extraneous WouldLoop function
The DNS resolver code should not and can not be responsible for
preventing packet looping.
2022-11-22 16:36:33 -05:00
Thomas Winget a518e654c5 add much logging around dns and windivert 2022-11-22 16:36:33 -05:00
Jason Rhinelander e8d1361865
Remove another obsolete bootstrap
I found another defunct obsolete boostrap file on a few foundation
service nodes; this adds it to the list.
2022-11-18 16:00:12 -04:00
Jason Rhinelander 5345c60b30
Merge pull request #2065 from Bilb/fix-min-height-gui
fix: allow GUI window height as low as 600 for small screens
2022-11-17 19:47:14 -04:00
Audric Ackermann c57d8ef091 fix: allow GUI window height as low as 600 for small screens 2022-11-18 10:00:32 +11:00
Jason Rhinelander f9db657f64
Make Default&Required or Required&Hidden compilation failures
Default & Required makes no sense: if we have a default it makes no
sense to make it required.  The previous behaviour when this was
specified was to force an (uncommented) value in the config with the
value, but this was only used in the test suite.

Required & Hidden makes no sense either: if it's required to be
specified we definitely don't want to hide it from the generated config
file.

These are now compile-time failures.
2022-11-15 13:15:54 -04:00
Jason Rhinelander 68bb74a95d
Make [lokid]:rpc setting required in SN mode
When running as a service node we can't do anything without a lokid rpc
URL, and we don't necessarily have a good default for it.

This makes it required so that we fail with an appropriate error message
(rather than connect timeouts) if it is not specified.
2022-11-15 13:14:15 -04:00
Jason Rhinelander c8ce78315d
Fix missing option names
At some point between 0.9.9 and 0.9.10 we removed the printing of option
names when a value doesn't have a default, but this means the config is
littered with things like:

    # This option sets the greater foo value.

with no actual option name printed out when there is no default.

This fixes it by always printing the option name in such a case, just
with an empty value, e.g.:

    # This option sets the greater foo value.
    #big-foo=
2022-11-15 13:11:11 -04:00
Jason Rhinelander 7906fac4f0
Merge pull request #2053 from jagerman/mac-dmg-bg
Make dmg background retina capable
2022-11-10 22:33:26 -04:00
Jason Rhinelander 7f3cb0ff38 Make dmg background retina capable
The bg has to get encoded in a multi-format TIFF to make it work.

Also increase the vertical size a bit so that it still looks okay in
case you are a crazy person with a bunch of toolbars and other junk
cluttering up the window.
2022-11-10 20:32:23 -04:00
majestrate 4b5ab4bde3
Merge pull request #2051 from jagerman/mac-dmg-bg
Add mac .dmg background
2022-11-10 13:33:44 -05:00
Jason Rhinelander 135664ccb0 Add mac .dmg background 2022-11-09 20:46:37 -04:00
majestrate 27fd4d8faf
Merge pull request #2049 from majestrate/add-omitted-header-2022-11-08
add omitted header
2022-11-09 17:37:20 -05:00
Thomas Winget bb14a7bd09
when in rome, remove duplicate includes 2022-11-09 10:39:01 -05:00
Jeff Becker 259114b51d
add omitted header
certain files needed to include either fstream and our shim for std::filesystem.
this includes fstream into our shim and includes this shim in places
that require fstream. this is done because some toolchains (cough
cough broke af arch linux amalgums) can have weird subsets of the
requirements of C++17 that overlap, except when they dont, denoted by
unknowable undisclosed circumstances.

this issue was reported by a user in the wild, and this fixes it.
2022-11-09 07:16:29 -05:00
Jason Rhinelander 4f1f336e50
Bump openssl static build version 2022-11-03 20:51:02 -03:00
majestrate 7325878afd
Merge pull request #2048 from majestrate/simplify-ons-ready-logic-2022-11-03
simplify llarp::service::Endpoint::ReadyToDoLookup()
2022-11-03 11:14:35 -04:00
majestrate 29da2a9943
Update llarp/service/endpoint.cpp
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2022-11-03 10:49:57 -04:00
Jeff Becker e5efe793ca
llarp::service::Endpoint::ReadyToDoLookup()
previously we had a checking style function that passes in an optional
defaulting to nullopt as a micro optimzation, this makes the code
unnessarily obtuse.

simplify this by splitting up into 2 functions,
one for getting the unique endpoints and one for checking if the
number of them is above the minimum.

add overload for ReadyToDoLookup() that checks against constant but
can do more in the future if desired to reduce the burden on future contributors.
2022-11-03 10:00:44 -04:00
Jason Rhinelander 9dfb4a389c
Update gui subproject 2022-11-02 20:47:28 -03:00
majestrate b67a70517d
Merge pull request #2046 from majestrate/fix-lokinet-vpn-2022-11-02
prevent throwing on no error in lokinet-vpn
2022-11-02 16:41:44 -04:00
Jeff Becker 0cf637178d
prevent throwing on no error in lokinet-vpn 2022-11-02 15:42:49 -04:00
Jeff Becker 0bb58b4ac0
dont hardcode keyid 2022-11-02 09:32:31 -04:00
Jeff Becker 88b5a84df3
explicitly select signing key used in source tarball signing script 2022-11-02 09:24:31 -04:00
Jeff Becker 9adf099d20
remove dead file 2022-11-02 09:13:37 -04:00
majestrate 8ec1a57dac
correct documentation
the `make format` target doesn't exist anymore as we moved it to a shell script.
2022-11-02 09:12:47 -04:00
majestrate bcaf9f886c
point to explicit link
linking to docs directory is technically not correct. we should link to the file github shows for preview which is docs/readme.md
2022-11-02 09:07:12 -04:00
majestrate 9ca0d7094e
update note about platform support
android is currently unsupported
2022-11-02 09:05:34 -04:00
majestrate 1c51bb1041
Merge pull request #2045 from majestrate/windows-service-issues
windows platform bug fixes
2022-11-02 08:27:12 -04:00
Jeff Becker d911e26b1d
remove duplicate log statement 2022-11-01 19:09:17 -04:00
Jeff Becker 3a8007cc3f
remove assert()
we_changed_our_state can accept the state we are in right now, so this
assert no longer is correct.
2022-11-01 11:29:00 -04:00
Jason Rhinelander 6a110a4f1b
RPC: fix "halt" command 2022-11-01 11:06:03 -04:00
Jason Rhinelander 3bc3ae9d84
patch unbound to fix windows shutdown crash 2022-11-01 11:06:03 -04:00
Jason Rhinelander 40348b24e1
Fix crash on unbound cleanup
We need to make a copy here because (see comment).
2022-11-01 11:06:03 -04:00
Jason Rhinelander b8678a767e
Fix crashy race condition in shutdown
Query->Cancel() will remove the Query, but that introduces a race
condition where unbound may still try to invoke the callback (with a
no-longer-valid pointer) if we do it before the ub_ctx_delete call.

Move to it afterwards so that we only cancel things that unbound didn't
2022-11-01 11:06:02 -04:00
Jeff Becker 9aa6b64c1e
use std::shared_ptr for pending queries 2022-11-01 11:06:02 -04:00
Jason Rhinelander c7a133ac9c
windivert: avoid trying to send during shutdown
Occasionally during shutdown windivert will crash because a thread tries
sending after we've called wd::shutdown, which isn't allowed.  Add an
atomic bool to prevent this.
2022-11-01 11:06:02 -04:00
Jason Rhinelander cdc4c486c4
Add more stopping signals 2022-11-01 11:06:02 -04:00
Jason Rhinelander 2b5f1ee029
Remove bad assert
We do and should be able to call this multiple times during shutdown to
signal that we are advancing through shutdown.
2022-11-01 11:06:02 -04:00
Jason Rhinelander 3d429b353a
Don't raise log level on shutdown
If already below info (e.g. debug) it should stay there; we only want to
*lower* it to info if above info.
2022-11-01 11:06:01 -04:00
Thomas Winget 9960aed45c
stop-time debug statements 2022-11-01 11:06:01 -04:00
Jeff Becker 57b77fecb3
fix crash on shutdown
we were calling llarp::Context::HandleSignal from a non mainloop
thread when running as a win32 service. this caused issues with a non
clean destruction.

call our signal handler instead of llarp::Context::HandleSignal
2022-11-01 11:06:01 -04:00
Thomas Winget dceef0b21e
remove dead dns resolver code 2022-11-01 11:06:01 -04:00
Jason Rhinelander 95c0c8a707
Improve windows running-as-a-service detection works
Get rid of the --win32-daemon hack (which was removed from the service
itself earlier in this PR, by mistake) and replace it with detection of
the error code for "not running as a service" that windows gives us back
if we try to set up service controller dispatching but aren't a service.
2022-11-01 11:06:00 -04:00
Jason Rhinelander 4ad66ac2a5
Remove unused VERSION_STR constant 2022-11-01 11:06:00 -04:00
Jason Rhinelander 5be7dbf8ec
Move log init even earlier 2022-11-01 11:06:00 -04:00
Jeff Becker 3b6cbec08e
fix typo in filename 2022-11-01 11:06:00 -04:00
Jeff Becker a16af792d2
simplify logic for disabling service manager on windows 2022-11-01 11:06:00 -04:00
majestrate 84834089d1
Update llarp/router/router.cpp
use `fmt::join` for lokinet version string in status

Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2022-11-01 11:05:59 -04:00
Jason Rhinelander 31c312ad41
Extend windows startup timeout
If wintun fails it seems to take about 15s, so extend the startup
timeout so that it can fail gracefully (and let us clean up before
exiting).

Also refactors the timeouts to chrono constants.
2022-11-01 11:05:59 -04:00
Jason Rhinelander 71bea4f0fc
Add networkReady to stats result 2022-11-01 11:05:59 -04:00
Jason Rhinelander bd5efd8149
Update gui to latest 2022-11-01 11:05:59 -04:00
Jason Rhinelander 5c12110e93
Add some more debugging 2022-11-01 11:05:58 -04:00
Jason Rhinelander 64cf268457
Fix crashes in wintun and windivert stopping
Fixes windows shutdown crashes:

- windivert wasn't handling an ERROR_NO_DATA, which it gets when
  finished handling everything after a shutdown.
- wintun ReadPacket still gets invoked after end_session is called, but
  shouldn't be.  This adds an atomic<bool> to early return.
- fixes up some settings we send for windows service manager notify
2022-11-01 11:05:58 -04:00
Jason Rhinelander 879e678771
Remove dead/redundant code
- win32_platform.cpp is dead
- win32_platform.hpp is useless

Style changes from clang-tidy warnings:
- remove `virtual` from some definitions that already have `override`
- remove virtual destructor from NetworkInterface because it already has
  a virtual destructor via the base type (and clang-tiny warns about it)
2022-11-01 11:05:58 -04:00
Jeff Becker 4103908a8d
system layer manager (llarp::sys::service_manager)
the win32 and sd_notify components provided a disjointed set of
similar high level functionality so we consolidate these duplicate
code paths into one that has the same lifecycle regardless of platform
to reduce complexity of this feature.

this new component is responsible for reporting state changes to the
system layer and optionally propagating state change to lokinet
requested by the system layer (used by windows service).
2022-11-01 11:04:58 -04:00
Jeff Becker a7f3c3595b
fix comment to reflect reality 2022-10-27 11:03:45 -04:00
Thomas Winget 7ddad87dbf some useful log statements 2022-10-27 11:00:40 -04:00
Jeff Becker 9cdfae2e42
correct windows service manager behavior.
report status to window service manager when we get and iterogate
message from the service manager.
update comments to reflect these changes.
2022-10-27 10:54:43 -04:00
Thomas Winget a9a2a115bc
debian missing yacc apparently all of a sudden 2022-10-27 09:32:06 -04:00
Thomas Winget fcc4f6050d
wait until actually stopped to tell windows we are
We should send STOP_PENDING rather than STOPPED while we aren't yet
actually stopped; STOPPED is already sent when we actually finish
stopping.

Also fixes some silly argc/argv shenanigans, I think.
2022-10-27 09:32:06 -04:00
majestrate e8055a05ad
Merge pull request #2039 from jagerman/shorter-gossip-times
Shorten gossip times in systemd status line
2022-10-27 08:44:58 -04:00
Jason Rhinelander b6924f3ef1
Replace duration/timestamp formats with functions
We're defining formats for std::chrono types, which feels wrong (because
fmt itself also has these), so just replace them with functions:

short_time_from_now(...) gives a short "in 14m12s" or "5.123s ago" time
span relative to now, given a time point.  Precision gets reduced for
larger deviations from now (e.g. "4h12m ago").

ToString(Duration_t) gives a string such as "-3h22m02.123s" for a
duration.
2022-10-26 21:20:14 -03:00
majestrate d91c82c623
Merge pull request #2038 from majestrate/bind-fix-2022-10-26
proper handling of public ips
2022-10-26 17:04:21 -04:00
Jason Rhinelander 67e002c8ee
Fix time_delta<seconds> formatting in milliseconds
The time_delta<T> was using the wrong duration type when formatting, so
was outputting millisecond precision in the systemd status string which
is pointless (and unintended).
2022-10-26 17:19:00 -03:00
Jason Rhinelander 9f10e8003e
Remove useless iterator assignments
A back_inserter doesn't change when you insert onto it.
2022-10-26 17:18:47 -03:00
majestrate 3d0bc4a76c
Merge pull request #2037 from jagerman/ico-using-rsvg-convert
Use rsvg instead of imagemagick to make windows .ico; split up windows build
2022-10-26 15:24:28 -04:00
Jeff Becker 1e5b5ca1f5
proper handling of public ips
in service node mode make sure that when overriding public ip we only
fail when using 2 different public ip.
2022-10-26 14:58:32 -04:00
Jason Rhinelander 491f452dd7
Windows prebuilt gui fixes
Currently you can't use GUI_EXE without BUILD_GUI, but BUILD_GUI also
requires the yarn command (even though it will never use it when GUI_EXE
is set).

This commit fixes it:

- Make `GUI_EXE` a windows-only top-level project options, rather than
  being guarded by `BUILD_GUI`.
- Make `BUILD_GUI` control *building* the GUI instead of bundling it.
- GUI_EXE and BUILD_GUI are now mutually exclusive.
2022-10-26 15:27:22 -03:00
Jason Rhinelander caf97b1861
Split windows into gui/main builds, main now builds on bookworm
The options we need in rsvg-convert are apparently too new for bullseye,
so split the build so that we do the gui separately (in the nodejs-lts
container) and then build lokinet in bookworm.
2022-10-26 14:17:18 -03:00
Jason Rhinelander 11e052cb39
Add rsvg-convert dep to windows readme 2022-10-26 13:44:53 -03:00
Jason Rhinelander c8aa53a456
Use rsvg instead of imagemagick to make windows .ico
imagemagick is messing up the conversion, so just avoid it entirely and
use rsvg-convert directly to do it instead.
2022-10-26 13:24:34 -03:00
Jason Rhinelander 09c05d8206
Merge pull request #2036 from jagerman/win-x64
Use Windows-y 'x64' instead of '64bit' in static upload
2022-10-26 13:24:24 -03:00
Jason Rhinelander 6be4621aea
Use Windows-y 'x64' instead of '64bit' in static upload 2022-10-26 11:42:56 -03:00
majestrate 4c9d076c10
Merge pull request #2034 from jagerman/fix-router-startup
Fix router startup
2022-10-25 21:01:35 -04:00
majestrate 359ea1a3cd
Merge pull request #2033 from jagerman/fix-conf-backcompat
Fix backwards compatible config option handler
2022-10-25 21:01:20 -04:00
Jason Rhinelander 1980ca4d59 Fix bootstrap list bad bootstrap skipping
The iterator here to skip an obsolete bootstrap wasn't properly
reassigning the iterator, so "didn't work" (though why it was hanging
for me is entirely non-obvious).

Also refactored it to simplify/clarify it a bit.
2022-10-25 20:11:23 -03:00
Jason Rhinelander a828ef3f6d Remove obsolete junk
This stuff is already set earlier, in Configure.
2022-10-25 20:10:56 -03:00
Jason Rhinelander 9f49e006e4 Debug Router::Configure; initialize logging earlier
- Move logging initialization to early in Configure rather than at the
  end of FromConfig so that we can add debug logging inside
  Configure/FromConfig/etc.

- add said debug logging to Configure/FromConfig/etc.
2022-10-25 20:10:01 -03:00
Jason Rhinelander 3131297b00
Fix backwards compatible config option handler
Without this, old config (with now-irrelevant settings) won't work in
newer lokinet, making lokinet fatal error on startup if one of the
no-longer-used options is still present.
2022-10-25 18:06:25 -03:00
majestrate e8a27d1db3
Merge pull request #2032 from tewinget/pinned_node_config_cleanup
clarify strict-connect usage and enforce minimum of 2 nodes
2022-10-25 14:07:09 -04:00
majestrate 36dbbd19bf
Merge pull request #2031 from tewinget/get_status_ready_flag
add 'networkReady' to endpoint status
2022-10-25 14:07:00 -04:00
Thomas Winget 3b6953badc clarify strict-connect usage and enforce minimum of 2 nodes 2022-10-24 21:58:50 -04:00
Thomas Winget 1231d4e6c4 add 'networkReady' to endpoint status 2022-10-24 20:46:00 -04:00
majestrate cc2bbc20ca
Merge pull request #2030 from majestrate/issue-2029-keyfile-errors-2022-10-24
llarp_buffer_t idiocy
2022-10-24 15:04:40 -04:00
Jeff Becker bd5da10885
fixes issue #2029
when read/writing a .loki privkey file we dont rewind a llarp_buffer_t
after use. this is an argument in favor of just removing that type
from the code entirely.

fixes by using 2 distinct locally scoped llarp_buffer_t, one for read,
one for write.
2022-10-24 14:10:52 -04:00
majestrate cd858a00ea
Merge pull request #2027 from jagerman/clang-format-14
Bump clang-format to 14
2022-10-21 12:57:12 -04:00
majestrate 37ddecbd20
Merge pull request #2024 from jagerman/dep-updates
Dep updates
2022-10-21 12:56:31 -04:00
majestrate bb904294b1
Merge pull request #2023 from jagerman/drone-fixes
Drone fixes
2022-10-21 12:56:14 -04:00
Jason Rhinelander d011f8fb4a
Bump clang-format to 14 2022-10-20 19:53:52 -03:00
Jason Rhinelander 02108f0504
Merge pull request #2021 from tewinget/route-metric-preference
select gateway with lowest metric
2022-10-20 14:43:45 -03:00
Jason Rhinelander f01b075d3e
Rename darwin -> macos in uploaded build file 2022-10-20 13:43:00 -03:00
Jason Rhinelander f2454285fe
Set _WIN32_WINNT in static deps
Set -D_WIN32_WINNT for static deps; unbound, in particular, needs this
as the latest version appears to rely on something only provided in
non-ancient windows to build properly.

This required moving _winver into the toolchain file so that it is
available earlier in cmake code (StaticBuild is included long before
win32.cmake), but also this seems a more appropriate place for it.
2022-10-20 13:38:36 -03:00
Jason Rhinelander 0e09539b61 CI fixes
- cd .. after the build, before running extra_cmds, because the scripts
  we invoke expect to be in the root, not in the build dir (and it's
  dirtier for the build function to not undo the `cd build` that it
  runs).
- fix unclosed parenthesis in mac static lib checker
2022-10-20 12:46:36 -03:00
Jason Rhinelander 081dfd3328 Update submodules to latest version:
cpr: 1.9.2
cxxopts: 3.0.0
ghc-filesystem: 1.5.12
nlohmann-json: 3.11.2
pybind11: 2.10.0
sqlite_orm: 1.7.1

Plus other updates need to make these work:
- cpr needs a cprver.h configured with the version (cmake code copied
  from oxen-core).
2022-10-20 12:17:23 -03:00
Jason Rhinelander 0ed3d51aa2 Update static deps to latest stable versions 2022-10-20 11:56:47 -03:00
majestrate 86c3b2f4ae
Merge pull request #2019 from jagerman/config-reformat
Config setting documentation edits
2022-10-20 08:35:42 -04:00
Thomas Winget 0c0ba29bae use first gateway, not last... 2022-10-19 22:29:09 -04:00
Jason Rhinelander c3a515da49
Config setting documentation edits
Rewords/reformats the documentation of various configuration options.
2022-10-18 12:05:13 -03:00
jeff 011bd2e84f format 2022-10-17 19:05:30 -04:00
Jeff Becker e5b7ea5f2d
dont do queries while down 2022-10-17 09:38:19 -04:00
Jeff Becker 082756c64c
cancel pending queries on down.
after calling Down() any pending queries will not be properly
canceled and results in a crash when we destruct the queries on our side.
2022-10-17 09:10:34 -04:00
Jeff Becker 306d54e285
when running as a client squelch warnings about snode status and make sure we connect out 2022-10-17 08:33:50 -04:00
majestrate 8f532dec89
Merge pull request #2015 from jagerman/oxend-rpc-updates
Oxend RPC updates
2022-10-16 19:11:11 -04:00
jeff 6813dd659c lint 2022-10-16 14:53:23 -04:00
majestrate 9176ab1157
Merge pull request #2014 from jagerman/fix-sockaddr-ordering
Fix multi-field ordering
2022-10-15 10:54:07 -04:00
majestrate 666642f906
Merge pull request #2016 from jagerman/zlib-bump
zlib version bump
2022-10-15 10:53:52 -04:00
Jason Rhinelander e143bd13cd
zlib version bump 2022-10-14 22:29:58 -03:00
Jason Rhinelander c5e787b8cb Oxend error ping + unfunded tracking
Currently (from a recent PR) we aren't pinging oxend if not active, but
that behaviour ended up being quite wrong because lokinet needs to ping
even when decommissioned or deregistered (when decommissioned we need
the ping to get commissioned again, and if not registered we need the
ping to get past the "lokinet isn't pinging" nag screen to prepare a
registration).

This considerably revises the pinging behaviour:

- We ping oxend *unless* there is a specific error with our connections
  (i.e. we *should* be establishing peer connections but don't have any)
- If we do have such an error, we send a new oxend "error" ping to
  report the error to oxend and get oxend to hold off on sending uptime
  proofs.

Along the way this also changes how we handle the current node state:
instead of just tracking deregistered/decommissioned, we now track three
states:

- LooksRegistered -- which means the SN is known to the network (but not
  necessarily active or fully staked)
- LooksFunded -- which means it is known *and* is fully funded, but not
  necessarily active
- LooksDecommissioned -- which means it is known, funded, and not
  currently active (which implies decommissioned).

The funded (or more precisely, unfunded) state is now tracked in
rc_lookup_handler in a "greenlist" -- i.e. new SNs that are so new (i.e.
"green") that they aren't even fully staked or active yet.
2022-10-14 20:55:21 -03:00
Jason Rhinelander bd869b3b07 Log demotion
Demote a couple spammy messages to trace level.
2022-10-14 20:37:19 -03:00
Jason Rhinelander 0e576ff59e Clean up oxend service node list handling
This aligns service node updating logic a bit closer to what happens in
storage server, and should make it a bit more resilient, hopefully
tracking down the (off-Github) reported issue where lokinet sometimes
doesn't see itself as active.

- Initiate a service node list update in the 30s timer lokinet ping
  timer (in case we miss a block notify for some reason); although this
  is expensive, the next point mitigates it:

- Retrieve the block hash with the SN state update, and feed it back
  into the next get_service_nodes call (as "poll_block_hash") so that
  oxend just sends back a mostly-empty response when the block hasn't
  changed, allowing both oxend and lokinet to skip nearly all of the
  work of a service node list update when the block hasn't changed since
  the last poll.  (This was already partially implemenated--we were
  already looking for "unchanged"--but without a block hash to get from
  and pass back to oxend we'd never actually get an "unchanged" result).

- Tighten up the service node list handling by moving the "unchanged"
  handling into the get_service_nodes response handler: this way the
  HandleNewServiceNodeList function is only handling the list but not
  the logic as to whether there actually is a new list or not.
2022-10-14 18:02:53 -03:00
Jason Rhinelander 36792d4337
Fix multi-field < ordering
Lots and lots of places in the code had broken < operators because they
are returning something like:

    foo < other.foo or bar < other.bar;

but this breaks both the strict weak ordering requirements that are
required for the "Compare" requirement for things like
std::map/set/priority_queue.

For example:

    a = {.foo=1, .bar=3}
    b = {.foo=3, .bar=1}

does not have an ordering over a and b (both `a < b` and `b < a` are
satisfied at the same time).

This needs to be instead something like:

    foo < other.foo or (foo == other.foo and bar < other.bar)

but that's a bit clunkier, and it is easier to use std::tie for tuple's
built-in < comparison which does the right thing:

    std::tie(foo, bar) < std::tie(other.foo, other.bar)

(Initially I noticed this in SockAddr/sockaddr_in6, but upon further
investigation this extends to the major of multi-field `operator<`'s.)

This fixes it by using std::tie (or something similar) everywhere we are
doing multi-field inequalities.
2022-10-13 16:29:13 -03:00
majestrate 54fba30516
Merge pull request #2008 from jagerman/win32-routepoker-logging
Add more logging around route poking conditions
2022-10-07 09:33:13 -04:00
Jason Rhinelander bc071231c8
Add a net::ToString() to help stringify ipaddr_t
Android, in particular, has problems with fmt's built-in variant
handling for this type for some reason.
2022-10-06 22:21:41 -03:00
Jason Rhinelander 25d73d627a
Remake non-mac icon; regenerate during build for windows
The non-mac icon was an old version with white foreground and a
completely transparent background, but this looks bad (or invisible)
depending on where you view it.  This updates it based on the macos
icon, but with a round white circle background instead of the macos
"squircle" background.

This also replaces the .ico file for the installer with one that we
build during the win32 build rather than a pregenerated one.

Bumps the gui as well to a version with the new icons in place.
2022-10-06 21:32:58 -03:00
Jason Rhinelander 768e953522
De-prioritize some windivert logging
We don't really need to log at info level for every
windivert-intercepted incoming and outgoing packet.
2022-10-06 21:32:58 -03:00
Jason Rhinelander 6f31d5108b
Windows fix: iterate over IPv4/IPv6 interfaces separately
If we get back an IPv6 address as the first gateway then we won't have
the expected IPv4 gateway that the route poker needs to operate.

This iterates through them separately so that we treat the IPv4 and IPv6
sides of an address as separate interfaces which should allow the route
poker to find the one it wants (and just skip the IPv6 one).
2022-10-06 21:32:58 -03:00
Jason Rhinelander e398b5bff8
Fix interface enumeration on posix
The last interface wouldn't be considered.
2022-10-06 21:32:57 -03:00
Jason Rhinelander fe0f916a09
DRY private range selection; add missing ranges
DRY a chunk of repeated code for finding a free private range.

Also fix it so that it will consider 10.255.0.1/16 and 192.168.255.1/24
(previously it would only check up to octet 254).
2022-10-06 21:32:57 -03:00
Jason Rhinelander d10c4b9d17
Add more logging around route poking conditions
Log why we aren't doing anything if we aren't going to do anything.
2022-10-06 21:32:57 -03:00
Jason Rhinelander 4bf80833f4
Add InterfaceInfo formatter 2022-10-06 21:32:57 -03:00
Jason Rhinelander bd8dffc730
Merge pull request #1991 from jagerman/lokinet-vpn-cleanups
Lokinet vpn cleanups
2022-10-06 16:09:56 -03:00
Jason Rhinelander ba6a3f0e80
Merge pull request #1996 from tewinget/fallback-bootstrap
Fallback bootstrap router build parameter, ignore obsolete bootstrap routers
2022-10-06 16:09:29 -03:00
Jason Rhinelander 9a2cd19eb8
Fix obsolete oxenmq/hex.h usage 2022-10-06 14:29:50 -03:00
Jason Rhinelander 6ee7306217
oxen-mq update to tagged stable release 2022-10-06 14:01:09 -03:00
Jason Rhinelander 82e2e6fb10
bake in bootstrap fallbacks at build time
also change the defailt/fallback bootstrap file for testnet to be a list
of RCs (albeit of size 1) rather than just an RC dict.
2022-10-06 13:59:49 -03:00
Thomas Winget 82c95a2486
don't ping core if active with too few peers
If running as a service node, we ping core on a regular interval to
inform it we're running and in a good state.  If we're an active
(not decommissioned or deregistered) service node and have too few
peers and thus we're not actually connected to lokinet, we should skip
that ping so core doesn't think we're ok.
2022-10-06 13:59:49 -03:00
Thomas Winget cc1bcf86fa
Fallback bootstrap router build parameter
Adds a fallback bootstrap file path parameter to CMake, specify
-DBOOTSTRAP_SYSTEM_PATH="/path/to/file" to use.

Adds a list of (currently 1) obsolete bootstrap RouterIDs to check
bootstrap RCs against.  Will not use bootstrap RCs if they're on that
list.

Log an error periodically if we appear to be an active service node but
have fewer than a set number (5) known peers.

Bumps oxen-logging version for literal _format.
2022-10-06 13:59:47 -03:00
Jason Rhinelander 20281ccc60
Clean up/simplify SN list handling 2022-10-06 13:58:33 -03:00
Jason Rhinelander ebdb37ac77
Significantly decrease decomm warning frequency
30s is insanely fast for a error level log statement and spams logs
incessantly; reduce it to repeating once every 5 minutes.
2022-10-06 13:58:26 -03:00
Jason Rhinelander d944b6542c
Merge pull request #1997 from tewinget/omq-rpc-logs
omq rpc log subscription
2022-10-06 13:56:07 -03:00
Jason Rhinelander 3276ed1d71
Bump lokinet-gui to latest
For log support, and other various changes/improvements.
2022-10-06 11:56:07 -03:00
Jason Rhinelander bac3f9dca1
fix macos assemble_gui dependency
The `sign` target on macos was not working properly -- the signing
script would run before the build is finished.  This was caused by
cmake/macos.cmake having an `if(BUILD_GUI)`, but BUILD_GUI isn't defined
as an option until cmake/gui.cmake, which hadn't been included yet where
macos.cmake was included.

This extracts just the `option(BUIL_GUI)` from gui.cmake into a separate
gui-option.cmake file that we can load earlier to fix it.

While here I also noticed the GUI_EXE setting was defined as an option,
but isn't actually a boolean value, as an option, but isn't actually a
boolean value, so fixed it by making it a `set(... CACHE FILEPATH ...)`.
2022-10-06 11:56:07 -03:00
Jason Rhinelander 9f258700b7
Lower log level for renewals to debug
Otherwise you see a lot of unnecessary subscription renewals every 30s
in the logs.
2022-10-06 11:56:07 -03:00
Jason Rhinelander dc358a6eda
macos: Fix hanging --start when Lokinet already running
If you stop/start the GUI but it doesn't exit on start, the second
--start (when lokinet is already running) waits for a state change that
doesn't come (because lokinet is already running).  This add a check for
already-running so that we exit right away in such a case.
2022-10-06 11:56:07 -03:00
Jason Rhinelander 307ae40e00
Apple: fix build failure when file already exists
The tools to create a dmg on Apple are flakey, of course, and fail in
cryptic ways if the file already exists, so purge it in the
contrib/mac.sh script.
2022-10-06 11:56:07 -03:00
Jason Rhinelander c4c5d128c3
Add ring buffer sink to macos build 2022-10-06 11:56:06 -03:00
Thomas Winget eaf30de1fd
omq rpc log subscription
respects whether RPC is enabled, removes the log sink otherwise

bumps oxen-mq and oxen-logging
2022-10-06 11:56:04 -03:00
Jason Rhinelander fc07b8a10e
Merge pull request #2005 from jagerman/profiling-bencode-refactor
file slurp/dump and profiling refactor
2022-10-06 11:55:19 -03:00
Jason Rhinelander 006394315d
Add local mirror to most jobs; build script cleanups 2022-10-05 19:29:47 -03:00
Jason Rhinelander fae527517d
Try to appease android's crappy toolchain 2022-10-05 17:34:55 -03:00
Jason Rhinelander 75e382604b
Bump required oxenc version 2022-10-05 16:48:59 -03:00
Jason Rhinelander f641c08e80
llarp/profiling: refactor to use oxenc producer/consumer
No more llarp_buffer_t here!

(I was tracking down a segfault which led me in here and it was easier
to rewrite this to use bt_dict_{consumer,producer} than to decipher all
the cursed llarp_buffer_t and bencode callback nest).
2022-10-05 16:35:16 -03:00
Jason Rhinelander d335527a70
Add binary file slurp/dump utility functions
We have basically this same bit of code in tons of places; consolidate
it into llarp::util::slurp_file/llarp::util::dump_file.

Also renames all the extra junk that crept into llarp/util/fs.hpp out of
there into llarp/util/file.hpp instead.
2022-10-05 16:34:32 -03:00
Jason Rhinelander 3891141755
Merge pull request #2004 from jagerman/mac-icon-rework
Rewrite and tweak the macos icon
2022-10-05 12:53:38 -03:00
Jason Rhinelander ca26b20b2f
Scale down the inner part of the logo a bit 2022-10-04 20:51:29 -03:00
Jason Rhinelander 6b352c7fd8
Rewrite and tweak the macos icon
The old one was way too big on mac relative to other icons.  This scales
the background down, while keeping the black logo parts the same, and
changes the rounding of the corners to match native macos apps.

This also rewrites it from scratch to use a useful coordinate system
which allows drawing all the fundamentals in much more useful units.
2022-10-04 13:57:59 -03:00
Jason Rhinelander 66c79b232a
Fix log warning 2022-09-22 13:22:43 -03:00
Jason Rhinelander ab11a8128d
lokinet-vpn: misc cleanups
- Add a function to extract a value from parsed options, to DRY out the
  code a little bit.
- Add a exit_error function to format a message to stdout and then
  return the code, to simplify the repeated print-and-return code used
  when errors occur.
- Use fmt for output formatting
- Add an error if multiple modes are specified at once
  (--up/--down/--status/--exit)
- Add error printing around unmap
2022-09-21 13:38:18 -03:00
Jason Rhinelander f8f7f20666
Rename LMQ -> OMQ 2022-09-21 13:38:18 -03:00
Jason Rhinelander 71ea4f4fa2
RPC: Relax token/range argument handling
- Accept empty string or `null` for token to mean "no token."
- Accept `null` for range to mean "default range."
- Don't use a default range (::0/0) in lokinet-vpn because this will
  fail if IPv6 ranges aren't supported on the platform (e.g. on
  Windows), and isn't necessary: if we omit it then the rpc code already
  uses ::0/0 or 0.0.0.0/0 by default, as needed.
2022-09-21 13:38:17 -03:00
Jason Rhinelander 8b321612da
Merge pull request #1969 from majestrate/wintun-windivert-2022-08-02
use wintun and windivert for windows platform bits
2022-09-21 13:37:41 -03:00
majestrate f777075893
Merge pull request #1986 from majestrate/docs-2022-09-04
restructure readme and docs
2022-09-20 11:48:07 -04:00
Jason Rhinelander 90be75d04e
Disable mips cross compile build on ci 2022-09-19 21:54:36 -03:00
Jason Rhinelander 9529553cf6
Add oxen build mirror to linux static builds 2022-09-19 20:42:45 -03:00
Jason Rhinelander 83f7e8193c
Disable installer path modification
This is not likely to be usable to many people, and people who it *is*
useful for are knowledgeable enough to modify it themselves.  Most users
get no use at all and it most likely just confuses them instead.
2022-09-19 20:26:41 -03:00
Jason Rhinelander 2709ec1930
Android build fixes for openssl 3.0.5
- ANDROID_NDK_ROOT must be set in env
- cmake should be setting `-DANDROID_API=23`
- specify the correct android API via a define when building openssl; it
  has to be in CPPFLAGS (not CFLAGS) because otherwise openssl's
  configure script doesn't notice and overrides our define with the
  latest API version.
- openssl configure puts $(ANDROID_NDK_ROOT) in the makefile, so we have
  to be sure that we put it in the environment for the build command,
  too.
2022-09-19 20:26:41 -03:00
Jason Rhinelander 616f559761
macos CI fixes
- Split up mac.sh into a configure + build scripts (like Windows).
- Don't attempt to build the 'package' target in CI: apparently you have
  to have a logged in user at the GUI in order to build a .dmg because
  being obtuse is the Apple way.
- Upload the raw Lokinet unsigned app in a .tar.xz, rather than dmg,
  because of the above.
- make mac.sh respect JOBS (pun not intended (but still good))
2022-09-19 20:26:41 -03:00
Jason Rhinelander 1f9779cdcd
Windows compilation fix 2022-09-19 20:26:41 -03:00
Jason Rhinelander b2cd9a9eec
openssl 3 build fixes
SYSTEM/MACHINE apparently doesn't work anymore and you have to pass the
system-machine value into the (cursed nasty hacky perl) configure
script.
2022-09-19 20:26:40 -03:00
Jason Rhinelander 7078ab06bc
compiler warnings cmake 3.13 compatibility fix 2022-09-19 20:26:40 -03:00
Jason Rhinelander 93c01623b0
Format fixes & fix warning in format script
- Don't escape '#' in the greps in format.sh: they warn about a spurious
  `\` in the latest grep.
- reformat
2022-09-19 20:26:40 -03:00
Jason Rhinelander ec91a6db05
ReconfigureDNS fixes, fixes macos exit mode
- ReconfigureDNS wasn't returning the old servers; made it void instead
  (the Apple code can just store a copy of the original upstream
  servers instead).
- Reconfiguring DNS reset the unbound context but didn't replace it, so
  a Down()/Up() would crash.
- Simplify Resolver() destructor to just call Down(), and make it final
  just so that no one tries to inherit from us (so that calling a
  virtual function from the destructor is safe).
- Rename CancelPendingQueries() to Down(); the former cancelled but also
  shut down the object, so the name seemed a bit misleading.
- Rename SetInternalState in Resolver_Base to ResetResolver, so that we
  aren't conflicting with ResetInternalState from Endpoint (which was a
  problem because TunEndpoint inherited from both; it could be resolved
  through the different argument type if we removed the default, but
  that seems gross).
- Make Resolver use a bare unbound context pointer rather than a
  shared_ptr; since Resolver (now) entirely manages it already we don't
  need an extra management layer, and it saves a bunch of `.get()`s.
2022-09-19 20:26:40 -03:00
Jason Rhinelander 2ccc518849
Fix apple dns, part 817 2022-09-19 20:26:40 -03:00
Jeff Becker bd09f7716d
override method 2022-09-19 20:26:40 -03:00
Jeff Becker 13d1301e08
rewire up dns reconfiguration for macos 2022-09-19 20:26:40 -03:00
Jason Rhinelander 52c6cd497f
Apple DNS fix WIP 2022-09-19 20:26:40 -03:00
Jason Rhinelander 2aae56b0e0
Apple DNS configuration fix: don't obliterate trampoline
On Apple, the network extension is outside the tunnel routing, so we
cannot have libunbound talk directly to upstream (it would leak DNS when
exit mode is enabled).  Instead unbound *always* talks to a localhost
port where we have a "dns trampoline" that takes UDP packets and shoves
them through the tunnel.

We were doing that already, but recent changes here were overwriting the
libunbound settings with.

This also moves the upstream DNS configuration part of `Up()` into its
own method.
2022-09-19 20:26:40 -03:00
Jason Rhinelander 4d920bb2e2
Fix macos
We don't have a resolver on macos, so we were running through this loop
with fails == 0 == m_Impls.size() and throwing, crashing the process.

Early return to avoid the failure and fix macos crash.
2022-09-19 20:26:39 -03:00
Jeff Becker b81ae95246
remove hunk of win32 specific code, it is dead in this codepath 2022-09-19 20:26:39 -03:00
Jason Rhinelander 27d58044c7
macos compilation fixes 2022-09-19 20:26:39 -03:00
Jason Rhinelander a82907bc6c
Set various -W flags on apple
Apple supports anything here that Clang supports and should have them
set the same as everywhere else.

Most importantly this gives apple the -Wno-deprecated-declarations flag
which has been driving me nuts on macos.

This also version-gates the -Wno-deprecated-declarations so that it
will turn on again when we bump the version beyond .10.
2022-09-19 20:26:39 -03:00
Jason Rhinelander c7597c1abd
OpenSSL 1.1.1 -> 3.0.5 2022-09-19 20:26:39 -03:00
Jeff Becker 379ac755ec
make unit tests pass
changes to how config defaults, specifically allowing defaults to be a
vector, broke unit test compilation. this makes them compile again.
2022-09-19 20:26:39 -03:00
Jason Rhinelander 291f311259
Fix linked list iteration for windows ip/gateways
We were requiring `->Next` be true, which means we skipped the last (and
often only) entry of the linked lists and so never properly found the
gateway.
2022-09-19 20:26:39 -03:00
Jason Rhinelander 9097435f64
Refactor/fix GetAdaptersAddresses
- We need to pass a flag to get Windows to include gateway info.
- Refactor it to use microsoft's recommended magic default 15000 buffer
  size and repeat in a loop a few times until it works.  Developers,
  developers, developers, developers!
2022-09-19 20:26:39 -03:00
Jason Rhinelander d1e997177d
Add missing != operator to nuint_t 2022-09-19 20:26:38 -03:00
Jason Rhinelander 613459401d
Linux route poker fixes
- don't add routes when not in exit mode
- don't call Up() from rpc code (the RouterPoker itself decides when to
  call Up())
2022-09-19 20:26:38 -03:00
Jason Rhinelander e9554c7c5e
Don't do route poking when disabled
IsEnabled() is a bit broader than just IsServiceNode, so use it instead.
2022-09-19 20:26:38 -03:00
Jason Rhinelander 45b3365002
Simplifications
- a `static` is less verbose and otherwise identical to an empty
  namespace for a single declaration like this.
- operator== on two optionals already does exactly what the `is_equal`
  lambda here is doing.
- formatting
2022-09-19 20:26:38 -03:00
Jason Rhinelander 517911b499
Fix crash on shutdown
For some (wrong) reason this chunk of code was here.  Removed it to stop
a crash on shutdown.
2022-09-19 20:26:38 -03:00
Jeff Becker 0fb639db53
idempotent dns 2022-09-19 20:26:38 -03:00
Jeff Becker 26c1336517
limit route poker 2022-09-19 20:26:38 -03:00
Jeff Becker 61f66ac1ec
fix up win32 route poker a bit 2022-09-19 20:26:38 -03:00
Jason Rhinelander 15144f193c
cleanups/simplifications 2022-09-19 20:26:38 -03:00
Jason Rhinelander 9ddf7413af
Windows DNS fixes
- windivert was being set up *before* DNS is set up, so the DNS port was
  nullopt and thus we couldn't properly identify upstream DNS traffic.
- close() doesn't close a socket on Windows, so the socket-bind-close
  approach to get a free UDP port wasn't actually closing, and thus
  unbound upstream constrained to the given port were completely
  failing.
- The unbound thread was accessing the same shared_ptr instance as the
  outer code, which isn't thread-safe; changed it to copy a weak_ptr
  into the lambda instead.
- Exclude upstream DNS traffic in the filter rather than capturing and
  reinjecting it.
2022-09-19 20:26:37 -03:00
Jason Rhinelander c470349fb3
Log upstream DNS servers when setting it up 2022-09-19 20:26:37 -03:00
Jason Rhinelander ab2177bee9
Restore Apple hax 2022-09-19 20:26:37 -03:00
Jason Rhinelander de4bce1d96
Disable upstream TCP DNS
windivert, in particular, will get filtered by this and it almost
certainly won't work.
2022-09-19 20:26:37 -03:00
Jason Rhinelander d32a37e30b
Upgrade unbound to latest stable 2022-09-19 20:26:37 -03:00
Jason Rhinelander bb85ec4595
De-inline vpn/win32.hpp 2022-09-19 20:26:37 -03:00
Jason Rhinelander 2a27698016
Fix backwards from/to in PacketSource_Wrapper
This resulted in DNS responses in Windows having reversed direction when
reinjected, and thus not arriving as expected.
2022-09-19 20:26:37 -03:00
Jason Rhinelander 7a0d4a905e
fix speeling 2022-09-19 20:26:37 -03:00
Jason Rhinelander 07231dd9e1
Fixed crash in DNS resolving
The inner lambda here wasn't keeping the `Query` (`this`) alive, so
`src` wasn't valid anymore.  This changes it to copy the `src`
shared_ptr into the lambda instead of capturing `this`, and fixes it.
2022-09-19 20:26:36 -03:00
Jason Rhinelander d4739d5d47
Fix sockaddr_len initial value 2022-09-19 20:26:36 -03:00
Jason Rhinelander b856b78de3
format 2022-09-19 20:26:36 -03:00
Jason Rhinelander 05ed9d6de0
llarp/dns logging refactor
Convert everything in llarp/dns to new-style logging.
2022-09-19 20:26:36 -03:00
Jason Rhinelander 49223a7853
bind/close to find free UDP port
The current code isn't working and gives a 0 (which then fails unbound
initialization).  This replaces it by doing a socket+bind to find a free
port then immediately closes (but passes the port we got into unbound).
2022-09-19 20:26:36 -03:00
Jason Rhinelander 9921dd6c77
Simplify dll loading via static function pointers
- Replaces RAII handling of DLLs with global function pointers.  (We
  don't unload the dll this way, but that seems unnecessary anyway).
- Simplifies code by just needing to call an init function, but not
  needing to pass around an object holding the function pointers.
- Adds a templated dll loader that takes the dll and a list of
  name/pointer pairs to load the dll and set the pointers in one shot.
2022-09-19 20:26:36 -03:00
Jeff Becker 281fbe57f7
promote log statement 2022-09-19 20:26:36 -03:00
Jason Rhinelander aee618e0d7
Fail if wintun can't retrieve its version 2022-09-19 20:26:36 -03:00
Jason Rhinelander 84ad0ab4d3
Slightly DRY thread-setting code, fix warning
There were warnings from the rc variable being unused; this DRYes it to
use the same code as linux (including the failure check on rc).
2022-09-19 20:26:36 -03:00
Jason Rhinelander 4065413977
Simplify/fix ip_header layout
ip_header wasn't 20 bytes on windows compilations for some unholy
reason.  This restructures it to avoid the template and just use two
different structs for le/be with a condition_t for the ifdef, which
resolves it (and *also* apparently avoids the need for the pack).

Also add a static_assert to check the size.

Also do the same for ipv6.
2022-09-19 20:26:35 -03:00
Jason Rhinelander 58eec9ed11
Avoid strict aliasing warning on function pointers
Cast via an ordinary function pointer rather than a function pointer
reference to avoid the warning.

Also make the pointer in `Func_t` explicit rather than implicit (deduced
into the `Func_t` type) to make it clearer what is going on here.
2022-09-19 20:26:35 -03:00
Jason Rhinelander ef4e720890
Bump cmake min to 3.13 and adopt policies up to 3.24
3.13...3.xx means "minimum is 3.13, but use any new cmake policies
introduced up to 3.xx".

There was, in particular, a policy w.r.t.  external project timestamps
causing warnings under 3.24.
2022-09-19 20:26:35 -03:00
Jason Rhinelander dd16158081
DNS: default to 127.3.2.1 & high port on Linux
Lots of tools struggle with non-default DNS port, so keep a listener on
127.3.2.1:53 (by default).

This required various changes to the config handling to hold a vector
(instead of an optional) of defaults and values, and now allows passing
in an array of defaults instead of just a single default.
2022-09-19 20:26:35 -03:00
Jeff Becker beb07bf46f
small optimizations and fixes
- Ensure ip header struct is packed
- Use fmt
- add missing header
2022-09-19 20:26:28 -03:00
Jason Rhinelander cfd80f6a17
Fix buffer_printer overflow 2022-09-19 20:25:52 -03:00
Jason Rhinelander f168b7cf72
llarp_buffer_t: rename badly named operator==
It didn't do equality, it did "does the remaining space start with the
argument" (and so the replacement in the previous commit was broken).

This renames it to avoid the confusion and restores to what it was doing
on dev.
2022-09-19 20:25:51 -03:00
Jason Rhinelander b9c9ee1ca7
Fix read problem in linux
errno is only set if read returns < 0 and won't be set to 0 if read
succeeds, so we were bailing here frequently on successful reads
(whenever errno happened to be non-0).
2022-09-19 20:25:51 -03:00
Jason Rhinelander 15443568db
Apply some lipstick to llarp_buffer_t
This class is cursed, but also broken under gcc-12.  Apply some lipstick
to get it moving again (but we really need to refactor this because it
is a mess).
2022-09-19 20:25:51 -03:00
Jeff Becker 24dcffabe5
unit tests 2022-09-08 14:25:01 -04:00
Jeff Becker 4490fdcf46
fix up CI
add jason's suggested changes for artifact upload

use lokinet-ci-nodejs-lts as base image so we can build the installer

update ci pipeline for windows to have building gui toggle-able

by default we will build the gui from this repo, but this allows it to
easily run using a custom gui asset if needed
2022-09-08 14:25:01 -04:00
Jason Rhinelander c9d928950a
C-cast to work around gross enum==int assumption in windows API 2022-09-08 14:25:01 -04:00
Jason Rhinelander 49b97f47cc
Make windows-configure.sh runnable without root/build
For when you want to set up a windows build dir, without doing the build
yet.
2022-09-08 14:25:00 -04:00
Jeff Becker a02679b87a
revise ./contrib/format.sh 2022-09-08 14:25:00 -04:00
Jeff Becker 7f27760c97
disable lokinet-bootstrap on windows builds 2022-09-08 14:25:00 -04:00
Jeff 871c3e3281
changeset for windows port
* wintun vpn platform for windows
* bundle config snippets into nsis installer for exit node, keyfile persisting, reduced hops mode.
* use wintun for vpn platform
* isolate all windows platform specific code into their own compilation units and libraries
* split up internal libraries into more specific components
* rename liblokinet.a target to liblokinet-amalgum.a to elimiate ambiguity with liblokinet.so
* DNS platform for win32
* rename llarp/ev/ev_libuv.{c,h}pp to llarp/ev/libuv.{c,h}pp as the old name was idiotic
* split up net platform into win32 and posix specific compilation units
* rename lokinet_init.c to easter_eggs.cpp as that is what they are for and it does not need to be a c compilation target
* add cmake option STRIP_SYMBOLS for seperating out debug symbols for windows builds
* intercept dns traffic on all interfaces on windows using windivert and feed it into lokinet
2022-09-08 14:24:59 -04:00
Jeff e981c9f899
tweaks for wine and yarn for gui
* allow specifying a custom yarn binary for building the gui using -DYARN= cmake option
* unset DISPLAY when calling wine because i hate popups
* do not rebuild gui when building for windows
* by setting the magical undocumented env var USE_SYSTEM_7ZA to 'true' we can have the pile of npm bullshit code use our system's local 7z binary instead of the probably not backdoored binary from npm, yes for real. i hate nodejs so god damn much you have no fucking idea
* allow providing a custom gui from a zip file via -DGUI_ZIP_FILE cmake option
2022-09-08 14:23:54 -04:00
Jeff d846bab0e1
unbreak android config loading 2022-09-08 14:23:53 -04:00
Jeff baddad9564
remove compat wrapper 2022-09-08 14:23:53 -04:00
Jeff 253d22db4f
restucture dbus parts
* move dbus into llarp/linux/dbus.hpp and llarp/linux/dbus.cpp
* provide platform abstraction for setting dns in preparation for network manager
2022-09-08 14:23:53 -04:00
Jeff 2d586145ee
wire up dns srv records 2022-09-08 14:23:52 -04:00
Jeff 74362149eb
refactor dns subsystem
we want to be able to have multiple locally bound dns sockets in lokinet so
i restructured most of the dns subsystem in order to make this easier.

specifically, we have a new structure to dns subsystem:

* dns::QueryJob_Base

base type for holding a dns query and response with virtual methods
in charge of sending a reply to whoever requested.

* dns::PacketSource_Base

base type for reading and writing dns messages to and from wherever they came from

* dns::Resolver_Base

base type for filtering and handling of dns messages asynchronously.

* dns::Server

contextualized per endpoint dns object, responsible for all dns related isms.

this change hides all impelementation details of all of the dns components.
adds some more helper functions for parsing dns and dealing with OwnedBuffer.

overall dns becomes less of a pain with this new structure. probably.
2022-09-08 14:23:52 -04:00
Jeff Becker bf2488d9e8
zero copy compare 2022-09-08 11:22:36 -04:00
Jeff Becker 1b9898aabc
restructure readme and docs 2022-09-04 10:04:15 -04:00
majestrate a8c0f76e1c
Merge pull request #1971 from majestrate/docs-and-such-2022-08-06
more docs
2022-09-03 08:03:28 -04:00
majestrate d5a2616d6f
Merge pull request #1983 from jagerman/macos-packaging
Macos packaging
2022-08-31 09:51:50 -04:00
Jason Rhinelander 2eef7c5915
Don't look for sqlite when not building peerstats 2022-08-30 17:26:08 -03:00
Jason Rhinelander 57cebe5c9f Don't build peerstats tests when peer stats disabled 2022-08-30 16:23:06 -03:00
Jason Rhinelander 955cecb21d Drone macos fixes
- fix lib check script to look at the network extension
- amend the list of intented linked libs
- upload the dmg
2022-08-30 16:20:28 -03:00
Jason Rhinelander 6e5db4f560 Set up sign target dependencies always; mark unsigned package
Even if we aren't codesigning, things like the `package` target expect
to be able to depend on `notarize` (and thus implicitly sign ->
assemble) to require a built package.

Also add a `-UNSIGNED` into the built dmg filename.
2022-08-30 15:58:53 -03:00
Jason Rhinelander ceed8e3238
Remove unused parameter names 2022-08-30 15:53:40 -03:00
Jason Rhinelander dccc86ea62 Apple icon bullshit
Apple introduced a bug in macOS 11 that they can't be arsed to fix which
breaks PNG loading into icns files by dropping the blue channel of the
last pixel, leaving a streak of yellow pixels at the bottom of the
image.

This hacks around it by setting a fully transparent, non-white (actually
yellow) pixel in the bottom-right corner of the images.

This is such inexcusable trash.
2022-08-30 15:46:13 -03:00
Jason Rhinelander 500530a336 dmg: version, and set icon
- Add the version number into the .dmg filename
- Set the lokinet icon on the .dmg.  This is done via a swift program
  because all the Apple CLI tools to do this are deprecated.
2022-08-30 14:00:58 -03:00
Jason Rhinelander 4605b49cfc Fix codesigning: reenable extension provisioning profile
The macOS PR that was merged accidentally dropped a cmake option that
result in the extension's provisioning profile not getting copied into
place (but was working locally because I was using a build dir where the
variable was still set).  This restores the option to fix the
codesigning.
2022-08-29 15:54:46 -03:00
Jason Rhinelander f5376e98c2 Lower minimum version for swift binary
CMake apparently doesn't do anything with CMAKE_OSX_DEPLOYMENT_TARGET
for swift, which results in a 12+ minimum version.  This fixes it
(albeit in a hacky way since the only apple-sanctioned way to properly
set this appears to be "use xcode").

Shame on Apple, as usual.
2022-08-29 15:53:16 -03:00
Jason Rhinelander 039d1429f5 Build an installer dmg 2022-08-29 12:53:08 -03:00
Jason Rhinelander 182f1dccb9 Fix mac.sh defaults to make a signed, notarized build 2022-08-26 16:05:46 -03:00
Jason Rhinelander 8b157c304e Remove obsolete mac packaging cruft 2022-08-26 16:05:46 -03:00
Jason Rhinelander d6fe1f1610 Update gui submodule to dev branch 2022-08-26 16:05:46 -03:00
Jeff 4c897f583c
fix up log statements
* make socket bind errors have a distinct message reported when caught using their own exception type
* omit printing banner in setup when we run from the lokinet executable (but not the liblokinet.so entry point)
2022-08-22 16:50:46 -04:00
Jeff a9abeb33cc
bump version to 0.9.10
* update release motto for 0.9.10
2022-08-22 16:50:34 -04:00
jeff 6929a02842
set up links to new docs pages 2022-08-21 12:25:15 -04:00
majestrate 256470229d
add more info
clarifiy what .loki and .snode gtld are
2022-08-21 12:18:10 -04:00
Jeff f6613c9526
wire up new docs pages
reword a few things about the links rewired.
2022-08-21 12:18:10 -04:00
Jeff f3533e9912
add initial high level usage docs 2022-08-21 12:18:09 -04:00
Jeff badf72838e
move all code directory readmes into docs/project-structure.md 2022-08-21 12:18:09 -04:00
majestrate 13c71c3626
Merge pull request #1942 from jagerman/macos-sysex
macOS system extension
2022-08-16 11:32:51 -04:00
Jason Rhinelander ab16d428cb Don't use sign target for contrib/mac.sh 2022-08-12 21:18:46 -03:00
Jason Rhinelander 2b7b1fcc79 Working signed macOS GUI build 2022-08-12 21:13:39 -03:00
Jason Rhinelander 496c1d274c Stub out the peer stats sqlite_orm code
This avoids needing to build it and include it in static builds since we
aren't currently making use of it.
2022-08-12 21:13:39 -03:00
Jason Rhinelander 8c2f4175d6 contrib/windows.sh: do a release build by default 2022-08-12 21:13:39 -03:00
jeff 181de210cd Build apple/macos GUI from lokinet project
This adds the gui as a submodule, and consolidates the GUI handling a
bit between the two platforms.
2022-08-12 21:13:39 -03:00
Jason Rhinelander 7b2b114240 Remove disabled submodule check
It's easy enough to add -DSUBMODULE_CHECK=OFF yourself if you really
won't want it, and much more useful to have it enabled as a default.
2022-08-12 21:13:39 -03:00
Jason Rhinelander c504c030cf Update mingw zmq patch
The one we were applying for closesocket breaks on some versions.
2022-08-12 21:13:38 -03:00
jeff b8896740de build gui and assemble app bundles into one singular app bundle 2022-08-12 21:13:38 -03:00
jeff 279b5710cc maker packet tunnel provider compile 2022-08-12 21:13:38 -03:00
Jason Rhinelander 5530ec3057 Handle Apple's trash servers when polling for notarization
Apple's servers have a gateway timeout a small but noticeable percentage
of the time, which was breaking the script.  Detect such Apple flakiness
and keep trying.
2022-08-12 21:13:38 -03:00
Jason Rhinelander 09372994bb macOS system extension support
Adds support for building Lokinet as a system extension, and fixes
various problems in the macos implementation found during development of
the system extension support.
2022-08-12 21:13:38 -03:00
Jeff 61d7ff3787 on apple write packets back to interface when it is for us because that does not have a route spec for the interace ip on loopback as apple finds having sensible defaults bothersome internally 2022-08-12 20:23:00 -03:00
Jason Rhinelander e97752734d Fix `platform::is_apple` value 2022-08-12 20:23:00 -03:00
Jason Rhinelander 4c39a2d395 Make sure BUILD_SHARED_LIBS is a cache variable
Otherwise cmake warns about propagation of normal variables into cache
variables when it hits the option in the oxen-mq submodule.
2022-08-12 20:23:00 -03:00
Jason Rhinelander 93421c6eaf Change permissions for system extension 2022-08-12 20:23:00 -03:00
Jason Rhinelander 49b2878209 Require explicit disabling of codesigning
Make the mac build require passing either an explicit -DCODESIGN=OFF or
the code signing identities.
2022-08-12 20:23:00 -03:00
Jeff 5dd71995c4 add lokinet.swift cli args
* add --start flag to start lokinet
* add --stop flag to stop
* by default lokinet on macos needs a flag or it will be a nop
2022-08-12 20:23:00 -03:00
majestrate c81e950d13
Merge pull request #1973 from majestrate/nodedb-logic-fix-2022-08-07
do not clear out entries that are valid from nodedb when we are a service node
2022-08-07 17:28:18 -04:00
Jeff 4341b8c684 do not clear out entries that are valid from nodedb when we are a service node.
this logic was inverted.
2022-08-07 13:44:48 -04:00
majestrate 9917daa84d
Merge pull request #1972 from majestrate/happyify-ci-pipelin-2022-08-06
fix ci pipeline
2022-08-07 13:41:59 -04:00
Jeff 8d1d1d0b57 make unit tests happy 2022-08-06 16:04:25 -04:00
Jeff 2d1645bfe1 fix up sid ci pipeline 2022-08-06 16:04:25 -04:00
Jeff 58052f5b17 macos ci fixes 2022-08-06 16:04:25 -04:00
majestrate 7a8331e79d
Merge pull request #1961 from majestrate/rc-expiration-reeanble-07-18-2022
re enable rc expiration
2022-07-26 12:07:40 -04:00
majestrate db961ac728
Merge pull request #1943 from majestrate/keygen-script-2022-06-26
simple keygen script
2022-07-26 12:07:06 -04:00
Jeff d0408a1c4e
remove invalid entries on loading nodedb 2022-07-26 11:05:31 -04:00
Jason Rhinelander f230a3f695
Add debug logging for RC removal 2022-07-26 11:26:35 -03:00
Jason Rhinelander a190c14889
Fix comment 2022-07-26 11:26:07 -03:00
Jeff cc2b4df676
kill log statements 2022-07-26 09:45:58 -04:00
Jeff 3337125110
re enable rc expiration 2022-07-26 09:43:45 -04:00
majestrate 4091fdb8bb
Merge pull request #1958 from majestrate/readmes-and-such-2022-07-16
add documentation on project structure
2022-07-26 09:30:13 -04:00
Jeff 23fd46c0db
add directory specific readmes 2022-07-26 09:26:28 -04:00
majestrate 769bc1e8df
Merge pull request #1962 from jagerman/dns-parsing-fixes
DNS message parsing fixes and cleanup
2022-07-24 11:16:39 -04:00
Jason Rhinelander 874221db70
Merge pull request #1965 from jagerman/fix-double-logging
Remove the initial sink before reconfiguring logging
2022-07-22 12:20:18 -03:00
Jason Rhinelander 884c5052a0
Merge pull request #1964 from jagerman/inbound-default-ip
Fix inbound IP handling; update [bind] docs
2022-07-22 12:20:00 -03:00
Jason Rhinelander 841abffaf5
Make outbound wildcard default to inbound IP
outbound=:1234
    outbound=0.0.0.0:1234
    outbound=
    outbound=0.0.0.0

now all default to use the inbound= IP.  (If multiple inbound= IPs are
given, we raise an exception to abort startup).

Only applies to routers (since clients don't have inbound IPs), and
eliminates potential weird edge cases with local system IP and routing
shenanigans.
2022-07-21 17:53:25 -03:00
Jason Rhinelander f0590a9672
Remove the initial sink before reconfiguring logging
Without this, the original sink set up very early in daemon/lokinet.cpp
(which goes to stderr) is still around, and so we get double logging.
2022-07-21 15:02:23 -03:00
Jason Rhinelander 2be422fcc0
Reorganize [bind] comments
The general section comments contained all the descriptions for the
inbound/outbound settings, while inbound/outbound had no comment at all.
This moves the comments around to the individual settings, plus updates
some of the wording in the section.
2022-07-21 14:55:57 -03:00
Jason Rhinelander c9f492d85a
Fix [bind]inbound IP-omitted handling
We were failing when using `inbound=:1234`, rather than looking for a
default IP.  This fixes it to still use the default IP, and change only
the default port.

Outbound behaviour should remain unchanged: i.e. `outbound=:2345` means
bind-to-wildcard-IP with a specific port.
2022-07-21 14:55:57 -03:00
Jason Rhinelander 6df83b613d
Fix log level being forced to warning
This code shouldn't be here; the log level was already set to its proper
default value via the earlier FromConfig call.
2022-07-21 11:34:11 -03:00
Jeff 3a97acfb51
this code needs to detect the first non-existing interface by name, not the first existing one. this remidies this. sorry testnet for breaking you 2022-07-21 07:19:43 -04:00
Jeff 83f648fd87
reword message 2022-07-20 17:04:14 -04:00
Jason Rhinelander 9ea82edc07
DNS message parsing fixes and cleanup
Fixes:

- tighten reserved name detection to not match fooloki.loki, but instead
  only match "foo.loki.loki" and "loki.loki" (and similar for reserved
  name "snode.loki").
- IPv6 PTR parsing was completely broken.
- Added tests for the above two issues.

Cleanups:

- Eliminate llarp::dns::Name_t typedef for std::string
- Use optional return instead of bool + output param
- Use string_views; we were doing a *lot* of string substr's during
  parsing, each of which allocates a new string.
- Use fmt instead of stringstream
- Simplify IPv4 PTR parsing
2022-07-20 16:50:38 -03:00
Jeff f222aecc79
actually use correct variable in iteration 2022-07-20 15:46:45 -04:00
majestrate 6ea97ccaf4
Merge pull request #1930 from majestrate/issue-1929-06-02-2022
redo bind section of config
2022-07-20 15:02:19 -04:00
Jeff a7cfa3ea87
use info as default log level on clients as most users have continously been confused by lack of log output with warn level as default, which i predicted would happen 2022-07-20 14:47:53 -04:00
Jeff b819ed21d2
clean up build helper scripts:
* cleanup of android build shims
* cleanup of windows build shims
2022-07-20 13:36:04 -04:00
Jeff 68148e098f
* add mockable network functions
* add unit tests with ability to pretend to be different network setups
2022-07-20 13:36:03 -04:00
majestrate 12653d4ac2
Merge pull request #1955 from jagerman/spdlog
Logging overhaul, fmt::format, and related
2022-07-19 18:27:05 -04:00
Jason Rhinelander f9371233ee
hive fmt/spdlog updates 2022-07-19 15:27:31 -03:00
Jason Rhinelander f6019210c3
oxen-logging update to handle level/type parsing exceptions 2022-07-19 13:39:00 -03:00
Jason Rhinelander 9bf1d5837a
Update oxen-logging for macos compilation 2022-07-19 12:40:07 -03:00
Jeff 8cde7c7e7a
fix win32 and android builds 2022-07-19 11:31:14 -04:00
Jason Rhinelander e094125000
gcc 8/9 fix 2022-07-18 17:38:04 -03:00
Jason Rhinelander 86fd77733e
Add missing header to fix libc++ build 2022-07-18 17:23:35 -03:00
Jason Rhinelander 784f2938f1
Use more fmt 2022-07-18 17:13:04 -03:00
Jason Rhinelander eec8244a6c
Remote util::Printer and related cruft 2022-07-18 14:56:09 -03:00
Jason Rhinelander 2f9e182b20
Avoid ctor inheritance to make diagnostics better
Using constructor inheritance DRYs the code, but unfortunately confuses
GCC as to where the proper "required from here" location is, which makes
debugging formatting errors very difficult.  Avoid it (and update
oxen-logging to avoid it there as well).
2022-07-18 13:07:33 -03:00
Jason Rhinelander c82ade2d81
Make test code work with new logging 2022-07-18 12:59:13 -03:00
Jason Rhinelander b81f7025c9
Replace logging with oxen-logger
Replaces custom logging system with spdlog-based oxen logging.  This
commit mainly replaces the backend logging with the spdlog-based system,
but doesn't (yet) convert all the existing LogWarn, etc. to use the new
format-based logging.

New logging statements will look like:

    llarp::log::warning(cat, "blah: {}", val);

where `cat` should be set up in each .cpp or cluster of .cpp files, as
described in the oxen-logging README.

As part of spdlog we get fmt, which gives us nice format strings, where
are applied generously in this commit.

Making types printable now requires two steps:
- add a ToString() method
- add this specialization:

      template <>
      constexpr inline bool llarp::IsToStringFormattable<llarp::Whatever> = true;

This will then allow the type to be printed as a "{}" value in a
fmt::format string.  This is applied to all our printable types here,
and all of the `operator<<` are removed.

This commit also:
- replaces various uses of `operator<<` to ToString()
- replaces various uses of std::stringstream with either fmt::format or
  plain std::string
- Rename some to_string and toString() methods to ToString() for
  consistency (and to work with fmt)
- Replace `stringify(...)` and `make_exception` usage with fmt::format
  (and remove stringify/make_exception from util/str.hpp).
2022-07-15 22:17:59 -03:00
Jason Rhinelander 43191ec100
Add missing header
Needed for uint_least32_t.
2022-07-15 21:51:32 -03:00
Jeff a3725284e4
simple keygen script 2022-06-26 10:02:59 -04:00
majestrate a9a9593128
Merge pull request #1938 from jagerman/no-empty-compilations
Don't build empty cpp files
2022-06-22 17:06:09 -04:00
majestrate 193ab47372
Merge pull request #1941 from jagerman/no-shellhooks
Remove dead code, cmake cleanups
2022-06-22 16:49:57 -04:00
Jason Rhinelander 81f05d63c1
Move destructor back to .cpp file
Having it there (even defaulted, like this) means endpoint.hpp doesn't
have to include endpoint_state.hpp (which it otherwise would need,
because of the std::unique_ptr<EndpointState> default deleter
requirements).
2022-06-22 14:48:45 -03:00
Jason Rhinelander c37d6ea43b
Remove shadow testing framework
Bitrotten and apparently doesn't work with libuv event loop.
2022-06-22 11:08:07 -03:00
Jason Rhinelander 0edb4435d4
Cmake cleanup: remove unneeded =1 from definitions
We only check for definedness, not truth, in the code so make the cmake
definitions agree with that.

This also avoids warnings when building on macos (because swift only
allowed defined/undefined but not values)
2022-06-21 18:57:36 -03:00
Jason Rhinelander 4a4f16e5c8
Remove dead code: netns, shell hooks
These haven't been activated in a long time and aren't worth
resuscitating.
2022-06-21 18:56:25 -03:00
Jason Rhinelander 8c3d1b3281
Don't build empty cpp files
We shouldn't be compiling these .cpp files at all on other platforms,
rather than compiling empty .cpp files (which later results in "... has
no symbols" warnings).
2022-06-16 13:17:13 -03:00
majestrate 2e0822889a
Merge pull request #1937 from jagerman/print-snode-addr-on-startup
Show router pubkey at startup
2022-06-15 21:07:34 -04:00
Jason Rhinelander 3cd699fa7f
Show router pubkey at startup 2022-06-15 21:23:15 -03:00
majestrate 85cf2dad10
Merge pull request #1926 from jagerman/tag-override
Add -DLOKINET_VERSIONTAG to override version tag
2022-06-14 07:43:18 -04:00
Jason Rhinelander 1de7b070d1
Add -DLOKINET_VERSIONTAG to override version tag
Currently I maintain a patch in the debs to do the same thing here, but
it fails to apply often enough; this change makes the behaviour
consistent with oxen-core/oxen-ss and will let me drop that patch and
just pass in the cmake option.

(Recommend ignore-whitespace for viewing the diff)
2022-06-13 20:00:35 -03:00
majestrate 10db0a0d2d
link to french readme 2022-06-07 16:45:56 -04:00
majestrate 83fe986749
add french readme
this translation was provided from a session user
2022-06-07 16:45:35 -04:00
majestrate 3ef13bab7f
Merge pull request #1931 from pebu1337/patch-1
Update error message
2022-06-06 11:45:15 -04:00
Pebu 9db192079b
Update error message
Message is paths must be >= 2 but condition is checking for < 3
2022-06-06 10:00:20 -04:00
majestrate f2d7d5eabf
Merge pull request #1925 from jagerman/system-or-submodule
Clean up system-or-submodule handling
2022-06-03 18:53:55 -04:00
Jason Rhinelander 523a8a74ca
Clean up system-or-submodule handling
Fixes a bug on older cmake linking against oxenmq (older cmake hates the
direct oxenmq::oxenmq -> PkgConfig::OXENMQ alias), and also makes it
easier to handle things like nlohmann::json (which we can use from the
system *or* submodule).

Borrowed from oxen-ss/oxen-core.
2022-05-31 19:51:29 -03:00
Jeff 4a10868f85
add additional fallback case 2022-05-31 15:23:36 -04:00
majestrate 229e1277fd
Merge pull request #1923 from majestrate/replace-llarp-proto-verison-macros-2022-05-26
final fixups before 0.9.9 tag
2022-05-30 17:49:49 -04:00
Jeff 2576b87c5d
version bump to 0.9.9 2022-05-30 17:08:41 -03:00
Jason Rhinelander 34c3b8d0de
Add oxen repo to bionic for updated cmake version
Also rename the arg from loki_repo to oxen_repo
2022-05-30 17:08:27 -03:00
Jeff 73a49f5473
do not build liblokinet in windows, exe gets too big 2022-05-30 17:08:08 -03:00
Jason Rhinelander 6a2114fa1d
Don't be dynamic for win32 rc crap 2022-05-30 17:08:08 -03:00
Jeff 1dfc2e883b
bump verions of all deps
bump submodules

Fix dynamic version generation

   - GIT_FOUND OR Git_FOUND wasn't available because we hadn't done a
     find_package(Git) yet.
   - required version variables weren't being passed through to the cmake
     script
2022-05-30 17:08:08 -03:00
Jeff 065e52ab80
move windows nsis parts for cpack into external files 2022-05-30 09:27:05 -04:00
Jeff e480e36f3d
generate windows rc for each executable target so we can set the executable name right for each one 2022-05-30 09:06:48 -04:00
Jeff f05c2ebc71
macro removals
clean up version cmake stuff

clean up generated cpp version stuff

make all the windows rc stuff get generated by cmake

bump release motto message

properly inject release motto into version
2022-05-30 09:06:48 -04:00
Jeff 1eba0f836e
replace LLARP_PROTO_VERSION macro 2022-05-28 13:18:43 -04:00
majestrate 0331db494e
Merge pull request #1905 from majestrate/connect-out-2022-04-28
connect to routers even if we are decomissioned
2022-05-27 13:39:05 -04:00
Jeff 33a2226079
footcannon prevention: check for invalid address family.
throw if we pass in a bogus af value when getting a sockaddr for all interfaces
2022-05-27 13:26:30 -04:00
Jeff 98b3860655
set source ip on service nodes for outbound link to not use all interfaces 2022-05-27 13:26:30 -04:00
Jeff 60ada470db
format systemd status as time deltas from now 2022-05-27 13:21:09 -04:00
Jeff 18e1272c76
add gossip info to systemd status
* adds next and last gossip datetimes
* adds a few things for time points, like ostream operator overloads for time point
2022-05-27 13:21:08 -04:00
Jeff 3c44a06403
publish our rc out to the network when we regenerate them 2022-05-27 13:21:08 -04:00
Jeff 5f496259b7
if we are decommissioned or deregistered, do not test other routers so we do not spam them.
disambiguiate error message to distinguish between decomissioned and deregistered.
2022-05-27 13:21:08 -04:00
Jeff 706e34c082
connect to routers even if we are decomissioned 2022-05-27 13:21:07 -04:00
majestrate d9a8710ccf
Merge pull request #1909 from majestrate/bump-ci-ubuntu-debs-2022-05-02
[chore] bump ci to make jammy debs
2022-05-27 13:06:55 -04:00
Jeff 994c6e1a21
remove focal deb build from ci 2022-05-27 11:34:15 -04:00
Jeff 0df26fe81c
bump ci to make jammy debs 2022-05-27 11:34:15 -04:00
Jeff 0d0295e2dc
remove unneeded submodule 2022-05-25 16:42:10 -04:00
majestrate 608dced827
typofix 2022-05-24 12:56:55 -04:00
majestrate f16c2ecd43
use oxenc submodule in android 2022-05-24 12:56:37 -04:00
majestrate 8529ab2c62
Merge pull request #1920 from majestrate/fixup-link-layer-state-machine-2022-05-20
state machine fix for link layer
2022-05-20 11:33:29 -04:00
Jeff a61e9636b2
state machine fix for link layer
if a pending inbound session did not complete a handshake after an unclean close from a previous session the
remote udp endpoint would remain stuck mapped as authed and thus any further attempts from the remote would
be silently dropped as it entered a stuck state in the state machine. this was happening as a small part
of the state machine was hidden in the implementation details of iwp, but instead should be in the super type
as it is logic exclusively outside the details which every dialect would have regardless of its details.

this commit will unmap the udp endpoint every time it needs to in the link layer state machine, independat of
the implementation details of the diact.
2022-05-20 10:18:37 -04:00
majestrate a149e6e384
Merge pull request #1918 from majestrate/fixup-win32-2022-05-19
fixup edge case on windows
2022-05-19 11:55:08 -04:00
Jeff 3fccb3ab0c
fixup edge case on windows
* add platform detection constexprs
* add quark for platforms without native ipv6 like windows, exit mapping cannot work with ipv6 yet
2022-05-19 10:24:18 -04:00
majestrate e3aedda4c8
Merge pull request #1917 from majestrate/ip-fixups-2022-05-18
clean up ip packet code
2022-05-18 22:11:26 -04:00
Jeff f0867832e5
alignas 2022-05-18 18:02:57 -04:00
Jeff 7396eb7f3b
bump oxenc submodule and force oxenc submodule on win32 2022-05-18 17:40:55 -04:00
Jeff 70b07bab44
clean up ip packet code 2022-05-18 17:18:31 -04:00
majestrate d30fe95f2e
use ::/0
makes us map all ranges not just ipv4 when exit mode is on by default.
2022-05-18 12:16:46 -04:00
majestrate a610dd6e50
Merge pull request #1912 from majestrate/issue-1911-fixup-oxenc-linkage
split up link order for oxenmq and oxenc
2022-05-14 18:41:29 -04:00
Jeff 9556741f6a
split up link order for oxenmq and oxenc
* lokinet uberlib needs oxenc and oxenmq
* lokinet-util only needs oxenc

fixes #1911
2022-05-10 10:34:19 -04:00
majestrate bad98b5476
Merge pull request #1907 from majestrate/link-layer-priority-2022-05-02
propagate message priority to link layer
2022-05-02 19:04:28 -04:00
Jeff 3c92568881
typo 2022-05-02 17:48:46 -04:00
Jeff d85d208156
bump libuv version with hashpin 2022-05-02 17:31:21 -04:00
Jeff 8efac67c0a
add static deps mirror to ci 2022-05-02 16:52:32 -04:00
Jeff 546aede528
add mirror for cmake static deps 2022-05-02 16:32:45 -04:00
majestrate 5b0ece3f9e
Update llarp/router/outbound_message_handler.cpp
add comment

Co-authored-by: Thomas Winget <tewinget@gmail.com>
2022-05-02 16:24:54 -04:00
majestrate 238c33f565
Update llarp/iwp/session.cpp
return

Co-authored-by: Thomas Winget <tewinget@gmail.com>
2022-05-02 15:27:09 -04:00
Jeff 26c8063fc9
convert priority queues 2022-05-02 15:27:08 -04:00
Jeff 14d75cc654
add util::ascending_priority_queue type 2022-05-02 15:27:08 -04:00
Jeff 8960ca08f3
propagate link layer message priority to link layer so it can order retransmissions with that in mind 2022-05-02 15:27:07 -04:00
majestrate a80f7e1cf6
Merge pull request #1908 from majestrate/lrsm-and-queue-flush-2022-05-02
plug LRSM infoleak and queue flushing
2022-05-02 15:01:09 -04:00
Jeff 8aa465d0ed
randomize all frames in lrsm to prevent info leak about hop length 2022-05-02 08:23:53 -04:00
Jeff 926074f7c4
add idempotent pump after sending lrcm to very make sure that it is pumped 2022-05-02 08:23:40 -04:00
majestrate da4a3e517a
Merge pull request #1903 from jagerman/oxenc-endian
Replace llarp/util/endian.hpp with oxenc/endian.h
2022-04-28 15:52:41 -04:00
Jason Rhinelander c2f8a618e0
Update to oxenc 1.0.2 2022-04-28 14:23:52 -03:00
Jason Rhinelander b09298e211
Replace llarp/util/endian.hpp with oxenc/endian.h 2022-04-28 12:09:51 -03:00
majestrate 64d6ba8a53
Merge pull request #1830 from majestrate/static-auth-codes-2021-12-26
static endpoint auth codes
2022-04-20 16:22:22 -04:00
Jeff 64684d4dd4 dont require libcrypt for cross compiled builds 2022-04-20 15:26:39 -04:00
Jeff 7a8410b375 make more platforms ignore libcrypt 2022-04-20 15:26:39 -04:00
Jeff ee12ba51d5 disable hashed auth on windows 2022-04-20 15:26:39 -04:00
Jeff 5050cd0299 add hashed password capability to endpoint auth by file 2022-04-20 15:26:39 -04:00
Jeff a51576d1ea make destructor virtual 2022-04-20 15:26:39 -04:00
Jeff a082ba4e77 add file auth for tokens 2022-04-20 15:26:39 -04:00
Jeff 9a6bfe6013 static endpoint auth codes 2022-04-20 15:26:39 -04:00
majestrate 1dfed9e061
Merge pull request #1899 from majestrate/use-new-gui-2022-04-18
windows updates
2022-04-18 18:34:46 -04:00
Jeff 1a254a4301 kill/restore ipv6 with powershell because windows is vile 2022-04-18 17:50:48 -04:00
Jeff d05518be57 use the new electron gui in windows build 2022-04-18 17:25:16 -04:00
majestrate d972b04fe0
Merge pull request #1891 from majestrate/idempotent-flush-path-builds-2022-04-12
idempotent flush queues on path builds
2022-04-18 15:54:09 -04:00
majestrate 9fd20c885b
Merge pull request #1896 from majestrate/unstuck-obctx-2022-04-17
handle edge case better
2022-04-18 15:48:20 -04:00
Jeff 9765eeee7e handle edge case better
when our path is fine but the recipiant's path on the pivot router isn't we should pivot to another router
2022-04-17 21:22:53 -04:00
majestrate dfa291fb91
Merge pull request #1894 from majestrate/cleanup-readmes-2022-04-15
remove bitrotten files
2022-04-15 19:27:15 -04:00
majestrate 293bccb6d8
Merge pull request #1893 from majestrate/issue-1892-rpc-ping-pubkey-2022-04-13
add public key in rpc ping
2022-04-15 17:55:05 -04:00
Jeff 699591b76e remove bitrotten files 2022-04-15 17:47:46 -04:00
Jeff 768ed30c05 add public key in rpc ping 2022-04-13 22:49:24 -04:00
Jeff 3fbddac464 idempotent flush queues on path builds 2022-04-12 11:48:08 -04:00
majestrate f702aacc38
add arch linux section to readme
cite current ongoing discussion thread on the aur.
2022-04-05 19:13:11 -04:00
majestrate b6a087187c
Merge pull request #1881 from majestrate/mark-dead-obctx-2022-03-31
reduce excess path builds
2022-04-04 16:20:26 -04:00
Jeff ffadcb2e93 clean up paths that are ignored and inactive 2022-04-01 10:32:38 -04:00
Jeff af041cfee4 try not to spam builds 2022-04-01 10:32:34 -04:00
majestrate 619d8d3776
Merge pull request #1877 from majestrate/path-cache-cpu-reduction-2022-03-29
Cache best paths determined by GetPathByRouter to reduce cpu usage
2022-03-30 20:12:58 -04:00
Jeff 17687e300e drone-ci image name fix, use -builder images 2022-03-30 19:38:41 -04:00
Jeff 77bf2f4af9 disable building fat liblokinet.so on bionic because lto is broken on bionoic still 2022-03-30 17:35:45 -04:00
Jeff 38a157808e Cache best paths determined by GetPathByRouter to reduce cpu usage 2022-03-30 17:11:04 -04:00
majestrate 65ef0e4bfb
Merge pull request #1849 from majestrate/dry-cross-2022-02-02
dry cross compile
2022-03-30 16:48:00 -04:00
majestrate 1fc901330c
Merge pull request #1851 from majestrate/ci-docs-generation-2022-02-04
ci docs generation
2022-03-30 16:45:53 -04:00
majestrate a71e9423bd
Merge pull request #1864 from majestrate/gutt-old-code-2022-02-27
remove old dead code
2022-03-30 16:42:32 -04:00
majestrate 3d32e3b36a
Merge pull request #1876 from majestrate/zlib-hashpin-update-2022-03-29
bump zlib hashpin
2022-03-30 16:34:07 -04:00
Jeff e2a94b44bb bump zlib hashpin 2022-03-29 09:18:04 -04:00
Jeff 7265a6c80e ci pipeline for cross compile 2022-03-16 14:21:40 -04:00
Jeff 7251944adc redo contrib/cross.sh to take cmake arguments 2022-03-16 14:21:40 -04:00
Jeff 66b7c3698e remove unneeded line from contrib/cross.sh 2022-03-16 14:21:40 -04:00
Jeff 56492c88ac dry cross compile 2022-03-16 14:21:40 -04:00
majestrate 12044af04e
Update readme.md
add note about updating alternatives in windows cross build
2022-03-15 21:37:55 -04:00
majestrate 2476d97bf5
Merge pull request #1869 from pebu1337/patch-1
Fix spelling changes
2022-03-14 08:17:15 -04:00
Pebu 1a74abca31
Fix spelling changes 2022-03-14 08:04:58 -04:00
majestrate 27d883157d
Merge pull request #1865 from majestrate/proto-fix-2022-03-06
fix wire protocol race condition
2022-03-07 15:55:43 -05:00
Jeff a76acd4956 fix wire protocol race condition
only send close packet once, before we were sending a close after we got a close causing excess log spam.
include handshake phase when checking for connection timeouts.

when we change our rc make sure to put it into nodedb too when we are a service node to prevent weirdness in dht lookups.
2022-03-05 21:08:53 -05:00
Jeff b4c4c3977a oxenc 2022-02-28 10:49:23 -05:00
Jeff 6629e8c881 cmake workarround for quark in older cmake where pkg config produces non existing targets 2022-02-28 10:46:41 -05:00
Jeff ae96458f8a remove old dead code 2022-02-27 11:10:15 -05:00
majestrate 6f46fe7e0c
Merge pull request #1862 from Bilb/fix-abort-exit-on-stop
summary status: no services means not running
2022-02-23 10:23:28 -05:00
Jeff eeb93343c0 rpc fixes for lokinet gui
only add stats for services when we have them
2022-02-23 09:24:50 -05:00
audric 41405be612 summary status: no services means not running 2022-02-23 14:21:47 +11:00
majestrate a8faffe76e
Merge pull request #1860 from Bilb/add-version-and-uptime-summary-status
add version and uptime to summary status endpoint
2022-02-22 20:17:14 -05:00
Audric Ackermann ad6d206aa6
add version and uptime to summary status endpoint 2022-02-21 10:57:47 +11:00
Jeff 0fe716e1dd more docs 2022-02-19 16:08:09 -05:00
Jeff 54f431c9e8 make doxybook2 run from PATH if installed on our system 2022-02-17 18:01:53 -05:00
Jeff 6bb438ca33 make comments with colins in them not have them in it 2022-02-17 18:01:53 -05:00
Jeff c39bd827d0 remove markdown extension that is not required 2022-02-17 18:01:53 -05:00
Jeff bebfcbdba2 move documentation builder closer to the top of the ci jobs 2022-02-17 18:01:53 -05:00
Jeff c70f1866f8 include mkdocs.yml in ci artifacts for docs 2022-02-17 18:01:53 -05:00
Jeff 283eabd1a8 use COPYONLY for the non templated configure_file targets 2022-02-17 18:01:53 -05:00
Jeff 97f4545fd5 make CI pipline generate docs with doxygen, doxybook2 and mkdocs. 2022-02-17 18:01:53 -05:00
majestrate 8a849e81df
Merge pull request #1858 from jagerman/omq-11
Crank oxen-mq to (1.2.)11; switch to oxen-encoding
2022-02-17 16:18:28 -05:00
Jason Rhinelander d02558350a
Crank oxen-mq to (1.2.)11; switch to oxen-encoding
- Update oxen-mq submodule to latest stable
- Add oxen-encoding submodule
- Convert all oxenmq encoding usage to oxenc
- Modernize cmake handling of oxenmq/oxenc
2022-02-17 16:30:17 -04:00
majestrate f8b6b9d34b
Merge pull request #1856 from Bilb/fix-num-path-built-summary-status
fix numPaths value in Router::ExtractSummaryStatus
2022-02-15 21:09:58 -05:00
Audric Ackermann d9467f4dee fix numPaths value in Router::ExtractSummaryStatus 2022-02-16 13:07:55 +11:00
majestrate 6cec95f0f7
Merge pull request #1857 from majestrate/upstream-dns-default-quad-nine-2022-02-15
use quad nine as default upstream dns
2022-02-15 20:32:29 -05:00
Jeff ac9fb9d479 use quad nine as default upstream dns 2022-02-15 20:29:55 -05:00
majestrate c0f47063cb
Delete llarp.png
remove unused image
2022-02-12 19:08:01 -05:00
majestrate 79662aaa9a
spruce up README more
remove dead links for docs

link all support platforms

add anchors in markdown
2022-02-12 19:05:34 -05:00
majestrate e61ca2934e
Update readme.md
fix anchor
2022-02-12 14:52:08 -05:00
majestrate 101650d742
Update readme.md
typofix
2022-02-12 14:51:20 -05:00
majestrate 09e91cce13
fix up readme
point install links to sections in readme.md
2022-02-12 14:50:43 -05:00
majestrate 257f48a166
Merge pull request #1852 from majestrate/lokinet-shared-sid-compiler-fix-2022-02-06
dont capture flow_addr, results in compiler error on sid
2022-02-09 14:55:30 -05:00
Jeff 810e3cc9c2 dont capture flow_addr, results in compiler error on sid 2022-02-06 13:27:19 -05:00
majestrate 838183e36e
Merge pull request #1748 from majestrate/liblokinet-udp-api-2021-09-19
liblokinet updates
2022-02-06 13:19:08 -05:00
majestrate fbb0ed8245
Merge pull request #1848 from majestrate/fixup-2022-02-02
fixup cross targets
2022-02-02 08:42:54 -05:00
Jeff 48559bd282 fix up ppc64le cross target 2022-02-02 08:34:58 -05:00
Jeff eae4d3cf74 fixup armhf target 2022-02-02 08:10:03 -05:00
majestrate d66364ab7c
Merge pull request #1847 from majestrate/mip64-cross-2022-01-30
update cross compiling infra
2022-02-02 07:41:27 -05:00
Jeff f543f6962d fix up ppc64le toolchain, remove suffix 2022-02-02 07:41:10 -05:00
Jeff 24811aff37 fix up contrib/cross.sh to put everything in build-cross 2022-02-02 07:40:52 -05:00
Jeff 08a9e0ad39 add cross compile helpers and update/add toolchains 2022-02-02 07:35:39 -05:00
majestrate b3068fe76d
Merge pull request #1846 from majestrate/bump-static-deps-2022-01-31
chore: bump static deps versions
2022-01-31 16:34:44 -05:00
majestrate 217c76e45b
Merge pull request #1815 from majestrate/cleanup-docs-subdir-2021-11-28
docs makeover
2022-01-31 15:26:46 -05:00
Jeff 582fdeda27 add close_reason parameter to quic::Endpoint::close_connection defaulting to emtpy string 2022-01-31 14:43:38 -05:00
Jeff 95efe8f4e5 bump ngtcp2 to v0.1.0 tag 2022-01-31 13:05:03 -05:00
Jeff 3c983e2cd7 libcurl no long users --without-libmetalink so remove the flag 2022-01-31 12:03:15 -05:00
Jeff 199055a6aa chore: bump static deps versions 2022-01-31 11:57:26 -05:00
Jeff Becker 04b23416ed do less allocations in lokinet_hex_tobase32z 2022-01-31 10:53:48 -05:00
Jeff Becker 743bc2433a resolve race condition in udp flow and packet handling 2022-01-31 10:53:48 -05:00
Jeff Becker 635f4bcd8c make it compile 2022-01-31 10:53:48 -05:00
Jeff Becker c655a21d68 typofix 2022-01-31 10:53:48 -05:00
Jeff Becker f8768488ed make pybind compile 2022-01-31 10:53:48 -05:00
Jeff Becker bf6dfaaef8 cmake fixups 2022-01-31 10:53:48 -05:00
Jeff Becker 5286d442fb updates:
* add udptest example
* fix up udp codepath in liblokinet
2022-01-31 10:53:48 -05:00
Jeff Becker b20e7bedf8 identify 2022-01-31 10:53:48 -05:00
Jeff Becker e2cd4d66cc docstring update 2022-01-31 10:53:48 -05:00
Jeff Becker 94ce7a9af7 make function pointer arguments named 2022-01-31 10:53:48 -05:00
Jeff Becker ef19111f88 dont pack struct becuase alignment 2022-01-31 10:53:48 -05:00
Jeff 97966976d0 Update CMakeLists.txt
dont depend on lokinet-shared target for sign target as we disabled it by default.
2022-01-31 10:53:48 -05:00
Jeff 82ffa2f02c Update mac.sh
disable liblokinet on mac by default in mac.sh
2022-01-31 10:53:48 -05:00
Jeff Becker 8153edbf43 dont enable apple languages when not building daemon 2022-01-31 10:53:48 -05:00
Jeff Becker 65b29a1b70 add liblokinet custom logger 2022-01-31 10:53:48 -05:00
Jeff Becker b31cac4b71 nodejs dipshittery 2022-01-31 10:53:48 -05:00
Jeff Becker 51b1d41b12 disable gost in static build 2022-01-31 10:53:48 -05:00
Jeff Becker 1feaec1169 build liblokinet on macos 2022-01-31 10:53:48 -05:00
Jeff Becker 50b8056491 enable liblokinet on macos 2022-01-31 10:53:48 -05:00
Jeff Becker f38bf2770d move WITH_BOOTSTRAP option to root project CMakeLists.txt 2022-01-31 10:53:48 -05:00
Jeff Becker f5157c31da make it compile 2022-01-31 10:53:48 -05:00
Jeff Becker b225ec1043 thread safety stuff 2022-01-31 10:53:48 -05:00
Jeff Becker ba57ab04aa wire up liblokient_udp_* 2022-01-31 10:53:48 -05:00
Jeff Becker 1c70b0f42f add lokinet_hex_to_base32z 2022-01-31 10:53:48 -05:00
Jeff Becker d3d07fe53e typofix 2022-01-31 10:53:48 -05:00
Jeff Becker e11e736ea5 typofix 2022-01-31 10:53:48 -05:00
Jeff Becker 71364da9f4 fix typos add lokinet_udp_close 2022-01-31 10:53:48 -05:00
Jeff Becker 9fb11bf3da typo fixes and clarify docs 2022-01-31 10:53:48 -05:00
Jeff Becker 9d069983b4 add WITH_BOOTSTRAP option for toggling building lokinet-bootstrap 2022-01-31 10:53:48 -05:00
Jeff Becker 13c3786067 correct function names 2022-01-31 10:53:48 -05:00
Jeff Becker bbb082931a more logging 2022-01-31 10:53:48 -05:00
Jeff Becker 66de680884 sanity check 2022-01-31 10:53:48 -05:00
Jeff Becker 8c8f97adda more logging 2022-01-31 10:53:48 -05:00
Jeff Becker 38d4cec7d1 log errors on decoding 2022-01-31 10:53:48 -05:00
Jeff Becker c5b5ff7810 typo fix 2022-01-31 10:53:48 -05:00
Jeff Becker 2428cc189e llarp::BootstrapConfig update
* make routers member a llarp::BootstrapList
2022-01-31 10:53:48 -05:00
Jeff Becker c4b1a9c074 lokinet_add_bootstrap_rc
* allow bootstrap lists to be passed in
2022-01-31 10:53:48 -05:00
Jeff Becker 00075f541b fix compile error 2022-01-31 10:53:48 -05:00
Jeff Becker 5b8ebb269c changes for liblokinet-ffi
* cmake option BUILD_DAEMON for toggling building of daemon directory
* when WITH_BOOTSTRAP is OFF dont build curl or cpr
2022-01-31 10:53:48 -05:00
Jeff Becker db7050cd2d update liblokinet udp header 2022-01-31 10:53:48 -05:00
Jeff Becker 50001da9a1 remove dead shit from header 2022-01-31 10:53:48 -05:00
Jeff Becker 433febe5c6 update liblokinet udp api header 2022-01-31 10:53:48 -05:00
Jeff Becker 5f49d3a49f update header with notes 2022-01-31 10:53:48 -05:00
majestrate 7a992c7ebc
Merge pull request #1845 from majestrate/make-github-see-we-are-gpl3-2022-01-28
make it so github sees the repo is gpl3
2022-01-28 13:03:46 -05:00
Jeff 185809907d fix typo in readme, use 3 hashes instead of 2 because it is a sub 3 section 2022-01-28 11:21:11 -05:00
Jeff 996de3d4c6 make it so github sees the repo is gpl3 2022-01-28 11:20:22 -05:00
majestrate 36925d0576
Merge pull request #1844 from majestrate/sigusr1-wire-up-thaw-2022-01-27
wire up sigusr1 to trigger a network thaw on non win32 platforms
2022-01-27 11:22:09 -05:00
Jeff fc444741f1 move constant to new header
create llarp/constants/time.hpp for time/duration constants
2022-01-27 11:11:57 -05:00
Jeff 5fac6c84d8 detect timeskip and thaw network when we think it happened. 2022-01-27 10:59:04 -05:00
Jeff 38c6d99375 wire up sigusr1 to trigger a network thaw on non win32 platforms 2022-01-27 09:59:52 -05:00
majestrate cf0e3146a2
Merge pull request #1843 from majestrate/disable-unit-tests-on-broken-gcc-2022-01-24
work around gcc lto bug
2022-01-25 13:21:21 -05:00
Jeff 7e92f36b6a disable tests by default
make ci enable tests explicitly
2022-01-25 13:15:37 -05:00
majestrate 27619f5fb4
Merge pull request #1838 from majestrate/sd_notify_extra_info-2022-01-13
redo systemd status line
2022-01-14 17:01:52 -05:00
majestrate 9d1111a0b1
Merge pull request #1839 from majestrate/disable-route-blackhole-config-2022-01-14
route poker: allow not blackholing routes.
2022-01-14 17:01:32 -05:00
Jeff b3d9cd463f route poker: allow not blackholing routes.
allow runtime configuration to disable ip blackholing.
2022-01-14 13:03:01 -05:00
Jeff 205584acdf redo systemd status line to include number of paths and endpoint count. optionally warn about low path success. 2022-01-14 11:18:07 -05:00
majestrate 53526f386a
Merge pull request #1834 from majestrate/route-poker-fix-2022-01-03
prevent segfault in route poker if Init() is not called
2022-01-11 17:59:05 -05:00
majestrate 2c44ffe85b
Update llarp/router/route_poker.cpp
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2022-01-11 12:44:05 -05:00
majestrate 68a7174807
Merge pull request #1837 from jagerman/gentler-install-instructions
readme: point to oxen docs; mention systemctl controls
2022-01-11 11:29:01 -05:00
Jason Rhinelander b442e8a43b
readme: point to oxen docs; mention systemctl controls 2022-01-11 12:13:24 -04:00
Jeff 27ba3e044d
prevent segfault in route poker if Init() is not called 2022-01-03 10:16:08 -05:00
majestrate 9e4bd2cd44
Merge pull request #1801 from majestrate/introset-publish-spam-fix-2021-11-16
prevent introset publish spam
2021-12-27 10:04:48 -05:00
majestrate 838208217d
Merge pull request #1819 from majestrate/android-drop-x86-2021-12-05
drop x86 for android as flutter does not support it
2021-12-26 10:59:03 -05:00
majestrate 94611eda19
Merge pull request #1818 from majestrate/toggle-route-poker-2021-12-04
configurable route poker
2021-12-26 10:58:50 -05:00
majestrate 229a6c9bb9
Merge pull request #1828 from zoobab/dev
Add missing libssl-dev
2021-12-19 11:11:53 -05:00
Benjamin Henrion 409772f763
Add missing libssl-dev
Add missing libssl-dev on Ubuntu to compile it from source.
2021-12-19 17:09:40 +01:00
Jeff Becker 061aebc964
reword auto-routing config comment 2021-12-15 18:42:22 -05:00
Jeff Becker 14ffdb6639
configurable route poker
this allows you to use exit nodes without forcing routes over the interface, useful for using lokinet with an exit and selectively routing over the lokinet interface using an external socks proxy or binding to device explicitly.

* make route poker configurable, defaults to enabled but allows disabling it on runtime if desired
* add config option [network]:auto-routing to enable/disable route poker
2021-12-15 18:42:22 -05:00
majestrate 54bff69a0a
Merge pull request #1816 from majestrate/exit-pooling-2021-12-01
client side exit node pooling
2021-12-15 16:27:18 -05:00
Jeff Becker da887dc559
implement exit node pooling, allows users to use multiple exits for an address range.
mappings per ip stick to the same exit, each new ip is mapped to a random exit in the specified pool.

make exit-auth multi value
2021-12-15 16:26:21 -05:00
majestrate 64224f2344
Merge pull request #1822 from majestrate/make-windows-work-again-2021-12-07
Make windows work again
2021-12-15 15:39:00 -05:00
Jeff 776e9227fd
make serivce::Endpoint::EnsurePathToService have a default timeout as a named constant. 2021-12-15 15:25:53 -05:00
Jeff 301b19bd0f
do not send buggy reply as rpc 2021-12-15 15:25:53 -05:00
Jeff 388fc53380
match io loop event order on windows/apple to match linux.
on win32/apple reading packets from the interface does not count as an io operation.
manually trigger pump on win32/apple to pretend that it is an io event.
add platform quark function MaybeWakeUpperLayers on vpn::Interface to manaully wake up the other components on platforms that need that (ones on which packet io is not done via io events).
on non linux platforms, use uv_prepare_t instead of uv_check_t as the former triggers before blocking for io, instead of after. this better matches linux's order of operations in libuv.
2021-12-15 15:25:53 -05:00
majestrate 44c7cf5f27
Update readme.md
remove old parts about macos from readme
2021-12-13 22:59:29 -05:00
majestrate 019a9f1611
Update readme.md
remove pedantic separation in readme
2021-12-13 22:58:05 -05:00
majestrate 6af589d845
Update readme.md
correct cmake flag
2021-12-13 22:57:11 -05:00
majestrate d186a887d3
Update readme.md
remove note in readme
2021-12-13 22:55:51 -05:00
majestrate b7bbb7f40d
Update readme.md
fix readme, do not use static deps.
2021-12-13 22:53:53 -05:00
Jeff fe07665ac5
remove duplicate file 2021-12-10 16:42:19 -05:00
Jeff 9c68f64929
add deps to doxygen 2021-12-10 16:42:19 -05:00
Jeff be47299b5d
more docs 2021-12-10 16:42:13 -05:00
Jeff 4bbf5522b4
spaces 2021-12-10 15:29:58 -05:00
Jeff 479fba6bd0
add big chunks of docs 2021-12-10 15:29:53 -05:00
Jeff 2772a32907
* fix up lokinet cli help opts
* document doxygen
2021-12-10 10:40:18 -05:00
Jeff Becker 29df7bec74
remove old out of date documentation 2021-12-10 10:09:06 -05:00
Jeff e0df1875fb
drop x86 for android as flutter does not support it 2021-12-05 14:17:58 -05:00
Jeff 5890c99a81
Merge pull request #1817 from majestrate/disable-upstream-ip6-dns-2021-12-03
disable ip6 upstream dns in libunbound
2021-12-04 09:19:34 -05:00
Jeff Becker 0e2b0edaf6
when lokinet looses ip4 connectivity libunbound used to freak out and only use ip6 after such an event.
as a result dns queries stop working because we blackhole ip6 routes if exit mode is on.
this prevents this case from being hit.
2021-12-03 16:12:10 -05:00
Jeff ce8b3c83a7
Update high-level.txt
add notice to file as very out of date.
2021-11-28 14:01:12 -05:00
Jeff b23ceefc5a
Merge pull request #1812 from majestrate/log-level-demotion-11-28-2021
demote log statement levels
2021-11-28 11:02:36 -05:00
Jeff Becker ec8d990163
demote log statement levels 2021-11-28 09:57:10 -05:00
Jeff d7529dafbc
Merge pull request #1811 from majestrate/android-ci-optimize-2021-11-23
parallelize android build much better
2021-11-23 17:48:19 -05:00
Jeff Becker 8c6bf31c52
paralellize android build much better
* split up configure step and build step so that build steps goes all at once
* update ci to use new build structure for android
2021-11-23 12:43:54 -05:00
Jason Rhinelander 5de5091e8d docker CI: Fix error message 2021-11-16 20:24:47 -04:00
Jason Rhinelander d24f89192d Bump version 2021-11-16 19:50:52 -04:00
Jeff Becker 172c2dec45
create new constexpr for the staleness window for introsets and use it in publishing introsets and intro selection 2021-11-16 12:22:08 -05:00
Jason Rhinelander 189c4bfba4
Also consider last publish; eliminate unwanted condition
We don't really carry about when the last regen was attempted, but
rather about when the last publish was attempted (or succeeded).
2021-11-16 12:21:57 -05:00
Jeff Becker 8ba03de44e
match timeouts in introset selection spread with logic for publishing 2021-11-16 10:57:17 -05:00
Jeff e4514aec3d
Merge pull request #1799 from majestrate/static-ci-disable-lokinet-bootstrap-2021-11-16
disable lokinet-bootstrap in static linux ci pipeline
2021-11-16 10:29:16 -05:00
Jeff Becker e7d282993a
in static linux ci pipeline disable building lokinet-bootstrap and bundle a bootstrap.signed 2021-11-16 09:43:08 -05:00
Jeff b95e53daf9
Merge pull request #1797 from jagerman/random-optimizations
Random optimizations
2021-11-15 20:54:50 -05:00
Jason Rhinelander 5115162066 Use libuv's cached current time for `time_now()`
We are calling time_now() a huge amount, and it is a major consumer of
CPU cycles, but we don't need it: most of the time the current event
loop time is enough.
2021-11-15 18:32:05 -04:00
Jason Rhinelander b2ee003329 Optimization: eliminate unneeded shared_ptrs
We have a few cases where we're making an extra shared_ptr which we copy
into a lambda, which then results in an extra unnecessary refcount
decrement in the parent; this changes them to give an rvalue reference
to the lambda to avoid the extra incr/decr instead.

The one in Session::Pump is particularly noticeable and shows up in
profiling.
2021-11-15 18:32:03 -04:00
Jeff 3fc172f4dd
Merge pull request #1796 from jagerman/hotloop-optimization
Avoid std::function in hot pump code
2021-11-15 17:30:09 -05:00
Jason Rhinelander 7a04911b9b Avoid std::function in hot pump code
We're seeing overhead here of the std::function invocation, which we can
easily avoid in this case by not using a std::function around the
callback.
2021-11-15 18:29:26 -04:00
Jason Rhinelander f270d74441
Merge pull request #1795 from majestrate/try-reducing-cpu-usage-2021-11-09
make PumpLL idempotent to reduce cpu use a bit
2021-11-15 18:28:52 -04:00
Jason Rhinelander 09c2b31b25 Move paths pumping into PumpLL 2021-11-15 18:24:07 -04:00
Jason Rhinelander 687b54f860 Abstract & simplify logic 2021-11-15 17:15:16 -04:00
Jason Rhinelander 711038d150 Remove debug comment 2021-11-15 16:57:17 -04:00
Jason Rhinelander f63fff37a3 Remove broken test
This test isn't very useful, but also broken with the other changes on
this branch.
2021-11-15 16:20:07 -04:00
Jason Rhinelander 0fe7153f6e Fix client latency bug; De-shared_ptr IHopHandler queues
- Replace m_FlushWakeup with a call to the router's god mode pump
  method.  m_FlushWakeup apparently isn't enough to get things out, and
  we can end up with incoming packets that don't get properly handled
  right away without it.

- The shared_ptr around the ihophandler queues isn't needed and is just
  adding a layer of obfuscation; instead just exchange the list directly
  into the lambda.

- Use std::exchange rather than swap

- A couple other small code cleanups.
2021-11-15 13:39:57 -04:00
Jason Rhinelander 70553c7627 Remove hopeless flush
The TriggerPump just below this is *already* going to trigger a flush,
so the extra flush call here can't do anything useful (and in
particular, it won't clear up the queue *immediately*, which is what
this code looks like it was aimed at doing).
2021-11-15 13:39:52 -04:00
Jason Rhinelander fbc5cb0a6d Add another missing pump trigger 2021-11-15 13:38:24 -04:00
Jason Rhinelander bce7e2e56d Pump outbound context 2021-11-15 13:38:21 -04:00
Jason Rhinelander 846577a0aa Add missing inbound traffic pump trigger 2021-11-15 13:38:10 -04:00
Jason Rhinelander 8cdde74020 Simplify 2021-11-15 13:38:08 -04:00
Jason Rhinelander b3a8160c89 Pump hidden context sooner
This has to happen before pumping links because it is putting things on
links.
2021-11-15 13:38:05 -04:00
Jason Rhinelander 0924dd8862 Remove dead declaration 2021-11-15 13:38:02 -04:00
Jason Rhinelander f9395cd5dd Cleanup: avoid pointless copy of `this` pointer 2021-11-15 13:38:00 -04:00
Jason Rhinelander 9844d358e6 Fix packet delay creep
- Make the main PumpLL also pump hidden services, rather than using
  separate wakers in each TunEndpoint.  It seems there is some
  interactions that just one or the other is not enough.

- Eliminate TunEndpoint send queue -- it isn't needed as we can just
  send directly.
2021-11-15 13:37:57 -04:00
Jason Rhinelander 99b12940ad Cleanups 2021-11-15 13:37:54 -04:00
Jason Rhinelander e47d3098ac Increase plaintext queue size from 32 to 512
In testing we were sometimes hitting a full queue error, which makes
sense because the queue size seems really small.

Increase it to 512.
2021-11-15 13:37:49 -04:00
Jason Rhinelander 78cc466bf2 Rename PumpLL -> TriggerPump
And rename the actual pump implementation back to PumpLL.
2021-11-15 13:37:47 -04:00
Jason Rhinelander 031ea7aa37 Get rid of external event loop direct wakeups
If something needs to wake up the event loop it should be using an
async, as we are now with PumpLL(); but we had various code triggering a
wakeup, expecting that PumpLL gets called on every wakeup, which isn't
true anymore.
2021-11-15 13:36:44 -04:00
Jason Rhinelander 74215fc44c Fix link layer delivery race condition (fix random ping delays)
We trigger a pump immediately, but this is racey because we add to our
plaintext data in a worker thread; if the worker thread runs after the
pump then it ends up leaving plaintext to be handled, but there's no
wakeup until the next one.

This was the cause of seeing a random +1s and bunching added to ping
responses sometimes: it wasn't until the *next* ping goes through the
network that the plaintext queue gets processed, at which point it
flushes the old one and often the new one together.

The fix here gets rid of the map of sessions needing wakeups and instead
adds an atomic flag to all of them to let us figure out which ones
need to be flushed.
2021-11-15 13:36:28 -04:00
Jason Rhinelander aa1dc83459 Simplify 2021-11-15 13:36:13 -04:00
Jason Rhinelander 362fda5a56 Combine empty + pop into single call 2021-11-15 13:36:09 -04:00
Jason Rhinelander b03f3c2d79 Remove another unwanted unconditional PumpLL 2021-11-15 13:36:03 -04:00
Jason Rhinelander 9113a6b36b Triggered pumping
This redoes how/when we pump so that we should only be calling the
idempotent PumpLL() when we actually have (or may have) something to
pump.
2021-11-15 13:35:57 -04:00
Jason Rhinelander bfc6d35b33 Simplifications & C++17
- Modernize some iterator loops
- Simplify a couple places by using `if (init; ...)`
- Replace various std::binds with lambdas
2021-11-14 10:11:00 -04:00
Jason Rhinelander 41807f1763 transit hop: drop instead of flushing when full
If full happens we are going to trigger a bunch of flushes which
probably isn't very useful, so drop instead.
2021-11-14 10:10:58 -04:00
Jason Rhinelander cf5c4e7284 outbound_message_handler: skip instead of aborting on removed paths 2021-11-14 10:10:19 -04:00
Jason Rhinelander 633431be66 Make outbound message queue PumpLL again if it doesn't send all 2021-11-14 10:10:19 -04:00
Jason Rhinelander faf95cbd0a Allow a nullptr callback for event loop PumpLL 2021-11-14 10:07:31 -04:00
Jeff Becker 8a9025e234 only pump path context in idempotent pumpll 2021-11-14 10:07:31 -04:00
Jeff Becker bb86996acf make event loop pump function non idempotent 2021-11-14 10:07:31 -04:00
Jeff Becker 8744c93944 prevent 100% cpu usage on service nodes
call_soon wakes up the mainloop and is often reentrant, we dont want to
ever way up the event loop but we also want to always defer the call so
we always use the workers
2021-11-14 10:07:11 -04:00
Jeff Becker 22d4b88edc
make PumpLL idempotent to reduce cpu use a bit 2021-11-09 11:59:57 -05:00
Jason Rhinelander 1ddfb7420a
Merge pull request #1791 from majestrate/exclude-failing-from-queue-2021-10-29
exclude fully failed nodes from service node testing list
2021-10-29 14:44:16 -03:00
Jason Rhinelander 0ec50e6624 Fix comment typo 2021-10-29 11:52:54 -03:00
Jeff Becker fcba709fcb
do not requeue nodes for testing from failing queue if we do not have them marked as failing anymore 2021-10-29 10:46:50 -04:00
Jeff 60c1b69ea3
Merge pull request #1784 from jagerman/deb-docker-images
Generate CI images with much DRY-er Python dockerfile generating script
2021-10-28 14:01:04 -04:00
Jason Rhinelander e6622c1d46 Install g++-8 on bionic 2021-10-28 13:49:37 -03:00
Jason Rhinelander cd49031bd2 Fix race condition in interactive output 2021-10-28 13:49:20 -03:00
Jason Rhinelander fd81ee76af
Merge pull request #1778 from majestrate/net-range-detection-bug-2021-10-22
check for intersecting ip ranges correctly, add unit test
2021-10-27 21:29:23 -03:00
Jason Rhinelander 52f8273dc1
Merge pull request #1781 from majestrate/bump-static-deps-2021-10-25
bump libunbound static dep hashpin
2021-10-27 16:44:39 -03:00
Jason Rhinelander 0b4c56dff5 Add hacks; add --distro to rebuild just one
Bionic is broken and needs a hack to create some dumb pgm include
directory.

Add --distro cli argument so that you can rebuild just one distro.
2021-10-26 17:38:17 -03:00
Jason Rhinelander 0572713533 Fix i386 builds 2021-10-26 15:10:54 -03:00
Jason Rhinelander 09e97eef77 Make it snazzy
Shows statuses that "fill in" when run interactively.
2021-10-26 14:57:58 -03:00
Jason Rhinelander 2064ca049d Parallelize builds 2021-10-26 14:05:35 -03:00
Jason Rhinelander 9b7ec7dd50 Add --no-cache option; fix manifest generation 2021-10-26 10:59:24 -03:00
Jason Rhinelander 1c4332ad6a Replace dockerfiles with a Python script 2021-10-26 03:28:49 -03:00
Jason Rhinelander cbbee59774 Add a bunch of base CI images for building debs
Installs just the base tools (which are quite substantial), but not the
deps (which get installed as part of the build).
2021-10-26 03:25:26 -03:00
Jeff Becker b5f5d07f03
bump libunbound static dep hashpin 2021-10-25 11:35:50 -04:00
Jason Rhinelander 808c2df6cc
Merge pull request #1779 from jagerman/ci-python-deps
Add python packages to ci images
2021-10-22 20:12:00 -03:00
Jason Rhinelander f3bac4ae72 Pass DOCKER_BUILD_OPTS env var to docker build 2021-10-22 19:15:46 -03:00
Jason Rhinelander c7410660c8 Make sure we apt-get update in the build
The base image can get out of date.
2021-10-22 19:15:46 -03:00
Jason Rhinelander 78e829a03f Add python build deps to ci images 2021-10-22 19:15:46 -03:00
Jeff Becker 6c70022dcc
check for intersecting ip ranges correctly, add unit test 2021-10-22 15:53:19 -04:00
Jeff Becker 1a360c1a36
version bump to 0.9.7 2021-10-19 15:17:42 -04:00
Jason Rhinelander 410e98f4eb
Merge pull request #1775 from jagerman/parallel-submodules
Fetch CI submodules in parallel
2021-10-18 22:26:53 -03:00
Jason Rhinelander 45249422b1 Fetch CI submodules in parallel 2021-10-18 13:50:43 -03:00
Jeff dce6c1e3b6
Merge pull request #1774 from jagerman/clang-13
Docker + clang updates
2021-10-18 07:13:21 -04:00
Jason Rhinelander 7bc86ff983 Reorder pipelines to put static builds together 2021-10-17 23:44:03 -03:00
Jason Rhinelander b64a38ff2c Add missing xz-utils to buster 2021-10-17 23:42:13 -03:00
Jason Rhinelander 31d2242cc6 Disable ABI warnings on buster/armhf 2021-10-17 23:11:17 -03:00
Jason Rhinelander d27a095f1f Fix arch-specific docker repo names 2021-10-17 18:11:55 -03:00
Jason Rhinelander f71d795f1d Make sure we always pull the latest image 2021-10-17 18:04:34 -03:00
Jason Rhinelander 55356face2 No recommends 2021-10-17 17:33:30 -03:00
Jason Rhinelander 76d69a3d70 Add cached images with debhelper & related tools for deb pipelines 2021-10-17 17:27:40 -03:00
Jason Rhinelander 4351611859 Add automake, libtool, libjemalloc-dev 2021-10-17 17:22:26 -03:00
Jason Rhinelander 0a9b020555 Update Catch2 to latest to fix build on impish 2021-10-17 16:30:43 -03:00
Jason Rhinelander d64e2ae0af Reformat RUN commands to make editing easier
- split them on multiple lines
- sort the installed package deps
- don't use extra unnecessary `bash` invocation
2021-10-17 15:20:52 -03:00
Jason Rhinelander 326670b959 Docker package updates:
- add `make`
- add `patch`
2021-10-17 15:13:36 -03:00
Jason Rhinelander 47d8c95e68 CI docker multiarch
Adds multiarch docker images and starts using them.
2021-10-17 14:46:30 -03:00
Jason Rhinelander 1dccbb5814 Update deb repo dns name 2021-10-16 16:00:27 -03:00
Jason Rhinelander ca9d979361 Docker image updates
- split debian sid into base/sid/clang images
- similarly for debian stable
- add jsonnet to lint
- add `--pull` to docker build so that we always pull the latest images
  (otherwise we were building on whatever local cache we have for
  `debian:sid`, etc., which made the base image update layer much
  larger).
- don't install Recommends by default
- add libzmq3-dev
- split android into android (base) and flutter
- hard-code registry.oxen.rocks into the dockerfile stuff because that
  seems to be the only way to properly depend on other docker builds.
- update a few CI builds that should have been using our images but
  weren't.
- Update a few CI images to bullseye instead of buster

Add openssh-client (for sftp to upload builds)
2021-10-16 15:54:22 -03:00
Jason Rhinelander 6f58648161 Add libzmq3-dev; change deps into arrays
We're currently rebuilding libzmq3-dev all the time in most of the CI
jobs.
2021-10-16 15:16:55 -03:00
Jason Rhinelander 9c32058a50 Remove windows linefeeds 2021-10-16 15:16:55 -03:00
Jason Rhinelander 1526b2a2eb which => command -v; different format.sh exit codes
`which` is a debian tool that is being deprecated in favour of
posix-standard `command -v`, so which to that to avoid deprecation
warnings.

Change the exit codes of `contrib/format.sh verify` to be unique for
each formatting program.
2021-10-16 15:16:55 -03:00
Jason Rhinelander 52492c6253 make format 2021-10-16 15:16:55 -03:00
Jason Rhinelander 9b0b9fe67b Add jsonnet formatting (if jsonnet is installed) 2021-10-16 15:16:55 -03:00
Jason Rhinelander 1e22417ade Add missing deprecated copy assignment operator
Clang-13 warns (and -Werror dies) without it.
2021-10-16 15:16:55 -03:00
Jason Rhinelander 497c62b586 Update clang build to 13; add full llvm-13 build 2021-10-16 15:16:55 -03:00
Jason Rhinelander aee5dd2776
Merge pull request #1769 from majestrate/fix-sid-2021-10-13
fix debian sid compiler error
2021-10-16 15:16:37 -03:00
Jason Rhinelander 50449038b4 Another gcc-11 fix
GCC is wrongly warning that `h` is uninitialized here, but it clearly
isn't.  Work around it.
2021-10-16 15:02:06 -03:00
Jeff Becker 07fb41cfd4
fix debian sid compiler error 2021-10-13 08:05:12 -04:00
Sean e11a94c95c
RPC call for summary get_status (#1742)
* RPC call for summary get_status

* lint

* update with review notes

* further review points

* uint64_t
2021-10-13 07:20:36 -04:00
Jason Rhinelander 51016e672f
Merge pull request #1760 from majestrate/default-to-unix-socket-for-rpc-2021-10-06
catch exceptions on setup and dont abort
2021-10-12 20:21:48 -03:00
Jason Rhinelander 0768593fa5
Merge pull request #1762 from majestrate/v6-base-address-configuration-fix-2021-10-06
catch ipv6 ioctl throwing when someone runs lokinet with no ipv6
2021-10-12 20:21:04 -03:00
Jeff 1846c3e3d8
prevent bizare half open state. (#1754)
* attempt path timeout bullshittery fix

* make sure ServiceInfo always has its address set up

* do not copy intros in constuctor, ammend logging and
add assert
2021-10-12 17:37:01 -04:00
Nuc1eoN 8989910881
Add missing dep 'cppzmq' (#1764)
* Add missing dep to cppzmq
2021-10-07 11:54:59 -04:00
Jeff Becker 937d07b6ce
catch ipv6 ioctl throwing when someone runs lokinet with no ipv6 2021-10-06 18:08:08 -04:00
Jeff 40f26bb674
Merge pull request #1761 from majestrate/v6-base-address-configuration-fix-2021-10-06
resepct empty ipv6 range setting
2021-10-06 16:28:05 -04:00
Jeff Becker 5e9f9686e7
set base v6 address to nullopt when explicit empty string is provided 2021-10-06 16:22:49 -04:00
Jeff Becker 4c5b90fb03
handle exceptions on setup and config load without aborting 2021-10-06 15:36:29 -04:00
Jeff 24681fd35d
Merge pull request #1759 from majestrate/iterate-dir-in-order-2021-10-06
iterate through directory entries in lexigraphical order
2021-10-06 15:15:26 -04:00
Jeff 12bca7031b
Merge pull request #1638 from majestrate/log-refactor-source-location-2021-05-11
refactor logging to use std::source_location
2021-10-06 15:14:55 -04:00
Jeff 1d955cf28d
Update fs.hpp
style nit
2021-10-06 14:37:09 -04:00
Jeff Becker 00f81b1dac
iterate through directory entries in lexigraphical order 2021-10-06 14:04:11 -04:00
Jeff Becker d882f1a302
some compilers hated [[maybe_unused]] so use (void) when they are unused 2021-10-06 11:10:49 -04:00
Jeff Becker cf187ddffc
fix up logging, put _log into anonynous namespace, make only log trace nop in release builds 2021-10-06 11:10:48 -04:00
Jeff Becker 20814a4adc
use llarp:: prefix for LogError 2021-10-06 11:10:48 -04:00
Jeff Becker 1b06e263fb
update log statement for win32 2021-10-06 11:10:48 -04:00
Jeff Becker 2d5faccb9f
refactor for apple 2021-10-06 11:10:48 -04:00
Jeff Becker 7d07dea235
fix up gripes in source_location
* get rid of columns we dont need those
2021-10-06 11:10:48 -04:00
Jeff Becker acdb8a19a6
for some reason [[maybe_unused]] is hated by buster 32 bit x86 so we do something else
to appease that compiler.
2021-10-06 11:10:48 -04:00
Jeff Becker 18c5b43e63
use inline source_location implementation for android too 2021-10-06 11:10:48 -04:00
jeff 0546dab2e3
make source location happy on macos
* because of course apple doesn't provide any implementation (lmao) we provide one ourself
2021-10-06 11:10:48 -04:00
Jeff Becker 5c457ff486
refactor logging to use std::source_location
* use std::source_location instead of godawful macros in logging
* remove unused/absolutely haram af json logstream
* fix bug in android logger where it doesn't respect eLogNone
2021-10-06 11:10:48 -04:00
Jeff 5a5765edd5
Merge pull request #1756 from majestrate/ngtcp2-build-static-fix-2021-10-06
always build ngtcp2 as static
2021-10-06 10:13:22 -04:00
Jeff Becker d354a35869
always build ngtcp2 as static
squashme
2021-10-06 10:09:04 -04:00
Jason Rhinelander e32f7faf55
Merge pull request #1751 from majestrate/update-ngtcp2-2021-08-24
Update ngtcp2
2021-09-27 10:46:21 -03:00
Jason Rhinelander d733e37d9f
Merge pull request #1750 from majestrate/ci-update-2021-09-24
update ci to use main lokinet mobile repo
2021-09-27 10:44:09 -03:00
Jeff Becker 7d299d1c74
update ci to use main lokinet mobile repo 2021-09-24 17:23:51 -04:00
Jeff Becker 9c37e0146e
make it compile again 2021-09-24 17:15:50 -04:00
Jeff Becker ec83641ee8
update submodule 2021-09-24 16:51:03 -04:00
Jeff Becker 45b5fec314
make it compile again (squashme) 2021-09-24 16:51:03 -04:00
Jeff Becker 3c61af1de9
bump ngtcp2 submodule 2021-09-24 16:51:03 -04:00
Jeff ed271de715
make lokinet-util library static
every other lokinet internal lib is static, but liblokinet-util was not, this fixes that.
2021-09-18 19:54:06 -04:00
Jeff 9f19a3653e
Merge pull request #1741 from majestrate/systemd-resolved-dns-fix-2021-09-16
SystemD DNS fix
2021-09-16 17:53:46 -04:00
Jeff Becker d1246947f7
SystemD DNS fix:
when dns is port 53 call SetLinKDNS otherwise call SetLinkDNSEx as on older versions of systemd-resolved SetLinkDNSEx is not available.
2021-09-16 17:52:30 -04:00
Jeff cf1086e4ac
Update readme.md 2021-09-14 17:29:36 -04:00
Jeff 2fbfeb1112
Update readme.md 2021-09-14 17:26:53 -04:00
Jeff ad9bbe9290
Update readme.md 2021-09-14 17:23:49 -04:00
Jeff 3f57427bba
Update readme.md
more updates to readme, remove unmaintained parts, add and remove chunks of information.
2021-09-14 17:21:13 -04:00
Jeff 1e5f753dc9
Update readme.md
our readme sucks, make it suck a bit less
2021-09-14 17:16:37 -04:00
Jeff 2a5c601f90
Merge pull request #1738 from jagerman/fix-jemalloc-option-dupe
Remove duplicate handling of jemalloc
2021-09-14 09:16:41 -04:00
Jason Rhinelander 488ed47cda Remove duplicate handling of jemalloc
We were linking/loading it in different ways, one with cmake option
`USE_JELLOC` and the other, older version `WITH_JEMALLOC`.  This removes
the latter (which was default OFF) and keeps the former (which was added
and has been default ON since 0.9.4 or so).

Also removes the `ifdef`ed JEMALLOC code in lokinet.cpp because we don't
need it; just linking to jemalloc is enough to get the malloc/free
replacements.
2021-09-13 13:26:12 -03:00
Jeff c30538a381
Update exit-setup.md
`hops=1` is not supported anymore.
2021-09-12 11:07:10 -04:00
Jeff baa89771fb
Merge pull request #1735 from majestrate/cmake-lokinet-bootstrap-tweaks-2021-09-10
make lokinet-bootstrap target toggleable
2021-09-10 22:13:34 -04:00
Jason Rhinelander 62d7192a50 Add mainnet/testnet bootstrap files into repo
We use them everywhere now (include the debs) so it makes sense to have
them bundled here rather than needing a download during package build
(in particular for debs that's considered a bad thing).
2021-09-10 19:38:32 -03:00
Jason Rhinelander 8df5005f54
Apply suggestions from code review 2021-09-10 19:22:22 -03:00
Jeff ff71e65ae0
Merge pull request #1736 from jagerman/ngtcp2-only-lib
Redo how we build ngtcp2 lib
2021-09-10 16:00:38 -04:00
Jason Rhinelander 089fc026d8 Redo how we build ngtcp2 lib
ngtcp2's top-level CMakeLists.txt is not friendly to being used as a
subdirectory (for instance, it always adds a `check` target when cunit
is installed), so stop using it in favour of skipping directly into the
ngtcp2/lib subdir.

This requires some hackery to set up a couple of the things the
top-level cmake does, but it isn't *too* painful.
2021-09-10 15:12:57 -03:00
Jeff Becker 7e1236503c
make lokinet-bootstrap target toggleable
add cmake option to disable building lokinet-bootstrap binary
2021-09-10 10:41:42 -04:00
Jason Rhinelander dbea1f98e7
Merge pull request #1651 from majestrate/lokinet-bootstrap-help-messages-2021-05-18
add --help and -h flags to lokinet-bootstrap to show help message
2021-09-08 19:56:32 -03:00
Jason Rhinelander 6c3c523404 Update wording and wrap help message 2021-09-08 19:48:25 -03:00
Jason Rhinelander 0f8297a186 Bump dev branch version 2021-09-03 23:04:14 -03:00
Jason Rhinelander 1972cf3f27
Merge pull request #1723 from majestrate/rc-gossip-limiter-2021-08-30
limit RC gossip to 20 peers max
2021-09-03 22:56:59 -03:00
Jason Rhinelander 53b62857da Disable tests on static bionic
It's failing to link with LTO on bionic because of an internal compiler
error for some random reason, so just disable building the tests there
for now (keeping LTO on is more useful since that is also what gets used
for a static build).
2021-09-03 22:21:45 -03:00
Jeff Becker 9ad63140f2
use std::sample to grab MaxGossipPeers when populating std::unordered_set 2021-09-03 17:45:08 -04:00
Jeff Becker a739e7b532
try not to prefer outbound vs inbound link sessions
before when we get the list of router ids for gossip it was highly bias towards outbound sessions.
instead now we get a full list of link session router ids in random order, truncate them to be at most MaxGossipPeers number of keys, and then put them into an unordered set
2021-09-03 17:45:08 -04:00
Jeff Becker d91ce53da1
limit RC gossip to 20 peers max 2021-09-03 17:45:08 -04:00
Jason Rhinelander 41ba49a185
Merge pull request #1688 from majestrate/macos-network-extension-2021-05-14
Macos network extension port
2021-09-03 18:44:23 -03:00
Jeff Becker 344d0a2f2d
format 2021-09-03 15:21:08 -04:00
Jeff Becker 2ee43c2162
set ipv6 address on apple to hardcoded value 2021-09-03 15:17:46 -04:00
Jason Rhinelander c52782ab32 Add IPv6 addr/routing for macos 2021-09-03 15:35:33 -03:00
Jeff Becker b52cf97e11
override ShouldHandlePacket on android to bypass non .snode/.loki dns hooking. 2021-09-03 14:03:55 -04:00
Jason Rhinelander 7fe5ffb209 Fix IPv4 routes are disabling exit
(This was actually already working because macOS is buggy and doesn't
actually remove routes other than the default).
2021-09-03 12:06:27 -03:00
Jeff Becker 979488830e
remove unused import
lokinet.swift no longer touches internals of lokinet network extension so we remove the import for it
2021-09-03 07:49:29 -04:00
Jeff Becker 0d64de17c8
tmp commit for debugging (revert me) 2021-09-02 18:46:39 -04:00
Jeff Becker 82314a3cac
add comment about android dns 2021-09-02 18:36:38 -04:00
Jason Rhinelander 831cc23de1 Remove obsolete bigs
Removes stuff we didn't end up needing/using:
- Lokinet.modulemap
- apple bits from lokinet.cpp (we don't use lokinet.cpp at all on macos
  anymore).
- dnsproxy/extension C++ headers
- apple-specific network extension config in llarp::config::Config
2021-09-02 19:19:54 -03:00
Jason Rhinelander 12e00b7a99 Remove advertising of big crappy company 2021-09-02 19:14:33 -03:00
Jason Rhinelander 2b8ef416c3 Remove old mac installer packaging 2021-09-02 19:13:51 -03:00
Jason Rhinelander 92c7fb9872 LOKINET_VERSION -> built in lokinet_VERSION 2021-09-02 19:11:41 -03:00
Jason Rhinelander 38335f13a2 Remove debugging 2021-09-02 19:09:02 -03:00
Jason Rhinelander 8aef5d742d Re-enable LTO; target macos 10.12+ 2021-09-02 19:07:40 -03:00
Jeff Becker 10cd331863
invert logic for android dns hook 2021-09-02 15:23:13 -04:00
Jason Rhinelander f51d0a80a2
Forward-declare ub_ctx/ub_result
Avoids needing unbound.h in the search path to include the
unbound_resolver.hpp header.
2021-09-02 14:17:11 -04:00
Jeff Becker 1315dabcb9
disable language ASM, yolo 2021-09-02 14:17:11 -04:00
Jason Rhinelander 067fcf71d3
Remove dead code 2021-09-02 14:17:10 -04:00
Jason Rhinelander a7decd5ec3
Silence warnings 2021-09-02 14:17:10 -04:00
Jason Rhinelander e11efe9bc5
Reformat 2021-09-02 14:17:10 -04:00
Jason Rhinelander 9dd604820f
Unleak exit mode DNS via unbound DNS trampoline on (macOS)
When we enable/disable exit mode on this restarts the unbound DNS
responder with the DNS trampoline (or restores upstream, when disabling)
to properly route DNS requests through the tunnel (because libunbound's
direct requests don't get tunneled because unbound is inside the network
extension).
2021-09-02 14:17:10 -04:00
Jason Rhinelander 0f097450d7
Remove debug 2021-09-02 14:17:10 -04:00
Jason Rhinelander f00e78c1a3
Add DNS trampoline
This runs a DNS listener on localhost:1053 that bounces requests to the
upstream DNS through the tunnel.  The idea here is that, when we turn on
exit mode, we start libunbound bouncing the requests through the
trampoline (since if it makes direct requests they won't go through the
tunnel).

(The actual libunbound configuration is still to follow).
2021-09-02 14:17:10 -04:00
Jason Rhinelander fd759914b6
Remove unused vars 2021-09-02 14:17:10 -04:00
Jason Rhinelander e84390748d
Add RouteManager; make exit on/off work 2021-09-02 14:17:10 -04:00
Jason Rhinelander c74dcba463
Add lokinet subnet to default routes
Mac doesn't route to a tunnel's ip range by default.  WTF.
2021-09-02 14:17:10 -04:00
Jason Rhinelander 9afa95cd7a
Remove unused/empty/no longer used apple headers 2021-09-02 14:17:10 -04:00
Jason Rhinelander 3527c9cdb5
Remove more unused dns-proxy files 2021-09-02 14:17:10 -04:00
Jason Rhinelander 58da228f62
Generate a default client lokinet.ini on startup if it doesn't exist
Thus when a user goes looking for it they'll find the (commented out)
default in the right place and can edit it.

(That right place is: ~/Library/Containers/com.loki-project.lokinet.network-extension/Data/lokinet.ini)
2021-09-02 14:17:09 -04:00
Jason Rhinelander fec3598e16
Remove no-longer-used framework.mm 2021-09-02 14:17:09 -04:00
Jason Rhinelander e39c473c88
format.sh: support macports clang-format
macports names it clang-format-mp-N to avoid clashing with a
system-installed one.
2021-09-02 14:17:09 -04:00
Jason Rhinelander 2964051f0d
Remove swift version (do not squash)
Don't squash this commit so that the swift version stays around in
history in case we need to resurrect it again some day (i.e. when Apple
decides to kill off Objective-C support).
2021-09-02 14:17:09 -04:00
Jason Rhinelander 329da951b7
Apple OS interface cleanup & refactoring
- Add a C callback interface (context_wrapper.h) between lokinet and the
  objective-C code so that:
  - we can use objective-C (rather than objective-C++), which seems more
    likely to be supported by Apple into the future;
  - we minimize the amount of code that needs to be aware of the Apple
    APIs.
  - this replaces apple logger objective c++ implementation with a plain
    c++ implementation that takes a very simple C callback (provided
    from the obj-c code) to actually make the call to NSLog.

- Add various documentation to the code of what is going on.

- Send all DNS traffic to the primary IP on the tun interface.  The
  match prefixes simply don't work as advertised, and have weird shit
  (like even if you get it working for some domains, "instagram.com"
  still doesn't because of god-knows-what Apple internal politics).

- Drop the dns proxy code as we don't need it anymore.

- Don't use 9.9.9.9 for default DNS.  (We might consider the unfiltered
  9.9.9.10 as an alternative default, but if we do it should be a global
  lokinet change rather than a Mac-specific change).

- Parse a lokinet.ini in the data directory, if it exists.  (Since we
  are sandboxed, it is an app-specific "home" directory so is probably
  buried god knows where, but at least the GUI ought to be able to get
  it to let users add things to it).

- This commit also adds a swift version of the PacketTunnelProvider
  glue, which ought to work in theory, but the *tooling* for cmake is so
  underdeveloped that I couldn't find any way to actually get the damn
  thing working.  So I'm committing it here anyway (and will revert it
  away in the next commit) in case we someday want to switch to it.

-
2021-09-02 14:17:09 -04:00
Jason Rhinelander 712b5a5608
Tweak icns generation to only run when necessary 2021-09-02 14:17:09 -04:00
Jason Rhinelander 3f0b34e860
Consolidate apple-specific bits into llarp/apple 2021-09-02 14:17:09 -04:00
jeff deb0a982be
it works 2021-09-02 14:17:09 -04:00
jeff 1272a4fbe1
add dummy sign target for ci when we don't have signing keys
remove static macos from ci pipeline
2021-09-02 14:17:09 -04:00
jeff d24221e67a
make ci run ./contrib/mac.sh with no codesigning 2021-09-02 14:17:09 -04:00
jeff 7db2459469
macos sort of works now 2021-09-02 14:17:09 -04:00
Jason Rhinelander 81d27c35c1
Default CODESIGN_APPEX to CODESIGN_APP
Sometimes (e.g. dev builds) these can apparently be the same; sometimes
it seems they need to be different, because Apple.
2021-09-02 14:17:08 -04:00
Jason Rhinelander 3ab117a03b
Switch extension from a framework to an appex 2021-09-02 14:17:08 -04:00
Jason Rhinelander faf8a699a6
Set version into Info.plist, don't manually configure
cmake already treats the info plist as a file to be configured (not
merely copied) so we don't need to configure_file ourselves to a temp
file.
2021-09-02 14:17:08 -04:00
Jason Rhinelander 0bb00baacf
Various cmake build cleanups/refactors
- Added contrib/macos/README.txt with description of the cancer
  happening here.
- Add provisioningprofiles that Apple wants to make things work properly
- Made the entitlements files match the provisioningprofiles
- Remove configured entitlements files; we *can't* change any of the
  things here because they are closedly tied to the provisioningprofiles
  -- which means if someone wants to build their own Lokinet, they have
  to replace a bunch of crap and change application IDs throughout.
  This is the hostile-to-open-source Apple way.
- Remove unused old lokinet binary, as we're no longer using it on macos
- Use a POST_BUILD rather than install to copy things around into the
  right places
- Convert all the configure_file's to consistently use @ONLY
- Misc cleanups
2021-09-02 14:17:08 -04:00
jeff 5edd045c9b
add swift version bullshit file and additional bullshittery 2021-09-02 14:17:08 -04:00
jeff 0708a0d897
initial network extension code for macos
probably does not work
2021-09-02 14:17:08 -04:00
Jeff Becker 63ed5c16ed
upload bare apk as ci artifact 2021-09-02 13:11:29 -04:00
Jeff Becker 92cfa8a558
dont bundle raw jni libs 2021-09-02 13:05:16 -04:00
Jeff Becker c39225b3b9
correct lokinet flutter url 2021-09-02 12:03:04 -04:00
Jeff Becker f65ec8e79f
make ci try building the flutter apk in the android apk pipeline 2021-09-02 12:01:36 -04:00
Jason Rhinelander f3bc00bcd8
Merge pull request #1724 from majestrate/update-static-deps-2021-08-31
bump openssl static deps version for upstream security update
2021-09-01 17:30:51 -03:00
Jeff 3bcc8f99c0
Merge pull request #1726 from majestrate/dns-graceful-teardown-2021-09-01
dns refactor
2021-09-01 16:23:27 -04:00
Jeff 060c571060
Merge pull request #1727 from majestrate/android-hang-fix-2021-09-01
dont save addrmap on android as it hangs
2021-09-01 16:23:17 -04:00
Jeff cd99e5c4f4
Merge pull request #1729 from jagerman/fix-omq-deprecation
Stop using deprecated OMQ connect_remote overload
2021-09-01 16:19:35 -04:00
Jason Rhinelander a8a7ef5461 Stop using deprecated OMQ connect_remote overload 2021-09-01 15:40:25 -03:00
Jeff 0447ffc829
Merge pull request #1728 from jagerman/fix-arg-order-v2
Unbound callbacks also need arguments reversed
2021-09-01 14:19:05 -04:00
Jason Rhinelander 14c93e2b93 Unbound callbacks also need arguments reversed
PR #1725 reversed argument orders but UnboundResolver was still using
(from,to) ordering in its callbacks, which leaked through to make a
wrong order in our reply function (which simply forwards arguments).

This fixes that bug by making UnboundResolver callback argument order
consistent (i.e. using to, from) with the PacketHandler argument order.
2021-09-01 14:40:18 -03:00
Jeff Becker 0c1a3e19bd
redo dns to use event loop on non windows and threading bullshit on windows 2021-09-01 13:08:37 -04:00
Jeff Becker a4a9062f12
dont save addrmap on android as it hangs 2021-09-01 12:07:10 -04:00
Jeff c0b8c87f81
Merge pull request #1725 from jagerman/dnsinterceptor-arg-reverse
Reapply "fix dns on android" + fix argument order
2021-09-01 11:58:02 -04:00
Jason Rhinelander 3ce329d2bf Reapply "fix dns on android" + fix argument order
The reason the dns fix on android didn't work is that the DnsInterceptor
had a reversed to/from argument order for its
`SendServerMessageBufferTo` overload, and so android/mac needed the
to/from to be reversed so that the second reverse cancelled out the
first one.

Upon review, the DnsInterceptor order (to, from) is more intuitive than
the base order (from, to), so this reapplies the dns fix and swaps
everything *except* DnsInterceptor to match the (to, from) argument
order.
2021-09-01 12:09:27 -03:00
Jason Rhinelander a70035b7ec
Revert "fix dns on android"
This reverts commit dace0224ec.

This reportedly didn't fix things on Android, and most definitely breaks
macOS (with this we get a bunch of errors about expecting inbound when
we have outbound).
2021-08-31 18:58:03 -04:00
Jeff 418eb4efaa
Merge pull request #1721 from majestrate/platform-bits-2021-08-26
initial routing table platform bits refactor
2021-08-31 12:10:32 -04:00
Jeff Becker 439183bf19
bump openssl static deps version for upstream security update 2021-08-31 12:05:01 -04:00
Jeff 2e52908510
Merge pull request #1722 from jagerman/sockaddr-optimization
SockAddr string optimization
2021-08-31 09:11:34 -04:00
Jason Rhinelander 3deb55193f SockAddr string optimization
- Reduce buffer size to INET6_ADDRSTRLEN, and use a single buf rather
  than two identical ones in each branch.
- Don't pre-reserve because doing so is usually going to over-allocate,
  but also because it prevents SSO, especially for the IPv4 case which
  should fit in SSO for all IPv4 addresses.
2021-08-30 16:55:17 -03:00
Jeff Becker 6251c13d46
add NOP implementation of VPN route manager for android 2021-08-27 19:49:01 -04:00
Jeff Becker 07a58ffa6c
use vpn::NetworkInterface for add/del route via interface instead of string 2021-08-27 11:55:57 -04:00
Jeff Becker c9b9ed91c2
make add/del blackhole default to empty implementation 2021-08-27 11:42:24 -04:00
Jeff Becker e25ae7192f
introduce add/del route via interface to route manager 2021-08-27 11:40:40 -04:00
Jeff Becker 64cd2990bc
remove old routing table maniuplation code 2021-08-27 11:07:54 -04:00
Jeff Becker 9791fd62a0
initial win32 port of route manager 2021-08-27 11:02:21 -04:00
Jeff Becker 0871862452
initial routing table refactor
* move routing table manipulation to vpn platform
* add initial linux implementation of vpn platform route manipulation
2021-08-27 10:42:04 -04:00
Jeff Becker 37dde7da05
format 2021-08-16 08:37:58 -04:00
Jason Rhinelander f39084bffa
Merge pull request #1714 from jagerman/remove-broken-split
Remove unneeded split(str, char) method
2021-08-11 19:08:14 -03:00
Jason Rhinelander 1b878e348b
Merge pull request #1715 from jagerman/default-upstream-dns-port
Fix default upstream DNS not working
2021-08-11 19:08:00 -03:00
Jason Rhinelander 73f0432b28 Fix default upstream DNS not working
The default upstream DNS was being set to 1.1.1.1:0, which doesn't work.
This fixes it to also set the port so that default upstream resolution
(i.e. with an empty config) works again.
2021-08-11 18:24:11 -03:00
Jason Rhinelander 9950adf472 Remove unneeded split(str, char) method
This function had a bug in stable (fixed in dev) when `last` returns
npos, but the function also appears to basically be duplicating what the
next split version can do, so this just removes it and uses the single
more generic split(strview, strview) method.
2021-08-11 00:26:52 -03:00
Jeff ea79d1c48c
Merge pull request #1713 from jagerman/remove-unused-user-defines
Remove unused defaults.hpp
2021-08-10 18:30:13 -04:00
Jason Rhinelander f40052df85 Remove old unused lokinet-bootstrap script
We compile one now for various, but the script apparently never got
removed.
2021-08-10 17:27:23 -03:00
Jason Rhinelander ae1243e9d9 Remove unused defaults.hpp
The definitions in here aren't actually used anywhere anymore, so just
drop it.
2021-08-10 17:13:27 -03:00
Jeff ee4e73fd94
Merge pull request #1712 from jagerman/bencode-dump-stdin
bencode-dump.py: support reading from stdin
2021-08-06 14:52:42 -04:00
Jason Rhinelander 29418f7a7b bencode-dump.py: support reading from stdin
So that you can pipe bt-encoded output into it, e.g. from the
in-progress oxend bt-rpc interface.
2021-08-06 14:25:32 -03:00
Jeff f1303125a0
Merge pull request #1708 from darcys22/patch-1
Update readme.md
2021-07-29 07:26:44 -04:00
Sean 048fdad056
Update readme.md 2021-07-29 15:51:19 +10:00
Jeff a4b552a268
Merge pull request #1682 from majestrate/route-blackhole-linux-2021-06-25
[linux] route blackholing
2021-07-12 08:27:17 -04:00
Jeff Becker e96ec156ea
add / remove route blackhole so we dont leak if we crash 2021-07-12 08:26:53 -04:00
Jeff Becker dace0224ec
fix dns on android 2021-07-09 09:51:51 -04:00
Jeff Becker 4f1bd14d3c
fix issue with excessively pedantic stl on archlinux 2021-07-06 08:54:39 -04:00
Jason Rhinelander 75b4758037
Merge pull request #1693 from majestrate/inane-fixings-2021-06-30
fixes for 0.9.5
2021-07-05 17:24:27 -03:00
Jeff Becker 14cc115489
dont use constexpr 2021-07-05 12:38:18 -04:00
Jason Rhinelander ed456b0c7e Fix typo in libuv error message 2021-07-05 10:41:09 -03:00
Jeff Becker 069d9487b7
* throw exception on invalid SessionResult when transforming to SendStatus
* add case for printing unknown SessionResult
2021-07-05 09:18:28 -04:00
Jeff Becker 114c7bab62
bump up the jam, bump it up, while your feet are jumping. 2021-07-05 09:13:05 -04:00
Jeff Becker 18cb59a1b5
* make tranform function for SessionResult to SendStatus
* add case for SessionResult::EstablishFail
* clean up outbound message handler to use transform function instead of many private member functions
2021-07-05 09:09:21 -04:00
Jeff Becker 8f4c23ef47
add option to invert regex filter results 2021-07-05 09:09:21 -04:00
Jeff Becker 3893a94e07
better time formatting for future times 2021-07-05 09:09:21 -04:00
Jeff Becker 6df1d6412d
unify introset-filter and path-filter 2021-07-05 09:09:21 -04:00
Jeff Becker 264616c8ba
fix unicode char 2021-07-05 09:09:21 -04:00
Jeff Becker 63c601b0c0
fixes for lokinetmon filters 2021-07-05 09:09:21 -04:00
Jeff Becker 91f6ca9869
typofix 2021-07-05 09:09:21 -04:00
Jeff Becker 383312a74d
make filters consistent for localhost.loki 2021-07-05 09:09:21 -04:00
Jeff Becker 30848165e7
add path filter in lokinetmon 2021-07-05 09:09:21 -04:00
Jeff Becker d918e1edda
add age to outbound contexts in lokinetmon
better time foratting in lokinetmon
2021-07-05 09:09:20 -04:00
Jeff Becker e7ac0f3902
expunge outbound contexts that have not gotten inbound traffic for a long while 2021-07-05 09:09:20 -04:00
Jeff Becker 32a94c73e2
update lokinetmon
* add --introset-filter option to filter results in introset inspection mode by regex
2021-07-05 09:09:20 -04:00
Jeff Becker 75451d7124
* add establish fail enum
* dont call outbound session hooks for inbound sessions
2021-07-05 09:09:20 -04:00
Jeff Becker e3281cd026
add string representation to SessionResult 2021-07-05 09:09:20 -04:00
Jeff Becker 1d1d97b0ef
disable peer status entirely 2021-07-05 09:09:20 -04:00
Jeff Becker 2578983a09
dont give peer stats in rpc 2021-07-05 09:09:20 -04:00
Jeff Becker 20bc338eba
inbound sessions from CLIENTS should only have an elevated lifetime 2021-07-05 09:09:20 -04:00
Jeff Becker caddeef2e8
more information in logs 2021-07-05 09:09:20 -04:00
Jeff Becker 977ea3d689
* add log warn
* throw if inbound link makes outbound session
2021-07-05 09:09:20 -04:00
Jeff Becker 99379c5def
establish outbound sessions when we have no outbound session.
when we have an inbound session we still want to make an outbound session.
2021-07-05 09:09:20 -04:00
Jeff Becker cf0349c259
if we have an inbound session don't fail with NoLink 2021-07-05 09:09:19 -04:00
Jeff Becker a316f5f787
add wine as dependancy because god made windows so that man may suffer 2021-07-05 07:26:04 -04:00
Jeff Becker da985c4c44
add docker image for nodejs 2021-07-05 07:26:03 -04:00
Jeff e28e23171d
Merge pull request #1686 from tewinget/outbound_session_maker_fixes
fix minor oversight/inefficiency with already established connections
2021-06-30 06:53:30 -04:00
Jeff Becker f4fa83703f
refactor to use RouterID instead of rc.pubkey 2021-06-30 06:45:11 -04:00
Jeff Becker e78d0b5e77
update urls 2021-06-30 05:47:16 -04:00
Thomas Winget 8515fe09d4 fix minor oversight/inefficiency with already established connections 2021-06-29 18:44:42 -04:00
Jeff bff81c62e2
Merge pull request #1685 from jagerman/jemalloc
Link to jemalloc for better memory usage
2021-06-29 16:42:22 -04:00
Jason Rhinelander 4f71276928 Link to jemalloc for better memory usage 2021-06-29 16:15:54 -03:00
Jeff 94912ba21b fix up docs generation 2021-06-29 12:17:33 -04:00
Jeff Becker abd6e4c558
use weak_ptr instead of bare pointer to prevent use after free 2021-06-25 05:08:31 -04:00
Jeff Becker aa48a1de1b
lower log level 2021-06-23 07:30:30 -04:00
Jeff Becker 3ad59105ef
when an outbound context is "marked bad" we want to ignore any new paths.
before this commit when a new path was made when an outbound context marked bad lokinet would segfault.
2021-06-23 07:21:01 -04:00
Jeff c040a1510a
update deps for source build
* change package list for static dev build
* reword the line describing why one may want to do a source build
2021-06-23 06:54:51 -04:00
Jeff 058e358b5c
Merge pull request #1669 from majestrate/inbound-convo-wrong-path-fix-2021-06-14
[bugfix] make inbound convotags reply on the correct path
2021-06-22 13:04:28 -04:00
Jason Rhinelander d2dc3b8c1b Fix program name in bencode-dump.py --help 2021-06-22 12:27:04 -03:00
Jeff 0b3b65fe4e
Merge pull request #1675 from jagerman/bencode-dumper
Add bencoded file dumper
2021-06-22 11:23:42 -04:00
Jason Rhinelander 4b0a10328a Add bencoded file dumper 2021-06-22 12:18:55 -03:00
Jeff Becker 9d0dffe086
only permit 1 pending session per udp endpoint 2021-06-22 09:26:03 -04:00
Jeff Becker 67f8a7116f
if we get a discard message from the pivot discard the outbound context if the remote intro is also expired 2021-06-21 16:02:03 -04:00
Jeff Becker 0900ab88d1
publish introsets on nearest routers
fetch introset from random routers
2021-06-21 16:01:38 -04:00
Jeff Becker 872a8d8045
use exisitng convotag first instead of trying to send to directly 2021-06-21 15:16:28 -04:00
Jeff Becker ee5723ecdc
add upperbound to number of endpoints used in lns lookups 2021-06-21 15:16:28 -04:00
Jeff Becker 1c457e2858
bump version to 0.9.4 2021-06-21 15:16:28 -04:00
Jeff Becker 3393b5a5a7
make it so lookups dont time out 2021-06-21 15:16:27 -04:00
Jeff Becker b5efb8c604
rename local variable to be clear about meaning, add comment 2021-06-21 15:16:27 -04:00
Jeff Becker 1a0e6a7ac1
remove redundant check as ReadyToSend also checks IntroSent() 2021-06-21 15:16:27 -04:00
Jeff Becker d45f0f8951
value initialize introduction so that expiresAt defaults to zero 2021-06-21 15:16:27 -04:00
Jeff Becker 9f353238af
ReadyToSend also should include checking we have a path to the remote 2021-06-21 15:16:27 -04:00
Jeff Becker ae36fd42bb
remove badIntros from lokinetmon as rpc no longer has them in it 2021-06-21 15:16:27 -04:00
Jeff Becker 4b11858bb0
make clang compile, remove unused variable 2021-06-21 15:16:27 -04:00
Jeff Becker 963250c0ef
format 2021-06-21 15:16:27 -04:00
Jeff Becker 00d4942d85
more 2021-06-21 15:16:26 -04:00
Thomas Winget 7f9a60066b
make sure we have a path to the next introduction we want to use 2021-06-21 15:16:26 -04:00
Jeff Becker d9cae4a6c6
in outbound context, ShouldBuildMore intro.ExpiresSoon delta is too big and has no overlap, change it so that 2021-06-21 15:16:26 -04:00
Jeff Becker e48feb8b9a
kill outbound context when we remove our convotag 2021-06-21 15:16:26 -04:00
Jeff Becker 71d17dc2c9
format and logging
ignore outbound session auth messages
2021-06-21 15:16:26 -04:00
Jeff Becker 5c3b4090d2
dont mark inbound sessions as outbound when we get a DNS lookup for it 2021-06-21 15:16:26 -04:00
Jeff Becker b70ecade2b
correct the logic for inbound convos
send back traffic on the correct path
2021-06-21 15:16:25 -04:00
Jeff 5da3bb6c0a
Merge pull request #1656 from majestrate/issue-1655-2021-05-30
DNS fixes and features
2021-06-21 15:14:26 -04:00
Jeff 8482952cff
Merge pull request #1661 from majestrate/android-updates-2021-06-04
android updates
2021-06-21 15:13:45 -04:00
Jeff Becker 5924ca5b3f
update android ci docker jizz 2021-06-21 11:49:04 -04:00
Jeff Becker ff796cd142
if git describe fails fall back to a placeholder 2021-06-21 07:52:25 -04:00
Jeff Becker 9e65f262f9
update docker ci jizz to include flutter on android 2021-06-21 07:48:07 -04:00
Jeff Becker a0505d8e85
mitigate lto compiler bug with lto 2021-06-20 06:06:29 -04:00
Jeff Becker db5862cda8
only use @ syntax when the dns port is not port 53 2021-06-20 05:59:23 -04:00
Jeff Becker a6fbaa7c7a
add dns hosts file option for user side dns filtering 2021-06-20 05:59:22 -04:00
Jeff Becker a24b82119b
fix #1655
* make it so that we don't set up unbound resolver when we have no resolvers provided by config
* clean up dns codepath and make it use llarp::SockAddr instead of llarp::IpAddress
2021-06-20 05:59:22 -04:00
Jeff Becker 6992d98c6a
add new JNI function: LokinetDaemon DumpStatus 2021-06-20 05:55:33 -04:00
Jeff 13af82474c
Merge pull request #1673 from majestrate/no-more-ninja-2021-06-18
No more ninja
2021-06-19 10:02:01 -04:00
Jeff Becker 5c512601bf
use std::make_optional for backwards compat on older toolchains 2021-06-19 09:39:10 -04:00
Jeff Becker 2122463d98
pass VERBOSE=1 in ci jobs for full verbosity on builds 2021-06-19 09:35:50 -04:00
Jeff Becker ae186f7000
use $(MAKE) only on makefile generator 2021-06-19 09:35:49 -04:00
Jeff Becker e9a4081451
use make instead of build essential in ci so that it does not conflict with clang builds 2021-06-19 09:35:49 -04:00
Jeff Becker 6f9f527f50
ccache android builds in ci 2021-06-19 09:35:49 -04:00
Jeff Becker 0a1cc0fc90
fix android ci output path name so that it does not conflict 2021-06-19 09:35:49 -04:00
Jeff Becker 300638163b
typofix 2021-06-19 09:35:49 -04:00
Jeff Becker 79d881689d
fix windows static ci upload for windows 2021-06-19 09:35:49 -04:00
Jeff Becker b7485b4b25
* make android ABIS list configurable
* fix android ci jizz, correct typo, upload generated assets
2021-06-19 08:05:05 -04:00
Jeff Becker 5c6b0f7178
dont build shared libs when we are building static deps 2021-06-19 07:54:44 -04:00
Jeff Becker d79b9bf59a
update android ci docker image definition to include cmake and exclude gradle 2021-06-18 11:52:07 -04:00
Jeff Becker e5bc34a7b1
[buildsystem] remove use of ninja entirely
* modify contrib/window.sh now uses makefiles
* create contrib/android.sh for building shared libs for android apk
* update drone ci jizz for android
* update cmake/StaticBuild.cmake to use $(MAKE) so that builds can parallelize (super epic)
* remove android directory as it is no longer needed
2021-06-18 11:48:23 -04:00
Jeff c9b4ca85b2
[feature] optionally keep inbound convos mapped to same IP on restart (#1672)
* add option to persist address mappings between restarts using [network]:persist-addrmap-file

* make it work

* only persist address map for inbound convos

* turn persisting address map on by default

* dont load addrmap file if it has been modified last over a minute ago to prevent foot cannons fired from loading a really old version of it
2021-06-17 12:05:50 -04:00
Jeff Becker 7ba15f91f3
add --help and -h flags to lokinet-bootstrap to show help message 2021-05-25 06:41:59 -04:00
660 changed files with 24052 additions and 21671 deletions

View File

@ -54,3 +54,8 @@ PointerAlignment: Left
# when wrapping function calls/declarations, force each parameter to have its own line
BinPackParameters: 'false'
BinPackArguments: 'false'
# TODO: uncomment me when we are reading to rearrange the header includes
# IncludeBlocks: Regroup
# IncludeCategories: 'llarp/'

View File

@ -1,2 +1,2 @@
HeaderFilterRegex: 'llarp/.*'
Checks: 'readability-else-after-return,clang-analyzer-core-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard,bugprone-*'
Checks: 'readability-else-after-return,clang-analyzer-core-*,modernize-*,-modernize-use-trailing-return-type,-modernize-use-nodiscard,bugprone-*,-bugprone-easily-swappable-parameters'

View File

@ -1,293 +1,450 @@
local default_deps_base='libsystemd-dev python3-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev libsqlite3-dev libcurl4-openssl-dev';
local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18
local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement
local default_windows_deps='mingw-w64 zip nsis';
local default_deps_base = [
'libsystemd-dev',
'python3-dev',
'libuv1-dev',
'libunbound-dev',
'nettle-dev',
'libssl-dev',
'libevent-dev',
'libsqlite3-dev',
'libcurl4-openssl-dev',
'libzmq3-dev',
'make',
];
local default_deps_nocxx = ['libsodium-dev'] + default_deps_base; // libsodium-dev needs to be >= 1.0.18
local default_deps = ['g++'] + default_deps_nocxx;
local docker_base = 'registry.oxen.rocks/lokinet-ci-';
local submodule_commands = [
'git fetch --tags',
'git submodule update --init --recursive --depth=1 --jobs=4',
];
local submodules = {
name: 'submodules',
image: 'drone/git',
commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=1']
name: 'submodules',
image: 'drone/git',
commands: submodule_commands,
};
// cmake options for static deps mirror
local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else '');
local apt_get_quiet = 'apt-get -o=Dpkg::Use-Pty=0 -q';
// Regular build on a debian-like system:
local debian_pipeline(name, image,
arch='amd64',
deps=default_deps,
build_type='Release',
lto=false,
werror=true,
cmake_extra='',
extra_cmds=[],
jobs=6,
loki_repo=false,
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: image,
[if allow_fail then "failure"]: "ignore",
environment: { SSH_KEY: { from_secret: "SSH_KEY" } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
] + (if loki_repo then [
'eatmydata ' + apt_get_quiet + ' install -y lsb-release',
'cp contrib/deb.loki.network.gpg /etc/apt/trusted.gpg.d',
'echo deb http://deb.loki.network $$(lsb_release -sc) main >/etc/apt/sources.list.d/loki.network.list',
'eatmydata ' + apt_get_quiet + ' update'
] else []
local debian_pipeline(name,
image,
arch='amd64',
deps=default_deps,
build_type='Release',
lto=false,
werror=true,
cmake_extra='',
local_mirror=true,
extra_cmds=[],
jobs=6,
tests=true,
oxen_repo=false,
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
] + (
if oxen_repo then [
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y lsb-release',
'cp contrib/deb.oxen.io.gpg /etc/apt/trusted.gpg.d',
'echo deb http://deb.oxen.io $$(lsb_release -sc) main >/etc/apt/sources.list.d/oxen.list',
'eatmydata ' + apt_get_quiet + ' update',
] else []
) + [
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install -y gdb cmake git ninja-build pkg-config ccache ' + deps,
'mkdir build',
'cd build',
'cmake .. -G Ninja -DWITH_SETCAP=OFF -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE='+build_type+' ' +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
'-DWITH_LTO=' + (if lto then 'ON ' else 'OFF ') +
cmake_extra,
'ninja -j' + jobs + ' -v',
'../contrib/ci/drone-gdb.sh ./test/testAll --use-colour yes',
] + extra_cmds,
}
],
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y gdb cmake git pkg-config ccache ' + std.join(' ', deps),
'mkdir build',
'cd build',
'cmake .. -DWITH_SETCAP=OFF -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_BUILD_TYPE=' + build_type + ' ' +
(if build_type == 'Debug' then ' -DWARN_DEPRECATED=OFF ' else '') +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
'-DWITH_LTO=' + (if lto then 'ON ' else 'OFF ') +
'-DWITH_TESTS=' + (if tests then 'ON ' else 'OFF ') +
cmake_extra +
ci_dep_mirror(local_mirror),
'VERBOSE=1 make -j' + jobs,
'cd ..',
]
+ (if tests then ['./contrib/ci/drone-gdb.sh ./build/test/testAll --use-colour yes'] else [])
+ extra_cmds,
},
],
};
local apk_builder(name, image, extra_cmds=[], allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: {arch: "amd64"},
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: image,
[if allow_fail then "failure"]: "ignore",
environment: { SSH_KEY: { from_secret: "SSH_KEY" }, ANDROID: "android" },
commands: [
"cd android",
"rm -f local.properties",
"echo 'sdk.dir=/usr/lib/android-sdk' >> local.properties",
"echo 'ndk.dir=/usr/lib/android-ndk' >> local.properties",
"GRADLE_USER_HOME=/cache/gradle/${DRONE_STAGE_MACHINE} gradle --no-daemon assembleDebug",
] + extra_cmds
}
]
local apk_builder(name, image, extra_cmds=[], allow_fail=false, jobs=6) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: 'amd64' },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, ANDROID: 'android' },
commands: [
'VERBOSE=1 JOBS=' + jobs + ' NDK=/usr/lib/android-ndk ./contrib/android.sh',
'git clone https://github.com/oxen-io/lokinet-flutter-app lokinet-mobile',
'cp -av build-android/out/* lokinet-mobile/lokinet_lib/android/src/main/jniLibs/',
'cd lokinet-mobile',
'flutter build apk --debug',
'cd ..',
'cp lokinet-mobile/build/app/outputs/apk/debug/app-debug.apk lokinet.apk',
] + extra_cmds,
},
],
};
// windows cross compile on debian
local windows_cross_pipeline(name, image,
arch='amd64',
build_type='Release',
lto=false,
werror=false,
cmake_extra='',
toolchain='32',
extra_cmds=[],
jobs=6,
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: image,
[if allow_fail then "failure"]: "ignore",
environment: { SSH_KEY: { from_secret: "SSH_KEY" }, WINDOWS_BUILD_NAME: toolchain+"bit" },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install -y build-essential cmake git ninja-build pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip automake libtool',
'update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix',
'update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix',
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_EXE_LINKER_FLAGS=-fstack-protector -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always -DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw'+toolchain+'.cmake -DCMAKE_BUILD_TYPE='+build_type+' ' +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') +
(if lto then '' else '-DWITH_LTO=OFF ') +
"-DBUILD_STATIC_DEPS=ON -DDOWNLOAD_SODIUM=ON -DBUILD_PACKAGE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON" +
cmake_extra,
'ninja -j' + jobs + ' -v package',
] + extra_cmds,
}
],
local windows_cross_pipeline(name,
image,
gui_image=docker_base + 'nodejs-lts',
arch='amd64',
build_type='Release',
lto=false,
werror=false,
cmake_extra='',
local_mirror=true,
extra_cmds=[],
jobs=6,
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'GUI',
image: gui_image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y p7zip-full wine',
'cd gui',
'yarn install --frozen-lockfile',
'USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all yarn win32',
],
},
{
name: 'build',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, WINDOWS_BUILD_NAME: 'x64' },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y build-essential cmake git pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip icoutils automake libtool librsvg2-bin bison',
'JOBS=' + jobs + ' VERBOSE=1 ./contrib/windows.sh -DSTRIP_SYMBOLS=ON -DGUI_EXE=$${DRONE_WORKSPACE}/gui/release/Lokinet-GUI_portable.exe' +
ci_dep_mirror(local_mirror),
] + extra_cmds,
},
],
};
// linux cross compile on debian
local linux_cross_pipeline(name,
cross_targets,
arch='amd64',
build_type='Release',
cmake_extra='',
local_mirror=true,
extra_cmds=[],
jobs=6,
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: docker_base + 'debian-stable-cross',
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, CROSS_TARGETS: std.join(':', cross_targets) },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'VERBOSE=1 JOBS=' + jobs + ' ./contrib/cross.sh ' + std.join(' ', cross_targets) +
' -- ' + cmake_extra + ci_dep_mirror(local_mirror),
],
},
],
};
// Builds a snapshot .deb on a debian-like system by merging into the debian/* or ubuntu/* branch
local deb_builder(image, distro, distro_branch, arch='amd64', loki_repo=true) = {
kind: 'pipeline',
type: 'docker',
name: 'DEB (' + distro + (if arch == 'amd64' then '' else '/' + arch) + ')',
platform: { arch: arch },
environment: { distro_branch: distro_branch, distro: distro },
steps: [
submodules,
{
name: 'build',
image: image,
failure: 'ignore',
environment: { SSH_KEY: { from_secret: "SSH_KEY" } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
] + (if loki_repo then [
'cp contrib/deb.loki.network.gpg /etc/apt/trusted.gpg.d',
'echo deb http://deb.loki.network $${distro} main >/etc/apt/sources.list.d/loki.network.list'
] else []) + [
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install -y git devscripts equivs ccache git-buildpackage python3-dev',
|||
# Look for the debian branch in this repo first, try upstream if that fails.
if ! git checkout $${distro_branch}; then
git remote add --fetch upstream https://github.com/oxen-io/loki-network.git &&
git checkout $${distro_branch}
fi
|||,
# Tell the merge how to resolve conflicts in the source .drone.jsonnet (we don't
# care about it at all since *this* .drone.jsonnet is already loaded).
'git config merge.ours.driver true',
'echo .drone.jsonnet merge=ours >>.gitattributes',
local deb_builder(image, distro, distro_branch, arch='amd64', oxen_repo=true) = {
kind: 'pipeline',
type: 'docker',
name: 'DEB (' + distro + (if arch == 'amd64' then '' else '/' + arch) + ')',
platform: { arch: arch },
environment: { distro_branch: distro_branch, distro: distro },
steps: [
submodules,
{
name: 'build',
image: image,
pull: 'always',
failure: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
] + (if oxen_repo then [
'cp contrib/deb.oxen.io.gpg /etc/apt/trusted.gpg.d',
'echo deb http://deb.oxen.io $${distro} main >/etc/apt/sources.list.d/oxen.list',
] else []) + [
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git devscripts equivs ccache git-buildpackage python3-dev',
|||
# Look for the debian branch in this repo first, try upstream if that fails.
if ! git checkout $${distro_branch}; then
git remote add --fetch upstream https://github.com/oxen-io/lokinet.git &&
git checkout $${distro_branch}
fi
|||,
// Tell the merge how to resolve conflicts in the source .drone.jsonnet (we don't
// care about it at all since *this* .drone.jsonnet is already loaded).
'git config merge.ours.driver true',
'echo .drone.jsonnet merge=ours >>.gitattributes',
'git merge ${DRONE_COMMIT}',
'export DEBEMAIL="${DRONE_COMMIT_AUTHOR_EMAIL}" DEBFULLNAME="${DRONE_COMMIT_AUTHOR_NAME}"',
'gbp dch -S -s "HEAD^" --spawn-editor=never -U low',
'eatmydata mk-build-deps --install --remove --tool "' + apt_get_quiet + ' -o Debug::pkgProblemResolver=yes --no-install-recommends -y"',
'export DEB_BUILD_OPTIONS="parallel=$$(nproc)"',
#'grep -q lib debian/lokinet-bin.install || echo "/usr/lib/lib*.so*" >>debian/lokinet-bin.install',
'debuild -e CCACHE_DIR -b',
'./contrib/ci/drone-debs-upload.sh ' + distro,
]
}
]
'git merge ${DRONE_COMMIT}',
'export DEBEMAIL="${DRONE_COMMIT_AUTHOR_EMAIL}" DEBFULLNAME="${DRONE_COMMIT_AUTHOR_NAME}"',
'gbp dch -S -s "HEAD^" --spawn-editor=never -U low',
'eatmydata mk-build-deps --install --remove --tool "' + apt_get_quiet + ' -o Debug::pkgProblemResolver=yes --no-install-recommends -y"',
'export DEB_BUILD_OPTIONS="parallel=$$(nproc)"',
//'grep -q lib debian/lokinet-bin.install || echo "/usr/lib/lib*.so*" >>debian/lokinet-bin.install',
'debuild -e CCACHE_DIR -b',
'./contrib/ci/drone-debs-upload.sh ' + distro,
],
},
],
};
local clang(version) = debian_pipeline(
'Debian sid/clang-' + version + ' (amd64)',
docker_base + 'debian-sid-clang',
deps=['clang-' + version] + default_deps_nocxx,
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version + ' -DCMAKE_CXX_COMPILER=clang++-' + version + ' '
);
local full_llvm(version) = debian_pipeline(
'Debian sid/llvm-' + version + ' (amd64)',
docker_base + 'debian-sid-clang',
deps=['clang-' + version, ' lld-' + version, ' libc++-' + version + '-dev', 'libc++abi-' + version + '-dev']
+ default_deps_nocxx,
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version +
' -DCMAKE_CXX_COMPILER=clang++-' + version +
' -DCMAKE_CXX_FLAGS=-stdlib=libc++ ' +
std.join(' ', [
'-DCMAKE_' + type + '_LINKER_FLAGS=-fuse-ld=lld-' + version
for type in ['EXE', 'MODULE', 'SHARED']
])
);
// Macos build
local mac_builder(name,
build_type='Release',
werror=true,
cmake_extra='',
extra_cmds=[],
jobs=6,
allow_fail=false) = {
kind: 'pipeline',
type: 'exec',
name: name,
platform: { os: 'darwin', arch: 'amd64' },
steps: [
{ name: 'submodules', commands: ['git fetch --tags', 'git submodule update --init --recursive'] },
{
name: 'build',
environment: { SSH_KEY: { from_secret: "SSH_KEY" } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
// If you don't do this then the C compiler doesn't have an include path containing
// basic system headers. WTF apple:
'export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"',
'ulimit -n 1024', // because macos sets ulimit to 256 for some reason yeah idk
'mkdir build',
'cd build',
'cmake .. -G Ninja -DCMAKE_CXX_FLAGS=-fcolor-diagnostics -DCMAKE_BUILD_TYPE='+build_type+' ' +
(if werror then '-DWARNINGS_AS_ERRORS=ON ' else '') + cmake_extra,
'ninja -j' + jobs + ' -v',
'./test/testAll --use-colour yes',
] + extra_cmds,
}
]
build_type='Release',
werror=true,
cmake_extra='',
local_mirror=true,
extra_cmds=[],
jobs=6,
codesign='-DCODESIGN=OFF',
allow_fail=false) = {
kind: 'pipeline',
type: 'exec',
name: name,
platform: { os: 'darwin', arch: 'amd64' },
steps: [
{ name: 'submodules', commands: submodule_commands },
{
name: 'build',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
// If you don't do this then the C compiler doesn't have an include path containing
// basic system headers. WTF apple:
'export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"',
'ulimit -n 1024', // because macos sets ulimit to 256 for some reason yeah idk
'./contrib/mac-configure.sh ' +
ci_dep_mirror(local_mirror) +
(if build_type == 'Debug' then ' -DWARN_DEPRECATED=OFF ' else '') +
codesign,
'cd build-mac',
// We can't use the 'package' target here because making a .dmg requires an active logged in
// macos gui to invoke Finder to invoke the partitioning tool to create a partitioned (!)
// disk image. Most likely the GUI is required because if you lose sight of how pretty the
// surface of macOS is you might see how ugly the insides are.
'ninja -j' + jobs + ' assemble_gui',
'cd ..',
] + extra_cmds,
},
],
};
local docs_pipeline(name, image, extra_cmds=[], allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: 'amd64' },
trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } },
steps: [
submodules,
{
name: 'build',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: [
'cmake -S . -B build-docs',
'make -C build-docs doc',
] + extra_cmds,
},
],
};
[
{
name: 'lint check',
kind: 'pipeline',
type: 'docker',
steps: [{
name: 'build', image: 'registry.oxen.rocks/lokinet-ci-lint',
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install -y git clang-format-11',
'./contrib/ci/drone-format-verify.sh']
}]
},
{
name: 'lint check',
kind: 'pipeline',
type: 'docker',
steps: [{
name: 'build',
image: docker_base + 'lint',
pull: 'always',
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git clang-format-14 jsonnet',
'./contrib/ci/drone-format-verify.sh',
],
}],
},
// documentation builder
docs_pipeline('Documentation',
docker_base + 'docbuilder',
extra_cmds=['UPLOAD_OS=docs ./contrib/ci/drone-static-upload.sh']),
// Various debian builds
debian_pipeline("Debian sid (amd64)", "debian:sid"),
debian_pipeline("Debian sid/Debug (amd64)", "debian:sid", build_type='Debug'),
debian_pipeline("Debian sid/clang-11 (amd64)", docker_base+'debian-sid', deps='clang-11 '+default_deps_nocxx,
cmake_extra='-DCMAKE_C_COMPILER=clang-11 -DCMAKE_CXX_COMPILER=clang++-11 '),
debian_pipeline("Debian buster (i386)", "i386/debian:buster", cmake_extra='-DDOWNLOAD_SODIUM=ON'),
debian_pipeline("Ubuntu focal (amd64)", docker_base+'ubuntu-focal'),
debian_pipeline("Ubuntu bionic (amd64)", "ubuntu:bionic", deps='g++-8 ' + default_deps_nocxx,
cmake_extra='-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8', loki_repo=true),
// Various debian builds
debian_pipeline('Debian sid (amd64)', docker_base + 'debian-sid'),
debian_pipeline('Debian sid/Debug (amd64)', docker_base + 'debian-sid', build_type='Debug'),
clang(13),
full_llvm(13),
debian_pipeline('Debian stable (i386)', docker_base + 'debian-stable/i386'),
debian_pipeline('Debian buster (amd64)', docker_base + 'debian-buster', cmake_extra='-DDOWNLOAD_SODIUM=ON'),
debian_pipeline('Ubuntu latest (amd64)', docker_base + 'ubuntu-rolling'),
debian_pipeline('Ubuntu LTS (amd64)', docker_base + 'ubuntu-lts'),
debian_pipeline('Ubuntu bionic (amd64)',
docker_base + 'ubuntu-bionic',
deps=['g++-8'] + default_deps_nocxx,
cmake_extra='-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8',
oxen_repo=true),
// ARM builds (ARM64 and armhf)
debian_pipeline("Debian sid (ARM64)", "debian:sid", arch="arm64", jobs=4),
debian_pipeline("Debian buster (armhf)", "arm32v7/debian:buster", arch="arm64", cmake_extra='-DDOWNLOAD_SODIUM=ON', jobs=4),
// Static armhf build (gets uploaded)
debian_pipeline("Static (buster armhf)", "arm32v7/debian:buster", arch="arm64", deps='g++ python3-dev automake libtool',
cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON ' +
'-DCMAKE_CXX_FLAGS="-march=armv7-a+fp" -DCMAKE_C_FLAGS="-march=armv7-a+fp" -DNATIVE_BUILD=OFF ' +
'-DWITH_SYSTEMD=OFF',
extra_cmds=[
'../contrib/ci/drone-check-static-libs.sh',
'UPLOAD_OS=linux-armhf ../contrib/ci/drone-static-upload.sh'
],
jobs=4),
// android apk builder
apk_builder("android apk", "registry.oxen.rocks/lokinet-ci-android", extra_cmds=['UPLOAD_OS=anrdoid ../contrib/ci/drone-static-upload.sh']),
// Windows builds (x64)
windows_cross_pipeline("Windows (amd64)", docker_base+'debian-win32-cross',
toolchain='64', extra_cmds=[
'../contrib/ci/drone-static-upload.sh'
]),
// ARM builds (ARM64 and armhf)
debian_pipeline('Debian sid (ARM64)', docker_base + 'debian-sid', arch='arm64', jobs=4),
debian_pipeline('Debian stable (armhf)', docker_base + 'debian-stable/arm32v7', arch='arm64', jobs=4),
// Static build (on bionic) which gets uploaded to builds.lokinet.dev:
debian_pipeline("Static (bionic amd64)", docker_base+'ubuntu-bionic', deps='g++-8 python3-dev automake libtool', lto=true,
cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ' +
'-DCMAKE_CXX_FLAGS="-march=x86-64 -mtune=haswell" -DCMAKE_C_FLAGS="-march=x86-64 -mtune=haswell" -DNATIVE_BUILD=OFF ' +
'-DWITH_SYSTEMD=OFF',
extra_cmds=[
'../contrib/ci/drone-check-static-libs.sh',
'../contrib/ci/drone-static-upload.sh'
]),
// cross compile targets
// Aug 11: these are exhibiting some dumb failures in libsodium and external deps, TOFIX later
//linux_cross_pipeline('Cross Compile (arm/arm64)', cross_targets=['arm-linux-gnueabihf', 'aarch64-linux-gnu']),
//linux_cross_pipeline('Cross Compile (ppc64le)', cross_targets=['powerpc64le-linux-gnu']),
// integration tests
debian_pipeline("Router Hive", "ubuntu:focal", deps='python3-dev python3-pytest python3-pybind11 ' + default_deps,
cmake_extra='-DWITH_HIVE=ON'),
// Not currently building successfully:
//linux_cross_pipeline('Cross Compile (mips)', cross_targets=['mips-linux-gnu', 'mipsel-linux-gnu']),
// Deb builds:
deb_builder("debian:sid", "sid", "debian/sid"),
deb_builder("debian:buster", "buster", "debian/buster"),
deb_builder("ubuntu:focal", "focal", "ubuntu/focal"),
deb_builder("debian:sid", "sid", "debian/sid", arch='arm64'),
// android apk builder
// Aug 11: this is also failing in openssl, TOFIX later
//apk_builder('android apk', docker_base + 'flutter', extra_cmds=['UPLOAD_OS=android ./contrib/ci/drone-static-upload.sh']),
// Macos builds:
mac_builder('macOS (Release)'),
mac_builder('macOS (Debug)', build_type='Debug'),
mac_builder('macOS (Static)', cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON -DDOWNLOAD_SODIUM=FORCE -DDOWNLOAD_CURL=FORCE -DDOWNLOAD_UV=FORCE',
extra_cmds=[
'../contrib/ci/drone-check-static-libs.sh',
'../contrib/ci/drone-static-upload.sh'
]),
// Windows builds (x64)
windows_cross_pipeline('Windows (amd64)',
docker_base + 'debian-bookworm',
extra_cmds=[
'./contrib/ci/drone-static-upload.sh',
]),
// Static build (on bionic) which gets uploaded to builds.lokinet.dev:
debian_pipeline('Static (bionic amd64)',
docker_base + 'ubuntu-bionic',
deps=['g++-8', 'python3-dev', 'automake', 'libtool'],
lto=true,
tests=false,
oxen_repo=true,
cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON ' +
'-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ' +
'-DCMAKE_CXX_FLAGS="-march=x86-64 -mtune=haswell" ' +
'-DCMAKE_C_FLAGS="-march=x86-64 -mtune=haswell" ' +
'-DNATIVE_BUILD=OFF -DWITH_SYSTEMD=OFF -DWITH_BOOTSTRAP=OFF -DBUILD_LIBLOKINET=OFF',
extra_cmds=[
'./contrib/ci/drone-check-static-libs.sh',
'./contrib/ci/drone-static-upload.sh',
]),
// Static armhf build (gets uploaded)
debian_pipeline('Static (buster armhf)',
docker_base + 'debian-buster/arm32v7',
arch='arm64',
deps=['g++', 'python3-dev', 'automake', 'libtool'],
cmake_extra='-DBUILD_STATIC_DEPS=ON -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK=ON ' +
'-DCMAKE_CXX_FLAGS="-march=armv7-a+fp -Wno-psabi" -DCMAKE_C_FLAGS="-march=armv7-a+fp" ' +
'-DNATIVE_BUILD=OFF -DWITH_SYSTEMD=OFF -DWITH_BOOTSTRAP=OFF',
extra_cmds=[
'./contrib/ci/drone-check-static-libs.sh',
'UPLOAD_OS=linux-armhf ./contrib/ci/drone-static-upload.sh',
],
jobs=4),
// integration tests
debian_pipeline('Router Hive',
docker_base + 'ubuntu-lts',
deps=['python3-dev', 'python3-pytest', 'python3-pybind11'] + default_deps,
cmake_extra='-DWITH_HIVE=ON'),
// Deb builds:
deb_builder(docker_base + 'debian-sid-builder', 'sid', 'debian/sid'),
deb_builder(docker_base + 'debian-bullseye-builder', 'bullseye', 'debian/bullseye'),
deb_builder(docker_base + 'ubuntu-jammy-builder', 'jammy', 'ubuntu/jammy'),
deb_builder(docker_base + 'debian-sid-builder', 'sid', 'debian/sid', arch='arm64'),
// Macos builds:
mac_builder('macOS (Release)', extra_cmds=[
'./contrib/ci/drone-check-static-libs.sh',
'./contrib/ci/drone-static-upload.sh',
]),
mac_builder('macOS (Debug)', build_type='Debug'),
]

1
.gitattributes vendored
View File

@ -2,3 +2,4 @@ external/date/test export-ignore
external/nlohmann/doc export-ignore
external/nlohmann/test export-ignore
external/nlohmann/benchmarks/data export-ignore
*.signed binary

22
.github/workflows/clean_issues.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Close incomplete issues
on:
schedule:
- cron: "30 1 * * *"
jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/stale@v4.1.1
with:
only-labels: incomplete
days-before-issue-stale: 14
days-before-issue-close: 7
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been 'incomplete' for 14 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@ -26,6 +26,8 @@ callgrind.*
*.sig
*.signed
!/contrib/bootstrap/mainnet.signed
!/contrib/bootstrap/testnet.signed
*.key
shadow.data

22
.gitmodules vendored
View File

@ -1,25 +1,16 @@
[submodule "external/nlohmann"]
path = external/nlohmann
url = https://github.com/nlohmann/json.git
[submodule "external/cxxopts"]
path = external/cxxopts
url = https://github.com/jarro2783/cxxopts.git
[submodule "external/ghc-filesystem"]
path = external/ghc-filesystem
url = https://github.com/gulrak/filesystem.git
[submodule "test/Catch2"]
path = test/Catch2
url = https://github.com/catchorg/Catch2
[submodule "external/date"]
path = external/date
url = https://github.com/HowardHinnant/date.git
[submodule "external/pybind11"]
path = external/pybind11
url = https://github.com/pybind/pybind11
branch = stable
[submodule "external/clang-format-hooks"]
path = external/clang-format-hooks
url = https://github.com/barisione/clang-format-hooks/
[submodule "external/sqlite_orm"]
path = external/sqlite_orm
url = https://github.com/fnc12/sqlite_orm
@ -35,3 +26,16 @@
[submodule "external/ngtcp2"]
path = external/ngtcp2
url = https://github.com/ngtcp2/ngtcp2.git
branch = v0.1.0
[submodule "external/oxen-encoding"]
path = external/oxen-encoding
url = https://github.com/oxen-io/oxen-encoding.git
[submodule "external/oxen-logging"]
path = external/oxen-logging
url = https://github.com/oxen-io/oxen-logging.git
[submodule "gui"]
path = gui
url = https://github.com/oxen-io/lokinet-gui.git
[submodule "external/CLI11"]
path = external/CLI11
url = https://github.com/CLIUtils/CLI11.git

1
.swift-version Normal file
View File

@ -0,0 +1 @@
5.4.2

View File

@ -1,13 +1,21 @@
cmake_minimum_required(VERSION 3.10) # bionic's cmake version
cmake_minimum_required(VERSION 3.13...3.24) # 3.13 is buster's version
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Has to be set before `project()`, and ignored on non-macos:
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "macOS deployment target (Apple clang only)")
option(BUILD_DAEMON "build lokinet daemon and associated utils" ON)
set(LANGS C CXX)
if(APPLE AND BUILD_DAEMON)
set(LANGS ${LANGS} OBJC Swift)
endif()
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
foreach(lang C CXX)
foreach(lang ${LANGS})
if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/ccache")
message(STATUS "Enabling ccache for ${lang}")
set(CMAKE_${lang}_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "")
@ -15,44 +23,53 @@ if(CCACHE_PROGRAM)
endforeach()
endif()
project(lokinet
VERSION 0.9.3
VERSION 0.9.11
DESCRIPTION "lokinet - IP packet onion router"
LANGUAGES C CXX)
LANGUAGES ${LANGS})
set(RELEASE_MOTTO "A Series of Tubes" CACHE STRING "Release motto")
add_definitions(-DLLARP_VERSION_MAJOR=${lokinet_VERSION_MAJOR})
add_definitions(-DLLARP_VERSION_MINOR=${lokinet_VERSION_MINOR})
add_definitions(-DLLARP_VERSION_PATCH=${lokinet_VERSION_PATCH})
if(RELEASE_MOTTO AND CMAKE_BUILD_TYPE MATCHES "[Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}")
if(APPLE)
# Apple build number: must be incremented to submit a new build for the same lokinet version,
# should be reset to 0 when the lokinet version increments.
set(LOKINET_APPLE_BUILD 5)
endif()
set(RELEASE_MOTTO "Our Lord And Savior" CACHE STRING "Release motto")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(DEFAULT_WITH_BOOTSTRAP ON)
if(APPLE)
set(DEFAULT_WITH_BOOTSTRAP OFF)
endif()
# Core options
option(USE_AVX2 "enable avx2 code" OFF)
option(USE_NETNS "enable networking namespace support. Linux only" OFF)
option(NATIVE_BUILD "optimise for host system and FPU" ON)
option(EMBEDDED_CFG "optimise for older hardware or embedded systems" OFF)
option(BUILD_LIBLOKINET "build liblokinet.so" ON)
option(SHADOW "use shadow testing framework. linux only" OFF)
option(WITH_EMBEDDED_LOKINET "build liblokinet.so for embedded lokinet" OFF)
option(XSAN "use sanitiser, if your system has it (requires -DCMAKE_BUILD_TYPE=Debug)" OFF)
option(WITH_JEMALLOC "use jemalloc as allocator" OFF)
option(USE_JEMALLOC "Link to jemalloc for memory allocations, if found" ON)
option(TESTNET "testnet build" OFF)
option(WITH_COVERAGE "generate coverage data" OFF)
option(USE_SHELLHOOKS "enable shell hooks on compile time (dangerous)" OFF)
option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF)
option(TRACY_ROOT "include tracy profiler source" OFF)
option(WITH_TESTS "build unit tests" ON)
option(WITH_TESTS "build unit tests" OFF)
option(WITH_HIVE "build simulation stubs" OFF)
option(BUILD_PACKAGE "builds extra components for making an installer (with 'make package')" OFF)
option(WITH_BOOTSTRAP "build lokinet-bootstrap tool" ${DEFAULT_WITH_BOOTSTRAP})
option(WITH_PEERSTATS "build with experimental peerstats db support" OFF)
option(STRIP_SYMBOLS "strip off all debug symbols into an external archive for all executables built" OFF)
set(BOOTSTRAP_FALLBACK_MAINNET "${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed" CACHE PATH "Fallback bootstrap path (mainnet)")
set(BOOTSTRAP_FALLBACK_TESTNET "${PROJECT_SOURCE_DIR}/contrib/bootstrap/testnet.signed" CACHE PATH "Fallback bootstrap path (testnet)")
include(cmake/enable_lto.cmake)
option(CROSS_PLATFORM "cross compiler platform" "Linux")
option(CROSS_PREFIX "toolchain cross compiler prefix" "")
option(BUILD_STATIC_DEPS "Download, build, and statically link against core dependencies" OFF)
option(STATIC_LINK "link statically against dependencies" ${BUILD_STATIC_DEPS})
if(BUILD_STATIC_DEPS AND NOT STATIC_LINK)
@ -67,6 +84,19 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
set(debug OFF)
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
set(debug ON)
add_definitions(-DLOKINET_DEBUG)
endif()
option(WARN_DEPRECATED "show deprecation warnings" ${debug})
if(BUILD_STATIC_DEPS AND STATIC_LINK)
message(STATUS "we are building static deps so we won't build shared libs")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
endif()
include(CheckCXXSourceCompiles)
include(CheckLibraryExists)
set(CMAKE_CXX_STANDARD 17)
@ -78,27 +108,18 @@ set(CMAKE_C_EXTENSIONS OFF)
include(cmake/target_link_libraries_system.cmake)
include(cmake/add_import_library.cmake)
include(cmake/add_log_tag.cmake)
include(cmake/libatomic.cmake)
include(cmake/link_dep_libs.cmake)
if (STATIC_LINK)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
message(STATUS "setting static library suffix search")
endif()
add_definitions(-D${CMAKE_SYSTEM_NAME})
if(MSVC_VERSION)
enable_language(ASM_MASM)
list(APPEND CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS s)
add_definitions(-D_WIN32_WINNT=0x0600 -DNOMINMAX -DSODIUM_STATIC)
else()
enable_language(ASM)
endif()
include(cmake/gui-option.cmake)
include(cmake/solaris.cmake)
include(cmake/win32.cmake)
include(cmake/macos.cmake)
# No in-source building
include(MacroEnsureOutOfSourceBuild)
@ -127,7 +148,6 @@ endif()
find_package(PkgConfig REQUIRED)
if(NOT BUILD_STATIC_DEPS)
pkg_check_modules(LIBUV libuv>=1.18.0 IMPORTED_TARGET)
endif()
@ -136,7 +156,7 @@ if(LIBUV_FOUND AND NOT BUILD_STATIC_DEPS)
target_link_libraries(libuv INTERFACE PkgConfig::LIBUV)
else()
if(NOT BUILD_STATIC_DEPS)
message(FATAL_ERROR "Could not find libu >= 1.28.0; install it on your system or use -DBUILD_STATIC_DEPS=ON")
message(FATAL_ERROR "Could not find libuv >= 1.28.0; install it on your system or use -DBUILD_STATIC_DEPS=ON")
endif()
endif()
@ -163,28 +183,19 @@ if(NOT TARGET sodium)
export(TARGETS sodium NAMESPACE sodium:: FILE sodium-exports.cmake)
endif()
option(FORCE_OXENMQ_SUBMODULE "force using oxenmq submodule" OFF)
if(NOT FORCE_OXENMQ_SUBMODULE)
pkg_check_modules(OXENMQ liboxenmq>=1.2.4)
set(warning_flags -Wall -Wextra -Wno-unknown-pragmas -Wno-unused-function -Werror=vla)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
list(APPEND warning_flags -Wno-unknown-warning-option)
endif()
if(OXENMQ_FOUND)
add_library(oxenmq INTERFACE)
link_dep_libs(oxenmq INTERFACE "${OXENMQ_LIBRARY_DIRS}" ${OXENMQ_LIBRARIES})
target_include_directories(oxenmq INTERFACE ${OXENMQ_INCLUDE_DIRS})
add_library(oxenmq::oxenmq ALIAS oxenmq)
message(STATUS "Found system liboxenmq ${OXENMQ_VERSION}")
if(WARN_DEPRECATED)
list(APPEND warning_flags -Wdeprecated-declarations)
else()
message(STATUS "using oxenmq submodule")
add_subdirectory(${CMAKE_SOURCE_DIR}/external/oxen-mq)
list(APPEND warning_flags -Wno-deprecated-declarations)
endif()
# this is messing with release builds
add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux" AND SHADOW)
message( FATAL_ERROR "shadow-framework is Linux only" )
endif()
# If we blindly add these directly as compile_options then they get passed to swiftc on Apple and
# break, so we use a generate expression to set them only for C++/C/ObjC
add_compile_options("$<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:OBJC>>:${warning_flags}>")
if(XSAN)
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fsanitize=${XSAN} -fno-omit-frame-pointer -fno-sanitize-recover")
@ -194,31 +205,6 @@ if(XSAN)
message(STATUS "Doing a ${XSAN} sanitizer build")
endif()
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
add_definitions(-DLOKINET_DEBUG=1)
endif()
if(WITH_SHELLHOOKS)
add_definitions(-DENABLE_SHELLHOOKS)
endif()
if(TRACY_ROOT)
include_directories(${TRACY_ROOT})
add_definitions(-DTRACY_ENABLE)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-unknown-warning-option)
endif()
if (NOT MSVC_VERSION)
add_compile_options(-Wall -Wextra -Wno-unknown-pragmas)
# vla are evil
add_compile_options(-Werror=vla)
add_compile_options(-Wno-unused-function -Wno-deprecated-declarations)
endif()
include(cmake/coverage.cmake)
# these vars are set by the cmake toolchain spec
@ -226,18 +212,20 @@ if (WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
include(cmake/cross_compile.cmake)
endif()
if(NATIVE_BUILD)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le)
add_compile_options(-mcpu=native -mtune=native)
else()
add_compile_options(-march=native -mtune=native)
endif()
elseif(NOT NON_PC_TARGET)
if (USE_AVX2)
add_compile_options(-march=haswell -mtune=haswell -mfpmath=sse)
else()
# Public binary releases
add_compile_options(-march=nocona -mtune=haswell -mfpmath=sse)
if(NOT APPLE)
if(NATIVE_BUILD)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le)
add_compile_options(-mcpu=native -mtune=native)
else()
add_compile_options(-march=native -mtune=native)
endif()
elseif(NOT NON_PC_TARGET)
if (USE_AVX2)
add_compile_options(-march=haswell -mtune=haswell -mfpmath=sse)
else()
# Public binary releases
add_compile_options(-march=nocona -mtune=haswell -mfpmath=sse)
endif()
endif()
endif()
@ -245,22 +233,12 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
if(USE_NETNS)
add_definitions(-DNETNS=1)
else()
add_definitions(-DNETNS=0)
endif()
if(TESTNET)
add_definitions(-DTESTNET=1)
add_definitions(-DTESTNET)
# 5 times slower than realtime
# add_definitions(-DTESTNET_SPEED=5)
endif()
if(SHADOW)
include(cmake/shadow.cmake)
endif()
unset(GIT_VERSION)
unset(GIT_VERSION_REAL)
@ -295,7 +273,18 @@ if(WITH_SYSTEMD AND (NOT ANDROID))
endif()
add_subdirectory(external)
include_directories(SYSTEM external/sqlite_orm/include)
if(USE_JEMALLOC AND NOT STATIC_LINK)
pkg_check_modules(JEMALLOC jemalloc IMPORTED_TARGET)
if(JEMALLOC_FOUND)
target_link_libraries(base_libs INTERFACE PkgConfig::JEMALLOC)
else()
message(STATUS "jemalloc not found, not linking to jemalloc")
endif()
else()
message(STATUS "jemalloc support disabled")
endif()
if(ANDROID)
target_link_libraries(base_libs INTERFACE log)
@ -303,34 +292,34 @@ if(ANDROID)
set(ANDROID_PLATFORM_SRC android/ifaddrs.c)
endif()
if(TRACY_ROOT)
target_link_libraries(base_libs INTERFACE dl)
endif()
if(WITH_HIVE)
add_definitions(-DLOKINET_HIVE=1)
add_definitions(-DLOKINET_HIVE)
endif()
add_subdirectory(crypto)
add_subdirectory(llarp)
add_subdirectory(daemon)
if(BUILD_DAEMON)
add_subdirectory(daemon)
endif()
if(WITH_HIVE)
add_subdirectory(pybind)
endif()
if (NOT SHADOW)
if(WITH_TESTS OR WITH_HIVE)
add_subdirectory(test)
endif()
if(ANDROID)
add_subdirectory(jni)
endif()
if(WITH_TESTS OR WITH_HIVE)
add_subdirectory(test)
endif()
if(ANDROID)
add_subdirectory(jni)
endif()
add_subdirectory(docs)
include(cmake/gui.cmake)
if(APPLE)
macos_target_setup()
endif()
# uninstall target
if(NOT TARGET uninstall)
configure_file(
@ -342,7 +331,10 @@ if(NOT TARGET uninstall)
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
if(BUILD_PACKAGE)
include(cmake/installer.cmake)
if(BUILD_PACKAGE AND NOT APPLE)
include(cmake/installer.cmake)
endif()
if(TARGET package)
add_dependencies(package assemble_gui)
endif()

View File

@ -1,28 +0,0 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": []
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}

View File

@ -3,7 +3,7 @@
* Act like a responsible adult.
* RUN `make format` BEFORE COMMITING ALWAYS.
* RUN `./contrib/format.sh` BEFORE COMMITING ALWAYS.
# Do NOT

View File

@ -1,16 +1,3 @@
LokiNET is the reference implementation of LLARP (Low Latency Anonymous
Routing Protocol).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Copyright (c) 2018-2020 The Loki Project
Copyright (c) 2018-2020 Jeff Becker
Windows NT port and portions Copyright (c) 2018-2020 Rick V.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
@ -684,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

18
android/.gitignore vendored
View File

@ -1,18 +0,0 @@
gen
tests
bin
libs
log*
obj
.gradle
.idea
.externalNativeBuild
ant.properties
local.properties
build.sh
android.iml
build
gradle
gradlew
gradlew.bat
gradle.properties

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="network.loki.lokinet"
android:installLocation="auto"
android:versionCode="1"
android:versionName="0.8.4">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" /> <!-- normal perm, per https://developer.android.com/guide/topics/permissions/normal-permissions.html -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- normal perm -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
>
<receiver android:name=".NetworkStateChangeReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<activity
android:name=".LokiNetActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".LokinetDaemon"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>
</application>
</manifest>

View File

@ -1,81 +0,0 @@
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
google()
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "network.loki.lokinet"
targetSdkVersion 28
minSdkVersion 23
versionCode 1
versionName '0.8.4'
externalNativeBuild {
cmake {
targets "lokinet-android"
arguments "-DWITH_LTO=OFF", "-DCXXOPTS_BUILD_TESTS=OFF","-DWITH_TESTS=OFF", "-DCMAKE_CROSSCOMPILING=ON", "-DNATIVE_BUILD=OFF", "-DANDROID=ON", "-DANDROID_STL=c++_static", "-DBUILD_STATIC_DEPS=ON", "-DBUILD_SHARED_LIBS=OFF", "-DSTATIC_LINK=ON", "-DANDROID_ARM_MODE=arm", "-DFORCE_OXENMQ_SUBMODULE=ON", "-DBUILD_LIBLOKINET=OFF"
cppFlags "-std=c++17"
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
// abiFilters 'armeabi-v7a'
// abiFilters 'arm64-v8a', 'x86_64', 'armeabi-v7a'
}
}
}
externalNativeBuild {
cmake {
path "../CMakeLists.txt"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
assets.srcDirs = ['assets']
}
}
signingConfigs {
jeff {
storeFile file("jeff-apk.jks")
keyAlias "jeff-apk"
}
}
buildTypes {
release {
minifyEnabled true
//signingConfig signingConfigs.jeff
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
debuggable false
}
debug {
// jniDebuggable true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

View File

@ -1,96 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="lokinet" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Insert sdk.dir=... into './local.properties'. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<fail
message="ndk.dir is missing. Insert ndk.dir=... into './local.properties'."
unless="ndk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,20 +0,0 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,14 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-28

View File

@ -1,33 +0,0 @@
# lokinet android
this directory contains basic stuff for lokinet on android.
## Prerequsites
To build you need the following:
* Gradle (6.x)
* Android SDK (latest version)
* Android NDK (latest version)
## Building
Next set up the path to Android SDK and NDK in `local.properties`
```
sdk.dir=/path/to/android/sdk
ndk.dir=/path/to/android/ndk
```
Then build:
$ gradle assemble
This fetches a large amount (several dozen Gigabytes) of files from some
server somewhere dumping it on your filesystem to make the thing do the
building, then proceeds to peg all your cores for several dozen minutes
while it does the required incantations to build 2 apks.
The build outputs apks to to subdirectories in `build/outputs/apk/`
one called `debug` for debug builds and one called `release` for release builds.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -1,27 +0,0 @@
<LinearLayout android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/vertical_page_margin"
android:paddingLeft="@dimen/horizontal_page_margin"
android:paddingRight="@dimen/horizontal_page_margin"
android:paddingTop="@dimen/vertical_page_margin"
tools:context=".PermsAskerActivity">
<TextView
android:id="@+id/textview_retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/horizontal_page_margin"
android:visibility="gone"
/>
<Button
android:id="@+id/button_request_write_ext_storage_perms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Retry requesting VPN"
android:visibility="gone"/>
</LinearLayout>

View File

@ -1,27 +0,0 @@
<LinearLayout android:id="@+id/layout_prompt"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/vertical_page_margin"
android:paddingLeft="@dimen/horizontal_page_margin"
android:paddingRight="@dimen/horizontal_page_margin"
android:paddingTop="@dimen/vertical_page_margin"
tools:context=".PermsAskerActivity">
<TextView
android:id="@+id/textview_explanation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/horizontal_page_margin"
android:text="VPN permissions are required for lokinet usage."
/>
<Button
android:id="@+id/button_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
/>
</LinearLayout>

View File

@ -1,16 +0,0 @@
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".LokiNetActivity">
<item
android:id="@+id/action_start"
android:title="@string/action_start"
android:orderInCategory="98"
/>
<item
android:id="@+id/action_stop"
android:title="@string/action_stop"
android:orderInCategory="99"
/>
</menu>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">lokinet</string>
<string name="action_start">Start</string>
<string name="action_stop">Stop</string>
<string name="already_stopped">Already stopped</string>
<string name="loaded">lokinet loaded</string>
<string name="starting">lokinet is starting</string>
<string name="jniLibraryLoaded">lokinet: loaded JNI libraries</string>
<string name="startedOkay">lokinet started</string>
<string name="startFailed">lokinet start failed</string>
<string name="stopped">lokinet has stopped</string>
<string name="remaining">remaining</string>
<string name="title_activity_perms_asker_prompt">Prompt</string>
<string name="bootstrap_ok">got bootstrap node info</string>
<string name="bootstrap_fail">failed to bootstrap</string>
<string name="netdb_create_fail">failed to create netdb directory</string>
<string name="vpn_setup_fail">failed to set up vpn tunnel</string>
</resources>

View File

@ -1,16 +0,0 @@
<resources>
<!-- Define standard dimensions to comply with Holo-style grids and rhythm. -->
<dimen name="margin_tiny">4dp</dimen>
<dimen name="margin_small">8dp</dimen>
<dimen name="margin_medium">16dp</dimen>
<dimen name="margin_large">32dp</dimen>
<dimen name="margin_huge">64dp</dimen>
<!-- Semantic definitions -->
<dimen name="horizontal_page_margin">@dimen/margin_medium</dimen>
<dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
</resources>

View File

@ -1 +0,0 @@
rootProject.name = "lokinet"

View File

@ -1,185 +0,0 @@
package network.loki.lokinet;
import java.io.File;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.app.Activity;
import android.content.Context;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.Manifest;
import android.net.VpnService;
import android.os.AsyncTask;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.util.Log;
public class LokiNetActivity extends Activity {
private static final String TAG = "lokinet-activity";
private TextView textView;
private static final String DefaultBootstrapURL = "https://seed.lokinet.org/lokinet.signed";
private AsyncBootstrap bootstrapper;
public static final String LOG_TAG = "LokinetDaemon";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
textView = new TextView(this);
setContentView(textView);
System.loadLibrary("lokinet-android");
}
private static void writeFile(File out, InputStream instream) throws IOException {
OutputStream outstream = new FileOutputStream(out);
byte[] buffer = new byte[512];
int len;
try {
do {
len = instream.read(buffer);
if (len > 0) {
outstream.write(buffer, 0, len);
}
}
while (len != -1);
} finally {
outstream.close();
}
}
public void startLokinet()
{
if(bootstrapper != null)
return;
bootstrapper = new AsyncBootstrap();
bootstrapper.execute(DefaultBootstrapURL);
}
public void runLokinetService()
{
Intent intent = VpnService.prepare(getApplicationContext());
if (intent != null)
{
Log.d(LOG_TAG, "VpnService.prepare() returned an Intent, so launch that intent.");
startActivityForResult(intent, 0);
}
else
{
Log.w(LOG_TAG, "VpnService.prepare() returned null, not running.");
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
Log.d(LOG_TAG, "VpnService prepared intent RESULT_OK, launching LokinetDaemon Service");
startService(new Intent(LokiNetActivity.this,
LokinetDaemon.class));
}
else
{
Log.d(LOG_TAG, "VpnService prepared intent NOT RESULT_OK, shit.");
}
}
@Override
protected void onDestroy() {
super.onDestroy();
textView = null;
}
public File getRootDir()
{
return getFilesDir();
}
private class AsyncBootstrap extends AsyncTask<String, String, String>
{
public String doInBackground(String ... urls) {
try
{
File bootstrapFile = new File(getRootDir(), "bootstrap.signed");
URL bootstrapURL = new URL(urls[0]);
InputStream instream = bootstrapURL.openStream();
writeFile(bootstrapFile, instream);
instream.close();
return getString(R.string.bootstrap_ok);
}
catch(Exception thrown)
{
return getString(R.string.bootstrap_fail) + ": " + throwableToString(thrown);
}
}
public void onPostExecute(String val) {
textView.setText(val);
if(val.equals(getString(R.string.bootstrap_ok)))
runLokinetService();
bootstrapDone();
}
}
private void bootstrapDone()
{
bootstrapper = null;
}
private CharSequence throwableToString(Throwable tr) {
StringWriter sw = new StringWriter(8192);
PrintWriter pw = new PrintWriter(sw);
tr.printStackTrace(pw);
pw.close();
return sw.toString();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.options_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
switch(id){
case R.id.action_start:
startLokinet();
return true;
case R.id.action_stop:
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@ -1,28 +0,0 @@
package network.loki.lokinet;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class NetworkStateChangeReceiver extends BroadcastReceiver {
private static final String TAG = "lokinet";
//api level 1
@Override
public void onReceive(final Context context, final Intent intent) {
Log.d(TAG,"Network state change");
try {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
boolean isConnected = activeNetworkInfo!=null && activeNetworkInfo.isConnected();
// https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html?hl=ru
// boolean isWiFi = activeNetworkInfo!=null && (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI);
} catch (Throwable tr) {
Log.d(TAG,"",tr);
}
}
}

View File

@ -1,173 +0,0 @@
package network.loki.lokinet;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.lang.reflect.Method;
//dangerous perms, per https://developer.android.com/guide/topics/permissions/normal-permissions.html :
//android.permission.WRITE_EXTERNAL_STORAGE
public class PermsAskerActivity extends Activity {
private static final int PERMISSION_VPN = 0;
private Button button_request_write_ext_storage_perms;
private TextView textview_retry;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startMainActivity();
/*
//if less than Android 6, no runtime perms req system present
if (android.os.Build.VERSION.SDK_INT < 23) {
return;
}
setContentView(R.layout.activity_perms_asker);
button_request_write_ext_storage_perms = (Button) findViewById(R.id.button_request_write_ext_storage_perms);
textview_retry = (TextView) findViewById(R.id.textview_retry);
button_request_write_ext_storage_perms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
request_write_ext_storage_perms();
}
});
request_write_ext_storage_perms();
*/
}
private void request_write_ext_storage_perms() {
textview_retry.setVisibility(TextView.GONE);
button_request_write_ext_storage_perms.setVisibility(Button.GONE);
Method methodCheckPermission;
Method method_shouldShowRequestPermissionRationale;
Method method_requestPermissions;
try {
methodCheckPermission = getClass().getMethod("checkSelfPermission", String.class);
method_shouldShowRequestPermissionRationale =
getClass().getMethod("shouldShowRequestPermissionRationale", String.class);
method_requestPermissions =
getClass().getMethod("requestPermissions", String[].class, int.class);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
Integer resultObj;
try {
resultObj = (Integer) methodCheckPermission.invoke(
this, Manifest.permission.BIND_VPN_SERVICE);
} catch (Throwable e) {
throw new RuntimeException(e);
}
if (resultObj != PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
Boolean aBoolean;
try {
aBoolean = (Boolean) method_shouldShowRequestPermissionRationale.invoke(this,
Manifest.permission.BIND_VPN_SERVICE);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (aBoolean) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
showExplanation();
} else {
// No explanation needed, we can request the permission.
try {
method_requestPermissions.invoke(this,
new String[]{Manifest.permission.BIND_VPN_SERVICE},
PERMISSION_VPN);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} else startMainActivity();
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case PERMISSION_VPN: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the
// contacts-related task you need to do.
startMainActivity();
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
textview_retry.setText("you need to allow this to continue");
textview_retry.setVisibility(TextView.VISIBLE);
button_request_write_ext_storage_perms.setVisibility(Button.VISIBLE);
}
return;
}
// other 'case' lines to check for other
// permissions this app might request.
}
}
private void startMainActivity() {
startActivity(new Intent(this, LokiNetActivity.class));
finish();
}
private static final int SHOW_EXPLANATION_REQUEST = 1; // The request code
private void showExplanation() {
Intent intent = new Intent(this, PermsExplanationActivity.class);
startActivityForResult(intent, SHOW_EXPLANATION_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == SHOW_EXPLANATION_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// Request the permission
Method method_requestPermissions;
try {
method_requestPermissions =
getClass().getMethod("requestPermissions", String[].class, int.class);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
try {
method_requestPermissions.invoke(this,
new String[]{Manifest.permission.BIND_VPN_SERVICE},
PERMISSION_VPN);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
finish(); //close the app
}
}
}
}

View File

@ -1,38 +0,0 @@
package network.loki.lokinet;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
public class PermsExplanationActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_perms_explanation);
ActionBar actionBar = getActionBar();
if(actionBar!=null)actionBar.setHomeButtonEnabled(false);
Button button_ok = (Button) findViewById(R.id.button_ok);
button_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
returnFromActivity();
}
});
}
private void returnFromActivity() {
Intent data = new Intent();
Activity parent = getParent();
if (parent == null) {
setResult(Activity.RESULT_OK, data);
} else {
parent.setResult(Activity.RESULT_OK, data);
}
finish();
}
}

View File

@ -57,4 +57,4 @@ else()
endif()
endif()
configure_file("${SRC}" "${DEST}")
configure_file("${SRC}" "${DEST}" @ONLY)

View File

@ -5,32 +5,32 @@
set(LOCAL_MIRROR "" CACHE STRING "local mirror path/URL for lib downloads")
set(OPENSSL_VERSION 1.1.1k CACHE STRING "openssl version")
set(OPENSSL_VERSION 3.0.7 CACHE STRING "openssl version")
set(OPENSSL_MIRROR ${LOCAL_MIRROR} https://www.openssl.org/source CACHE STRING "openssl download mirror(s)")
set(OPENSSL_SOURCE openssl-${OPENSSL_VERSION}.tar.gz)
set(OPENSSL_HASH SHA256=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
set(OPENSSL_HASH SHA256=83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
CACHE STRING "openssl source hash")
set(EXPAT_VERSION 2.3.0 CACHE STRING "expat version")
set(EXPAT_VERSION 2.5.0 CACHE STRING "expat version")
string(REPLACE "." "_" EXPAT_TAG "R_${EXPAT_VERSION}")
set(EXPAT_MIRROR ${LOCAL_MIRROR} https://github.com/libexpat/libexpat/releases/download/${EXPAT_TAG}
CACHE STRING "expat download mirror(s)")
set(EXPAT_SOURCE expat-${EXPAT_VERSION}.tar.xz)
set(EXPAT_HASH SHA512=dde8a9a094b18d795a0e86ca4aa68488b352dc67019e0d669e8b910ed149628de4c2a49bc3a5b832f624319336a01f9e4debe03433a43e1c420f36356d886820
set(EXPAT_HASH SHA512=2da73b991b7c0c54440485c787e5edeb3567230204e31b3cac1c3a6713ec6f9f1554d3afffc0f8336168dfd5df02db4a69bcf21b4d959723d14162d13ab87516
CACHE STRING "expat source hash")
set(UNBOUND_VERSION 1.13.1 CACHE STRING "unbound version")
set(UNBOUND_VERSION 1.17.0 CACHE STRING "unbound version")
set(UNBOUND_MIRROR ${LOCAL_MIRROR} https://nlnetlabs.nl/downloads/unbound CACHE STRING "unbound download mirror(s)")
set(UNBOUND_SOURCE unbound-${UNBOUND_VERSION}.tar.gz)
set(UNBOUND_HASH SHA256=8504d97b8fc5bd897345c95d116e0ee0ddf8c8ff99590ab2b4bd13278c9f50b8
set(UNBOUND_HASH SHA512=f6b9f279330fb19b5feca09524959940aad8c4e064528aa82b369c726d77e9e8e5ca23f366f6e9edcf2c061b96f482ed7a2c26ac70fc15ae5762b3d7e36a5284
CACHE STRING "unbound source hash")
set(SQLITE3_VERSION 3350500 CACHE STRING "sqlite3 version")
set(SQLITE3_MIRROR ${LOCAL_MIRROR} https://www.sqlite.org/2021
set(SQLITE3_VERSION 3400000 CACHE STRING "sqlite3 version")
set(SQLITE3_MIRROR ${LOCAL_MIRROR} https://www.sqlite.org/2022
CACHE STRING "sqlite3 download mirror(s)")
set(SQLITE3_SOURCE sqlite-autoconf-${SQLITE3_VERSION}.tar.gz)
set(SQLITE3_HASH SHA512=039af796f79fc4517be0bd5ba37886264d49da309e234ae6fccdb488ef0109ed2b917fc3e6c1fc7224dff4f736824c653aaf8f0a37550c5ebc14d035cb8ac737
CACHE STRING "sqlite3 source hash")
set(SQLITE3_HASH SHA3_256=7ee8f02b21edb4489df5082b5cf5b7ef47bcebcdb0e209bf14240db69633c878
CACHE STRING "sqlite3 source hash")
set(SODIUM_VERSION 1.0.18 CACHE STRING "libsodium version")
set(SODIUM_MIRROR ${LOCAL_MIRROR}
@ -48,29 +48,27 @@ set(ZMQ_SOURCE zeromq-${ZMQ_VERSION}.tar.gz)
set(ZMQ_HASH SHA512=e198ef9f82d392754caadd547537666d4fba0afd7d027749b3adae450516bcf284d241d4616cad3cb4ad9af8c10373d456de92dc6d115b037941659f141e7c0e
CACHE STRING "libzmq source hash")
set(LIBUV_VERSION 1.41.0 CACHE STRING "libuv version")
set(LIBUV_VERSION 1.44.2 CACHE STRING "libuv version")
set(LIBUV_MIRROR ${LOCAL_MIRROR} https://dist.libuv.org/dist/v${LIBUV_VERSION}
CACHE STRING "libuv mirror(s)")
set(LIBUV_SOURCE libuv-v${LIBUV_VERSION}.tar.gz)
set(LIBUV_HASH SHA512=33613fa28e8136507300eba374351774849b6b39aab4e53c997a918d3bc1d1094c6123e0e509535095b14dc5daa885eadb1a67bed46622ad3cc79d62dc817e84
set(LIBUV_HASH SHA512=91197ff9303112567bbb915bbb88058050e2ad1c048815a3b57c054635d5dc7df458b956089d785475290132236cb0edcfae830f5d749de29a9a3213eeaf0b20
CACHE STRING "libuv source hash")
set(ZLIB_VERSION 1.2.11 CACHE STRING "zlib version")
set(ZLIB_VERSION 1.2.13 CACHE STRING "zlib version")
set(ZLIB_MIRROR ${LOCAL_MIRROR} https://zlib.net
CACHE STRING "zlib mirror(s)")
set(ZLIB_SOURCE zlib-${ZLIB_VERSION}.tar.gz)
set(ZLIB_HASH SHA512=73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae
CACHE STRING "zlib source hash")
set(CURL_VERSION 7.76.1 CACHE STRING "curl version")
set(ZLIB_SOURCE zlib-${ZLIB_VERSION}.tar.xz)
set(ZLIB_HASH SHA256=d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98
CACHE STRING "zlib source hash")
set(CURL_VERSION 7.86.0 CACHE STRING "curl version")
set(CURL_MIRROR ${LOCAL_MIRROR} https://curl.haxx.se/download https://curl.askapache.com
CACHE STRING "curl mirror(s)")
set(CURL_SOURCE curl-${CURL_VERSION}.tar.xz)
set(CURL_HASH SHA256=64bb5288c39f0840c07d077e30d9052e1cbb9fa6c2dc52523824cc859e679145
set(CURL_HASH SHA512=18e03a3c00f22125e07bddb18becbf5acdca22baeb7b29f45ef189a5c56f95b2d51247813f7a9a90f04eb051739e9aa7d3a1c5be397bae75d763a2b918d1b656
CACHE STRING "curl source hash")
include(ExternalProject)
set(DEPS_DESTDIR ${CMAKE_BINARY_DIR}/static-deps)
@ -127,21 +125,21 @@ if(ANDROID)
set(android_toolchain_prefix x86_64)
set(android_toolchain_suffix linux-android)
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES x86)
set(android_machine i686)
set(android_machine x86)
set(cross_host "--host=i686-linux-android")
set(android_compiler_prefix i686)
set(android_compiler_suffix linux-android23)
set(android_toolchain_prefix i686)
set(android_toolchain_suffix linux-android)
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES armeabi-v7a)
set(android_machine armv7)
set(android_machine arm)
set(cross_host "--host=armv7a-linux-androideabi")
set(android_compiler_prefix armv7a)
set(android_compiler_suffix linux-androideabi23)
set(android_toolchain_prefix arm)
set(android_toolchain_suffix linux-androideabi)
elseif(CMAKE_ANDROID_ARCH_ABI MATCHES arm64-v8a)
set(android_machine aarch64)
set(android_machine arm64)
set(cross_host "--host=aarch64-linux-android")
set(android_compiler_prefix aarch64)
set(android_compiler_suffix linux-android23)
@ -169,6 +167,18 @@ if(APPLE)
set(deps_CXXFLAGS "${deps_CXXFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
if(_winver)
set(deps_CFLAGS "${deps_CFLAGS} -D_WIN32_WINNT=${_winver}")
set(deps_CXXFLAGS "${deps_CXXFLAGS} -D_WIN32_WINNT=${_winver}")
endif()
if("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles")
set(_make $(MAKE))
else()
set(_make make)
endif()
# Builds a target; takes the target name (e.g. "readline") and builds it in an external project with
# target name suffixed with `_external`. Its upper-case value is used to get the download details
@ -178,8 +188,8 @@ set(build_def_DEPENDS "")
set(build_def_PATCH_COMMAND "")
set(build_def_CONFIGURE_COMMAND ./configure ${cross_host} --disable-shared --prefix=${DEPS_DESTDIR} --with-pic
"CC=${deps_cc}" "CXX=${deps_cxx}" "CFLAGS=${deps_CFLAGS}" "CXXFLAGS=${deps_CXXFLAGS}" ${cross_rc})
set(build_def_BUILD_COMMAND make)
set(build_def_INSTALL_COMMAND make install)
set(build_def_BUILD_COMMAND ${_make})
set(build_def_INSTALL_COMMAND ${_make} install)
set(build_def_BUILD_BYPRODUCTS ${DEPS_DESTDIR}/lib/lib___TARGET___.a ${DEPS_DESTDIR}/include/___TARGET___.h)
function(build_external target)
@ -218,7 +228,7 @@ build_external(libuv
add_static_target(libuv libuv_external libuv.a)
target_link_libraries(libuv INTERFACE ${CMAKE_DL_LIBS})
build_external(zlib
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS} -fPIC" ${cross_extra} ./configure --prefix=${DEPS_DESTDIR} --static
BUILD_BYPRODUCTS
@ -229,25 +239,56 @@ add_static_target(zlib zlib_external libz.a)
set(openssl_system_env "")
set(openssl_arch "")
set(openssl_configure_command ./config)
set(openssl_flags "CFLAGS=${deps_CFLAGS}")
set(unbound_ldflags "")
if(CMAKE_CROSSCOMPILING)
if(ARCH_TRIPLET STREQUAL x86_64-w64-mingw32)
set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib)
set(openssl_arch mingw64)
set(openssl_system_env RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib)
elseif(ARCH_TRIPLET STREQUAL i686-w64-mingw32)
set(openssl_system_env SYSTEM=MINGW32 RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib)
set(openssl_arch mingw)
set(openssl_system_env RC=${CMAKE_RC_COMPILER} AR=${ARCH_TRIPLET}-ar RANLIB=${ARCH_TRIPLET}-ranlib)
elseif(ANDROID)
set(openssl_system_env SYSTEM=Linux MACHINE=${android_machine} LD=${deps_ld} RANLIB=${deps_ranlib} AR=${deps_ar})
set(openssl_arch android-${android_machine})
set(openssl_system_env LD=${deps_ld} RANLIB=${deps_ranlib} AR=${deps_ar} ANDROID_NDK_ROOT=${CMAKE_ANDROID_NDK} "PATH=${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin:$ENV{PATH}")
list(APPEND openssl_flags "CPPFLAGS=-D__ANDROID_API__=${ANDROID_API}")
set(openssl_extra_opts no-asm)
elseif(ARCH_TRIPLET STREQUAL mips64-linux-gnuabi64)
set(openssl_arch linux-mips64)
elseif(ARCH_TRIPLET STREQUAL mips-linux-gnu)
set(openssl_arch linux-mips32)
elseif(ARCH_TRIPLET STREQUAL mips-openwrt-linux)
set(unbound_ldflags "-latomic")
set(openssl_arch linux-mips32)
elseif(ARCH_TRIPLET STREQUAL mipsel-linux-gnu)
set(openssl_arch linux-mips)
elseif(ARCH_TRIPLET STREQUAL aarch64-linux-gnu OR ARCH_TRIPLET STREQUAL aarch64-openwrt-linux-musl)
# cross compile arm64
set(openssl_arch linux-aarch64)
elseif(ARCH_TRIPLET MATCHES arm-linux)
# cross compile armhf
set(openssl_arch linux-armv4)
elseif(ARCH_TRIPLET MATCHES powerpc64le)
# cross compile ppc64le
set(openssl_arch linux-ppc64le)
endif()
elseif(CMAKE_C_FLAGS MATCHES "-march=armv7")
# Help openssl figure out that we're building from armv7 even if on armv8 hardware:
set(openssl_system_env SYSTEM=Linux MACHINE=armv7)
set(openssl_arch linux-armv4)
endif()
build_external(openssl
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${deps_cc} ${openssl_system_env} ./config
--prefix=${DEPS_DESTDIR} ${openssl_extra_opts} no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
no-heartbeats no-md2 no-rc5 no-rdrand no-rfc3779 no-sctp no-ssl-trace no-ssl2 no-ssl3
no-static-engine no-tests no-weak-ssl-ciphers no-zlib no-zlib-dynamic "CFLAGS=${deps_CFLAGS}"
INSTALL_COMMAND make install_sw
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${deps_cc} ${openssl_system_env} ${openssl_configure_command}
--prefix=${DEPS_DESTDIR} --libdir=lib ${openssl_extra_opts}
no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
no-md2 no-rc5 no-rdrand no-rfc3779 no-sctp no-ssl-trace no-ssl3
no-static-engine no-tests no-weak-ssl-ciphers no-zlib no-zlib-dynamic ${openssl_flags}
${openssl_arch}
BUILD_COMMAND ${CMAKE_COMMAND} -E env ${openssl_system_env} ${_make}
INSTALL_COMMAND ${_make} install_sw
BUILD_BYPRODUCTS
${DEPS_DESTDIR}/lib/libssl.a ${DEPS_DESTDIR}/lib/libcrypto.a
${DEPS_DESTDIR}/include/openssl/ssl.h ${DEPS_DESTDIR}/include/openssl/crypto.h
@ -260,7 +301,6 @@ endif()
set(OPENSSL_INCLUDE_DIR ${DEPS_DESTDIR}/include)
set(OPENSSL_CRYPTO_LIBRARY ${DEPS_DESTDIR}/lib/libcrypto.a ${DEPS_DESTDIR}/lib/libssl.a)
set(OPENSSL_VERSION 1.1.1)
set(OPENSSL_ROOT_DIR ${DEPS_DESTDIR})
build_external(expat
@ -271,13 +311,19 @@ build_external(expat
add_static_target(expat expat_external libexpat.a)
if(WIN32)
set(unbound_patch
PATCH_COMMAND ${PROJECT_SOURCE_DIR}/contrib/apply-patches.sh
${PROJECT_SOURCE_DIR}/contrib/patches/unbound-delete-crash-fix.patch)
endif()
build_external(unbound
DEPENDS openssl_external expat_external
${unbound_patch}
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared
--enable-static --with-libunbound-only --with-pic
--$<IF:$<BOOL:${WITH_LTO}>,enable,disable>-flto --with-ssl=${DEPS_DESTDIR}
--with-libexpat=${DEPS_DESTDIR}
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}" "LDFLAGS=${unbound_ldflags}"
)
add_static_target(libunbound unbound_external libunbound.a)
if(NOT WIN32)
@ -292,8 +338,11 @@ build_external(sodium CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --
--enable-static --with-pic "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}")
add_static_target(sodium sodium_external libsodium.a)
build_external(sqlite3)
add_static_target(sqlite3 sqlite3_external libsqlite3.a)
if(WITH_PEERSTATS_BACKEND)
build_external(sqlite3)
add_static_target(sqlite3 sqlite3_external libsqlite3.a)
endif()
if(ARCH_TRIPLET MATCHES mingw)
@ -305,7 +354,9 @@ endif()
if(CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
set(zmq_patch
PATCH_COMMAND ${PROJECT_SOURCE_DIR}/contrib/apply-patches.sh ${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-wepoll.patch ${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-closesocket.patch)
PATCH_COMMAND ${PROJECT_SOURCE_DIR}/contrib/apply-patches.sh
${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-wepoll.patch
${PROJECT_SOURCE_DIR}/contrib/patches/libzmq-mingw-unistd.patch)
endif()
build_external(zmq
@ -328,6 +379,19 @@ set_target_properties(libzmq PROPERTIES
INTERFACE_LINK_LIBRARIES "${libzmq_link_libs}"
INTERFACE_COMPILE_DEFINITIONS "ZMQ_STATIC")
#
#
#
# Everything that follows is *only* for lokinet-bootstrap (i.e. if adding new deps put them *above*
# this).
#
#
#
if(NOT WITH_BOOTSTRAP)
return()
endif()
set(curl_extra)
if(WIN32)
set(curl_ssl_opts --without-ssl --with-schannel)
@ -379,11 +443,12 @@ foreach(curl_arch ${curl_arches})
--enable-crypto-auth --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-cookies
--enable-http-auth --enable-doh --disable-mime --enable-dateparse --disable-netrc --without-libidn2
--disable-progress-meter --without-brotli --with-zlib=${DEPS_DESTDIR} ${curl_ssl_opts}
--without-libmetalink --without-librtmp --disable-versioned-symbols --enable-hidden-symbols
--without-librtmp --disable-versioned-symbols --enable-hidden-symbols
--without-zsh-functions-dir --without-fish-functions-dir
--without-nghttp3 --without-zstd
"CC=${deps_cc}" "CFLAGS=${deps_noarch_CFLAGS}${cflags_extra}" ${curl_extra}
BUILD_COMMAND true
INSTALL_COMMAND make -C lib install && make -C include install
INSTALL_COMMAND ${_make} -C lib install && ${_make} -C include install
BUILD_BYPRODUCTS
${curl_prefix}/lib/libcurl.a
${curl_prefix}/include/curl/curl.h
@ -392,7 +457,7 @@ foreach(curl_arch ${curl_arches})
list(APPEND curl_lib_outputs ${curl_prefix}/lib/libcurl.a)
endforeach()
message(STATUS "TARGETS: ${curl_lib_targets}")
if(IOS AND num_arches GREATER 1)
# We are building multiple architectures for different iOS devices, so we need to glue the

View File

@ -1,22 +1,46 @@
# We do this via a custom command that re-invokes a cmake script because we need the DEPENDS on .git/index so that we will re-run it (to regenerate the commit tag in the version) whenever the current commit changes. If we used a configure_file directly here, it would only re-run when something else causes cmake to re-run.
find_package(Git QUIET)
set(GIT_INDEX_FILE "${PROJECT_SOURCE_DIR}/.git/index")
if(EXISTS ${GIT_INDEX_FILE} AND ( GIT_FOUND OR Git_FOUND) )
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
COMMAND "${CMAKE_COMMAND}"
"-D" "GIT=${GIT_EXECUTABLE}"
"-D" "SRC=${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
"-D" "DEST=${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
"-P" "${CMAKE_CURRENT_LIST_DIR}/GenVersion.cmake"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
"${GIT_INDEX_FILE}")
if(LOKINET_VERSIONTAG)
set(VERSIONTAG "${LOKINET_VERSIONTAG}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp" @ONLY)
else()
message(STATUS "Git was not found! Setting version to to nogit")
set(VERSIONTAG "nogit")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
set(VERSIONTAG "${GIT_VERSION}")
set(GIT_INDEX_FILE "${PROJECT_SOURCE_DIR}/.git/index")
find_package(Git)
if(EXISTS "${GIT_INDEX_FILE}" AND ( GIT_FOUND OR Git_FOUND) )
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
set(genversion_args "-DGIT=${GIT_EXECUTABLE}")
foreach(v lokinet_VERSION lokinet_VERSION_MAJOR lokinet_VERSION_MINOR lokinet_VERSION_PATCH RELEASE_MOTTO)
list(APPEND genversion_args "-D${v}=${${v}}")
endforeach()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
COMMAND "${CMAKE_COMMAND}"
${genversion_args}
"-D" "SRC=${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
"-D" "DEST=${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
"-P" "${CMAKE_CURRENT_LIST_DIR}/GenVersion.cmake"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
"${GIT_INDEX_FILE}")
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp" @ONLY)
endif()
endif()
add_custom_target(genversion DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
if(WIN32)
foreach(exe IN ITEMS lokinet lokinet-vpn lokinet-bootstrap)
set(lokinet_EXE_NAME "${exe}.exe")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/win32/version.rc.in" "${CMAKE_BINARY_DIR}/${exe}.rc" @ONLY)
set_property(SOURCE "${CMAKE_BINARY_DIR}/${exe}.rc" PROPERTY GENERATED 1)
endforeach()
endif()
add_custom_target(genversion_cpp DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
if(WIN32)
add_custom_target(genversion_rc DEPENDS "${CMAKE_BINARY_DIR}/lokinet.rc" "${CMAKE_BINARY_DIR}/lokinet-vpn.rc" "${CMAKE_BINARY_DIR}/lokinet-bootstrap.rc")
else()
add_custom_target(genversion_rc)
endif()
add_custom_target(genversion DEPENDS genversion_cpp genversion_rc)

View File

@ -1,8 +0,0 @@
function(add_log_tag target)
get_target_property(TARGET_SRCS ${target} SOURCES)
foreach(F ${TARGET_SRCS})
get_filename_component(fpath "${F}" ABSOLUTE)
string(REPLACE "${PROJECT_SOURCE_DIR}/" "" logtag "${fpath}")
set_property(SOURCE ${F} APPEND PROPERTY COMPILE_DEFINITIONS LOG_TAG=\"${logtag}\")
endforeach()
endfunction()

View File

@ -44,7 +44,8 @@ if(filesystem_is_good EQUAL 1)
else()
# Probably broken AF macos
message(STATUS "std::filesystem is not available, apparently this compiler isn't C++17 compliant; falling back to ghc::filesystem")
set(GHC_FILESYSTEM_WITH_INSTALL OFF CACHE INTERNAL "")
add_subdirectory(external/ghc-filesystem)
target_link_libraries(filesystem INTERFACE ghc_filesystem)
target_compile_definitions(filesystem INTERFACE USE_GHC_FILESYSTEM)
target_compile_definitions(filesystem INTERFACE USE_GHC_FILESYSTEM CLI11_HAS_FILESYSTEM=0)
endif()

View File

@ -2,6 +2,9 @@
include(CheckIPOSupported)
option(WITH_LTO "enable lto on compile time" ON)
if(WITH_LTO)
if(WIN32)
message(FATAL_ERROR "LTO not supported on win32 targets, please set -DWITH_LTO=OFF")
endif()
check_ipo_supported(RESULT IPO_ENABLED OUTPUT ipo_error)
if(IPO_ENABLED)
message(STATUS "LTO enabled")

17
cmake/gui-option.cmake Normal file
View File

@ -0,0 +1,17 @@
set(default_build_gui OFF)
if(APPLE OR WIN32)
set(default_build_gui ON)
endif()
if(WIN32)
set(GUI_EXE "" CACHE FILEPATH "path to a pre-built Windows GUI .exe to use (implies -DBUILD_GUI=OFF)")
if(GUI_EXE)
set(default_build_gui OFF)
endif()
endif()
option(BUILD_GUI "build electron gui from 'gui' submodule source" ${default_build_gui})
if(BUILD_GUI AND GUI_EXE)
message(FATAL_ERROR "-DGUI_EXE=... and -DBUILD_GUI=ON are mutually exclusive")
endif()

67
cmake/gui.cmake Normal file
View File

@ -0,0 +1,67 @@
if(WIN32 AND GUI_EXE)
message(STATUS "using pre-built lokinet gui executable: ${GUI_EXE}")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GUI_EXE}" "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe")
elseif(BUILD_GUI)
message(STATUS "Building lokinet-gui from source")
set(default_gui_target pack)
if(APPLE)
set(default_gui_target macos:raw)
elseif(WIN32)
set(default_gui_target win32)
endif()
set(GUI_YARN_TARGET "${default_gui_target}" CACHE STRING "yarn target for building the GUI")
set(GUI_YARN_EXTRA_OPTS "" CACHE STRING "extra options to pass into the yarn build command")
# allow manually specifying yarn with -DYARN=
if(NOT YARN)
find_program(YARN NAMES yarnpkg yarn REQUIRED)
endif()
message(STATUS "Building lokinet-gui with yarn ${YARN}, target ${GUI_YARN_TARGET}")
if(NOT WIN32)
add_custom_target(lokinet-gui
COMMAND ${YARN} install --frozen-lockfile &&
${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
endif()
if(APPLE)
add_custom_target(assemble_gui ALL
DEPENDS assemble lokinet-gui
COMMAND mkdir "${lokinet_app}/Contents/Helpers"
COMMAND cp -a "${PROJECT_SOURCE_DIR}/gui/release/mac/Lokinet-GUI.app" "${lokinet_app}/Contents/Helpers/"
COMMAND mkdir -p "${lokinet_app}/Contents/Resources/en.lproj"
COMMAND cp "${PROJECT_SOURCE_DIR}/contrib/macos/InfoPlist.strings" "${lokinet_app}/Contents/Resources/en.lproj/"
COMMAND cp "${lokinet_app}/Contents/Resources/icon.icns" "${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Resources/icon.icns"
COMMAND cp "${PROJECT_SOURCE_DIR}/contrib/macos/InfoPlist.strings" "${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Resources/en.lproj/"
COMMAND /usr/libexec/PlistBuddy
-c "Delete :CFBundleDisplayName"
-c "Add :LSHasLocalizedDisplayName bool true"
-c "Add :CFBundleDevelopmentRegion string en"
-c "Set :CFBundleShortVersionString ${lokinet_VERSION}"
-c "Set :CFBundleVersion ${lokinet_VERSION}.${LOKINET_APPLE_BUILD}"
"${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Info.plist"
)
elseif(WIN32)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/gui")
add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
COMMAND ${YARN} install --frozen-lockfile &&
USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all WINEPREFIX="${PROJECT_BINARY_DIR}/wineprefix" ${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/gui/release/Lokinet-GUI_portable.exe"
"${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
add_custom_target(assemble_gui ALL COMMAND "true" DEPENDS "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe")
else()
message(FATAL_ERROR "Building/bundling the GUI from this repository is not supported on this platform")
endif()
else()
message(STATUS "not building gui")
endif()
if(NOT TARGET assemble_gui)
add_custom_target(assemble_gui COMMAND "true")
endif()

View File

@ -1,16 +1,46 @@
set(CPACK_PACKAGE_VENDOR "lokinet.org")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://lokinet.org/")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/contrib/readme-installer.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
if(WIN32)
include(cmake/win32_installer_deps.cmake)
install(FILES ${CMAKE_SOURCE_DIR}/contrib/configs/00-exit.ini DESTINATION share/conf.d COMPONENT exit_configs)
install(FILES ${CMAKE_SOURCE_DIR}/contrib/configs/00-keyfile.ini DESTINATION share/conf.d COMPONENT keyfile_configs)
install(FILES ${CMAKE_SOURCE_DIR}/contrib/configs/00-debug-log.ini DESTINATION share/conf.d COMPONENT debug_configs)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified" "lokinet" "gui" "exit_configs" "keyfile_configs" "debug_configs")
list(APPEND CPACK_COMPONENTS_ALL "lokinet" "gui" "exit_configs" "keyfile_configs" "debug_configs")
elseif(APPLE)
set(CPACK_GENERATOR DragNDrop;ZIP)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified")
endif()
if(APPLE)
include(cmake/macos_installer_deps.cmake)
endif()
# This must always be last!
include(CPack)
if(WIN32)
cpack_add_component(lokinet
DISPLAY_NAME "lokinet"
DESCRIPTION "core required lokinet files"
REQUIRED)
cpack_add_component(gui
DISPLAY_NAME "lokinet gui"
DESCRIPTION "electron based control panel for lokinet")
cpack_add_component(exit_configs
DISPLAY_NAME "auto-enable exit"
DESCRIPTION "automatically enable usage of exit.loki as an exit node\n"
DISABLED)
cpack_add_component(keyfile_configs
DISPLAY_NAME "persist address"
DESCRIPTION "persist .loki address across restarts of lokinet\nnot recommended when enabling exit nodes"
DISABLED)
cpack_add_component(debug_configs
DISPLAY_NAME "debug logging"
DESCRIPTION "enable debug spew log level by default"
DISABLED)
endif()

View File

@ -1,49 +1,49 @@
function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
if (EMBEDDED_CFG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -m32 -march=i486")
elseif(MSVC OR MSVC_VERSION)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32 -std:c++14")
else()
# CMAKE_CXX_STANDARD does not propagate to cmake compile tests
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++14")
endif()
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return 0;
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction()
function(link_libatomic)
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
if(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
message(STATUS "Have working 64bit atomics")
return()
endif()
if (NOT MSVC AND NOT MSVC_VERSION)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
if (HAVE_CXX_LIBATOMICS64)
message(STATUS "Have 64bit atomics via library")
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (HAVE_CXX_ATOMICS64_WITH_LIB)
message(STATUS "Can link with libatomic")
link_libraries(-latomic)
return()
endif()
endif()
endif()
if (MSVC OR MSVC_VERSION)
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic! (What does MSVC do to inline atomics?)")
else()
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
endif()
endfunction()
function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
if (EMBEDDED_CFG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -m32 -march=i486")
elseif(MSVC OR MSVC_VERSION)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32 -std:c++14")
else()
# CMAKE_CXX_STANDARD does not propagate to cmake compile tests
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++14")
endif()
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return 0;
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction()
function(link_libatomic)
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
if(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
message(STATUS "Have working 64bit atomics")
return()
endif()
if (NOT MSVC AND NOT MSVC_VERSION)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
if (HAVE_CXX_LIBATOMICS64)
message(STATUS "Have 64bit atomics via library")
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (HAVE_CXX_ATOMICS64_WITH_LIB)
message(STATUS "Can link with libatomic")
link_libraries(-latomic)
return()
endif()
endif()
endif()
if (MSVC OR MSVC_VERSION)
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic! (What does MSVC do to inline atomics?)")
else()
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
endif()
endfunction()

View File

@ -1,13 +0,0 @@
# Properly links a target to a list of library names by finding the given libraries. Takes:
# - a target
# - a linktype (e.g. INTERFACE, PUBLIC, PRIVATE)
# - a library search path (or "" for defaults)
# - any number of library names
function(link_dep_libs target linktype libdirs)
foreach(lib ${ARGN})
find_library(link_lib-${lib} NAMES ${lib} PATHS ${libdirs})
if(link_lib-${lib})
target_link_libraries(${target} ${linktype} ${link_lib-${lib}})
endif()
endforeach()
endfunction()

214
cmake/macos.cmake Normal file
View File

@ -0,0 +1,214 @@
if(NOT APPLE)
return()
endif()
option(MACOS_SYSTEM_EXTENSION
"Build the network extension as a system extension rather than a plugin. This must be ON for non-app store release builds, and must be OFF for dev builds and Mac App Store distribution builds"
OFF)
option(CODESIGN "codesign the resulting app and extension" ON)
set(CODESIGN_ID "" CACHE STRING "codesign the macos app using this key identity; if empty we'll try to guess")
set(default_profile_type "dev")
if(MACOS_SYSTEM_EXTENSION)
set(default_profile_type "release")
endif()
set(CODESIGN_PROFILE "${PROJECT_SOURCE_DIR}/contrib/macos/lokinet.${default_profile_type}.provisionprofile" CACHE FILEPATH
"Path to a .provisionprofile to use for the main app")
set(CODESIGN_EXT_PROFILE "${PROJECT_SOURCE_DIR}/contrib/macos/lokinet-extension.${default_profile_type}.provisionprofile" CACHE FILEPATH
"Path to a .provisionprofile to use for the lokinet extension")
if(CODESIGN AND NOT CODESIGN_ID)
if(MACOS_SYSTEM_EXTENSION)
set(codesign_cert_pattern "Developer ID Application")
else()
set(codesign_cert_pattern "Apple Development")
endif()
execute_process(
COMMAND security find-identity -v -p codesigning
COMMAND sed -n "s/^ *[0-9][0-9]*) *\\([A-F0-9]\\{40\\}\\) *\"\\(${codesign_cert_pattern}.*\\)\"\$/\\1 \\2/p"
RESULT_VARIABLE find_id_exit_code
OUTPUT_VARIABLE find_id_output)
if(NOT find_id_exit_code EQUAL 0)
message(FATAL_ERROR "Finding signing identities with security find-identity failed; try specifying an id using -DCODESIGN_ID=...")
endif()
string(REGEX MATCHALL "(^|\n)[0-9A-F]+" find_id_sign_id "${find_id_output}")
if(NOT find_id_sign_id)
message(FATAL_ERROR "Did not find any \"${codesign_cert_pattern}\" identity; try specifying an id using -DCODESIGN_ID=...")
endif()
if (find_id_sign_id MATCHES ";")
message(FATAL_ERROR "Found multiple \"${codesign_cert_pattern}\" identities:\n${find_id_output}\nSpecify an identify using -DCODESIGN_ID=...")
endif()
set(CODESIGN_ID "${find_id_sign_id}" CACHE STRING "" FORCE)
endif()
if(CODESIGN)
message(STATUS "Codesigning using ${CODESIGN_ID}")
if (NOT MACOS_NOTARIZE_USER AND NOT MACOS_NOTARIZE_PASS AND NOT MACOS_NOTARIZE_ASC AND EXISTS "$ENV{HOME}/.notarization.cmake")
message(STATUS "Loading notarization info from ~/.notarization.cmake")
include("$ENV{HOME}/.notarization.cmake")
endif()
if (MACOS_NOTARIZE_USER AND MACOS_NOTARIZE_PASS AND MACOS_NOTARIZE_ASC)
message(STATUS "Enabling notarization with account ${MACOS_NOTARIZE_ASC}/${MACOS_NOTARIZE_USER}")
else()
message(WARNING "You have not set one or more of MACOS_NOTARIZE_USER, MACOS_NOTARIZE_PASS, MACOS_NOTARIZE_ASC: notarization will fail; see contrib/macos/README.txt")
endif()
else()
message(WARNING "Codesigning disabled; the resulting build will not run on most macOS systems")
endif()
foreach(prof IN ITEMS CODESIGN_PROFILE CODESIGN_EXT_PROFILE)
if(NOT ${prof})
message(WARNING "Missing a ${prof} provisioning profile: Apple will most likely log an uninformative error message to the system log and then kill harmless kittens if you try to run the result")
elseif(NOT EXISTS "${${prof}}")
message(FATAL_ERROR "Provisioning profile ${${prof}} does not exist; fix your -D${prof} path")
endif()
endforeach()
message(STATUS "Using ${CODESIGN_PROFILE} app provisioning profile")
message(STATUS "Using ${CODESIGN_EXT_PROFILE} extension provisioning profile")
set(lokinet_installer "${PROJECT_BINARY_DIR}/Lokinet ${PROJECT_VERSION}")
if(NOT CODESIGN)
set(lokinet_installer "${lokinet_installer}-UNSIGNED")
endif()
set(lokinet_app "${lokinet_installer}/Lokinet.app")
if(MACOS_SYSTEM_EXTENSION)
set(lokinet_ext_dir Contents/Library/SystemExtensions)
else()
set(lokinet_ext_dir Contents/PlugIns)
endif()
if(CODESIGN)
if(MACOS_SYSTEM_EXTENSION)
set(LOKINET_ENTITLEMENTS_TYPE sysext)
set(notarize_py_is_sysext True)
else()
set(LOKINET_ENTITLEMENTS_TYPE plugin)
set(notarize_py_is_sysext False)
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/contrib/macos/sign.sh.in"
"${PROJECT_BINARY_DIR}/sign.sh"
@ONLY)
add_custom_target(
sign
DEPENDS "${PROJECT_BINARY_DIR}/sign.sh"
COMMAND "${PROJECT_BINARY_DIR}/sign.sh"
)
if(MACOS_NOTARIZE_USER AND MACOS_NOTARIZE_PASS AND MACOS_NOTARIZE_ASC)
configure_file(
"${PROJECT_SOURCE_DIR}/contrib/macos/notarize.py.in"
"${PROJECT_BINARY_DIR}/notarize.py"
@ONLY)
add_custom_target(
notarize
DEPENDS "${PROJECT_BINARY_DIR}/notarize.py" sign
COMMAND "${PROJECT_BINARY_DIR}/notarize.py"
)
else()
message(WARNING "You have not set one or more of MACOS_NOTARIZE_USER, MACOS_NOTARIZE_PASS, MACOS_NOTARIZE_ASC: notarization disabled")
endif()
else()
add_custom_target(sign COMMAND "true")
add_custom_target(notarize DEPENDS sign COMMAND "true")
endif()
set(mac_icon "${PROJECT_BINARY_DIR}/lokinet.icns")
add_custom_command(OUTPUT "${mac_icon}"
COMMAND ${PROJECT_SOURCE_DIR}/contrib/macos/mk-icns.sh ${PROJECT_SOURCE_DIR}/contrib/lokinet-mac.svg "${mac_icon}"
DEPENDS ${PROJECT_SOURCE_DIR}/contrib/lokinet-mac.svg ${PROJECT_SOURCE_DIR}/contrib/macos/mk-icns.sh)
add_custom_target(icon DEPENDS "${mac_icon}")
if(BUILD_PACKAGE)
add_executable(seticon "${PROJECT_SOURCE_DIR}/contrib/macos/seticon.swift")
add_custom_command(OUTPUT "${lokinet_installer}.dmg"
DEPENDS notarize seticon
COMMAND create-dmg
--volname "Lokinet ${PROJECT_VERSION}"
--volicon lokinet.icns
--background "${PROJECT_SOURCE_DIR}/contrib/macos/installer.tiff"
--text-size 16
--icon-size 128
--window-size 555 440
--icon Lokinet.app 151 196
--hide-extension Lokinet.app
--app-drop-link 403 196
--eula "${PROJECT_SOURCE_DIR}/LICENSE"
--no-internet-enable
"${lokinet_installer}.dmg"
"${lokinet_installer}"
COMMAND ./seticon lokinet.icns "${lokinet_installer}.dmg"
)
add_custom_target(dmg DEPENDS "${lokinet_installer}.dmg")
endif()
# Called later to set things up, after the main lokinet targets are set up
function(macos_target_setup)
if(MACOS_SYSTEM_EXTENSION)
target_compile_definitions(lokinet PRIVATE MACOS_SYSTEM_EXTENSION)
endif()
set_target_properties(lokinet
PROPERTIES
OUTPUT_NAME Lokinet
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_STRING "Lokinet IP Packet Onion Router"
MACOSX_BUNDLE_BUNDLE_NAME "Lokinet"
MACOSX_BUNDLE_BUNDLE_VERSION "${lokinet_VERSION}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${lokinet_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${lokinet_VERSION_MAJOR}.${lokinet_VERSION_MINOR}"
MACOSX_BUNDLE_GUI_IDENTIFIER "org.lokinet"
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/contrib/macos/lokinet.Info.plist.in"
MACOSX_BUNDLE_COPYRIGHT "© 2022, The Oxen Project"
)
add_custom_target(copy_bootstrap
DEPENDS lokinet-extension
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed
$<TARGET_BUNDLE_DIR:lokinet-extension>/Contents/Resources/bootstrap.signed
)
add_dependencies(lokinet lokinet-extension icon)
if(CODESIGN_PROFILE)
add_custom_target(copy_prov_prof
DEPENDS lokinet
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CODESIGN_PROFILE}
$<TARGET_BUNDLE_DIR:lokinet>/Contents/embedded.provisionprofile
)
else()
add_custom_target(copy_prov_prof COMMAND true)
endif()
add_custom_target(assemble ALL
DEPENDS lokinet lokinet-extension icon copy_prov_prof copy_bootstrap
COMMAND rm -rf "${lokinet_app}"
COMMAND mkdir -p "${lokinet_installer}"
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet> "${lokinet_app}"
COMMAND mkdir -p "${lokinet_app}/${lokinet_ext_dir}"
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet-extension> "${lokinet_app}/${lokinet_ext_dir}/"
COMMAND mkdir -p "${lokinet_app}/Contents/Resources"
COMMAND cp -a "${mac_icon}" "${lokinet_app}/Contents/Resources/icon.icns"
)
if(BUILD_GUI)
add_dependencies(sign assemble_gui)
else()
add_dependencies(sign assemble)
endif()
endfunction()

View File

@ -1,113 +0,0 @@
# macos specific cpack stuff goes here
# Here we build lokinet-network-control-panel into 'lokinet-gui.app' in "extra/" where a postinstall
# script will then move it to /Applications/.
set(LOKINET_GUI_REPO "https://github.com/oxen-io/loki-network-control-panel.git"
CACHE STRING "Can be set to override the default lokinet-gui git repository")
set(LOKINET_GUI_CHECKOUT "origin/master"
CACHE STRING "Can be set to specify a particular branch or tag to build from LOKINET_GUI_REPO")
set(MACOS_SIGN_APP "" # FIXME: it doesn't use a Apple Distribution key because WTF knows.
CACHE STRING "enable codesigning of the stuff inside the .app and the lokinet binary -- use a 'Apple Distribution' key (or description) from `security find-identity -v`")
set(MACOS_SIGN_PKG ""
CACHE STRING "enable codesigning of the .pkg -- use a 'Developer ID Installer' key (or description) from `security find-identity -v`")
set(MACOS_NOTARIZE_USER ""
CACHE STRING "set macos notarization username; can also set it in ~/.notarization.cmake")
set(MACOS_NOTARIZE_PASS ""
CACHE STRING "set macos notarization password; can also set it in ~/.notarization.cmake")
set(MACOS_NOTARIZE_ASC ""
CACHE STRING "set macos notarization asc provider; can also set it in ~/.notarization.cmake")
include(ExternalProject)
message(STATUS "Building UninstallLokinet.app")
ExternalProject_Add(lokinet-uninstaller
SOURCE_DIR ${CMAKE_SOURCE_DIR}/contrib/macos/uninstaller
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
)
message(STATUS "Building LokinetGUI.app from ${LOKINET_GUI_REPO} @ ${LOKINET_GUI_CHECKOUT}")
if(NOT BUILD_STATIC_DEPS)
message(FATAL_ERROR "Building an installer on macos requires -DBUILD_STATIC_DEPS=ON")
endif()
ExternalProject_Add(lokinet-gui
DEPENDS oxenmq::oxenmq
GIT_REPOSITORY "${LOKINET_GUI_REPO}"
GIT_TAG "${LOKINET_GUI_CHECKOUT}"
CMAKE_ARGS -DMACOS_APP=ON -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DMACOS_SIGN=${MACOS_SIGN_APP}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DBUILD_SHARED_LIBS=OFF
"-DOXENMQ_LIBRARIES=$<TARGET_FILE:oxenmq::oxenmq>$<SEMICOLON>$<TARGET_FILE:libzmq>$<SEMICOLON>$<TARGET_FILE:sodium>"
"-DOXENMQ_INCLUDE_DIRS=$<TARGET_PROPERTY:oxenmq::oxenmq,INCLUDE_DIRECTORIES>"
)
install(PROGRAMS ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_uninstall.sh
DESTINATION "bin/"
COMPONENT lokinet)
install(DIRECTORY ${PROJECT_BINARY_DIR}/LokinetGUI.app
DESTINATION "../../Applications/Lokinet"
USE_SOURCE_PERMISSIONS
COMPONENT gui
PATTERN "*"
)
install(DIRECTORY ${PROJECT_BINARY_DIR}/UninstallLokinet.app
DESTINATION "../../Applications/Lokinet"
USE_SOURCE_PERMISSIONS
COMPONENT gui
PATTERN "*"
)
# copy files that will be later moved by the postinstall script to proper locations
install(FILES ${CMAKE_SOURCE_DIR}/contrib/macos/lokinet_macos_daemon_script.sh
${CMAKE_SOURCE_DIR}/contrib/macos/network.loki.lokinet.daemon.plist
${CMAKE_SOURCE_DIR}/contrib/macos/lokinet-newsyslog.conf
DESTINATION "extra/"
COMPONENT lokinet)
set(CPACK_COMPONENTS_ALL lokinet gui)
set(CPACK_COMPONENT_LOKINET_DISPLAY_NAME "Lokinet Service")
set(CPACK_COMPONENT_LOKINET_DESCRIPTION "Main Lokinet runtime service, managed by Launchd")
set(CPACK_COMPONENT_GUI_DISPLAY_NAME "Lokinet GUI")
set(CPACK_COMPONENT_GUI_DESCRIPTION "Small GUI which provides stats and limited runtime control of the Lokinet service. Resides in the system tray.")
set(CPACK_GENERATOR "productbuild")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/lokinet")
set(CPACK_PREINSTALL_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/preinstall)
set(CPACK_POSTFLIGHT_LOKINET_SCRIPT ${CMAKE_SOURCE_DIR}/contrib/macos/postinstall)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PRODUCTBUILD_IDENTITY_NAME "${MACOS_SIGN_PKG}")
if(MACOS_SIGN_APP)
add_custom_target(sign ALL
echo "Signing lokinet and lokinet-vpn binaries"
COMMAND codesign -s "${MACOS_SIGN_APP}" --strict --options runtime --force -vvv $<TARGET_FILE:lokinet> $<TARGET_FILE:lokinet-vpn>
DEPENDS lokinet lokinet-vpn
)
endif()
if(MACOS_SIGN_APP AND MACOS_SIGN_PKG)
if(NOT MACOS_NOTARIZE_USER)
if(EXISTS "$ENV{HOME}/.notarization.cmake")
include("$ENV{HOME}/.notarization.cmake")
endif()
endif()
if(MACOS_NOTARIZE_USER AND MACOS_NOTARIZE_PASS AND MACOS_NOTARIZE_ASC)
message(STATUS "'notarization' target enabled")
configure_file(${CMAKE_SOURCE_DIR}/contrib/macos/notarize.py.in ${CMAKE_CURRENT_BINARY_DIR}/contrib/notarize.py ESCAPE_QUOTES @ONLY)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/contrib/notarize.py DESTINATION ${PROJECT_BINARY_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
add_custom_target(notarize ./notarize.py)
else()
message(WARNING "Not enable 'notarization' target: signing is enabled but notarization info not provided. Create ~/.notarization.cmake or set cmake parameters directly")
endif()
endif()

53
cmake/ngtcp2_lib.cmake Normal file
View File

@ -0,0 +1,53 @@
# ngtcp2's top-level CMakeLists.txt loads a bunch of crap we don't want (examples, a conflicting
# 'check' target, etc.); instead we directly include it's lib subdirectory to build just the
# library, but we have to set up a couple things to make that work:
function(add_ngtcp2_lib)
file(STRINGS ngtcp2/CMakeLists.txt ngtcp2_project_line REGEX "^project\\(ngtcp2 ")
if(NOT ngtcp2_project_line MATCHES "^project\\(ngtcp2 VERSION ([0-9]+)\\.([0-9]+)\\.([0-9]+)\\)$")
message(FATAL_ERROR "Unable to extract ngtcp2 version from ngtcp2/CMakeLists.txt (found '${ngtcp2_project_line}')")
endif()
set(PACKAGE_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
include(ngtcp2/cmake/Version.cmake)
HexVersion(PACKAGE_VERSION_NUM ${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${CMAKE_MATCH_3})
configure_file("ngtcp2/lib/includes/ngtcp2/version.h.in" "ngtcp2/lib/includes/ngtcp2/version.h" @ONLY)
set(BUILD_SHARED_LIBS OFF)
# Checks for header files.
include(CheckIncludeFile)
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
check_include_file("stddef.h" HAVE_STDDEF_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
check_include_file("endian.h" HAVE_ENDIAN_H)
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
include(CheckTypeSize)
check_type_size("ssize_t" SIZEOF_SSIZE_T)
if(SIZEOF_SSIZE_T STREQUAL "")
set(ssize_t ptrdiff_t)
endif()
include(CheckSymbolExists)
if(HAVE_ENDIAN_H)
check_symbol_exists(be64toh "endian.h" HAVE_BE64TOH)
endif()
if(NOT HAVE_BE64TO AND HAVE_SYS_ENDIAN_H)
check_symbol_exists(be64toh "sys/endian.h" HAVE_BE64TOH)
endif()
check_symbol_exists(bswap_64 "byteswap.h" HAVE_BSWAP_64)
configure_file(ngtcp2/cmakeconfig.h.in ngtcp2/config.h)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/ngtcp2") # for config.h
set(ENABLE_STATIC_LIB ON FORCE BOOL)
set(ENABLE_SHARED_LIB OFF FORCE BOOL)
add_subdirectory(ngtcp2/lib EXCLUDE_FROM_ALL)
target_compile_definitions(ngtcp2_static PRIVATE -DHAVE_CONFIG_H -D_GNU_SOURCE)
endfunction()

View File

@ -1,18 +0,0 @@
set(WITH_STATIC OFF)
set(WITH_SHARED ON)
if("${SHADOW_ROOT}" STREQUAL "")
set(SHADOW_ROOT "$ENV{HOME}/.shadow")
endif("${SHADOW_ROOT}" STREQUAL "")
if(EXISTS "${SHADOW_ROOT}")
message(STATUS "SHADOW_ROOT = ${SHADOW_ROOT}")
else()
message(FATAL_ERROR "SHADOW_ROOT path does not exist: '${SHADOW_ROOT}'")
endif(EXISTS "${SHADOW_ROOT}")
set(CMAKE_MODULE_PATH "${SHADOW_ROOT}/share/cmake/Modules")
include_directories(${CMAKE_MODULE_PATH})
include(ShadowTools)
add_compile_options(-fno-inline -fno-strict-aliasing )
add_definitions(-DTESTNET=1)
add_definitions(-DLOKINET_SHADOW)
include_directories(${SHADOW_ROOT}/include)

View File

@ -7,15 +7,6 @@ endif()
include(CheckCXXSourceCompiles)
include(CheckLibraryExists)
if(WITH_JEMALLOC)
find_package(Jemalloc REQUIRED)
if(NOT JEMALLOC_FOUND)
message(FATAL_ERROR "did not find jemalloc")
endif()
add_definitions(-DUSE_JEMALLOC)
message(STATUS "using jemalloc")
endif()
add_definitions(-DUNIX)
add_definitions(-DPOSIX)

View File

@ -1,31 +1,49 @@
if(NOT WIN32)
return()
endif()
if (NOT STATIC_LINK)
message(FATAL_ERROR "windows requires static builds (thanks balmer)")
endif()
enable_language(RC)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
option(WITH_WINDOWS_32 "build 32 bit windows" OFF)
if(NOT MSVC_VERSION)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-bad-function-cast>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-cast-function-type>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
# unlike unix where you get a *single* compiler ID string in .comment
# GNU ld sees fit to merge *all* the .ident sections in object files
# to .r[o]data section one after the other!
add_compile_options(-fno-ident -Wa,-mbig-obj)
link_libraries( -lws2_32 -lshlwapi -ldbghelp -luser32 -liphlpapi -lpsapi -luserenv)
# zmq requires windows xp or higher
add_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501)
endif()
# unlike unix where you get a *single* compiler ID string in .comment
# GNU ld sees fit to merge *all* the .ident sections in object files
# to .r[o]data section one after the other!
add_compile_options(-fno-ident -Wa,-mbig-obj)
if(EMBEDDED_CFG)
link_libatomic()
endif()
add_definitions(-DWIN32_LEAN_AND_MEAN -DWIN32)
set(WINTUN_VERSION 0.14.1 CACHE STRING "wintun version")
set(WINTUN_MIRROR https://www.wintun.net/builds
CACHE STRING "wintun mirror(s)")
set(WINTUN_SOURCE wintun-${WINTUN_VERSION}.zip)
set(WINTUN_HASH SHA256=07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51
CACHE STRING "wintun source hash")
if (NOT STATIC_LINK AND NOT MSVC)
message("must ship compiler runtime libraries with this build: libwinpthread-1.dll, libgcc_s_dw2-1.dll, and libstdc++-6.dll")
message("for release builds, turn on STATIC_LINK in cmake options")
endif()
set(WINDIVERT_VERSION 2.2.0-A CACHE STRING "windivert version")
set(WINDIVERT_MIRROR https://reqrypt.org/download
CACHE STRING "windivert mirror(s)")
set(WINDIVERT_SOURCE WinDivert-${WINDIVERT_VERSION}.zip)
set(WINDIVERT_HASH SHA256=2a7630aac0914746fbc565ac862fa096e3e54233883ac52d17c83107496b7a7f
CACHE STRING "windivert source hash")
set(WINTUN_URL ${WINTUN_MIRROR}/${WINTUN_SOURCE}
CACHE STRING "wintun download url")
set(WINDIVERT_URL ${WINDIVERT_MIRROR}/${WINDIVERT_SOURCE}
CACHE STRING "windivert download url")
message(STATUS "Downloading wintun from ${WINTUN_URL}")
file(DOWNLOAD ${WINTUN_URL} ${CMAKE_BINARY_DIR}/wintun.zip EXPECTED_HASH ${WINTUN_HASH})
message(STATUS "Downloading windivert from ${WINDIVERT_URL}")
file(DOWNLOAD ${WINDIVERT_URL} ${CMAKE_BINARY_DIR}/windivert.zip EXPECTED_HASH ${WINDIVERT_HASH})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar x ${CMAKE_BINARY_DIR}/wintun.zip
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar x ${CMAKE_BINARY_DIR}/windivert.zip
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

View File

@ -1,45 +1,46 @@
if(NOT GUI_ZIP_URL)
set(GUI_ZIP_URL "https://oxen.rocks/oxen-io/loki-network-control-panel/lokinet-gui-windows-32bit-v0.3.8.zip")
set(GUI_ZIP_HASH_OPTS EXPECTED_HASH SHA256=60c2b738cf997e5684f307e5222498fd09143d495a932924105a49bf59ded8bb)
install(DIRECTORY ${CMAKE_BINARY_DIR}/gui DESTINATION share COMPONENT gui)
if(WITH_WINDOWS_32)
install(FILES ${CMAKE_BINARY_DIR}/wintun/bin/x86/wintun.dll DESTINATION bin COMPONENT lokinet)
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x86/WinDivert.sys DESTINATION lib COMPONENT lokinet)
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x86/WinDivert.dll DESTINATION bin COMPONENT lokinet)
else()
install(FILES ${CMAKE_BINARY_DIR}/wintun/bin/amd64/wintun.dll DESTINATION bin COMPONENT lokinet)
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x64/WinDivert64.sys DESTINATION lib COMPONENT lokinet)
install(FILES ${CMAKE_BINARY_DIR}/WinDivert-${WINDIVERT_VERSION}/x64/WinDivert.dll DESTINATION bin COMPONENT lokinet)
endif()
set(TUNTAP_URL "https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe")
set(TUNTAP_EXE "${CMAKE_BINARY_DIR}/tuntap-install.exe")
set(BOOTSTRAP_URL "https://seed.lokinet.org/lokinet.signed")
set(BOOTSTRAP_FILE "${CMAKE_BINARY_DIR}/bootstrap.signed")
set(BOOTSTRAP_FILE "${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed")
install(FILES ${BOOTSTRAP_FILE} DESTINATION share COMPONENT lokinet RENAME bootstrap.signed)
file(DOWNLOAD
${TUNTAP_URL}
${TUNTAP_EXE})
file(DOWNLOAD
${BOOTSTRAP_URL}
${BOOTSTRAP_FILE})
file(DOWNLOAD
${GUI_ZIP_URL}
${CMAKE_BINARY_DIR}/lokinet-gui.zip
${GUI_ZIP_HASH_OPTS})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/lokinet-gui.zip
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
install(DIRECTORY ${CMAKE_BINARY_DIR}/gui DESTINATION share COMPONENT gui)
install(PROGRAMS ${TUNTAP_EXE} DESTINATION bin COMPONENT tuntap)
install(FILES ${BOOTSTRAP_FILE} DESTINATION share COMPONENT lokinet)
set(win_ico "${PROJECT_BINARY_DIR}/lokinet.ico")
add_custom_command(OUTPUT "${win_ico}"
COMMAND ${PROJECT_SOURCE_DIR}/contrib/make-ico.sh ${PROJECT_SOURCE_DIR}/contrib/lokinet.svg "${win_ico}"
DEPENDS ${PROJECT_SOURCE_DIR}/contrib/lokinet.svg ${PROJECT_SOURCE_DIR}/contrib/make-ico.sh)
add_custom_target(icon ALL DEPENDS "${win_ico}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Lokinet")
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/win32-setup/lokinet.ico")
set(CPACK_NSIS_MUI_ICON "${PROJECT_BINARY_DIR}/lokinet.ico")
set(CPACK_NSIS_DEFINES "RequestExecutionLevel admin")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ifFileExists $INSTDIR\\\\bin\\\\tuntap-install.exe 0 +2\\nExecWait '$INSTDIR\\\\bin\\\\tuntap-install.exe /S'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --install'\\nExecWait 'sc failure lokinet reset= 60 actions= restart/1000'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe -g C:\\\\ProgramData\\\\lokinet\\\\lokinet.ini'\\nCopyFiles '$INSTDIR\\\\share\\\\bootstrap.signed' C:\\\\ProgramData\\\\lokinet\\\\bootstrap.signed\\n")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "ExecWait 'net stop lokinet'\\nExecWait 'taskkill /f /t /im lokinet-gui.exe'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --remove'\\nRMDir /r /REBOOTOK C:\\\\ProgramData\\\\lokinet")
set(CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Lokinet.lnk' '$INSTDIR\\\\share\\\\gui\\\\lokinet-gui.exe'"
)
set(CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\Lokinet.lnk'"
)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified")
function(read_nsis_file filename outvar)
file(STRINGS "${filename}" _outvar)
list(TRANSFORM _outvar REPLACE "\\\\" "\\\\\\\\")
list(JOIN _outvar "\\n" out)
set(${outvar} ${out} PARENT_SCOPE)
endfunction()
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_preinstall.nsis" _extra_preinstall)
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_install.nsis" _extra_install)
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_uninstall.nsis" _extra_uninstall)
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_create_icons.nsis" _extra_create_icons)
read_nsis_file("${CMAKE_SOURCE_DIR}/win32-setup/extra_delete_icons.nsis" _extra_delete_icons)
set(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "${_extra_preinstall}")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${_extra_install}")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "${_extra_uninstall}")
set(CPACK_NSIS_CREATE_ICONS_EXTRA "${_extra_create_icons}")
set(CPACK_NSIS_DELETE_ICONS_EXTRA "${_extra_delete_icons}")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")

67
contrib/android-configure.sh Executable file
View File

@ -0,0 +1,67 @@
#!/bin/bash
set -e
default_abis="armeabi-v7a arm64-v8a x86_64"
build_abis=${ABIS:-$default_abis}
test x$NDK = x && test -e /usr/lib/android-ndk && export NDK=/usr/lib/android-ndk
test x$NDK = x && exit 1
echo "building abis: $build_abis"
root=$(readlink -f "$1")
shift
build=$(readlink -f "$1")
shift
mkdir -p $build
cd $build
for abi in $build_abis; do
mkdir -p build-$abi
cd build-$abi
cmake \
-S "$root" -B . \
-G 'Unix Makefiles' \
-DANDROID=ON \
-DANDROID_ABI=$abi \
-DANDROID_ARM_MODE=arm \
-DANDROID_PLATFORM=android-23 \
-DANDROID_API=23 \
-DANDROID_STL=c++_static \
-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
-DBUILD_STATIC_DEPS=ON \
-DBUILD_PACKAGE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DWITH_TESTS=OFF \
-DWITH_BOOTSTRAP=OFF \
-DNATIVE_BUILD=OFF \
-DSTATIC_LINK=ON \
-DWITH_SYSTEMD=OFF \
-DFORCE_OXENMQ_SUBMODULE=ON \
-DFORCE_OXENC_SUBMODULE=ON \
-DFORCE_FMT_SUBMODULE=ON \
-DFORCE_SPDLOG_SUBMODULE=ON \
-DFORCE_NLOHMANN_SUBMODULE=ON \
-DSUBMODULE_CHECK=OFF \
-DWITH_LTO=OFF \
-DCMAKE_BUILD_TYPE=Release \
"$@"
cd -
done
rm -f $build/Makefile
echo "# generated makefile" >> $build/Makefile
echo "all: $build_abis" >> $build/Makefile
for abi in $build_abis; do
echo -ne "$abi:\n\t" >> $build/Makefile
echo -ne '$(MAKE) -C ' >> $build/Makefile
echo "build-$abi lokinet-android" >> $build/Makefile
echo -ne "\tmkdir -p out/$abi && cp build-$abi/jni/liblokinet-android.so out/$abi/liblokinet-android.so\n\n" >> $build/Makefile
echo -ne "clean-$abi:\n\t" >> $build/Makefile
echo -ne '$(MAKE) -C ' >> $build/Makefile
echo "build-$abi clean" >> $build/Makefile
done
echo -ne "clean:" >> $build/Makefile
for targ in $build_abis ; do echo -ne " clean-$targ" >> $build/Makefile ; done
echo "" >> $build/Makefile

8
contrib/android.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
set +x
root="$(readlink -f $(dirname $0)/../)"
cd "$root"
./contrib/android-configure.sh . build-android "$@"
make -C build-android -j ${JOBS:-$(nproc)}

109
contrib/bencode-dump.py Executable file
View File

@ -0,0 +1,109 @@
#!/usr/bin/python3
import sys
import pprint
if len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == '-'):
f = sys.stdin.buffer
elif len(sys.argv) != 2 or sys.argv[1].startswith('-'):
print("Usage: {} FILE -- dumps a bencoded file".format(sys.argv[0]), file=sys.stderr)
sys.exit(1)
else:
f = open(sys.argv[1], 'rb')
initial = f.peek(2)
is_hex = False
if initial.startswith(b'64') or initial.startswith(b'6c'):
print("Input looks like hex bencoded data; parsing as hex input", file=sys.stderr)
is_hex = True
class HexPrinter():
def __init__(self, data):
self.data = data
def __repr__(self):
return "hex({} bytes):'{}'".format(len(self.data), self.data.hex())
def next_byte():
if is_hex:
pair = f.read(2)
assert pair is not None and len(pair) == 2
b = int(pair, 16).to_bytes(1, 'big')
else:
b = f.read(1)
assert b is not None and len(b) == 1
return b
def parse_int():
s = b''
x = next_byte()
while x in b"0123456789-":
s += x
x = next_byte()
assert x == b'e' and len(s) > 0, "Invalid integer encoding"
return int(s)
def parse_string(s):
x = next_byte()
while x in b"0123456789":
s += x
x = next_byte()
assert x == b':', "Invalid string encoding"
s = int(s)
if is_hex:
data = bytes.fromhex(f.read(2*s).decode('ascii'))
else:
data = f.read(s)
assert len(data) == s, "Truncated string data"
# If the string is ascii then convert to string:
if all(0x20 <= b <= 0x7e for b in data):
return data.decode()
# Otherwise display as hex:
return HexPrinter(data)
def parse_dict():
d = {}
last_key = None
while True:
t = next_byte()
if t == b'e':
return d
assert t in b"0123456789", "Invalid dict: dict keys must be strings"
key = parse_string(t)
raw_key = key.data if isinstance(key, HexPrinter) else key.encode()
if last_key is not None and raw_key <= last_key:
print("Warning: found out-of-order dict keys ({} after {})".format(raw_key, last_key), file=sys.stderr)
last_key = raw_key
t = next_byte()
d[key] = parse_thing(t)
def parse_list():
l = []
while True:
t = next_byte()
if t == b'e':
return l
l.append(parse_thing(t))
def parse_thing(t):
if t == b'd':
return parse_dict()
if t == b'l':
return parse_list()
if t == b'i':
return parse_int()
if t in b"0123456789":
return parse_string(t)
assert False, "Parsing error: encountered invalid type '{}'".format(t)
pprint.PrettyPrinter(
indent=2
).pprint(parse_thing(next_byte()))

View File

@ -1 +0,0 @@
lokinet-bootserv

View File

@ -1,29 +0,0 @@
# replace your.server.tld with your server's fqdn
server {
listen 80;
server_name your.server.tld;
location / {
return 302 https://your.server.tld$request_uri;
}
location /.well-known/acme-challenge {
root /var/www/letsencrypt;
}
}
server {
listen 443 ssl;
server_name your.server.tld;
ssl_certificate /etc/letsencrypt/live/your.server.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.server.tld/privkey.pem;
location / {
root /var/www/lokinet-bootserv;
}
location /bootstrap.signed {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/bin/lokinet-bootserv;
fastcgi_pass unix://tmp/cgi.sock;
}
}

View File

@ -1,4 +0,0 @@
# set me to where the nodedb is for lokinet
#[nodedb]
#dir=/path/to/nodedb/

View File

@ -1,20 +0,0 @@
SRC = $(sort $(wildcard src/*.cpp))
OBJS = $(SRC:.cpp=.cpp.o)
CGI_EXE = lokinet-bootserv
CXX = clang++
all: build
build: $(CGI_EXE)
%.cpp.o: %.cpp
$(CXX) -g -std=c++17 -c -Wall -Werror -Wpedantic $^ -o $^.o
$(CGI_EXE): $(OBJS)
$(CXX) -o $(CGI_EXE) $^
clean:
rm -f $(CGI_EXE) $(OBJS)

View File

@ -1,35 +0,0 @@
# lokinet-bootserv
cgi executable for serving a random RC for bootstrap from a nodedb
## configuring
copy the example config (privileged)
# cp configs/lokinet-bootserv.ini /usr/local/etc/lokinet-bootserv.ini
edit config to have proper values,
specifically make sure the `[nodedb]` section has a `dir` value that points to a static copy of a healthy nodedb
## building
to build:
$ make
## installing (priviledged)
install cgi binary:
# cp lokinet-bootserv /usr/local/bin/lokinet-bootserv
set up with nginx cgi:
# cp configs/lokinet-bootserv-nginx.conf /etc/nginx/sites-available/lokinet-bootserv.conf
# ln -s /etc/nginx/sites-available/lokinet-bootserv.conf /etc/nginx/sites-enabled/
## maintainence
add the following to crontab
0 0 * * * /usr/local/bin/lokinet-bootserv --cron

View File

@ -1,171 +0,0 @@
#include "lokinet-cgi.hpp"
#include <fstream>
#include <dirent.h>
#include <list>
#include <sstream>
namespace lokinet
{
namespace bootserv
{
CGIHandler::CGIHandler(std::ostream& o) : Handler(o)
{
}
CGIHandler::~CGIHandler()
{
}
int
CGIHandler::Exec(const Config& conf)
{
const char* e = getenv("REQUEST_METHOD");
if(e == nullptr)
return ReportError("$REQUEST_METHOD not set");
std::string_view method(e);
if(method != "GET")
{
out << "Content-Type: text/plain" << std::endl;
out << "Status: 405 Method Not Allowed" << std::endl << std::endl;
return 0;
}
std::string fname;
if(!conf.VisitSection(
"nodedb", [&](const Config::Section_t& sect) -> bool {
auto itr = sect.find("dir");
if(itr == sect.end())
return false;
fname = PickRandomFileInDir(
std::string(itr->second.data(), itr->second.size()));
return true;
}))
return ReportError("bad values in nodedb section of config");
if(fname.empty())
{
// no files in nodedb
out << "Content-Type: text/plain" << std::endl;
out << "Status: 404 Not Found" << std::endl << std::endl;
return 0;
}
return ServeFile(fname.c_str(), "application/octect-stream");
}
std::string
CGIHandler::PickRandomFileInDir(std::string dirname) const
{
// collect files
std::list< std::string > files;
{
DIR* d = opendir(dirname.c_str());
if(d == nullptr)
{
return "";
};
std::list< std::string > subdirs;
dirent* ent = nullptr;
while((ent = readdir(d)))
{
std::string_view f = ent->d_name;
if(f != "." && f != "..")
{
std::stringstream ss;
ss << dirname;
ss << '/';
ss << f;
subdirs.emplace_back(ss.str());
}
}
closedir(d);
for(const auto& subdir : subdirs)
{
d = opendir(subdir.c_str());
if(d)
{
while((ent = readdir(d)))
{
std::string_view f;
f = ent->d_name;
if(f != "." && f != ".."
&& f.find_last_of(".signed") != std::string_view::npos)
{
std::stringstream ss;
ss << subdir << "/" << f;
files.emplace_back(ss.str());
}
}
closedir(d);
}
}
}
uint32_t randint;
{
std::basic_ifstream< uint32_t > randf("/dev/urandom");
if(!randf.is_open())
return "";
randf.read(&randint, 1);
}
auto itr = files.begin();
if(files.size() > 1)
std::advance(itr, randint % files.size());
return *itr;
}
int
CGIHandler::ServeFile(const char* fname, const char* contentType) const
{
std::ifstream f(fname);
if(f.is_open())
{
f.seekg(0, std::ios::end);
auto sz = f.tellg();
f.seekg(0, std::ios::beg);
if(sz)
{
out << "Content-Type: " << contentType << std::endl;
out << "Status: 200 OK" << std::endl;
out << "Content-Length: " << std::to_string(sz) << std::endl
<< std::endl;
char buf[512] = {0};
size_t r = 0;
while((r = f.readsome(buf, sizeof(buf))) > 0)
out.write(buf, r);
out << std::flush;
}
else
{
out << "Content-Type: text/plain" << std::endl;
out << "Status: 500 Internal Server Error" << std::endl << std::endl;
out << "could not serve '" << fname << "' as it is an empty file"
<< std::endl;
}
}
else
{
out << "Content-Type: text/plain" << std::endl;
out << "Status: 404 Not Found" << std::endl << std::endl;
out << "could not serve '" << fname
<< "' as it does not exist on the filesystem" << std::endl;
}
return 0;
}
int
CGIHandler::ReportError(const char* err)
{
out << "Content-Type: text/plain" << std::endl;
out << "Status: 500 Internal Server Error" << std::endl << std::endl;
out << err << std::endl;
return 0;
}
Handler_ptr
NewCGIHandler(std::ostream& out)
{
return std::make_unique< CGIHandler >(out);
}
} // namespace bootserv
} // namespace lokinet

View File

@ -1,43 +0,0 @@
#ifndef LOKINET_BOOTSERV_HANDLER_HPP
#define LOKINET_BOOTSERV_HANDLER_HPP
#include <iostream>
#include "lokinet-config.hpp"
namespace lokinet
{
namespace bootserv
{
struct Handler
{
Handler(std::ostream& o) : out(o){};
virtual ~Handler(){};
/// handle command
/// return exit code
virtual int
Exec(const Config& conf) = 0;
/// report an error to system however that is done
/// return exit code
virtual int
ReportError(const char* err) = 0;
protected:
std::ostream& out;
};
using Handler_ptr = std::unique_ptr< Handler >;
/// create cgi handler
Handler_ptr
NewCGIHandler(std::ostream& out);
/// create cron handler
Handler_ptr
NewCronHandler(std::ostream& out);
} // namespace bootserv
} // namespace lokinet
#endif

View File

@ -1,31 +0,0 @@
#ifndef BOOTSERV_LOKINET_CRON_HPP
#define BOOTSERV_LOKINET_CRON_HPP
#include "handler.hpp"
namespace lokinet
{
namespace bootserv
{
struct CGIHandler final : public Handler
{
CGIHandler(std::ostream& o);
~CGIHandler();
int
Exec(const Config& conf) override;
int
ReportError(const char* err) override;
int
ServeFile(const char* fname, const char* mime) const;
std::string
PickRandomFileInDir(std::string dirname) const;
};
} // namespace bootserv
} // namespace lokinet
#endif

View File

@ -1,132 +0,0 @@
#include "lokinet-config.hpp"
#include <fstream>
#include <list>
#include <iostream>
namespace lokinet
{
namespace bootserv
{
const char* Config::DefaultPath = "/usr/local/etc/lokinet-bootserv.ini";
bool
Config::LoadFile(const char* fname)
{
{
std::ifstream f(fname);
if(!f.is_open())
return false;
f.seekg(0, std::ios::end);
m_Data.resize(f.tellg());
f.seekg(0, std::ios::beg);
if(m_Data.size() == 0)
return false;
f.read(m_Data.data(), m_Data.size());
}
return Parse();
}
void
Config::Clear()
{
m_Config.clear();
m_Data.clear();
}
bool
Config::Parse()
{
std::list< String_t > lines;
{
auto itr = m_Data.begin();
// split into lines
while(itr != m_Data.end())
{
auto beg = itr;
while(itr != m_Data.end() && *itr != '\n' && *itr != '\r')
++itr;
lines.emplace_back(std::addressof(*beg), (itr - beg));
if(itr == m_Data.end())
break;
++itr;
}
}
String_t sectName;
for(const auto& line : lines)
{
String_t realLine;
auto comment = line.find_first_of(';');
if(comment == String_t::npos)
comment = line.find_first_of('#');
if(comment == String_t::npos)
realLine = line;
else
realLine = line.substr(0, comment);
// blank or commented line?
if(realLine.size() == 0)
continue;
// find delimiters
auto sectOpenPos = realLine.find_first_of('[');
auto sectClosPos = realLine.find_first_of(']');
auto kvDelim = realLine.find_first_of('=');
if(sectOpenPos != String_t::npos && sectClosPos != String_t::npos
&& kvDelim == String_t::npos)
{
// section header
// clamp whitespaces
++sectOpenPos;
while(std::isspace(realLine[sectOpenPos])
&& sectOpenPos != sectClosPos)
++sectOpenPos;
--sectClosPos;
while(std::isspace(realLine[sectClosPos])
&& sectClosPos != sectOpenPos)
--sectClosPos;
// set section name
sectName = realLine.substr(sectOpenPos, sectClosPos);
}
else if(kvDelim != String_t::npos)
{
// key value pair
String_t::size_type k_start = 0;
String_t::size_type k_end = kvDelim;
String_t::size_type v_start = kvDelim + 1;
String_t::size_type v_end = realLine.size() - 1;
// clamp whitespaces
while(std::isspace(realLine[k_start]) && k_start != kvDelim)
++k_start;
while(std::isspace(realLine[k_end]) && k_end != k_start)
--k_end;
while(std::isspace(realLine[v_start]) && v_start != v_end)
++v_start;
while(std::isspace(realLine[v_end]))
--v_end;
// sect.k = v
String_t k = realLine.substr(k_start, k_end);
String_t v = realLine.substr(v_start, v_end);
Section_t& sect = m_Config[sectName];
sect[k] = v;
}
else // malformed?
return false;
}
return true;
}
bool
Config::VisitSection(
const char* name,
std::function< bool(const Section_t& sect) > visit) const
{
auto itr = m_Config.find(name);
if(itr == m_Config.end())
return false;
return visit(itr->second);
}
} // namespace bootserv
} // namespace lokinet

View File

@ -1,47 +0,0 @@
#ifndef LOKINET_BOOTSERV_CONFIG_HPP
#define LOKINET_BOOTSERV_CONFIG_HPP
#include <unordered_map>
#include <string_view>
#include <functional>
#include <memory>
#include <vector>
namespace lokinet
{
namespace bootserv
{
struct Config
{
using String_t = std::string_view;
using Section_t = std::unordered_map< String_t, String_t >;
using Config_impl_t = std::unordered_map< String_t, Section_t >;
static const char* DefaultPath;
/// clear config
void
Clear();
/// load config file for bootserv
/// return true on success
/// return false on error
bool
LoadFile(const char* fname);
/// visit a section in config read only by name
/// return false if no section or value propagated from visitor
bool
VisitSection(const char* name,
std::function< bool(const Section_t&) > visit) const;
private:
bool
Parse();
std::vector< char > m_Data;
Config_impl_t m_Config;
};
} // namespace bootserv
} // namespace lokinet
#endif

View File

@ -1,37 +0,0 @@
#include "lokinet-cron.hpp"
namespace lokinet
{
namespace bootserv
{
CronHandler::CronHandler(std::ostream& o) : Handler(o)
{
}
CronHandler::~CronHandler()
{
}
int
CronHandler::Exec(const Config& conf)
{
// this runs the cron tasks
// TODO: implement me
return 0;
}
int
CronHandler::ReportError(const char* err)
{
out << "error: " << err << std::endl;
return 1;
}
Handler_ptr
NewCronHandler(std::ostream& out)
{
return std::make_unique< CronHandler >(out);
}
} // namespace bootserv
} // namespace lokinet

View File

@ -1,25 +0,0 @@
#ifndef BOOTSERV_LOKINET_CRON_HPP
#define BOOTSERV_LOKINET_CRON_HPP
#include "handler.hpp"
namespace lokinet
{
namespace bootserv
{
struct CronHandler final : public Handler
{
CronHandler(std::ostream& o);
~CronHandler();
int
Exec(const Config& conf) override;
int
ReportError(const char* err) override;
};
} // namespace bootserv
} // namespace lokinet
#endif

View File

@ -1,60 +0,0 @@
#include "handler.hpp"
#include "lokinet-config.hpp"
#include <getopt.h>
#include <string_view>
#include <sstream>
static int
printhelp(const char* exe)
{
std::cout << "usage: " << exe << " [--cron] [--conf /path/to/alt/config.ini]"
<< std::endl;
return 1;
}
int
main(int argc, char* argv[])
{
bool RunCron = false;
const char* confFile = lokinet::bootserv::Config::DefaultPath;
lokinet::bootserv::Config config;
lokinet::bootserv::Handler_ptr handler;
option longopts[] = {{"cron", no_argument, 0, 'C'},
{"help", no_argument, 0, 'h'},
{"conf", required_argument, 0, 'c'},
{0, 0, 0, 0}};
int c = 0;
int index = 0;
while((c = getopt_long(argc, argv, "hCc:", longopts, &index)) != -1)
{
switch(c)
{
case 'h':
return printhelp(argv[0]);
case 'C':
RunCron = true;
break;
case 'c':
confFile = optarg;
break;
}
}
if(RunCron)
handler = lokinet::bootserv::NewCronHandler(std::cout);
else
handler = lokinet::bootserv::NewCGIHandler(std::cout);
if(!config.LoadFile(confFile))
{
std::stringstream ss;
ss << "failed to load " << confFile;
return handler->ReportError(ss.str().c_str());
}
else
return handler->Exec(config);
}

Binary file not shown.

View File

@ -0,0 +1 @@
ld1:ald1:ci2e1:d3:iwp1:e32:9ãxÚsX«l%ìû€ê<,sØ›•©÷ïå_1:i21:::ffff:144.76.164.2021:pi1666e1:vi0eee1:i5:gamma1:k32:ÞÊðòm=o„ZÐ1ÿßmcŒ%»¸ÿû¾™SĹ1:p32:!EÏâéz˜ý:Š‹úý… /0¡Ú„ Ãݪ„µNçB1:rli0ei0ei8ei3ee1:ui1614788310454e1:vi0e1:xle1:z64:Œ¤u G¿”D“=Œxµ¢{ïÌ51þ`í߀ùEâw m)q2Øg¯±˜øš ï³À)˜TÑP•´ò³ö—Á1ee

View File

@ -1,8 +0,0 @@
FROM debian:testing
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
RUN /bin/bash -c 'sed -i "s/main/main contrib/g" /etc/apt/sources.list'
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 android-sdk google-android-ndk-installer'
RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q -y install wget git pkg-config'
RUN /bin/bash -c 'wget https://services.gradle.org/distributions/gradle-6.3-bin.zip -O /tmp/gradle.zip && unzip -d /opt/ /tmp/gradle.zip && ln -s /opt/gradle*/bin/gradle /usr/local/bin/gradle && rm -f /tmp/gradle.zip'
RUN /bin/bash -c 'git clone https://github.com/Shadowstyler/android-sdk-licenses.git /tmp/android-sdk-licenses && cp -a /tmp/android-sdk-licenses/*-license /usr/lib/android-sdk/licenses && rm -rf /tmp/android-sdk-licenses'
RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q -y install automake libtool'

View File

@ -1,3 +0,0 @@
FROM debian:sid
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
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 clang-11 libsodium-dev libsystemd-dev python3-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev libsqlite3-dev libboost-thread-dev libboost-serialization-dev libboost-program-options-dev libgtest-dev libminiupnpc-dev libunwind8-dev libreadline-dev libhidapi-dev libusb-1.0.0-dev qttools5-dev libcurl4-openssl-dev'

View File

@ -1,3 +0,0 @@
FROM debian:stable
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
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++ libsodium-dev libsystemd-dev python3-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev libsqlite3-dev libboost-thread-dev liboost-serialization-dev libboost-program-options-dev libgtest-dev libminiupnpc-dev libunwind8-dev libreadline-dev libhidapi-dev libusb-1.0.0-dev qttools5-dev libcurl4-openssl-dev'

View File

@ -1,4 +0,0 @@
FROM debian:testing
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
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 build-essential cmake git ninja-build pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip automake libtool autoconf make qttools5-dev file gperf patch openssh-client'
RUN /bin/bash -c 'update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix && update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix'

View File

@ -1,3 +0,0 @@
FROM debian:sid
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
RUN /bin/bash -c 'apt-get -o=Dpkg::Use-Pty=0 -q update && apt-get -o=Dpkg::Use-Pty=0 -q install -y eatmydata git clang-format-11'

View File

@ -1,8 +1,9 @@
## drone-ci docker jizz
To rebuild all ci images and push them to a registry server do:
To rebuild all ci images and push them to the oxen registry server do:
$ docker login your.registry.here
$ ./rebuild-docker-images.sh your.registry.here *.dockerfile
$ docker login registry.oxen.rocks
$ ./rebuild-docker-images.py
The docker images will be `your.registry.here/lokinet-ci-*`for each *.dockerfile in this directory
If you aren't part of the Oxen team, you'll likely need to set up your own registry and change
registry.oxen.rocks to your own domain name in order to do anything useful with this.

View File

@ -0,0 +1,350 @@
#!/usr/bin/env python3
import subprocess
import tempfile
import optparse
import sys
from concurrent.futures import ThreadPoolExecutor
import threading
parser = optparse.OptionParser()
parser.add_option("--no-cache", action="store_true",
help="Run `docker build` with the `--no-cache` option to ignore existing images")
parser.add_option("--parallel", "-j", type="int", default=1,
help="Run up to this many builds in parallel")
parser.add_option("--distro", type="string", default="",
help="Build only this distro; should be DISTRO-CODE or DISTRO-CODE/ARCH, "
"e.g. debian-sid/amd64")
(options, args) = parser.parse_args()
registry_base = 'registry.oxen.rocks/lokinet-ci-'
distros = [*(('debian', x) for x in ('sid', 'stable', 'testing', 'bullseye', 'buster')),
*(('ubuntu', x) for x in ('rolling', 'lts', 'impish', 'hirsute', 'focal', 'bionic'))]
if options.distro:
d = options.distro.split('-')
if len(d) != 2 or d[0] not in ('debian', 'ubuntu') or not d[1]:
print("Bad --distro value '{}'".format(options.distro), file=sys.stderr)
sys.exit(1)
distros = [(d[0], d[1].split('/')[0])]
manifests = {} # "image:latest": ["image/amd64", "image/arm64v8", ...]
manifestlock = threading.Lock()
def arches(distro):
if options.distro and '/' in options.distro:
arch = options.distro.split('/')
if arch not in ('amd64', 'i386', 'arm64v8', 'arm32v7'):
print("Bad --distro value '{}'".format(options.distro), file=sys.stderr)
sys.exit(1)
return [arch]
a = ['amd64', 'arm64v8', 'arm32v7']
if distro[0] == 'debian' or distro == ('ubuntu', 'bionic'):
a.append('i386') # i386 builds don't work on later ubuntu
return a
hacks = {
registry_base + 'ubuntu-bionic-builder': """g++-8 \
&& mkdir -p /usr/lib/x86_64-linux-gnu/pgm-5.2/include""",
}
failure = False
lineno = 0
linelock = threading.Lock()
def print_line(myline, value):
linelock.acquire()
global lineno
if sys.__stdout__.isatty():
jump = lineno - myline
print("\033[{jump}A\r\033[K{value}\033[{jump}B\r".format(jump=jump, value=value), end='')
sys.stdout.flush()
else:
print(value)
linelock.release()
def run_or_report(*args, myline):
try:
subprocess.run(
args, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8')
except subprocess.CalledProcessError as e:
with tempfile.NamedTemporaryFile(suffix=".log", delete=False) as log:
log.write("Error running {}: {}\n\nOutput:\n\n".format(' '.join(args), e).encode())
log.write(e.output.encode())
global failure
failure = True
print_line(myline, "\033[31;1mError! See {} for details".format(log.name))
raise e
def build_tag(tag_base, arch, contents):
if failure:
raise ChildProcessError()
linelock.acquire()
global lineno
myline = lineno
lineno += 1
print()
linelock.release()
with tempfile.NamedTemporaryFile() as dockerfile:
dockerfile.write(contents.encode())
dockerfile.flush()
tag = '{}/{}'.format(tag_base, arch)
print_line(myline, "\033[33;1mRebuilding \033[35;1m{}\033[0m".format(tag))
run_or_report('docker', 'build', '--pull', '-f', dockerfile.name, '-t', tag,
*(('--no-cache',) if options.no_cache else ()), '.', myline=myline)
print_line(myline, "\033[33;1mPushing \033[35;1m{}\033[0m".format(tag))
run_or_report('docker', 'push', tag, myline=myline)
print_line(myline, "\033[32;1mFinished build \033[35;1m{}\033[0m".format(tag))
latest = tag_base + ':latest'
global manifests
manifestlock.acquire()
if latest in manifests:
manifests[latest].append(tag)
else:
manifests[latest] = [tag]
manifestlock.release()
def base_distro_build(distro, arch):
tag = '{r}{distro[0]}-{distro[1]}-base'.format(r=registry_base, distro=distro)
codename = 'latest' if distro == ('ubuntu', 'lts') else distro[1]
build_tag(tag, arch, """
FROM {}/{}:{}
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
RUN 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 autoremove -y \
{hacks}
""".format(arch, distro[0], codename, hacks=hacks.get(tag, '')))
def distro_build(distro, arch):
prefix = '{r}{distro[0]}-{distro[1]}'.format(r=registry_base, distro=distro)
fmtargs = dict(arch=arch, distro=distro, prefix=prefix)
# (distro)-(codename)-base: Base image from upstream: we sync the repos, but do nothing else.
if (distro, arch) != (('debian', 'stable'), 'amd64'): # debian-stable-base/amd64 already built
base_distro_build(distro, arch)
# (distro)-(codename)-builder: Deb builder image used for building debs; we add the basic tools
# we use to build debs, not including things that should come from the dependencies in the
# debian/control file.
build_tag(prefix + '-builder', arch, """
FROM {prefix}-base/{arch}
RUN 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 --no-install-recommends -q install -y \
ccache \
devscripts \
equivs \
g++ \
git \
git-buildpackage \
openssh-client \
{hacks}
""".format(**fmtargs, hacks=hacks.get(prefix + '-builder', '')))
# (distro)-(codename): Basic image we use for most builds. This takes the -builder and adds
# most dependencies found in our packages.
build_tag(prefix, arch, """
FROM {prefix}-builder/{arch}
RUN 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 --no-install-recommends -q install -y \
automake \
ccache \
cmake \
eatmydata \
g++ \
gdb \
git \
libboost-program-options-dev \
libboost-serialization-dev \
libboost-thread-dev \
libcurl4-openssl-dev \
libevent-dev \
libgtest-dev \
libhidapi-dev \
libjemalloc-dev \
libminiupnpc-dev \
libreadline-dev \
libsodium-dev \
libsqlite3-dev \
libssl-dev \
libsystemd-dev \
libtool \
libunbound-dev \
libunwind8-dev \
libusb-1.0.0-dev \
libuv1-dev \
libzmq3-dev \
lsb-release \
make \
nettle-dev \
ninja-build \
openssh-client \
patch \
pkg-config \
pybind11-dev \
python3-dev \
python3-pip \
python3-pybind11 \
python3-pytest \
python3-setuptools \
qttools5-dev \
{hacks}
""".format(**fmtargs, hacks=hacks.get(prefix, '')))
# Android and flutter builds on top of debian-stable-base and adds a ton of android crap; we
# schedule this job as soon as the debian-sid-base/amd64 build finishes, because they easily take
# the longest and are by far the biggest images.
def android_builds():
build_tag(registry_base + 'android', 'amd64', """
FROM {r}debian-stable-base
RUN /bin/bash -c 'sed -i "s/main/main contrib/g" /etc/apt/sources.list'
RUN 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 --no-install-recommends -y \
android-sdk \
automake \
ccache \
cmake \
curl \
git \
google-android-ndk-installer \
libtool \
make \
openssh-client \
patch \
pkg-config \
wget \
xz-utils \
zip \
&& git clone https://github.com/Shadowstyler/android-sdk-licenses.git /tmp/android-sdk-licenses \
&& cp -a /tmp/android-sdk-licenses/*-license /usr/lib/android-sdk/licenses \
&& rm -rf /tmp/android-sdk-licenses
""".format(r=registry_base))
build_tag(registry_base + 'flutter', 'amd64', """
FROM {r}android
RUN cd /opt \
&& curl https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_2.2.2-stable.tar.xz \
| tar xJv \
&& ln -s /opt/flutter/bin/flutter /usr/local/bin/ \
&& flutter precache
""".format(r=registry_base))
# lint is a tiny build (on top of debian-stable-base) with just formatting checking tools
def lint_build():
build_tag(registry_base + 'lint', 'amd64', """
FROM {r}debian-stable-base
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
clang-format-11 \
eatmydata \
git \
jsonnet
""".format(r=registry_base))
def nodejs_build():
build_tag(registry_base + 'nodejs', 'amd64', """
FROM node:14.16.1
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
RUN 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 --no-install-recommends -y \
ccache \
cmake \
eatmydata \
g++ \
gdb \
git \
make \
ninja-build \
openssh-client \
patch \
pkg-config \
wine
""")
# Start debian-stable-base/amd64 on its own, because other builds depend on it and we want to get
# those (especially android/flutter) fired off as soon as possible (because it's slow and huge).
if ('debian', 'stable') in distros:
base_distro_build(['debian', 'stable'], 'amd64')
executor = ThreadPoolExecutor(max_workers=max(options.parallel, 1))
if options.distro:
jobs = []
else:
jobs = [executor.submit(b) for b in (android_builds, lint_build, nodejs_build)]
for d in distros:
for a in arches(d):
jobs.append(executor.submit(distro_build, d, a))
while len(jobs):
j = jobs.pop(0)
try:
j.result()
except (ChildProcessError, subprocess.CalledProcessError):
for k in jobs:
k.cancel()
if failure:
print("Error(s) occured, aborting!", file=sys.stderr)
sys.exit(1)
print("\n\n\033[32;1mAll builds finished successfully; pushing manifests...\033[0m\n")
def push_manifest(latest, tags):
if failure:
raise ChildProcessError()
linelock.acquire()
global lineno
myline = lineno
lineno += 1
print()
linelock.release()
subprocess.run(['docker', 'manifest', 'rm', latest], stderr=subprocess.DEVNULL, check=False)
print_line(myline, "\033[33;1mCreating manifest \033[35;1m{}\033[0m".format(latest))
run_or_report('docker', 'manifest', 'create', latest, *tags, myline=myline)
print_line(myline, "\033[33;1mPushing manifest \033[35;1m{}\033[0m".format(latest))
run_or_report('docker', 'manifest', 'push', latest, myline=myline)
print_line(myline, "\033[32;1mFinished manifest \033[35;1m{}\033[0m".format(latest))
for latest, tags in manifests.items():
jobs.append(executor.submit(push_manifest, latest, tags))
while len(jobs):
j = jobs.pop(0)
try:
j.result()
except (ChildProcessError, subprocess.CalledProcessError):
for k in jobs:
k.cancel()
print("\n\n\033[32;1mAll done!\n")

View File

@ -1,13 +0,0 @@
#!/bin/bash
# the registry server to use
registry=$1
test "x$registry" != "x" || exit 1
for file in ${@:2} ; do
name="$(echo $file | cut -d'.' -f1)"
echo "rebuild $name"
docker build -f $file -t $registry/lokinet-ci-$name --pull --no-cache --quiet .
docker push $registry/lokinet-ci-$name
done

View File

@ -1,3 +0,0 @@
FROM ubuntu:bionic
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
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 --no-install-recommends install -y eatmydata gdb cmake git ninja-build pkg-config ccache g++-8 python3-dev automake libtool autoconf make qttools5-dev file gperf patch openssh-client'

View File

@ -1,3 +0,0 @@
FROM ubuntu:focal
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
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 --no-install-recommends -q install -y eatmydata gdb cmake git ninja-build pkg-config ccache g++ libsodium-dev libsystemd-dev python3-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev libsqlite3-dev libboost-thread-dev libboost-serialization-dev libboost-program-options-dev libgtest-dev libminiupnpc-dev libunwind8-dev libreadline-dev libhidapi-dev libusb-1.0.0-dev qttools5-dev libcurl4-openssl-dev'

View File

@ -7,7 +7,8 @@ set -o errexit
bad=
if [ "$DRONE_STAGE_OS" == "darwin" ]; then
if otool -L daemon/lokinet | grep -Ev '^daemon/lokinet:|^\t(/usr/lib/libSystem\.|/usr/lib/libc\+\+\.|/System/Library/Frameworks/CoreFoundation)'; then
if otool -L llarp/apple/org.lokinet.network-extension.systemextension/Contents/MacOS/org.lokinet.network-extension | \
grep -Ev '^llarp/apple:|^\t(/usr/lib/lib(System\.|c\+\+|objc))|/System/Library/Frameworks/(CoreFoundation|NetworkExtension|Foundation|Network)\.framework'; then
bad=1
fi
elif [ "$DRONE_STAGE_OS" == "linux" ]; then

View File

@ -1,5 +1,9 @@
#!/usr/bin/env bash
test "x$IGNORE" != "x" && exit 0
. $(dirname $0)/../format-version.sh
repo=$(readlink -e $(dirname $0)/../../)
clang-format-11 -i $(find $repo/jni $repo/daemon $repo/llarp $repo/include $repo/pybind | grep -E '\.[hc](pp)?$')
$CLANG_FORMAT -i $(find $repo/jni $repo/daemon $repo/llarp $repo/include $repo/pybind | grep -E '\.[hc](pp)?$')
jsonnetfmt -i $repo/.drone.jsonnet
git --no-pager diff --exit-code --color || (echo -ne '\n\n\e[31;1mLint check failed; please run ./contrib/format.sh\e[0m\n\n' ; exit 1)

View File

@ -19,9 +19,15 @@ set -o xtrace # Don't start tracing until *after* we write the ssh key
chmod 600 ssh_key
os="${UPLOAD_OS:-$DRONE_STAGE_OS-$DRONE_STAGE_ARCH}"
if [ -n "$WINDOWS_BUILD_NAME" ]; then
os="windows-$WINDOWS_BUILD_NAME"
os="$UPLOAD_OS"
if [ -z "$os" ]; then
if [ "$DRONE_STAGE_OS" == "darwin" ]; then
os="macos-$DRONE_STAGE_ARCH"
elif [ -n "$WINDOWS_BUILD_NAME" ]; then
os="windows-$WINDOWS_BUILD_NAME"
else
os="$DRONE_STAGE_OS-$DRONE_STAGE_ARCH"
fi
fi
if [ -n "$DRONE_TAG" ]; then
@ -34,18 +40,29 @@ else
fi
mkdir -v "$base"
if [ -e daemon/lokinet.exe ]; then
cp -av lokinet-*.exe "$base"
if [ -e build/win32 ]; then
# save debug symbols
cp -av build/win32/daemon/debug-symbols.tar.xz "$base-debug-symbols.tar.xz"
# save installer
cp -av build/win32/*.exe "$base"
# zipit up yo
archive="$base.zip"
zip -r "$archive" "$base"
elif [ -e build/outputs/apk/debug/lokinet-debug.apk ] ; then
elif [ -e lokinet.apk ] ; then
# android af ngl
cp -av build/outputs/apk/debug/lokinet-debug.apk "$base"
archive="$base.apk"
cp -av lokinet.apk "$archive"
elif [ -e build-docs ]; then
archive="$base.tar.xz"
cp -av build-docs/docs/mkdocs.yml build-docs/docs/markdown "$base"
tar cJvf "$archive" "$base"
elif [ -e build-mac ]; then
archive="$base.tar.xz"
mv build-mac/Lokinet*/ "$base"
tar cJvf "$archive" "$base"
else
cp -av daemon/lokinet daemon/lokinet-vpn ../lokinet-bootstrap "$base"
cp -av build/daemon/lokinet{,-vpn} "$base"
cp -av contrib/bootstrap/mainnet.signed "$base/bootstrap.signed"
# tar dat shiz up yo
archive="$base.tar.xz"
tar cJvf "$archive" "$base"
@ -57,6 +74,7 @@ upload_to="oxen.rocks/${DRONE_REPO// /_}/${DRONE_BRANCH// /_}"
# -mkdir a/, -mkdir a/b/, -mkdir a/b/c/, ... commands. The leading `-` allows the command to fail
# without error.
upload_dirs=(${upload_to//\// })
put_debug=
mkdirs=
dir_tmp=""
for p in "${upload_dirs[@]}"; do
@ -64,13 +82,15 @@ for p in "${upload_dirs[@]}"; do
mkdirs="$mkdirs
-mkdir $dir_tmp"
done
if [ -e "$base-debug-symbols.tar.xz" ] ; then
put_debug="put $base-debug-symbols.tar.xz $upload_to"
fi
sftp -i ssh_key -b - -o StrictHostKeyChecking=off drone@oxen.rocks <<SFTP
$mkdirs
put $archive $upload_to
$put_debug
SFTP
set +o xtrace
echo -e "\n\n\n\n\e[32;1mUploaded to https://${upload_to}/${archive}\e[0m\n\n\n"

View File

@ -0,0 +1,2 @@
[logging]
level=debug

View File

@ -0,0 +1,5 @@
#
# "suggested" default exit node config
#
[network]
exit-node=exit.loki

View File

@ -0,0 +1,5 @@
#
# persist .loki address in a private key file in the data dir
#
[network]
keyfile=lokinet-addr.privkey

65
contrib/cross.sh Executable file
View File

@ -0,0 +1,65 @@
#!/bin/bash
#
# helper script for me for when i cross compile
# t. jeff
#
set -e
die() {
echo $@
exit 1
}
platform=${PLATFORM:-Linux}
root="$(readlink -e $(dirname $0)/../)"
cd $root
mkdir -p build-cross
targets=()
cmake_extra=()
while [ "$#" -gt 0 ]; do
if [ "$1" = "--" ]; then
shift
cmake_extra=("$@")
break
fi
targets+=("$1")
shift
done
test ${#targets[@]} = 0 && die no targets provided
archs="${targets[@]}"
echo "all: $archs" > build-cross/Makefile
for arch in $archs ; do
mkdir -p $root/build-cross/build-$arch
cd $root/build-cross/build-$arch
cmake \
-G 'Unix Makefiles' \
-DCROSS_PLATFORM=$platform \
-DCROSS_PREFIX=$arch \
-DCMAKE_EXE_LINKER_FLAGS=-fstack-protector \
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always \
-DCMAKE_TOOLCHAIN_FILE=$root/contrib/cross/cross.toolchain.cmake \
-DBUILD_STATIC_DEPS=ON \
-DSTATIC_LINK=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_LIBLOKINET=OFF \
-DWITH_TESTS=OFF \
-DNATIVE_BUILD=OFF \
-DSTATIC_LINK=ON \
-DWITH_SYSTEMD=OFF \
-DFORCE_OXENMQ_SUBMODULE=ON \
-DSUBMODULE_CHECK=OFF \
-DWITH_LTO=OFF \
-DWITH_BOOTSTRAP=OFF \
-DCMAKE_BUILD_TYPE=RelWithDeb \
"${cmake_extra[@]}" \
$root
cd $root/build-cross
echo -ne "$arch:\n\t\$(MAKE) -C build-$arch\n" >> $root/build-cross/Makefile
done
cd $root
make -j${JOBS:-$(nproc)} -C build-cross

View File

@ -1,12 +0,0 @@
set(CMAKE_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX aarch64-linux-gnu)
#set(TOOLCHAIN_SUFFIX)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})

View File

@ -1,7 +1,5 @@
set(CMAKE_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX arm-linux-gnueabihf)
set(TOOLCHAIN_SUFFIX -8)
set(CMAKE_SYSTEM_NAME ${CROSS_PLATFORM})
set(TOOLCHAIN_PREFIX ${CROSS_PREFIX})
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
@ -10,3 +8,4 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})
set(ARCH_TRIPLET ${TOOLCHAIN_PREFIX})

View File

@ -1,4 +1,8 @@
set(CMAKE_SYSTEM_VERSION 5.0)
set(CMAKE_SYSTEM_VERSION 6.0)
# the minimum windows version, set to 6 rn because supporting older windows is hell
set(_winver 0x0600)
add_definitions(-D_WIN32_WINNT=${_winver})
# target environment on the build host system
# second one is for non-root installs

View File

@ -1,12 +0,0 @@
set(CMAKE_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX powerpc64le-linux-gnu)
set(TOOLCHAIN_SUFFIX -8)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc${TOOLCHAIN_SUFFIX})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++${TOOLCHAIN_SUFFIX})

View File

@ -1,60 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
Created by Manifold
--><service_bundle type="manifest" name="lokinet">
<service name="site/lokinet" type="service" version="1">
<dependency name="network" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/milestone/network:default"/>
</dependency>
<dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/system/filesystem/local"/>
</dependency>
<instance name="default" enabled="false">
<method_context>
<method_credential user="lokinet" group="lokinet"/>
</method_context>
<exec_method type="method" name="start" exec="/usr/bin/lokinet %{config_file}" timeout_seconds="60"/>
<exec_method type="method" name="stop" exec="/usr/bin/kill -INT &lt;&lt;&lt; `pgrep lokinet`" timeout_seconds="60"/>
<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="child"/>
<propval name="ignore_error" type="astring" value="core,signal"/>
</property_group>
<property_group name="application" type="application">
<propval name="config_file" type="astring" value="/etc/loki/lokinet.ini"/>
</property_group>
</instance>
<stability value="Evolving"/>
<template>
<common_name>
<loctext xml:lang="C">
LokiNET: Anonymous Network layer thingydoo.
</loctext>
</common_name>
</template>
</service>
</service_bundle>

View File

@ -1,18 +0,0 @@
#!/usr/sbin/dtrace -s
syscall:::entry
/pid == $target/
{
@calls[ustack(10), probefunc] = count();
}
profile:::tick-1sec
{
/** print */
printa(@calls);
/** clear */
clear(@calls);
trunc(@calls, 15);
}

19
contrib/format-version.sh Normal file
View File

@ -0,0 +1,19 @@
CLANG_FORMAT_DESIRED_VERSION=15
CLANG_FORMAT=$(command -v clang-format-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
if [ $? -ne 0 ]; then
CLANG_FORMAT=$(command -v clang-format-mp-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
fi
if [ $? -ne 0 ]; then
CLANG_FORMAT=$(command -v clang-format 2>/dev/null)
if [ $? -ne 0 ]; then
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
exit 1
fi
version=$(clang-format --version)
if [[ ! $version == *"clang-format version $CLANG_FORMAT_DESIRED_VERSION"* ]]; then
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
exit 1
fi
fi

View File

@ -1,24 +1,38 @@
#!/usr/bin/env bash
CLANG_FORMAT_DESIRED_VERSION=11
binary=$(which clang-format-$CLANG_FORMAT_DESIRED_VERSION 2>/dev/null)
if [ $? -ne 0 ]; then
binary=$(which clang-format 2>/dev/null)
if [ $? -ne 0 ]; then
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
exit 1
fi
version=$(clang-format --version)
if [[ ! $version == *"clang-format version $CLANG_FORMAT_DESIRED_VERSION"* ]]; then
echo "Please install clang-format version $CLANG_FORMAT_DESIRED_VERSION and re-run this script."
exit 1
fi
fi
. $(dirname $0)/format-version.sh
cd "$(dirname $0)/../"
if [ "$1" = "verify" ] ; then
exit $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') | grep '</replacement>' | wc -l)
if [ $($CLANG_FORMAT --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|m(m)?)$' | grep -v '#') | grep '</replacement>' | wc -l) -ne 0 ] ; then
exit 2
fi
else
$binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') &> /dev/null
$CLANG_FORMAT -i $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|m(m)?)$' | grep -v '#') &> /dev/null
fi
swift_format=$(command -v swiftformat 2>/dev/null)
if [ $? -eq 0 ]; then
if [ "$1" = "verify" ] ; then
for f in $(find daemon | grep -E '\.swift$' | grep -v '#') ; do
if [ $($swift_format --quiet --dryrun < "$f" | diff "$f" - | wc -l) -ne 0 ] ; then
exit 3
fi
done
else
$swift_format --quiet $(find daemon | grep -E '\.swift$' | grep -v '#')
fi
fi
jsonnet_format=$(command -v jsonnetfmt 2>/dev/null)
if [ $? -eq 0 ]; then
if [ "$1" = "verify" ]; then
if ! $jsonnet_format --test .drone.jsonnet; then
exit 4
fi
else
$jsonnet_format --in-place .drone.jsonnet
fi
fi

View File

@ -1,20 +0,0 @@
#!/bin/sh
. /etc/rc.subr
name=lokinet
rcvar=lokinet_enable
command="/usr/local/bin/${name}"
command_args="/usr/local/etc/${name}/daemon.ini > /dev/null 2>&1"
pidfile="/usr/local/etc/${name}/lokinet.pid"
required_files="/usr/local/etc/${name}/daemon.ini"
sig_reload="HUP"
start_precmd="${command} -g /usr/local/etc/${name}/daemon.ini"
load_rc_config $name
run_rc_command "$1"

26
contrib/keygen.py Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
#
# .loki secret key generator script
# makes keyfile contents
#
# usage: python3 keygen.py out.private
# python3 keygen.py > /some/where/over/the/rainbow
#
from nacl.bindings import crypto_sign_keypair
import sys
out = sys.stdout
close_out = lambda : None
args = sys.argv[1:]
if args and args[0] != '-':
out = open(args[0], 'wb')
close_out = out.close
pk, sk = crypto_sign_keypair()
out.write(b'64:')
out.write(sk)
out.flush()
close_out()

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.10)
project(udptest LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
add_executable(udptest udptest.cpp)
include_directories(../../include)
target_link_libraries(udptest PUBLIC lokinet)

View File

@ -0,0 +1,13 @@
# liblokinet examples
building:
$ mkdir -p build
$ cd build
$ cp /path/to/liblokinet.so .
$ cmake .. -DCMAKE_EXE_LINKER_FLAGS='-L.'
$ make
running:
$ ./udptest /path/to/bootstrap.signed

View File

@ -0,0 +1,239 @@
#include <lokinet.h>
#include <signal.h>
#include <memory>
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
bool _run{true};
using Lokinet_ptr = std::shared_ptr<lokinet_context>;
[[nodiscard]] auto
MakeLokinet(const std::vector<char>& bootstrap)
{
auto ctx = std::shared_ptr<lokinet_context>(lokinet_context_new(), lokinet_context_free);
if (auto err = lokinet_add_bootstrap_rc(bootstrap.data(), bootstrap.size(), ctx.get()))
throw std::runtime_error{strerror(err)};
if (lokinet_context_start(ctx.get()))
throw std::runtime_error{"could not start context"};
return ctx;
}
void
WaitForReady(const Lokinet_ptr& ctx)
{
while (_run and lokinet_wait_for_ready(1000, ctx.get()))
{
std::cout << "waiting for context..." << std::endl;
}
}
class Flow
{
lokinet_udp_flowinfo const _info;
lokinet_context* const _ctx;
public:
explicit Flow(const lokinet_udp_flowinfo* info, lokinet_context* ctx) : _info{*info}, _ctx{ctx}
{}
lokinet_context*
Context() const
{
return _ctx;
}
std::string
String() const
{
std::stringstream ss;
ss << std::string{_info.remote_host} << ":" << std::to_string(_info.remote_port)
<< " on socket " << _info.socket_id;
return ss.str();
}
};
struct ConnectJob
{
lokinet_udp_flowinfo remote;
lokinet_context* ctx;
};
void
CreateOutboundFlow(void* user, void** flowdata, int* timeout)
{
auto* job = static_cast<ConnectJob*>(user);
Flow* flow = new Flow{&job->remote, job->ctx};
*flowdata = flow;
*timeout = 30;
std::cout << "made outbound flow: " << flow->String() << std::endl;
;
}
int
ProcessNewInboundFlow(void* user, const lokinet_udp_flowinfo* remote, void** flowdata, int* timeout)
{
auto* ctx = static_cast<lokinet_context*>(user);
Flow* flow = new Flow{remote, ctx};
std::cout << "new udp flow: " << flow->String() << std::endl;
*flowdata = flow;
*timeout = 30;
return 0;
}
void
DeleteFlow(const lokinet_udp_flowinfo* remote, void* flowdata)
{
auto* flow = static_cast<Flow*>(flowdata);
std::cout << "udp flow from " << flow->String() << " timed out" << std::endl;
delete flow;
}
void
HandleUDPPacket(const lokinet_udp_flowinfo* remote, const char* pkt, size_t len, void* flowdata)
{
auto* flow = static_cast<Flow*>(flowdata);
std::cout << "we got " << len << " bytes of udp from " << flow->String() << std::endl;
}
void
BounceUDPPacket(const lokinet_udp_flowinfo* remote, const char* pkt, size_t len, void* flowdata)
{
auto* flow = static_cast<Flow*>(flowdata);
std::cout << "bounce " << len << " bytes of udp from " << flow->String() << std::endl;
if (auto err = lokinet_udp_flow_send(remote, pkt, len, flow->Context()))
{
std::cout << "bounce failed: " << strerror(err) << std::endl;
}
}
Lokinet_ptr sender, recip;
void
signal_handler(int)
{
_run = false;
}
int
main(int argc, char* argv[])
{
if (argc == 1)
{
std::cout << "usage: " << argv[0] << " bootstrap.signed" << std::endl;
return 1;
}
/*
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
*/
std::vector<char> bootstrap;
// load bootstrap.signed
{
std::ifstream inf{argv[1], std::ifstream::ate | std::ifstream::binary};
size_t len = inf.tellg();
inf.seekg(0);
bootstrap.resize(len);
inf.read(bootstrap.data(), bootstrap.size());
}
if (auto* loglevel = getenv("LOKINET_LOG"))
lokinet_log_level(loglevel);
else
lokinet_log_level("none");
std::cout << "starting up" << std::endl;
recip = MakeLokinet(bootstrap);
WaitForReady(recip);
lokinet_udp_bind_result recipBindResult{};
const auto port = 10000;
if (auto err = lokinet_udp_bind(
port,
ProcessNewInboundFlow,
BounceUDPPacket,
DeleteFlow,
recip.get(),
&recipBindResult,
recip.get()))
{
std::cout << "failed to bind recip udp socket " << strerror(err) << std::endl;
return 0;
}
std::cout << "bound recip udp" << std::endl;
sender = MakeLokinet(bootstrap);
WaitForReady(sender);
std::string recipaddr{lokinet_address(recip.get())};
std::cout << "recip ready at " << recipaddr << std::endl;
lokinet_udp_bind_result senderBindResult{};
if (auto err = lokinet_udp_bind(
port,
ProcessNewInboundFlow,
HandleUDPPacket,
DeleteFlow,
sender.get(),
&senderBindResult,
sender.get()))
{
std::cout << "failed to bind sender udp socket " << strerror(err) << std::endl;
return 0;
}
ConnectJob connect{};
connect.remote.socket_id = senderBindResult.socket_id;
connect.remote.remote_port = port;
std::copy_n(recipaddr.c_str(), recipaddr.size(), connect.remote.remote_host);
connect.ctx = sender.get();
std::cout << "bound sender udp" << std::endl;
do
{
std::cout << "try establish to " << connect.remote.remote_host << std::endl;
if (auto err =
lokinet_udp_establish(CreateOutboundFlow, &connect, &connect.remote, sender.get()))
{
std::cout << "failed to establish to recip: " << strerror(err) << std::endl;
usleep(100000);
}
else
break;
} while (true);
std::cout << "sender established" << std::endl;
const std::string buf{"liblokinet"};
const std::string senderAddr{lokinet_address(sender.get())};
do
{
std::cout << senderAddr << " send to remote: " << buf << std::endl;
if (auto err = lokinet_udp_flow_send(&connect.remote, buf.data(), buf.size(), sender.get()))
{
std::cout << "send failed: " << strerror(err) << std::endl;
}
usleep(100000);
} while (_run);
return 0;
}

45
contrib/lokinet-mac.svg Normal file
View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- our size/viewbox is positioned such that 0,0 is the center of the image (to simplify scaling and rotation). -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="-512px" y="-512px"
viewBox="-512 -512 1024 1024" style="enable-background:new -512 -512 1024 1024;" xml:space="preserve">
<style type="text/css">
.bg{fill:#FFFFFF;}
</style>
<!--
Draw the background shape in a 2x2 box (from -1 to 1 in each dimension), then scale it up
(but not all the way to 512, because we want some padding around the outside.
-->
<g transform="scale(415)">
<path class="bg" d="
M 0.5 1
H -0.5
C -0.81,1 -1,0.81 -1,0.5
V -0.5
C -1,-0.81 -0.81,-1 -0.5,-1
H 0.5
C 0.81,-1 1,-0.81 1,-0.5
V 0.5
C 1,0.81 0.81,1 0.5,1
z
"/>
</g>
<g id="shape0">
<!--
Start with a simple 3x2 shape, where each unit we draw corresponds to 1 block edge length in the
final diagram, and shift it so that 2.5x2.5 becomes the new origin (around which we will rotate).
Then we rotate and scale it to the desired size.
We can then copy that at 90, 180, 270 degree rotations to complete the logo.
-->
<g transform="rotate(45) scale(85) translate(-2.5, -2.5)">
<polygon points="0,0 2,0 2,1 1,1 1,2 0,2"/>
<rect x="1" y="2" width="1" height="1"/>
</g>
</g>
<use xlink:href="#shape0" transform="rotate(90)"/>
<use xlink:href="#shape0" transform="rotate(180)"/>
<use xlink:href="#shape0" transform="rotate(270)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

34
contrib/lokinet.svg Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- our size/viewbox is positioned such that 0,0 is the center of the image (to simplify scaling and rotation). -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="-512px" y="-512px"
viewBox="-512 -512 1024 1024" style="enable-background:new -512 -512 1024 1024;" xml:space="preserve">
<style type="text/css">
.bg{fill:#FFFFFF;}
</style>
<!--
Draw the background shape in a 2x2 box (from -1 to 1 in each dimension), then scale it up
(but not all the way to 512, because we want some padding around the outside.
-->
<g transform="scale(512)">
<circle r="1" class="bg"/>
</g>
<g id="shape0">
<!--
Start with a simple 3x2 shape, where each unit we draw corresponds to 1 block edge length in the
final diagram, and shift it so that 2.5x2.5 becomes the new origin (around which we will rotate).
Then we rotate and scale it to the desired size.
We can then copy that at 90, 180, 270 degree rotations to complete the logo.
-->
<g transform="rotate(45) scale(105) translate(-2.5, -2.5)">
<polygon points="0,0 2,0 2,1 1,1 1,2 0,2"/>
<rect x="1" y="2" width="1" height="1"/>
</g>
</g>
<use xlink:href="#shape0" transform="rotate(90)"/>
<use xlink:href="#shape0" transform="rotate(180)"/>
<use xlink:href="#shape0" transform="rotate(270)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

27
contrib/mac-configure.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
set -x
if ! [ -f LICENSE ] || ! [ -d llarp ]; then
echo "You need to run this as ./contrib/mac.sh from the top-level lokinet project directory" >&2
exit 1
fi
mkdir -p build-mac
cd build-mac
cmake \
-G Ninja \
-DBUILD_STATIC_DEPS=ON \
-DWITH_TESTS=OFF \
-DWITH_BOOTSTRAP=OFF \
-DNATIVE_BUILD=OFF \
-DWITH_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DMACOS_SYSTEM_EXTENSION=ON \
-DCODESIGN=ON \
-DBUILD_PACKAGE=ON \
"$@" \
..
echo "cmake build configured in build-mac"

Some files were not shown because too many files have changed in this diff Show More