Commit Graph

68 Commits

Author SHA1 Message Date
Jason Rhinelander 1f16daf109 Replace epee C date crap with C++20 date backport 2021-11-01 14:54:18 -04:00
Jason Rhinelander 5b95224c39 Fix some missing LOKI -> OXEN logger defines
Various ones were unchanged in epee.

Also found a couple very old MONERO -> OXEN changes as well.
2021-08-19 16:03:32 -03:00
Jason Rhinelander b627b3b4bb Move epee includes under "epee/..."
This ends epee's include pollution.
2020-10-24 12:46:27 -03:00
Jason Rhinelander 1dd98f3dae std::filesystem
Converts all use of boost::filesystem to std::filesystem.

For macos and potentially other exotic systems where std::filesystem
isn't available, we use ghc::filesystem instead (which is a drop-in
replacement for std::filesystem, unlike boost::filesystem).

This also greatly changes how we handle filenames internally by holding
them in filesystem::path objects as soon as possible (using
fs::u8path()), rather than strings, which avoids a ton of issues around
unicode filenames.  As a result this lets us drop the boost::locale
dependency on Windows along with a bunch of messy Windows ifdef code,
and avoids the need for doing gross boost locale codecvt calls.
2020-10-24 12:45:37 -03:00
Jason Rhinelander fb0aff57f6 Replace epee http client with curl-based client
In short: epee's http client is garbage, standard violating, and
unreliable.

This completely removes the epee http client support and replaces it
with cpr, a curl-based C++ wrapper.  rpc/http_client.h wraps cpr for RPC
requests specifically, but it is also usable directly.

This replacement has a number of advantages:

- requests are considerably more reliable.  The epee http client code
  assumes that a connection will be kept alive forever, and returns a
  failure if a connection is ever closed.  This results in some very
  annoying things: for example, preparing a transaction and then waiting
  a long tim before confirming it will usually result in an error
  communication with the daemon.  This is just terribly behaviour: the
  right thing to do on a connection failure is to resubmit the request.

- epee's http client is broken in lots of other ways: for example, it
  tries throwing SSL at the port to see if it is HTTPS, but this is
  protocol violating and just breaks (with a several second timeout) on
  anything that *isn't* epee http server (for example, when lokid is
  behind a proxying server).

- even when it isn't doing the above, the client breaks in other ways:
  for example, there is a comment (replaced in this PR) in the Trezor PR
  code that forces a connection close after every request because epee's
  http client doesn't do proper keep-alive request handling.

- it seems noticeably faster to me in practical use in this PR; both
  simple requests (for example, when running `lokid status`) and
  wallet<->daemon connections are faster, probably because of crappy
  code in epee.  (I think this is also related to the throw-ssl-at-it
  junk above: the epee client always generates an ssl certificate during
  static initialization because it might need one at some point).

- significantly reduces the amount of code we have to maintain.

- removes all the epee ssl option code: curl can handle all of that just
  fine.

- removes the epee socks proxy code; curl can handle that just fine.
  (And can do more: it also supports using HTTP/HTTPS proxies).

- When a cli wallet connection fails we know show why it failed (which
  now is an error message from curl), which could have all sorts of
  reasons like hostname resolution failure, bad ssl certificate, etc.
  Previously you just got a useless generic error that tells you
  nothing.

Other related changes in this PR:

- Drops the check-for-update and download-update code.  To the best of
my knowledge these have never been supported in loki-core and so it
didn't seem worth the trouble to convert them to use cpr for the
requests.

- Cleaned up node_rpc_proxy return values: there was an inconsistent mix
  of ways to return errors and how the returned strings were handled.
  Instead this cleans it up to return a pair<bool, val>, which (with
  C++17) can be transparently captured as:

    auto [success, val] = node.whatever(req);

  This drops the failure message string, but it was almost always set to
  something fairly useless (if we want to resurrect it we could easily
  change the first element to be a custom type with a bool operator for
  success, and a `.error` attribute containing some error string, but
  for the most part the current code wasn't doing much useful with the
  failure string).

- changed local detection (for automatic trusted daemon determination)
  to just look for localhost, and to not try to resolve anything.
  Trusting non-public IPs does not work well (e.g. with lokinet where
  all .loki addresses resolve to a local IP).

- ssl fingerprint option is removed; this isn't supported by curl
  (because it is essentially just duplicating what a custom cainfo
  bundle does)

- --daemon-ssl-allow-chained is removed; it wasn't a useful option (if
  you don't want chaining, don't specify a cainfo chain).

- --daemon-address is now a URL instead of just host:port.  (If you omit
  the protocol, http:// is prepended).

- --daemon-host and --daemon-port are now deprecated and produce a
  warning (in simplewallet) if used; the replacement is to use
  --daemon-address.

- --daemon-ssl is deprecated; specify --daemon-address=https://whatever
  instead.

- the above three are now hidden from --help

- reordered the wallet connection options to make more logical sense.
2020-08-07 17:14:03 -03:00
Jason Rhinelander 24f084a73c Miscellaneous header updates via iwyu
Adds some missing required headers and removes some unnecessary ones.
2020-07-02 12:52:13 -03:00
Howard Chu 3b8dd4b25b Updated RandomX integration from upstream
Support RandomX PoW algorithm
2019-09-25 17:12:23 -03:00
moneromooo-monero 9fc266df58 epee: misc_log_ex.h can now be used in C code
use mfatal/merror/mwarning/minfo/mdebug/mtrace
2019-09-25 14:46:53 -03:00
Jason Rhinelander b0e2de3c1b Don't include stack trace dumping at default log-level (#710)
There are several places in loki now that legitimate use caught
exceptions, and these are polluting the logs (even at log-level=0) with
unnecessary stack traces which aren't actually errors to worry about.
2019-07-04 13:21:13 +10:00
Doyle e6c97579df Merge commit '5e80b3c' into LokiMergeUpstream 2019-05-17 04:14:11 +10:00
moneromooo-monero 367bb80ae7
mlog: default to not showing SSL errors 2019-05-06 07:38:52 +00:00
Doyle d4bc8106e1 Merge commit '581994b' into LokiMergeUpstream 2019-05-02 14:15:02 +10:00
moneromooo-monero 7a9316ebef
serialization: set default log category 2019-04-21 09:26:25 +00:00
doy-lee 085d452eb4 Merge commit 'e344d93' into LokiMergeUpstream 2019-01-17 15:59:38 +11:00
doy-lee 40506127a4 Merge commit '7e957c1' into LokiMergeUpstream 2018-12-11 13:46:35 +11:00
moneromooo-monero 0e2f5cb5fc
perf_timer: make all logs Info level
and make them not default at log level 1
2018-12-08 10:53:09 +00:00
moneromooo-monero 96e6b43970
blockchain_stats: don't use gmtime_r on Windows
In some cases, it doesn't like it (I don't know the details).

Factor into a new epee function
2018-11-21 00:50:53 +00:00
doy-lee 913b3a40b5 Merge commit '2287fb9' into CherryPickUnboundWindowsBuildFix 2018-10-22 15:43:00 +11:00
doy-lee 339f96b0cc Merge commit 'c23b6f8' into LokiMergeUpstreamUntil_20181010_77e1ebf 2018-10-10 15:07:16 +11:00
doy-lee c73da116ae Merge commit '4a652d6' into LokiMergeUpstreamUntil_20180911_e6d36c1 2018-10-10 13:48:01 +11:00
iDunk5400 2e2daebcc9
ANSI colors in Windows 10 2018-10-08 14:56:16 +02:00
Riccardo Spagni effcbf2060
Merge pull request #4459
bcf3f6af fuzz_tests: catch unhandled exceptions (moneromooo-monero)
3ebd05d4 miner: restore stream flags after changing them (moneromooo-monero)
a093092e levin_protocol_handler_async: do not propagate exception through dtor (moneromooo-monero)
1eebb82b net_helper: do not propagate exceptions through dtor (moneromooo-monero)
fb6a3630 miner: do not propagate exceptions through dtor (moneromooo-monero)
2e2139ff epee: do not propagate exception through dtor (moneromooo-monero)
0749a8bd db_lmdb: do not propagate exceptions in dtor (moneromooo-monero)
1b0afeeb wallet_rpc_server: exit cleanly on unhandled exceptions (moneromooo-monero)
418a9936 unit_tests: catch unhandled exceptions (moneromooo-monero)
ea7f9543 threadpool: do not propagate exceptions through the dtor (moneromooo-monero)
6e855422 gen_multisig: nice exit on unhandled exception (moneromooo-monero)
53df2deb db_lmdb: catch error in mdb_stat calls during migration (moneromooo-monero)
e67016dd blockchain_blackball: catch failure to commit db transaction (moneromooo-monero)
661439f4 mlog: don't remove old logs if we failed to rename the current file (moneromooo-monero)
5fdcda50 easylogging++: test for NULL before dereference (moneromooo-monero)
7ece1550 performance_test: fix bad last argument calling add_arg (moneromooo-monero)
a085da32 unit_tests: add check for page size > 0 before dividing (moneromooo-monero)
d8b1ec8b unit_tests: use std::shared_ptr to shut coverity up about leaks (moneromooo-monero)
02563bf4 simplewallet: top level exception catcher to print nicer messages (moneromooo-monero)
c57a65b2 blockchain_blackball: fix shift range for 32 bit archs (moneromooo-monero)
2018-09-29 22:20:38 +02:00
doy-lee 3f85a1b716 Merge commit '89645ec' into LokiMergeUpstream20180821 2018-09-25 17:50:49 +10:00
moneromooo-monero 4d52ec0ca4
mlog: do not display http errors by default
They're controllable by potential attackers and would just spam
2018-09-14 09:23:00 +00:00
Doyle T de8c58204d Merge commit '31f47d7' into LokiMergeUpstream 2018-08-21 15:08:21 +10:00
Doyle T 67c38b4861 Merge commit '51cdd76' into LokiMergeUpstream 2018-08-21 13:30:32 +10:00
moneromooo-monero 262e391fb1
mlog: handle filenames without parent directories
eg, --log-file=foo.log

This would otherwise throw and crash with a stack overflow
2018-07-26 22:49:54 +01:00
luigi1111 c0c6102260
Merge pull request #3972
8766528 epee: fallback to a counter if gmtime fails when rotating logs (moneromooo-monero)
2018-06-25 15:21:25 -05:00
stoffu 63d0ab09b5
mlog: --max-log-files to set the max number of rotated log files 2018-06-13 12:44:27 +09:00
moneromooo-monero 87665281ea
epee: fallback to a counter if gmtime fails when rotating logs 2018-06-09 19:23:48 +01:00
jcktm 956263a936 Merge remote-tracking branch 'monero/master' into merge-upstream-changes 2018-05-01 12:26:17 +10:00
moneromooo-monero 18c2f6e21d
mlog: fix setting no logs 2018-04-25 20:42:11 +01:00
Doyle T 808c07768c Update cmakelists and misc refs to Loki 2018-04-25 16:13:38 +10:00
Doyle T 161eda3fd1 First pass Monero to Loki refs 2018-04-10 14:49:20 +10:00
moneromooo-monero 38c8f4e0a3
mlog: terminate a string at last char, just in case 2017-12-18 15:15:16 +00:00
moneromooo-monero 09ce03d612
move includes around to lessen overall load 2017-12-16 22:46:38 +00:00
moneromooo-monero bc1b93333e
frob level 1 logs a bit for consistency
Level 1 logs map to INFO, so setting log level to 1 should
show these. Demote some stuff to DEBUG to avoid spam, though.
2017-10-07 20:03:42 +01:00
Riccardo Spagni 3bab2676ec
Merge pull request #2512
792ba4f0 Log categories can now be added to and removed from (moneromooo-monero)
48f92eb6 easylogging++: add categories getter (moneromooo-monero)
f35afe62 epee: factor log level/categories setting (moneromooo-monero)
2017-10-02 23:28:59 +04:00
moneromooo-monero 792ba4f0fe
Log categories can now be added to and removed from
Also, set_log without parameters now prints the log categories
2017-09-22 18:08:14 +01:00
moneromooo-monero f35afe62a4
epee: factor log level/categories setting 2017-09-22 14:14:58 +01:00
selsta 91def9a59b daemon, wallet: add --max-log-file-size option 2017-09-17 04:42:45 +02:00
moneromooo-monero cb2d5110ff
Tweak net logs so we get more info on why networking can't start
This should prevent "silent" failures to start
2017-08-15 19:49:25 +01:00
Riccardo Spagni b76ba219d9
Merge pull request #2189
335fc8ab mlog: fix crash accessing stale data when rotating logs (moneromooo-monero)
2017-08-07 15:25:46 +02:00
moneromooo-monero 599436a452
mlog: default to msgwriter logs only for log level 1
There might be privacy issues doing it by default
2017-07-24 10:34:52 +01:00
moneromooo-monero 335fc8ab23
mlog: fix crash accessing stale data when rotating logs 2017-07-22 19:15:44 +01:00
Riccardo Spagni 4014f31a73
Merge pull request #2173
a02d7458 mlog: make MONERO_LOGS env var understand N,logs type spec (moneromooo-monero)
2017-07-19 11:51:50 +02:00
moneromooo-monero a02d745844
mlog: make MONERO_LOGS env var understand N,logs type spec 2017-07-15 10:23:24 +01:00
moneromooo-monero 9706938016
mlog: add msgwriter:INFO to log 0 and 1 defaults
This ensures command output gets logged by default
2017-07-06 13:18:04 +01:00
stoffu dd8e3266b2
shared libs build (i.e. make debug) 2017-05-17 10:17:08 +09:00
moneromooo-monero 62efe5f656
mlog: direct log category changes to file only
Because some people just won't even try to read what is written
and freak out because the word FATAL is in here, despite the
context making it clear it's not an error.
2017-04-01 11:29:43 +01:00