Commit Graph

434 Commits

Author SHA1 Message Date
Jeff Becker
0cf637178d
prevent throwing on no error in lokinet-vpn 2022-11-02 15:42:49 -04:00
Jeff Becker
d911e26b1d
remove duplicate log statement 2022-11-01 19:09:17 -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
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
5be7dbf8ec
Move log init even earlier 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
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
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
Jason Rhinelander
d011f8fb4a
Bump clang-format to 14 2022-10-20 19:53:52 -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
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
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
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
c9d928950a
C-cast to work around gross enum==int assumption in windows API 2022-09-08 14:25:01 -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
majestrate
a8c0f76e1c
Merge pull request #1971 from majestrate/docs-and-such-2022-08-06
more docs
2022-09-03 08:03:28 -04: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
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
badf72838e
move all code directory readmes into docs/project-structure.md 2022-08-21 12:18:09 -04:00
Jason Rhinelander
2b7b1fcc79 Working signed macOS GUI build 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
jeff
b8896740de build gui and assemble app bundles into one singular app bundle 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
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
Jeff
23fd46c0db
add directory specific readmes 2022-07-26 09:26:28 -04:00
Jeff
8cde7c7e7a
fix win32 and android builds 2022-07-19 11:31:14 -04: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
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
majestrate
838183e36e
Merge pull request #1748 from majestrate/liblokinet-udp-api-2021-09-19
liblokinet updates
2022-02-06 13:19:08 -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 Becker
1feaec1169 build 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
2772a32907
* fix up lokinet cli help opts
* document doxygen
2021-12-10 10:40:18 -05:00
Jeff Becker
4c5b90fb03
handle exceptions on setup and config load without aborting 2021-10-06 15:36:29 -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
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
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 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