Compare commits

..

174 Commits

Author SHA1 Message Date
wowario
c70878b54e update git urls 2020-06-28 18:01:22 +03:00
jw
c8ed320949 Merge pull request #280 from wowario/gitian
gitian rename to wownero
2020-06-28 07:19:25 -07:00
jw
f7ba826cd2 Merge pull request #279 from wowario/warning
fix warning by removing std::move() on temporary http_client object
2020-06-28 07:19:12 -07:00
jw
e91b041c75 Merge pull request #278 from wowario/checkpoints
build: prepare v0.8.0.1 release
2020-06-28 07:18:43 -07:00
jw
aefce0c5fe Merge pull request #277 from wowario/off
build: disable trezor
2020-06-28 07:18:27 -07:00
jw
2f8ccfe0ca Merge pull request #276 from wowario/upstream
Upstream
2020-06-28 07:18:12 -07:00
wowario
a85e6fc276 gitian rename to wownero 2020-06-28 11:12:07 +03:00
woodser
0ce2ef719f fix warning by removing std::move() on temporary http_client object 2020-06-27 10:16:23 +03:00
wowario
9f5fa3f7f9 update checkpoints 2020-06-27 10:05:27 +03:00
wowario
c5e224944e build: disable trezor 2020-06-27 04:44:34 +03:00
Dusan Klinec
b5b1463487 add trezor support to sweep_single 2020-06-27 04:04:54 +03:00
moneromooo-monero
ae60c289f9 epee: fix array underflow in unicode parsing
Reported by minerscan

Also independently found by OSS-Fuzz just recently
2020-06-27 04:04:35 +03:00
moneromooo-monero
6da460a8df tx_pool: mine stem txes in fake chain mode
This fixes the functional tests, since txes would not be mined
after being sent to the daemon (they'd be waiting for the
dandelion timeout first)
2020-06-27 04:04:20 +03:00
moneromooo-monero
72655f78fc blockchain: fix timestamp/difficulty cache getting out of sync
The cache is discarded when a block is popped, but then gets
rebuilt when the difficulty for next block is requested.
While this is all properly locked, it does not take into account
the delay caused by a database transaction being only committed
(and thus its effects made visible to other threads) later on,
which means another thread could request difficulty between
the pop and the commit, which would end up using stale database
view to build the cache, but that cache would not be invalidated
again when the transaction gets committed, which would cause the
cache to not match the new database data.

To fix this, we now keep track of when the cache is invalidated
so we can invalidate it again upon database transaction commit
to ensure it gets calculated again with fresh data next time it
is nedeed.
2020-06-27 03:58:50 +03:00
Lee Clagett
4be84b7753 Fix D++ block template check 2020-06-27 03:53:37 +03:00
moneromooo-monero
b3847bc194 blockchain: fix total_height in getblocks.bin response 2020-06-27 03:53:19 +03:00
moneromooo-monero
c573ee65f6 rpc: fix loading rpc payment data from file
Got broken after making one of those micro optimizations requested on review..
2020-06-27 03:53:03 +03:00
moneromooo-monero
eb49cb728e rpc: fix comparison of seconds vs microseconds 2020-06-27 03:52:50 +03:00
moneromooo-monero
fd83d71bc7 functional_tests: add simple relay_tx test 2020-06-27 03:52:37 +03:00
moneromooo-monero
da1720ec30 rpc: fix relay_tx error return mixup 2020-06-27 03:52:22 +03:00
moneromooo-monero
6c652ef1ad daemon: remove time based "update needed" status string 2020-06-27 03:52:09 +03:00
moneromooo-monero
e592a515db rpc: don't display invalid json errors on default log level
It's not something the user needs to know, and will display
attacker controlled data
2020-06-27 03:51:55 +03:00
François Colas
5df0ffb57c Fix incorrect lenght of command INS_PREFIX_HASH
buffer_send[4] (LC) is an unsigned char, len should not
exceed 254 (255 - 1 for the option).
2020-06-27 03:51:41 +03:00
Denis Smirnov
d9939ce2fa fix typo in pick_preferred_rct_inputs 2020-06-27 03:51:27 +03:00
jw
29ebcc4e7e Merge pull request #274 from wowario/upstream
Upstream
2020-06-23 07:29:48 -07:00
jw
d759d13815 Merge pull request #272 from 00-matt/readme-gentoo
readme: Add Gentoo install instructions
2020-06-23 07:29:34 -07:00
jw
31ef8e30c4 Merge pull request #271 from wowario/rename
mining_status print output
2020-06-23 07:28:47 -07:00
jw
34779a4047 Merge pull request #270 from 00-matt/fix-boost173
Fix boost compatibility
2020-06-23 07:28:25 -07:00
jw
1b5a28351d Merge pull request #268 from Aluisyo/patch-5
update ppa keyserver keys
2020-06-23 07:27:15 -07:00
moneromooo-monero
c5d7dd9f18 fix a few typos in error messages
Reported by adrelanos
2020-06-23 07:27:04 +03:00
selsta
a4e2fac1ff workflows: update msys2 setup action v0 -> v1 2020-06-23 07:19:45 +03:00
selsta
b993d1b833 workflows: fix windows build 2020-06-22 18:41:43 +03:00
Matt Smith
d8b68a6369 readme: Add Gentoo install instructions 2020-06-22 15:06:37 +01:00
wowario
7c2b754321 mining_status print output 2020-06-22 17:05:23 +03:00
Lee Clagett
da7e511967 Fix boost <1.60 compilation and fix boost 1.73+ warnings 2020-06-22 15:01:41 +01:00
Suzyo Nyirenda
95afa9c538 update ppa keyserver keys 2020-06-10 13:26:58 +02:00
jw
c3e70dffc5 Merge pull request #264 from wowario/readme
remove link
2020-06-03 07:42:54 -07:00
清武 博二
72effc5c07 remove link 2020-06-03 08:52:30 +03:00
moneromooo-monero
804c985ecc rpc: add a sanity limit to a few RPC in restricted mode 2020-05-25 13:09:51 +03:00
moneromooo-monero
1861889b31 rpc: lock access to the rpc payment object 2020-05-25 13:09:37 +03:00
rbrunner7
81f79d900b [release-v0.16] MMS: New 'config_checksum' subcommand 2020-05-25 13:09:20 +03:00
Doyle
e0a9633557 ByteSlice: Fix persisting ptr to std::moved SSO buffer
The Bug:
1. Construct `byte_slice.portion_` with `epee::span(buffer)` which copies a pointer to the SSO buffer to `byte_slice.portion_`
2. It constructs `byte_slice.storage_` with `std::move(buffer)` (normally this swap pointers, but SSO means a memcpy and clear on the original SSO buffer)
3. `slice.data()` returns a pointer from `slice.portion_` that points to the original SSO cleared buffer, `slice.storage_` has the actual string.
2020-05-25 13:07:28 +03:00
moneromooo-monero
19f284ddf9 cryptonote_core: remove "We are most likely forked" message
It's time based and we don't have forks every 6 months anymore
2020-05-25 13:05:32 +03:00
moneromooo-monero
9c10229268 protocol: move the "peer claims higher version" warning to debug
Because there's a neverending supply of cunts claiming a wrong
version just to say "look at me" I guess
2020-05-25 13:05:18 +03:00
moneromooo-monero
18cb1753b7 wallet2: fix multisig data clearing stomping on a vector 2020-05-25 13:05:04 +03:00
moneromooo-monero
4eb2f5c2c8 serialization: fix bad rapidjson api usage 2020-05-25 13:04:50 +03:00
moneromooo-monero
e062e1efe3 cryptonote_protocol: stricter limit to number of objects requested
Reported by xnbya
2020-05-25 13:04:32 +03:00
moneromooo-monero
24660441a9 cryptonote_protocol: reject requests/notifications before handshake
Reported by xnbya
2020-05-25 13:04:17 +03:00
moneromooo-monero
1125b332d2 easylogging++: sanitize log payload
Some of it might be coming from untrusted sources

Reported by itsunixiknowthis
2020-05-25 13:04:04 +03:00
moneromooo-monero
009abd48e5 blockchain: detect and log bad difficulty calculations 2020-05-25 13:03:45 +03:00
moneromooo-monero
60cf237210 protocol: don't drop a connection if we can't get a compatible chain
This can now happen if:
- we have a pruned db
- we have not connected to the monero network for a while
- we connect to a node
- that node asks us for history
- we only have a pruned version of the most recent common block

In that case, it's better to not reply but keep the connection alive,
so we can sync off it.
2020-05-25 12:59:32 +03:00
moneromooo-monero
4ef1ab3e38 epee: use memwipe rather than memset for md5 secrets
That's used by HTTP auth now
2020-05-25 12:59:18 +03:00
jw
a37da20bc7 Merge pull request #261 from wowario/fix
build: fix boost 1.73 compatibility
2020-05-22 11:32:55 -07:00
selsta
7f868fafcc build: fix boost 1.73 compatibility 2020-05-22 21:27:12 +03:00
jw
1271a7e3a9 Merge pull request #259 from wowario/comment
comment out v16 fork
2020-05-19 11:51:20 -07:00
wowario
7a545ddc2d comment out v16 fork 2020-05-19 06:51:48 +03:00
jw
16a1f497e3 Merge pull request #258 from fuwa0529/SHA-3-tests
Sha 3 tests
2020-05-18 15:04:20 -07:00
jw
70804bd639 Merge pull request #257 from wowario/readme
add fork date to README.md
2020-05-18 15:04:10 -07:00
jw
3b1c27db69 Merge pull request #256 from wowario/SHA-3
switch to SHA-3 PoW
2020-05-18 15:03:57 -07:00
fuwa
ac29d15fc3 hash_tests: add sha3 2020-05-15 22:02:05 +08:00
fuwa
4b5eda696f hash_tests: disable slow-4, since wow uses cn-r 2020-05-15 22:01:59 +08:00
fuwa
533f58dae6 tests: fix build for wow 2020-05-15 22:01:56 +08:00
wowario
eeffe5c719 add fork date to README.md 2020-05-15 08:50:40 +03:00
wowario
87dcc37776 switch to SHA-3 PoW
Co-authored-by: fuwa <fuwa0529@users.noreply.github.com>
2020-05-15 08:37:36 +03:00
jw
6e43f020ae Merge pull request #255 from wowario/last
upstream
2020-05-14 08:40:03 -07:00
jw
57a5022f7d Merge pull request #254 from wowario/build
build: prepare v0.8.0.0 release
2020-05-14 08:39:46 -07:00
Lee Clagett
4c757a7a2a Fixed bugs for take_slice and byte_stream->byte_slice 2020-05-14 18:25:49 +03:00
moneromooo-monero
febb8df4bb blockchain: fix theoretical race getting bulk timestamps 2020-05-14 18:25:14 +03:00
moneromooo-monero
e74aff06c2 simplewallet: don't complain about incoming payment ids on change 2020-05-14 18:24:45 +03:00
wowario
7e3dbdde05 build: prepare v0.8.0.0 release 2020-05-14 17:44:48 +03:00
jw
116d29906c Merge pull request #253 from wowario/testforks
add testnet fork heights
2020-05-11 09:22:15 -07:00
wowario
9d31efa09e add testnet fork heights 2020-05-11 18:37:41 +03:00
jw
12a2a4084b Merge pull request #252 from wowario/testnet
refactor difficulty for testnet
2020-05-11 07:35:01 -07:00
jw
d1859d6224 Merge pull request #251 from wowario/upstream
Upstream
2020-05-11 07:05:44 -07:00
wowario
193c15ecce refactor difficulty for testnet 2020-05-09 23:22:28 +03:00
xiphon
eeadc8b723 p2p: startup speedup, init seed nodes on first 'connect_to_seed()' 2020-05-09 12:14:03 +03:00
moneromooo-monero
3a8f49f79c cryptonote_core: take out the time based upgrade warning
It doesn't really work anymore since we don't have a fork soon
2020-05-09 11:41:37 +03:00
xiphon
1e981f5be6 wallet2: fix keys file deserialization exception handling 2020-05-09 11:41:04 +03:00
moneromooo-monero
b59ef9a359 cryptonote_protocol: do not request pruned borromean sig txes
We don't have a function to calculate their weight from a pruned
version (yet).
2020-05-09 11:40:31 +03:00
Lee Clagett
e1bba18cc5 Fixes for ZMQ JSON-RPC endpoint names for raw tx 2020-05-09 11:40:06 +03:00
moneromooo-monero
a018e01370 wallet2: fix subaddress expansion when receiving monero 2020-05-09 11:39:42 +03:00
moneromooo-monero
014bc83b5e message_store: don't print an error when there is no mms file
It confuses people
2020-05-09 11:39:15 +03:00
xiphon
a0048e2a49 rpc: fix 'use_bootstrap_daemon_if_necessary' return value 2020-05-09 11:38:49 +03:00
xiphon
30ed4a23bf wallet2: check_connection return false on get_version status != OK 2020-05-09 11:38:25 +03:00
Lee Clagett
0e59f26064 Used legacy category to match insert_key_images behavior 2020-05-09 11:38:05 +03:00
Lee Clagett
a3fc63fa78 Revert functional test changes in babf25d2e and 571546067 2020-05-09 11:37:44 +03:00
moneromooo-monero
0c201ab438 cryptonote: fix reuse of non default tx data when relaying
An automatic tx variable is initialized properly on the first
run through the loop, but not the second. Moving the variable
inside the loop ensures the ctor is called again to init it.
2020-05-09 11:37:19 +03:00
xiphon
4cb99f9365 cryptonote_core: skip dns checkpoints on startup if not enforced 2020-05-09 11:36:53 +03:00
moneromooo-monero
c26c40472d simplewallet: report timestamp based expected unlock time on balance 2020-05-09 11:36:23 +03:00
moneromooo-monero
9ac662cb14 use memwipe on secret k/alpha values
Reported by UkoeHB_ and sarang
2020-05-09 11:35:47 +03:00
Lee Clagett
0b8e49a0aa Add byte_stream for zero-copy serialization, and add support in ZMQ-JSON. 2020-05-09 11:35:23 +03:00
jw
f879d48df7 Merge pull request #250 from wowario/upstream
Upstream
2020-05-04 08:27:07 -07:00
jw
603ca020ed Merge pull request #249 from fuwa0529/remove-unbound-rebased
Remove remove unbound
2020-05-04 08:26:40 -07:00
Sarang Noether
ecc2c3b707 Bulletproofs: verification speedup 2020-05-04 17:45:02 +03:00
Sumo Gr
8347fb8d58 unit_tests: fix gcc+ warning 2020-05-04 17:45:02 +03:00
xiphon
2b8bab2132 bootstrap_daemon: fix missing virtual destructor and lambda capture (clang warning) 2020-05-04 17:45:02 +03:00
mj-xmr
9b70fad289 FindCcache automatically 2020-05-04 17:45:02 +03:00
moneromooo-monero
4aad596a95 simplewallet: add sweep_account command
Expects an account number, then the usual sweep_all options

Useful to move monero that was accidentally sent to a subaddress
with a very large account index.
2020-05-04 17:45:02 +03:00
Dusan Klinec
ebe75aaa5f trezor: adapt to new passphrase mechanism
- choice where to enter passphrase is now made on the host
- use wipeable string in the comm stack
- wipe passphrase memory
- protocol optimizations, prepare for new firmware version
- minor fixes and improvements
- tests fixes, HF12 support
2020-05-04 17:45:01 +03:00
Sumo Gr
f5765455c5 simplewallet : missing function block separator 2020-05-04 17:45:01 +03:00
sumogr
9fde7e7253 simplewallet: fix strings (show_transfers & export_transfers) 2020-05-04 10:14:57 +03:00
cslashm
43cadb23b6 Add timelock verification on device 2020-05-04 10:14:35 +03:00
ArqTras
b5920da958 openssl update
Not available source updated

g version
2020-05-04 10:14:11 +03:00
Lee Clagett
9fb542e89c Use byte_slice for sending zmq messages - removes data copy within zmq 2020-05-04 10:13:38 +03:00
Sumo Gr
39e2802b9a txpool.cpp: rename var to fix for old g++ version (xenial default) 2020-05-04 10:13:12 +03:00
Lee Clagett
2f8fff39bf Always reject duplicate key-images from second txid 2020-05-04 10:12:11 +03:00
Lee Clagett
839a9e3707 Allow unrestricted rpc calls to get full txpool info 2020-05-04 10:11:52 +03:00
moneromooo-monero
2dcfca2799 functional_tests: ensure signatures never reuse a timestamp 2020-05-04 10:11:31 +03:00
moneromooo-monero
47b8e6437a functional_tests: ensure signed timestamps are fresh
This fixes a test failure now that timestamps are more constrained
2020-05-04 10:11:11 +03:00
xiphon
a0b1b89534 wallet_api: checkUpdate - optional version and buildtag params 2020-05-04 10:10:37 +03:00
Sumo Gr
b38aac4a81 update openssl 1.0.2r link 2020-05-04 10:10:12 +03:00
moneromooo-monero
0df692a814 daemon: fix print_net_stats RPC calls 2020-05-04 10:08:49 +03:00
Lee Clagett
b7be110ec3 Fixed string_ref usage bug in epee::from_hex::vector 2020-05-04 10:08:22 +03:00
woodser
3278e86ed8 Allow wallet2.h to run in WebAssembly
- Add abstract_http_client.h which http_client.h extends.
- Replace simple_http_client with abstract_http_client in wallet2,
message_store, message_transporter, and node_rpc_proxy.
- Import and export wallet data in wallet2.
- Use #if defined __EMSCRIPTEN__ directives to skip incompatible code.
2020-05-04 10:07:52 +03:00
rbrunner7
5fcc5da9f7 Daemon: Print estimates for time until fully synced 2020-05-04 10:07:26 +03:00
fuwa
8f17e8c0af Revert "remove unbound"
This reverts commit d9e982cba569c72a17801857addd4fb9ad929449.
2020-05-02 16:47:02 +08:00
fuwa
03743db2ed Revert "fix unbound on static build"
This reverts commit 86b6758dad0137fb997b320892ff7e59c575d26a.
2020-05-02 16:47:02 +08:00
jw
56c01e22bc Merge pull request #248 from qvqc/dev-v0.8
WOW'up translations
2020-04-30 09:36:19 -07:00
qvqc
6a5f0688b8 WOW'up translations 2020-04-30 11:55:27 -04:00
jw
459f8da6af Merge pull request #246 from wownero/revert-245-tor
Revert "allow sync over tor"
2020-04-22 17:05:05 -07:00
jw
acab673a6e Revert "allow sync over tor" 2020-04-22 17:03:37 -07:00
jw
ed16ffcb4e Merge pull request #245 from fuwa0529/tor
allow sync over tor
2020-04-22 16:32:42 -07:00
fuwa
d3184d030d allow sync over tor 2020-04-23 06:35:50 +08:00
jw
a17e36f1f5 Merge pull request #244 from qvqc/dev-v0.8
Dev v0.8
2020-04-22 14:53:13 -07:00
qvqc
7747151e98 update current seed nodes 2020-04-22 17:10:35 -04:00
qvqc
24974ccd36 update p2p peers in readme 2020-04-22 17:10:14 -04:00
jw
9312008532 Merge pull request #242 from fuwa0529/dev-v0.8
add tor peers
2020-04-22 10:58:28 -07:00
fuwa
7a73554c04 add tor peers 2020-04-22 21:43:32 +08:00
jw
b39feaad30 Merge pull request #240 from fuwa0529/dev-v0.8
duplicate v0.8 ASCII art in wallet-rpc
2020-04-18 10:18:23 -07:00
jw
67eaf231ad Merge pull request #239 from wowario/upstream
Upstream
2020-04-18 10:17:58 -07:00
fuwa
c74ff98e78 duplicate v0.8 ASCII art in wallet-rpc 2020-04-19 00:26:59 +08:00
Lee Clagett
94f4af6cc4 Adding Dandelion++ support to public networks:
- New flag in NOTIFY_NEW_TRANSACTION to indicate stem mode
  - Stem loops detected in tx_pool.cpp
  - Embargo timeout for a blackhole attack during stem phase
2020-04-18 11:24:38 +03:00
Lee Clagett
d4c7ae4554 Correct key image check in tx_pool 2020-04-18 11:24:04 +03:00
Sumo Gr
8d6e97ba0d depends: update qt 5.7.1 download link
5.7.1 was removed from official qt.io archive, this is one of the few mirrors remaining that keep a copy.
I think it would be better if @TheCharlatan updated to a newer version soon than merging this PR
2020-04-18 11:23:39 +03:00
moneromooo-monero
a33c86d875 blockchain_db: faster fetching of consecutive txes
Useful for wallet refresh or node sync
2020-04-18 11:23:01 +03:00
moneromooo-monero
b33dfc2ee4 simplewallet: fix smart mining not starting after first setup
Also avoid rewriting the wallet if the setting is already was we need
2020-04-18 11:22:32 +03:00
moneromooo-monero
1bbb2cbd63 simplewallet: new "address one-off <major> <minor>" command 2020-04-18 11:22:02 +03:00
jw
ca0abf8615 Merge pull request #238 from fuwa0529/dev-v0.8
fix unbound on static build
2020-04-12 10:53:27 -07:00
fuwa
146f5ea3f4 fix unbound on static build 2020-04-12 23:37:57 +08:00
jw
dc517f5da6 Merge pull request #237 from fuwa0529/dev-v0.8
remove unbound
2020-04-12 07:55:47 -07:00
fuwa
f516f8ce23 remove unbound 2020-04-12 19:35:55 +08:00
jw
b0e3091152 Merge pull request #236 from wowario/rebase
Rebase
2020-04-06 08:12:44 -07:00
wowario
f30b320d41 update Dockerfile 2020-04-06 18:04:07 +03:00
wowario
ca5db2fb30 update PKGBUILD 2020-04-06 18:03:58 +03:00
wowario
3c0737a8c0 drop test build 2020-04-06 15:21:12 +03:00
wowario
40d7bec2a7 update approx_blockchain_height 2020-04-06 14:26:05 +03:00
wowario
4fae945114 bender 2020-04-06 14:06:42 +03:00
wowario
c9a8f4f01c update checkpoints.dat 2020-04-06 13:10:35 +03:00
wowario
69663861e0 add v0.8 ASCII art 2020-04-06 09:47:39 +03:00
wowario
aafa830f85 update RandomWOW submodule 2020-04-06 09:40:49 +03:00
wowario
6a9515697e build: prepare v0.7.1.0 update
Signed-off-by: wowario <wowario@protonmail.com>
2020-04-06 09:09:32 +03:00
清武 博二
65f6d4cc47 Update README.md 2020-04-06 09:09:32 +03:00
wowario
5ebb10cb5b remove ded code 2020-04-06 09:09:32 +03:00
wowario
0705cff367 add wowario gpg key 2020-04-06 09:09:32 +03:00
wowario
2185265e44 update tor addresses 2020-04-06 09:09:32 +03:00
fuwa
3434473395 update the package name on NixOS 2020-04-06 09:09:31 +03:00
wowario
9d1e2828d4 absurdity day hard fork 2020-04-06 09:09:31 +03:00
wowario
cd36916956 update README 2020-04-06 09:09:31 +03:00
wowario
2bcaa4ec02 update checkpoints.dat 2020-04-06 09:09:31 +03:00
wowario
17d4fb378e fix hash2rct in get_exponent 2020-04-06 09:09:31 +03:00
fuwa
b78a40f7a4 fix cn-pow variant 2020-04-06 09:09:31 +03:00
wowario
cf607654b6 add RandomWOW submodule 2020-04-06 09:09:31 +03:00
wowario
a2ab66e258 remove Randomx submodule 2020-04-06 09:09:30 +03:00
fuwa
f764cf0626 remove zeromq completely 2020-04-06 09:09:30 +03:00
fuwa
338771fe21 hotfix "no ring" error 2020-04-06 09:09:30 +03:00
Suzyo Nyirenda
87f6f29c4b added public node (wow.aluisyo.network) 2020-04-06 09:09:30 +03:00
fuwa
22d3dc9a45 fix old bulletproof conditional branches 2020-04-06 09:09:30 +03:00
fuwa
140daa4783 wallet2: fix hf rules for small BP 2020-04-06 09:09:30 +03:00
wowario
e5e2ca539f sanity check: comment out #4691 2020-04-06 09:09:29 +03:00
wowario
1730faf01a sanity check: change to false #5434 2020-04-06 09:09:29 +03:00
fuwa
aff20484c3 allow system libminiupnp, revert #6b8539 2020-04-06 09:09:29 +03:00
wowario
6b1d4e67bc Cryptonight variant 4 aka cn/wow 2020-04-06 09:09:29 +03:00
wowario
e89be7b80c support old BP 2020-04-06 09:09:29 +03:00
wowario
652bd57080 initial commit 2020-04-06 09:09:17 +03:00
855 changed files with 289158 additions and 26205 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
custom: https://dev-funding.webui.wowkira.co

View File

@@ -1,44 +1,21 @@
name: ci/gh-actions/cli
name: continuous-integration/gh-actions/cli
on: [push, pull_request]
# The below variables reduce repetitions across similar targets
env:
REMOVE_BUNDLED_BOOST : rm -rf /usr/local/share/boost
APT_INSTALL_LINUX: 'sudo apt -y install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev libprotobuf-dev protobuf-compiler ccache'
APT_SET_CONF: |
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
jobs:
build-macos:
runs-on: macOS-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/cache@v2
with:
path: /Users/runner/Library/Caches/ccache
key: ccache-macos-build-${{ github.sha }}
restore-keys: ccache-macos-build-
- name: install dependencies
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf ccache
- name: update brew and install dependencies
run: brew update && brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf
- name: build
run: |
ccache --max-size=150M
make -j3
run: make -j3
build-windows:
runs-on: windows-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: C:\Users\runneradmin\.ccache-temp
CCACHE_DIR: C:\Users\runneradmin\.ccache
defaults:
run:
shell: msys2 {0}
@@ -46,128 +23,40 @@ jobs:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/cache@v2
with:
path: C:\Users\runneradmin\.ccache
key: ccache-windows-build-${{ github.sha }}
restore-keys: ccache-windows-build-
- uses: eine/setup-msys2@v2
- uses: eine/setup-msys2@v1
with:
update: true
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-ccache mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-protobuf-c mingw-w64-x86_64-libusb git
install: mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-protobuf-c mingw-w64-x86_64-libusb git
- name: build
run: |
ccache --max-size=150M
make release-static-win64 -j2
run: make release-static-win64 -j2
build-ubuntu:
runs-on: ubuntu-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-ubuntu-build-${{ github.sha }}
restore-keys: ccache-ubuntu-build-
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
run: ${{env.APT_SET_CONF}}
run: sudo rm -rf /usr/local/share/boost
- name: update apt
run: sudo apt update
- name: install monero dependencies
run: ${{env.APT_INSTALL_LINUX}}
run: sudo apt -y install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev
- name: build
run: |
ccache --max-size=150M
make -j3
run: make -j3
libwallet-ubuntu:
runs-on: ubuntu-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-ubuntu-libwallet-${{ github.sha }}
restore-keys: ccache-ubuntu-libwallet-
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
run: ${{env.APT_SET_CONF}}
run: sudo rm -rf /usr/local/share/boost
- name: update apt
run: sudo apt update
- name: install monero dependencies
run: ${{env.APT_INSTALL_LINUX}}
run: sudo apt -y install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev
- name: build
run: |
ccache --max-size=150M
cmake -DBUILD_GUI_DEPS=ON
make -j3
run: cmake -DBUILD_GUI_DEPS=ON && make -j3
test-ubuntu:
needs: build-ubuntu
runs-on: ubuntu-latest
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: ccache
uses: actions/cache@v2
with:
path: ~/.ccache
key: test-ubuntu-ccache-${{ github.sha }}
restore-keys: test-ubuntu-ccache-
- name: remove bundled boost
run: ${{env.REMOVE_BUNDLED_BOOST}}
- name: set apt conf
run: ${{env.APT_SET_CONF}}
- name: update apt
run: sudo apt update
- name: install monero dependencies
run: ${{env.APT_INSTALL_LINUX}}
- name: install Python dependencies
run: pip install requests psutil monotonic
- name: tests
env:
CTEST_OUTPUT_ON_FAILURE: ON
run: |
ccache --max-size=150M
DIR_BUILD="build/ci/release"
DIR_SRC="`pwd`"
mkdir -p "${DIR_BUILD}" && cd "${DIR_BUILD}"
cmake -S "${DIR_SRC}" -D ARCH="default" -D BUILD_SHARED_LIBS=ON -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release && make -j3 && make test
# ARCH="default" (not "native") ensures, that a different execution host can execute binaries compiled elsewhere.
# BUILD_SHARED_LIBS=ON speeds up the linkage part a bit, reduces size, and is the only place where the dynamic linkage is tested.
source-archive:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: archive
run: |
pip install git-archive-all
export VERSION="monero-$(git describe)"
export OUTPUT="$VERSION.tar"
echo "OUTPUT=$OUTPUT" >> $GITHUB_ENV
/home/runner/.local/bin/git-archive-all --prefix "$VERSION/" --force-submodules "$OUTPUT"
- uses: actions/upload-artifact@v2
with:
name: ${{ env.OUTPUT }}
path: /home/runner/work/monero/monero/${{ env.OUTPUT }}

View File

@@ -1,85 +0,0 @@
name: ci/gh-actions/depends
on: [push, pull_request]
jobs:
build-macos:
runs-on: ubuntu-18.04
env:
CCACHE_COMPRESS: 1
CCACHE_TEMPDIR: /tmp/.ccache-temp
strategy:
fail-fast: false
matrix:
toolchain:
- name: "RISCV 64bit"
host: "riscv64-linux-gnu"
packages: "python3 gperf g++-riscv64-linux-gnu"
- name: "ARM v7"
host: "arm-linux-gnueabihf"
packages: "python3 gperf g++-arm-linux-gnueabihf"
- name: "ARM v8"
host: "aarch64-linux-gnu"
packages: "python3 gperf g++-aarch64-linux-gnu"
- name: "i686 Win"
host: "i686-w64-mingw32"
packages: "python3 g++-mingw-w64-i686 qttools5-dev-tools"
- name: "i686 Linux"
host: "i686-pc-linux-gnu"
packages: "gperf cmake g++-multilib python3-zmq"
- name: "Win64"
host: "x86_64-w64-mingw32"
packages: "cmake python3 g++-mingw-w64-x86-64 qttools5-dev-tools"
- name: "x86_64 Linux"
host: "x86_64-unknown-linux-gnu"
packages: "gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
- name: "Cross-Mac"
host: "x86_64-apple-darwin11"
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev python3-setuptools-git"
osx_sdk: "10.11"
- name: "x86_64 Freebsd"
host: "x86_64-unknown-freebsd"
packages: "clang-8 gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
name: ${{ matrix.toolchain.name }}
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: ccache
uses: actions/cache@v2
with:
path: |
~/.ccache
contrib/depends/built
contrib/depends/sdk-sources
key: ccache-${{ matrix.toolchain.host }}-${{ github.sha }}
restore-keys: ccache-${{ matrix.toolchain.host }}-
- name: set apt conf
run: |
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
- name: install dependencies
run: sudo apt update; sudo apt -y install build-essential libtool cmake autotools-dev automake pkg-config bsdmainutils curl git ca-certificates ccache ${{ matrix.toolchain.packages }}
- name: prepare apple-darwin11
if: ${{ matrix.toolchain.host == 'x86_64-apple-darwin11' }}
run: |
mkdir -p contrib/depends/SDKs contrib/depends/sdk-sources
if [ ! -f contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz ]; then curl --location --fail https://bitcoincore.org/depends-sources/sdks/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz -o contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz; fi
if [ -f contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz ]; then tar -C contrib/depends/SDKs -xf contrib/depends/sdk-sources/MacOSX${{ matrix.toolchain.osx_sdk }}.sdk.tar.gz; fi
- name: prepare w64-mingw32
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'i686-w64-mingw32' }}
run: |
sudo update-alternatives --set ${{ matrix.toolchain.host }}-g++ $(which ${{ matrix.toolchain.host }}-g++-posix)
sudo update-alternatives --set ${{ matrix.toolchain.host }}-gcc $(which ${{ matrix.toolchain.host }}-gcc-posix)
- name: build
run: |
ccache --max-size=150M
make depends target=${{ matrix.toolchain.host }} -j2
- uses: actions/upload-artifact@v2
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'x86_64-apple-darwin11' || matrix.toolchain.host == 'x86_64-unknown-linux-gnu' }}
with:
name: ${{ matrix.toolchain.name }}
path: |
/home/runner/work/monero/monero/build/${{ matrix.toolchain.host }}/release/bin/monero-wallet-cli*
/home/runner/work/monero/monero/build/${{ matrix.toolchain.host }}/release/bin/monerod*

3
.gitignore vendored
View File

@@ -23,7 +23,6 @@ cscope.po.out
external/miniupnpc/Makefile
miniupnpcstrings.h
version/
ClangBuildAnalyzerSession.txt
# Created by https://www.gitignore.io
### C++ ###
@@ -110,5 +109,3 @@ nbproject
/testnet
__pycache__/
*.pyc
*.log

29
.gitmodules vendored
View File

@@ -1,18 +1,19 @@
[submodule "external/miniupnp"]
path = external/miniupnp
url = https://github.com/miniupnp/miniupnp
[submodule "external/rapidjson"]
path = external/rapidjson
url = https://github.com/Tencent/rapidjson
[submodule "external/supercop"]
path = external/supercop
url = https://github.com/monero-project/supercop
branch = monero
[submodule "external/RandomWOW"]
path = external/RandomWOW
url = https://git.wownero.com/wownero/RandomWOW
branch = 1.1.9-wow
[submodule "external/unbound"]
path = external/unbound
url = https://github.com/monero-project/unbound
branch = monero
[submodule "external/miniupnp"]
path = external/miniupnp
url = https://github.com/monero-project/miniupnp
branch = monero
[submodule "external/rapidjson"]
path = external/rapidjson
url = https://github.com/Tencent/rapidjson
[submodule "external/trezor-common"]
path = external/trezor-common
url = https://github.com/trezor/trezor-common.git
[submodule "external/RandomWOW"]
path = external/RandomWOW
url = https://github.com/wownero/RandomWOW
branch = 1.1.7-wow

66
.travis.yml Normal file
View File

@@ -0,0 +1,66 @@
sudo: required
dist: trusty
os: linux
language: minimal
cache:
directories:
- contrib/depends/built
- contrib/depends/sdk-sources
- $HOME/.ccache
env:
global:
- MAKEJOBS=-j3
- CCACHE_SIZE=100M
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- CCACHE_DIR=$HOME/.ccache
- BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
- SDK_URL=https://bitcoincore.org/depends-sources/sdks
- DOCKER_PACKAGES="build-essential libtool cmake autotools-dev automake pkg-config bsdmainutils curl git ca-certificates ccache"
matrix:
# RISCV 64bit
- HOST=riscv64-linux-gnu PACKAGES="python3 gperf g++-riscv64-linux-gnu"
# ARM v7
- HOST=arm-linux-gnueabihf PACKAGES="python3 gperf g++-arm-linux-gnueabihf"
# ARM v8
- HOST=aarch64-linux-gnu PACKAGES="python3 gperf g++-aarch64-linux-gnu"
# i686 Win
- HOST=i686-w64-mingw32 DEP_OPTS="NO_QT=1" PACKAGES="python3 g++-mingw-w64-i686 qttools5-dev-tools"
# i686 Linux
- HOST=i686-pc-linux-gnu PACKAGES="gperf cmake g++-multilib python3-zmq"
# Win64
- HOST=x86_64-w64-mingw32 DEP_OPTS="NO_QT=1" PACKAGES="cmake python3 g++-mingw-w64-x86-64 qttools5-dev-tools"
# x86_64 Linux
- HOST=x86_64-unknown-linux-gnu PACKAGES="gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
# Cross-Mac
- HOST=x86_64-apple-darwin11 PACKAGES="cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev python3-setuptools-git" OSX_SDK=10.11
# x86_64 Freebsd
- HOST=x86_64-unknown-freebsd PACKAGES="clang-8 gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
before_install:
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
install:
- env | grep -E '^(CCACHE_|DISPLAY|CONFIG_SHELL)' | tee /tmp/env
- if [[ $HOST = *-mingw32 ]]; then DOCKER_ADMIN="--cap-add SYS_ADMIN"; fi
- DOCKER_ID=$(docker run $DOCKER_ADMIN -idt --mount type=bind,src=$TRAVIS_BUILD_DIR,dst=$TRAVIS_BUILD_DIR --mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR -w $TRAVIS_BUILD_DIR --env-file /tmp/env ubuntu:18.04)
- DOCKER_EXEC="docker exec $DOCKER_ID"
- if [ -n "$DPKG_ADD_ARCH" ]; then $DOCKER_EXEC dpkg --add-architecture "$DPKG_ADD_ARCH" ; fi
- travis_retry $DOCKER_EXEC apt-get update
- travis_retry $DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES $DOCKER_PACKAGES
before_script:
- mkdir -p contrib/depends/SDKs contrib/depends/sdk-sources
- if [ -n "$OSX_SDK" -a ! -f contrib/depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o contrib/depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
- if [ -n "$OSX_SDK" -a -f contrib/depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then tar -C contrib/depends/SDKs -xf contrib/depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
- if [[ $HOST = *-mingw32 ]]; then $DOCKER_EXEC bash -c "update-alternatives --set $HOST-g++ \$(which $HOST-g++-posix)"; fi
- if [[ $HOST = *-mingw32 ]]; then $DOCKER_EXEC bash -c "update-alternatives --set $HOST-gcc \$(which $HOST-gcc-posix)"; fi
- if [ -z "$NO_DEPENDS" ]; then $DOCKER_EXEC bash -c "make $MAKEJOBS -C contrib/depends HOST=$HOST $DEP_OPTS"; fi
script:
- git submodule init && git submodule update
- export TRAVIS_COMMIT_LOG=`git log --format=fuller -1`
- OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
- if [ -z "$NO_DEPENDS" ]; then $DOCKER_EXEC ccache --max-size=$CCACHE_SIZE; fi
- $DOCKER_EXEC bash -c "mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=$TRAVIS_BUILD_DIR/contrib/depends/$HOST/share/toolchain.cmake .. && make $MAKEJOBS"
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/contrib/depends/$HOST/lib
after_script:
- echo $TRAVIS_COMMIT_RANGE
- echo $TRAVIS_COMMIT_LOG

View File

@@ -36,6 +36,10 @@ with additional exclusive IPv4 address(es).
## Usage
Anonymity networks have no seed nodes (the feature is still considered
experimental), so a user must specify an address. If configured properly,
additional peers can be found through typical p2p peerlist sharing.
### Outbound Connections
Connecting to an anonymous address requires the command line option
@@ -50,9 +54,8 @@ separate process. On most systems the configuration will look like:
which tells `monerod` that ".onion" p2p addresses can be forwarded to a socks
proxy at IP 127.0.0.1 port 9050 with a max of 10 outgoing connections and
".b32.i2p" p2p addresses can be forwarded to a socks proxy at IP 127.0.0.1 port
9000 with the default max outgoing connections.
If desired, peers can be manually specified:
9000 with the default max outgoing connections. Since there are no seed nodes
for anonymity connections, peers must be manually specified:
```
--add-exclusive-node rveahdfho7wo4b2m.onion:28083

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -31,7 +31,7 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
"${CMAKE_SOURCE_DIR}/cmake")
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLinkerFlag)
@@ -43,67 +43,12 @@ if (IOS)
INCLUDE(CmakeLists_IOS.txt)
endif()
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 2.8.7)
message(STATUS "CMake version ${CMAKE_VERSION}")
project(monero)
option (USE_CCACHE "Use ccache if a usable instance is found" ON)
if (USE_CCACHE)
include(FindCcache) # Has to be included after the project() macro, to be able to read the CXX variable.
else()
message(STATUS "ccache deselected")
endif()
option (USE_COMPILATION_TIME_PROFILER "Use compilation time profiler (for CLang >= 9 only)" OFF)
if (USE_COMPILATION_TIME_PROFILER)
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message(FATAL_ERROR "The flag USE_COMPILATION_TIME_PROFILER is meant to be set only for CLang compiler!")
endif()
add_compile_options("-ftime-trace")
endif()
if (${CMAKE_VERSION} VERSION_GREATER "3.0.0" AND CMAKE_MAKE_PROGRAM MATCHES "ninja")
set(MONERO_PARALLEL_COMPILE_JOBS "" CACHE STRING "The maximum number of concurrent compilation jobs.")
if (MONERO_PARALLEL_COMPILE_JOBS)
set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${MONERO_PARALLEL_COMPILE_JOBS})
set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
endif ()
set(MONERO_PARALLEL_LINK_JOBS "" CACHE STRING "The maximum number of concurrent link jobs.")
if (MONERO_PARALLEL_LINK_JOBS)
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${MONERO_PARALLEL_LINK_JOBS})
set(CMAKE_JOB_POOL_LINK link_job_pool)
endif ()
endif ()
option (USE_CLANG_TIDY_C "Lint the code with clang-tidy - variant C" OFF)
option (USE_CLANG_TIDY_CXX "Lint the code with clang-tidy - variant C++" OFF)
if (USE_CLANG_TIDY_C AND USE_CLANG_TIDY_CXX)
message(FATAL_ERROR "Enabling both USE_CLANG_TIDY_C and USE_CLANG_TIDY_CXX simultaneously crashes clang-tidy.")
endif()
if (USE_CLANG_TIDY_C OR USE_CLANG_TIDY_CXX)
include(SetClangTidy)
endif()
if (USE_CLANG_TIDY_C)
monero_clang_tidy("C")
elseif (USE_CLANG_TIDY_CXX)
monero_clang_tidy("CXX")
endif()
# Job pool feature requires Ninja.
if (${CMAKE_VERSION} VERSION_GREATER "3.0.0")
set(WOWNERO_PARALLEL_COMPILE_JOBS "" CACHE STRING "The maximum number of concurrent compilation jobs.")
if (WOWNERO_PARALLEL_COMPILE_JOBS)
set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${WOWNERO_PARALLEL_COMPILE_JOBS})
set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
endif ()
set(WOWNERO_PARALLEL_LINK_JOBS "" CACHE STRING "The maximum number of concurrent link jobs.")
if (WOWNERO_PARALLEL_LINK_JOBS)
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${WOWNERO_PARALLEL_LINK_JOBS})
set(CMAKE_JOB_POOL_LINK link_job_pool)
endif ()
endif()
include(FindCcache) # Has to be included after the project() macro, to be able to read the CXX variable.
enable_language(C ASM)
@@ -161,48 +106,6 @@ function (add_definition_if_library_exists library function header var)
endif()
endfunction()
option(RELINK_TARGETS "Relink targets, when just a dependant .so changed, but not its header?" OFF)
function (monero_set_target_no_relink target)
if (RELINK_TARGETS MATCHES OFF)
# Will not relink the target, when just its dependant .so has changed, but not it's interface
set_target_properties("${target}" PROPERTIES LINK_DEPENDS_NO_SHARED true)
endif()
endfunction()
option(STRIP_TARGETS "Strip symbols from targets?" OFF)
function (monero_set_target_strip target)
if (STRIP_TARGETS)
set_target_properties("${target}" PROPERTIES LINK_FLAGS_RELEASE -s)
set_target_properties("${target}" PROPERTIES LINK_FLAGS_DEBUG -s)
# Stripping from Debug might make sense if you're low on disk space, but want to test if debug version builds properly.
endif()
endfunction()
function (monero_add_minimal_executable name)
source_group("${name}"
FILES
${ARGN})
add_executable("${name}"
${ARGN})
monero_set_target_no_relink("${name}")
monero_set_target_strip ("${name}")
endfunction()
# Finds all headers in a directory and its subdirs, to be able to search for them and autosave in IDEs.
#
# Parameters:
# - headers_found: Output variable, which will hold the found headers
# - module_root_dir: The search path for the headers. Typically it will be the module's root dir, so "${CMAKE_CURRENT_SOURCE_DIR}" or a derivative of it.
macro (monero_find_all_headers headers_found module_root_dir)
file(GLOB ${headers_found}
"${module_root_dir}/*.h*" # h* will include hpps as well.
"${module_root_dir}/**/*.h*" # Any number of subdirs will be included.
"${module_root_dir}/*.inl" # .inl is typically template code and is being treated as headers (it's being included).
"${module_root_dir}/**/*.inl"
)
endmacro()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
@@ -309,8 +212,8 @@ if(NOT MANUAL_SUBMODULES)
check_submodule(external/miniupnp)
check_submodule(external/unbound)
check_submodule(external/rapidjson)
check_submodule(external/trezor-common)
check_submodule(external/RandomWOW)
check_submodule(external/supercop)
endif()
endif()
@@ -368,12 +271,6 @@ else()
endif()
option(BUILD_DEBUG_UTILITIES "Build debug utilities." DEFAULT_BUILD_DEBUG_UTILITIES)
if(OSSFUZZ)
message(STATUS "Using OSS-Fuzz fuzzing system")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOSSFUZZ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOSSFUZZ")
endif()
# Check whether we're on a 32-bit or 64-bit system
if(CMAKE_SIZEOF_VOID_P EQUAL "8")
set(DEFAULT_BUILD_64 ON)
@@ -412,7 +309,7 @@ endif()
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
# set(BSDI TRUE)
include_directories(external/rapidjson/include external/easylogging++ src contrib/epee/include external external/supercop/include)
include_directories(external/rapidjson/include external/easylogging++ src contrib/epee/include external)
if(APPLE)
include_directories(SYSTEM /usr/include/malloc)
@@ -495,7 +392,7 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW)
set(DEFAULT_STACK_TRACE ON)
set(STACK_TRACE_LIB "easylogging++") # for diag output only
set(LIBUNWIND_LIBRARIES "")
elseif (ARM)
elseif (ARM AND STATIC)
set(DEFAULT_STACK_TRACE OFF)
set(LIBUNWIND_LIBRARIES "")
else()
@@ -531,8 +428,8 @@ if (CMAKE_SYSTEM_NAME MATCHES "(SunOS|Solaris)")
endif ()
if (APPLE AND NOT IOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11")
if (NOT OPENSSL_ROOT_DIR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64 -fvisibility=default -std=c++11")
if (NOT OpenSSL_DIR)
EXECUTE_PROCESS(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -557,47 +454,6 @@ add_definition_if_function_found(strptime HAVE_STRPTIME)
add_definitions(-DAUTO_INITIALIZE_EASYLOGGINGPP)
set(MONERO_GENERATED_HEADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated_include")
include_directories(${MONERO_GENERATED_HEADERS_DIR})
option(COVERAGE "Enable profiling for test coverage report" OFF)
if(COVERAGE)
message(STATUS "Building with profiling for test coverage report")
endif()
macro (monero_enable_coverage)
if(COVERAGE)
foreach(COV_FLAG -fprofile-arcs -ftest-coverage --coverage)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COV_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COV_FLAG}")
endforeach()
endif()
endmacro()
function (monero_add_library name)
monero_add_library_with_deps(NAME "${name}" SOURCES ${ARGN})
endfunction()
function (monero_add_library_with_deps)
cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN})
source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES})
# Define a ("virtual") object library and an actual library that links those
# objects together. The virtual libraries can be arbitrarily combined to link
# any subset of objects into one library archive. This is used for releasing
# libwallet, which combines multiple components.
set(objlib obj_${MONERO_ADD_LIBRARY_NAME})
add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES})
add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>)
monero_set_target_no_relink("${MONERO_ADD_LIBRARY_NAME}")
monero_set_target_strip ("${MONERO_ADD_LIBRARY_NAME}")
if (MONERO_ADD_LIBRARY_DEPENDS)
add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
endif()
set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs")
target_compile_definitions(${objlib}
PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)
endfunction ()
# Generate header for embedded translations
# Generate header for embedded translations, use target toolchain if depends, otherwise use the
# lrelease and lupdate binaries from the host
@@ -607,10 +463,18 @@ ExternalProject_Add(generate_translations_header
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/translations"
STAMP_DIR ${LRELEASE_PATH}
CMAKE_ARGS -DLRELEASE_PATH=${LRELEASE_PATH}
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "")
INSTALL_COMMAND cmake -E echo "")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
add_subdirectory(external)
# Final setup for miniupnpc
if(UPNP_STATIC OR IOS)
add_definitions("-DUPNP_STATIC")
else()
add_definitions("-DUPNP_DYNAMIC")
include_directories(${UPNP_INCLUDE})
endif()
# Final setup for libunbound
include_directories(${UNBOUND_INCLUDE})
link_directories(${UNBOUND_LIBRARY_DIRS})
@@ -639,17 +503,6 @@ endif()
# Trezor support check
include(CheckTrezor)
# As of OpenBSD 6.8, -march=<anything> breaks the build
function(set_default_arch)
if (OPENBSD)
set(ARCH default)
else()
set(ARCH native)
endif()
set(ARCH ${ARCH} CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all")
endfunction()
if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")
@@ -663,7 +516,7 @@ if(MSVC)
else()
include(TestCXXAcceptsFlag)
if (NOT ARCH)
set_default_arch()
set(ARCH native CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all")
endif()
message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}")
if(ARCH STREQUAL "default")
@@ -725,8 +578,8 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAG}")
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(ARM)
set(WARNINGS "${WARNINGS} -Wno-error=inline-asm")
endif()
@@ -761,7 +614,13 @@ else()
set(STATIC_ASSERT_CPP_FLAG "-Dstatic_assert=_Static_assert")
endif()
monero_enable_coverage()
option(COVERAGE "Enable profiling for test coverage report" 0)
if(COVERAGE)
message(STATUS "Building with profiling for test coverage report")
set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage --coverage")
endif()
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
# is fixed in the code (Issue #847), force compiler to be conservative.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
@@ -804,16 +663,9 @@ else()
endif()
# linker
if (NOT SANITIZE AND NOT OSSFUZZ AND NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND (CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1 OR NOT STATIC))))
# PIE executables randomly crash at startup with ASAN
if (NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1)))
# Windows binaries die on startup with PIE when compiled with GCC <9.x
# Windows dynamically-linked binaries die on startup with PIE regardless of GCC version
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# Clang does not support -pie flag
add_linker_flag_if_supported("-Wl,-pie" LD_SECURITY_FLAGS)
else()
add_linker_flag_if_supported("-pie" LD_SECURITY_FLAGS)
endif()
add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS)
endif()
add_linker_flag_if_supported(-Wl,-z,relro LD_SECURITY_FLAGS)
add_linker_flag_if_supported(-Wl,-z,now LD_SECURITY_FLAGS)
@@ -839,19 +691,12 @@ else()
add_linker_flag_if_supported(-Wl,--high-entropy-va LD_SECURITY_FLAGS)
endif()
# Warnings, that when ignored are so severe, that they can segfault or even UB any application.
# Treat them as errors.
add_c_flag_if_supported( -Werror=switch C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-Werror=switch CXX_SECURITY_FLAGS)
add_c_flag_if_supported( -Werror=return-type C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-Werror=return-type CXX_SECURITY_FLAGS)
message(STATUS "Using C security hardening flags: ${C_SECURITY_FLAGS}")
message(STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}")
message(STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${PIC_FLAG} ${C_SECURITY_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${PIC_FLAG} ${CXX_SECURITY_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${COVERAGE_FLAGS} ${PIC_FLAG} ${C_SECURITY_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_CPP_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${COVERAGE_FLAGS} ${PIC_FLAG} ${CXX_SECURITY_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LD_SECURITY_FLAGS} ${LD_BACKCOMPAT_FLAGS}")
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
@@ -940,8 +785,7 @@ else()
endif(ARM)
# random crash on startup when asan is on if pie is enabled
if(NOT SANITIZE AND ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON" OR IOS)
if(ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON" OR IOS)
#From Android 5: "only position independent executables (PIE) are supported"
message(STATUS "Enabling PIE executable")
set(PIC_FLAG "")
@@ -969,7 +813,7 @@ else()
endif()
set(USE_LTO ${USE_LTO_DEFAULT} CACHE BOOL "Use Link-Time Optimization (Release mode only)")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled, so explicitly disable
set(USE_LTO false)
endif()
@@ -1076,12 +920,10 @@ list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED)
if (APPLE)
if(DEPENDS)
list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework AppKit -framework IOKit")
list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework IOKit")
else()
find_library(COREFOUNDATION CoreFoundation)
find_library(APPKIT AppKit)
find_library(IOKIT IOKit)
list(APPEND EXTRA_LIBRARIES ${APPKIT})
list(APPEND EXTRA_LIBRARIES ${IOKIT})
list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION})
endif()
@@ -1116,7 +958,7 @@ if(ANDROID)
set(ATOMIC libatomic.a)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=user-defined-warnings")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND ARCH_WIDTH EQUAL "32" AND NOT IOS AND NOT FREEBSD)
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32" AND NOT IOS AND NOT FREEBSD)
find_library(ATOMIC atomic)
if (ATOMIC_FOUND)
list(APPEND EXTRA_LIBRARIES ${ATOMIC})
@@ -1127,10 +969,12 @@ find_path(ZMQ_INCLUDE_PATH zmq.h)
find_library(ZMQ_LIB zmq)
find_library(PGM_LIBRARY pgm)
find_library(NORM_LIBRARY norm)
find_library(GSSAPI_LIBRARY gssapi_krb5)
find_library(PROTOLIB_LIBRARY protolib)
find_library(SODIUM_LIBRARY sodium)
set(ZMQ_INCLUDE_PATH zmq_dummy_include_path)
set(ZMQ_LIB zmq_dummy_lib_2)
if(NOT ZMQ_INCLUDE_PATH)
message(FATAL_ERROR "Could not find required header zmq.h")
endif()
@@ -1143,9 +987,6 @@ endif()
if(NORM_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${NORM_LIBRARY}")
endif()
if(GSSAPI_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${GSSAPI_LIBRARY}")
endif()
if(PROTOLIB_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${PROTOLIB_LIBRARY}")
endif()
@@ -1153,7 +994,6 @@ if(SODIUM_LIBRARY)
set(ZMQ_LIB "${ZMQ_LIB};${SODIUM_LIBRARY}")
endif()
include(external/supercop/functions.cmake) # place after setting flags and before src directory inclusion
add_subdirectory(contrib)
add_subdirectory(src)

View File

@@ -1,4 +1,4 @@
# Portions Copyright (c) 2017-2020, The Monero Project
# Portions Copyright (c) 2017-2019, The Monero Project
# This file is based off of the https://code.google.com/archive/p/ios-cmake/
# It has been altered for Monero iOS development
#

View File

@@ -11,8 +11,6 @@ RUN set -ex && \
g++ \
make \
pkg-config \
graphviz \
doxygen \
git \
curl \
libtool-bin \
@@ -46,7 +44,7 @@ ARG BOOST_VERSION=1_70_0
ARG BOOST_VERSION_DOT=1.70.0
ARG BOOST_HASH=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778
RUN set -ex \
&& curl -s -L -o boost_${BOOST_VERSION}.tar.bz2 https://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION_DOT}/boost_${BOOST_VERSION}.tar.bz2 \
&& curl -s -L -o boost_${BOOST_VERSION}.tar.bz2 https://dl.bintray.com/boostorg/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \
&& echo "${BOOST_HASH} boost_${BOOST_VERSION}.tar.bz2" | sha256sum -c \
&& tar -xvf boost_${BOOST_VERSION}.tar.bz2 \
&& cd boost_${BOOST_VERSION} \
@@ -55,8 +53,8 @@ RUN set -ex \
ENV BOOST_ROOT /usr/local/boost_${BOOST_VERSION}
# OpenSSL
ARG OPENSSL_VERSION=1.1.1i
ARG OPENSSL_HASH=e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
ARG OPENSSL_VERSION=1.1.1g
ARG OPENSSL_HASH=ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
RUN set -ex \
&& curl -s -O https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \
&& echo "${OPENSSL_HASH} openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c \
@@ -68,28 +66,6 @@ RUN set -ex \
&& make install
ENV OPENSSL_ROOT_DIR=/usr/local/openssl-${OPENSSL_VERSION}
# ZMQ
ARG ZMQ_VERSION=v4.3.2
ARG ZMQ_HASH=a84ffa12b2eb3569ced199660bac5ad128bff1f0
RUN set -ex \
&& git clone https://github.com/zeromq/libzmq.git -b ${ZMQ_VERSION} \
&& cd libzmq \
&& test `git rev-parse HEAD` = ${ZMQ_HASH} || exit 1 \
&& ./autogen.sh \
&& ./configure --enable-static --disable-shared \
&& make \
&& make install \
&& ldconfig
# zmq.hpp
ARG CPPZMQ_VERSION=v4.4.1
ARG CPPZMQ_HASH=f5b36e563598d48fcc0d82e589d3596afef945ae
RUN set -ex \
&& git clone https://github.com/zeromq/cppzmq.git -b ${CPPZMQ_VERSION} \
&& cd cppzmq \
&& test `git rev-parse HEAD` = ${CPPZMQ_HASH} || exit 1 \
&& mv *.hpp /usr/local/include
# Readline
ARG READLINE_VERSION=8.0
ARG READLINE_HASH=e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461
@@ -116,8 +92,8 @@ RUN set -ex \
&& make install
# Udev
ARG UDEV_VERSION=v3.2.10
ARG UDEV_HASH=be7068512c7512fa67c64fbff3472ab140c277c8
ARG UDEV_VERSION=v3.2.8
ARG UDEV_HASH=d69f3f28348123ab7fa0ebac63ec2fd16800c5e0
RUN set -ex \
&& git clone https://github.com/gentoo/eudev -b ${UDEV_VERSION} \
&& cd eudev \
@@ -127,44 +103,6 @@ RUN set -ex \
&& make \
&& make install
# Libusb
ARG USB_VERSION=v1.0.22
ARG USB_HASH=0034b2afdcdb1614e78edaa2a9e22d5936aeae5d
RUN set -ex \
&& git clone https://github.com/libusb/libusb.git -b ${USB_VERSION} \
&& cd libusb \
&& test `git rev-parse HEAD` = ${USB_HASH} || exit 1 \
&& ./autogen.sh \
&& ./configure --disable-shared \
&& make \
&& make install
# Hidapi
ARG HIDAPI_VERSION=hidapi-0.8.0-rc1
ARG HIDAPI_HASH=40cf516139b5b61e30d9403a48db23d8f915f52c
RUN set -ex \
&& git clone https://github.com/signal11/hidapi -b ${HIDAPI_VERSION} \
&& cd hidapi \
&& test `git rev-parse HEAD` = ${HIDAPI_HASH} || exit 1 \
&& ./bootstrap \
&& ./configure --enable-static --disable-shared \
&& make \
&& make install
# Protobuf
ARG PROTOBUF_VERSION=v3.7.1
ARG PROTOBUF_HASH=6973c3a5041636c1d8dc5f7f6c8c1f3c15bc63d6
RUN set -ex \
&& git clone https://github.com/protocolbuffers/protobuf -b ${PROTOBUF_VERSION} \
&& cd protobuf \
&& test `git rev-parse HEAD` = ${PROTOBUF_HASH} || exit 1 \
&& git submodule update --init --recursive \
&& ./autogen.sh \
&& ./configure --enable-static --disable-shared \
&& make \
&& make install \
&& ldconfig
WORKDIR /src
COPY . .
@@ -209,3 +147,4 @@ EXPOSE 34568
USER wownero
ENTRYPOINT ["wownerod", "--p2p-bind-ip=0.0.0.0", "--p2p-bind-port=34567", "--rpc-bind-ip=0.0.0.0", "--rpc-bind-port=34568", "--non-interactive", "--confirm-external-bind"]

View File

@@ -68,7 +68,7 @@ OUTPUT_DIRECTORY = doc
# performance problems for the file system.
# The default value is: NO.
CREATE_SUBDIRS = YES
CREATE_SUBDIRS = NO
# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
# characters to appear in the names of generated files. If set to NO, non-ASCII
@@ -754,7 +754,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.
INPUT = .
INPUT = src
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1552,7 +1552,7 @@ EXTRA_SEARCH_MAPPINGS =
# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.
# The default value is: YES.
GENERATE_LATEX = NO
GENERATE_LATEX = YES
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of

View File

@@ -10,7 +10,7 @@ extensibility.
One of the goals of this document is to clearly indicate what is being sent
"on the wire" to identify metadata that could de-anonymize users over I2P/Tor.
These issues will be addressed as they are found. See `ANONMITY_NETWORKS.md` in
the `docs` folder for any outstanding issues.
the top-level folder for any outstanding issues.
> This document does not currently list all data being sent by the monero
> protocol, that portion is a work-in-progress. Please take the time to do it

View File

@@ -1,4 +1,4 @@
Copyright (c) 2014-2021, The Monero Project
Copyright (c) 2014-2019, The Monero Project
All rights reserved.

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#

65
PKGBUILD Normal file
View File

@@ -0,0 +1,65 @@
# Maintainer: wowario <wowario[at]protonmail[dot]com>
pkgname=wownero-git
pkgver=0.8.0.0
pkgrel=1
pkgdesc="Wownero: a fairly launched privacy-centric meme coin with no premine and a finite supply"
license=('BSD')
arch=('x86_64')
url="https://wownero.org/"
depends=('boost-libs' 'libunwind' 'openssl' 'readline' 'zeromq' 'pcsclite' 'hidapi' 'protobuf')
makedepends=('git' 'cmake' 'boost')
source=(
"${pkgname}"::"git+https://github.com/wownero/wownero#tag=v${pkgver}"
"git+https://github.com/monero-project/unbound.git"
"git+https://github.com/monero-project/miniupnp.git"
"git+https://github.com/Tencent/rapidjson.git"
"git+https://github.com/trezor/trezor-common.git"
"git+https://github.com/wownero/RandomWOW.git"
"wownero.sysusers"
"wownero.tmpfiles")
sha512sums=('SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP')
prepare() {
cd "${pkgname}"
git submodule init
git config submodule.external/unbound.url "$srcdir/unbound"
git config submodule.external/miniupnp.url "$srcdir/miniupnp"
git config submodule.external/rapidjson.url "$srcdir/rapidjson"
git config submodule.external/trezor-common.url "$srcdir/trezor-common"
git config submodule.external/RandomWOW.url "$srcdir/RandomWOW"
git submodule update
}
build() {
cd "${pkgname}"
mkdir -p build && cd build
cmake -D BUILD_TESTS=OFF -D CMAKE_BUILD_TYPE=release -D ARCH=default ../
make
}
package() {
backup=('etc/wownerod.conf')
cd "${pkgname}"
install -Dm644 "LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"
install -Dm644 "utils/conf/wownerod.conf" "${pkgdir}/etc/wownerod.conf"
install -Dm644 "utils/systemd/wownerod.service" "${pkgdir}/usr/lib/systemd/system/wownerod.service"
install -Dm644 "../wownero.sysusers" "${pkgdir}/usr/lib/sysusers.d/wownero.conf"
install -Dm644 "../wownero.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/wownero.conf"
install -Dm755 "build/bin/wownero-wallet-cli" \
"build/bin/wownero-wallet-rpc" \
"build/bin/wownerod" \
-t "${pkgdir}/usr/bin"
}
# vim: ts=2 sw=2 et:

177
README.md
View File

@@ -1,80 +1,55 @@
# ~~Mo~~Wownero - Such privacy! Many coins! Wow! 🐕
Copyright (c) 2014-2021 The Monero Project.
Copyright (c) 2014-2019 The Monero Project.
Portions Copyright (c) 2012-2013 The Cryptonote developers.
# CyberWOW
An Android pruned full node for Wownero
[<img src="https://f-droid.org/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/org.wownero.cyberwow/)
<a href='https://play.google.com/store/apps/details?id=org.wownero.cyberwow'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height='80'/></a>
# Wownerujo
An Android Wallet for Wownero
[<img src="https://f-droid.org/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.wownero.wownerujo/)
<a href='https://play.google.com/store/apps/details?id=com.wownero.wownerujo'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height='80'/></a>
## Resources
- IRC: [OFTC #wownero](https://webchat.oftc.net/?channels=wownero)
- Web: [wownero.org](https://wownero.org)
- Web: [wownero.org](http://wownero.org)
- Twitter: [@w0wn3r0](https://twitter.com/w0wn3r0)
- Reddit: [/r/wownero](https://www.reddit.com/r/wownero)
- Mail: [wownero@protonmail.com](mailto:wownero@protonmail.com)
- Git: [git.wownero.com/wownero/wownero](https://git.wownero.com/wownero/wownero)
- Wownero Funding System: [funding.wownero.com](https://funding.wownero.com)
- Wownero Forum: [forum.wownero.com](https://forum.wownero.com)
- Discord: [discord.gg/ykZyAzJhDK](https://discord.com/invite/ykZyAzJhDK)
- Telegram: [t.me/wownero](https://t.me/wownero)
- Wowlet Desktop Wallet: [git.wownero.com/wowlet/wowlet](https://git.wownero.com/wowlet/wowlet/releases)
- WOW Stash Web Wallet: [wowstash.app](https://wowstash.app)
- Public Node Status: [monero.fail](https://monero.fail/?crypto=wownero)
- Map of Nodes: [wownero.fyi](https://wownero.fyi)
- Wownero Memes: [suchwow.xyz](https://suchwow.xyz/posts/top)
- XMR/WOW Swap: [nero Swap](https://neroswap.com)
- Mining Pools: [miningpoolstats.stream](https://miningpoolstats.stream/wownero)
- Market Info: [coinmarketcap.com](https://coinmarketcap.com/currencies/wownero), [coingecko.com](https://www.coingecko.com/en/coins/wownero/usd)
- GitHub: [https://git.wownero.com/wownero/wownero](https://git.wownero.com/wownero/wownero)
- IRC: [#wownero on Freenode](https://kiwiirc.com/client/irc.freenode.net/?nick=suchchatter|?#wownero)
- Bitmessage Chan: wownero (`BM-2cSzWtrj2pzLva9GF1Jp2TYsnLjrnJpvba`)
- Wownero Funding System: [https://funding.wownero.com](https://funding.wownero.com)
### Blockchain Explorers
Blockchain Explorers
- https://explore.wownero.com
- http://gffjxd5nn2heslj6jv5ts2ok5j6xi6m3pwlpz7le4i5bu56sirbxfiqd.onion:8081
- https://wownero.club
- https://explorer.wownero.fyi
- https://explorer.wowkira.com
- http://wow5eqtzqvsg5jctqzg5g7uk3u62sfqiacj5x6lo4by7bvnj6jkvubyd.onion
Free Public Nodes
- wow7dhbgiljnkspkzpjyy66auegbrye2ptfv4gucgbhireg5rrjza5ad.onion:34568
- so.wow.candy.surf:34568 (US)
- such.wow.candy.surf:34568 (CAN)
- very.wow.candy.surf:34568 (IN)
- much.wow.candy.surf:34568 (UK)
Tor Peers
- wowp2p5gelm6vhl2d5tvfqills63jilgy6hkvlrqljooov5ktaxgqdad.onion
- f3moshycuklu3mb3wnlfjwn26nsgzreqtfzfuyjjk46u7jqxlhf7d5id.onion
## Introduction
Wownero is a privacy-centric memecoin that was fairly launched on April 1, 2018 with no pre-mine, stealth-mine or ICO. Wownero has a maximum supply of around 184 million WOW with a slow and steady emission over 50 years. It is a fork of Monero, but with its own genesis block, so there is no degradation of privacy due to ring signatures using different participants for the same tx outputs on opposing forks.
## Supporting the project
Wownero is a 100% community-sponsored endeavor. Supporting services are also graciously provided by sponsors:
[<img src="https://git.wownero.com/wownero/meta/raw/branch/master/images/macstadium.png"
alt="MacStadium"
height="100">](https://www.macstadium.com)
[<img src="https://git.wownero.com/wownero/meta/raw/branch/master/images/jetbrains.png"
alt="JetBrains"
height="100">](https://www.jetbrains.com)
Developers are volunteers doing this mostly for shits and giggles. If you would like to support our shenanigans and stimulant addictions, please consider donating to [WFS proposals](https://funding.wownero.com/proposals) or the dev slush fund.
### Donation Addresses
WOW: `Wo3MWeKwtA918DU4c69hVSNgejdWFCRCuWjShRY66mJkU2Hv58eygJWDJS1MNa2Ge5M1WjUkGHuLqHkweDxwZZU42d16v94mP`
- view key: `e62e40bfd5ca7e3a7f199602a3c97df511780489e1c1861884b00c28abaea406`
XMR: `44SQVPGLufPasUcuUQSZiF5c9BFzjcP8ucDxzzFDgLf1VkCEFaidJ3u2AhSKMhPLKA3jc2iS8wQHFcaigM6fXmo6AnFRn5B`
- view key: `cb83681c31db0c79adf18f25b2a6d05f86db1109385b4928930e2acf49a3ed0b`
BTC: `bc1qcw9zglp3fxyl25zswemw7jczlqryms2lsmu464`
### Open Collective
Open Collective is an online funding platform for open source software and collaborative communities. The platform brings together legal entities that act as a “Fiscal Host”, “Collectives” (unincorporated, community-based projects), and individuals interested in supporting projects with donations. Fiscal hosts hold donations for collectives in trust and handle all the taxes and legal stuff.
Wownero is hosted by Open Collective Europe, a Brussels-based non-profit that hosts many other collectives, such as Manjaro, EndeavourOS, Xfce, and peertube.social. If you would like donate to the Wownero Project using this method, you can check out our [Wownero - Open Collective](https://opencollective.com/wownero) page.
## Release staging and Contributing
**Anyone is welcome to contribute to Wownero's codebase!**
If you have a fix or code change, feel free to submit it as a pull request. Ahead of a scheduled software upgrade, a development branch will be created with the new release version tag. Pull requests that address bugs should be made to Master. Pull requests that require review and testing (generally, optimizations and new features) should be made to the development branch. All pull requests will be considered safe until the US dollar valuation of 1 Wownero equals $1000. After this valuation has been reached, more research will be needed to introduce experimental cryptography and/or code into the codebase.
Things to Do, Work in Progress, and Help Wanted tasks are tracked in the [Meta](https://git.wownero.com/wownero/meta/issues) repo.
Join `#wownero-dev` on IRC OFTC to participate in development conversation.
## Scheduled software upgrades
Wownero uses a fixed-schedule software upgrade (hard fork) mechanism to implement new features. This means that users of Wownero (end users and service providers) should run current versions and upgrade their software on a regular schedule. The required software for these upgrades will be available prior to the scheduled date. Please check the repository prior to this date for the proper Wownero software version. Below is the historical schedule and the projected schedule for the next upgrade.
@@ -89,14 +64,18 @@ Dates are provided in the format YYYY-MM-DD.
| 81,769 | 2019-02-19 | Erotic EggplantEmoji | v0.5.0.0 | v0.5.0.2 | Cryptonight/wow, LWMA v1 with N=144, Updated Bulletproofs, Fee Per Byte, Auto-churn
| 114,969 | 2019-06-14 | F For Fappening | v0.6.1.0 | v0.6.1.2 | RandomWOW, new block weight algorithm, slightly more efficient RingCT format
| 160,777 | 2019-11-20 | Gaping Goatse | v0.7.0.0 | v0.7.1.0 | Only allow >= 2 outputs, change to the block median used to calculate penalty, rct sigs in coinbase forbidden, 4 unlock time as protocol rule
| - | 2020-06-28 | Hallucinogenic Hypnotoad | v0.8.0.0 | v0.8.0.2 | Dandelion++ support
| 253,999 | 2020-10-09 | Illiterate Illuminati | v0.9.0.0 | v0.9.3.3 | Dynamic coinbase unlock (up to 1 mo.), Deterministic unlock times, Enforce maximum coinbase amount, show_qr_code wallet command, CLSAG
| 331,170 | 2021-07-04 | Junkie Jeff | v0.10.0.0 | v0.10.0.3 | Bulletproofs+, Miner Block Header Signing, Vote by Block, Change coinbase unlock time to 1 day, Reset difficulty and switch back to Monero's difficulty algorithm
| 288,888 | 2021-02-08 | Hallucinogenic Hypnotoad | v0.8.0.0 | v0.8.0.1 | SHA3-256 PoW, Dandelion++ support
X's indicate that these details have not been determined as of commit date.
\* indicates estimate as of commit date
## Release staging and Contributing
**Anyone is welcome to contribute to Wownero's codebase!**
If you have a fix or code change, feel free to submit it as a pull request. Ahead of a scheduled software upgrade, a development branch will be created with the new release version tag. Pull requests that address bugs should be made to Master. Pull requests that require review and testing (generally, optimizations and new features) should be made to the development branch. All pull requests will be considered safe until the US dollar valuation of 1 Wownero equals $1000. After this valuation has been reached, more research will be needed to introduce experimental cryptography and/or code into the codebase.
## Installing from a package
Packages are available for
@@ -105,7 +84,7 @@ Packages are available for
yay -S wownero-git
* Gentoo - Russian hacking tool
* Gentoo
emerge --noreplace eselect-repository
eselect repository enable monero
@@ -131,29 +110,26 @@ Packaging for your favorite distribution would be a welcome contribution!
## Building from Source
* Docker
git clone https://git.wownero.com/wownero/wownero && cd wownero
docker build -t git-wow:master -m 4g .
docker run -it -p 34567:34567 -p 34568:34568 -w /home/wownero/build/release/bin git-wow:master bash
* Arch Linux/Manjaro
sudo pacman -Syu && sudo pacman -S base-devel cmake boost openssl zeromq libpgm unbound libsodium git libusb systemd
git clone https://git.wownero.com/wownero/wownero && cd wownero
sudo pacman -Syu && sudo pacman -S base-devel cmake boost openssl zeromq libpgm unbound libsodium git
git clone https://git.wownero.com/wownero/wownero
cd wownero
make -j2
* Debian/Ubuntu
sudo apt update && sudo apt install build-essential cmake pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libpgm-dev libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev git -y
git clone https://git.wownero.com/wownero/wownero && cd wownero
sudo apt update && sudo apt install build-essential cmake pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev libsodium-dev libpgm-dev git
git clone https://git.wownero.com/wownero/wownero
cd wownero
make -j2
## Running Binaries
The build places the binary in `bin/` sub-directory within the build directory
from which cmake was invoked (repository root by default). To run in the
from which cmake was invoked (repository root by default). To run in
foreground:
./bin/wownerod
@@ -162,7 +138,7 @@ To list all available options, run `./bin/wownerod --help`. Options can be
specified either on the command line or in a configuration file passed by the
`--config-file` argument. To specify an option in the configuration file, add
a line with the syntax `argumentname=value`, where `argumentname` is the name
of the argument without the leading dashes, for example, `log-level=1`.
of the argument without the leading dashes, for example `log-level=1`.
To run in background:
@@ -170,10 +146,10 @@ To run in background:
To run as a systemd service, copy
[wownerod.service](utils/systemd/wownerod.service) to `/etc/systemd/system/` and
[wownerod.conf](wownerod.conf) to `/etc/`. The [example
[wownerod.conf](utils/conf/wownerod.conf) to `/etc/`. The [example
service](utils/systemd/wownerod.service) assumes that the user `wownero` exists
and its home is the data directory specified in the [example
config](wownerod.conf).
config](utils/conf/wownerod.conf).
Once node is synced to network, run the CLI wallet by entering:
@@ -183,37 +159,36 @@ Type `help` in CLI wallet to see standard commands (for advanced options, type `
## Tor Anonymity Network
### Ubuntu
* Install [Tor Browser](https://www.torproject.org/download/)
* Open `torrc` file in a text editor ([installation directory]/Browser/TorBrowser/Data/Tor/torrc) and add hidden service information as follows:
* `sudo apt-get update && sudo apt-get install tor -y`
* `sudo nano /etc/tor/torrc`
add the following:
```
HiddenServiceDir /var/lib/tor/wownero/
HiddenServicePort 34568 127.0.0.1:34568
HiddenServicePort 34566 127.0.0.1:34566
HiddenServiceDir [installation directory]/Browser/TorBrowser/Data/Tor/wow_node
HiddenServiceVersion 3
HiddenServicePort 44568 127.0.0.1:44568
```
save and close nano
* `sudo /etc/init.d/tor restart && sudo systemctl enable tor`
* copy [wownerod.conf](https://git.wownero.com/wownero/wownero/raw/branch/master/wownerod.conf) file and save it in same directory as `wownerod`.
* start wownerod like this:
* Save `torrc` file and restart Tor Browser (keep open)
* Change directory to the `wow_node` folder, open `hostname` file, and copy your node's ".onion" address
* Start wownerod with the following parameters:
```
./wownerod --config-file=wownerod.conf
./wownerod --tx-proxy tor,127.0.0.1:9150,10 --add-peer hdps3qwnusz64r7odvynmae6myc2uyvrsc2emap6636qeuzll72eouid.onion:44568 --anonymous-inbound YOUR_NODE_ADDRESS.onion:44568,127.0.0.1:44568,25
```
* `sudo cat /var/lib/tor/wownero/hostname`
copy your onion address and share node with others [here](https://monero.fail/?crypto=wownero) and [here](https://forum.wownero.com/t/wownero-tor-onion-sites/623)
To share your node over p2p, uncomment first line of wownerod.conf and add your onion address.
More information on running Tor and i2p nodes is available [here](https://forum.wownero.com/t/how-to-setup-a-full-node-with-tor-i2p/588)
### Access remote Tor node from CLI wallet
```
./wownero-wallet-cli --proxy 127.0.0.1:9050 --daemon-address iy6ry6uudpzvbd72zsipepukp6nsazjdu72n52vg3isfnxqn342flzad.onion:34568
./wownero-wallet-cli --proxy 127.0.0.1:9150 --daemon-address wow7dhbgiljnkspkzpjyy66auegbrye2ptfv4gucgbhireg5rrjza5ad.onion:34568
```
Use port `9050` instead of `9150` if you installed Tor as a standalone daemon. For more information, check out [ANONYMITY_NETWORKS](https://git.wownero.com/wownero/wownero/src/branch/master/ANONYMITY_NETWORKS.md).
## Donating to Wownero Project
Developers are volunteers doing this mostly for shits and giggles. If you would like to support our shenanigans and stimulant addictions, please consider donating to [WFS proposals](https://funding.wownero.com/proposals) or the [dev slush fund](https://dev-funding.webui.wowkira.com).
Donations may also be sent to:
XMR: `44SQVPGLufPasUcuUQSZiF5c9BFzjcP8ucDxzzFDgLf1VkCEFaidJ3u2AhSKMhPLKA3jc2iS8wQHFcaigM6fXmo6AnFRn5B`
BTC: `bc1qcw9zglp3fxyl25zswemw7jczlqryms2lsmu464`

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#

View File

@@ -15,7 +15,6 @@ macro(CHECK_LINKER_FLAG flag VARIABLE)
${_cle_source}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${flag}
CMAKE_FLAGS
"-DCMAKE_EXE_LINKER_FLAGS=${flag}"
OUTPUT_VARIABLE OUTPUT)
unset(_cle_source)
set(CMAKE_C_FLAGS ${saved_CMAKE_C_FLAGS})

View File

@@ -91,7 +91,7 @@ endif()
# Protobuf compilation test
if(Protobuf_FOUND AND USE_DEVICE_TREZOR AND TREZOR_PYTHON)
execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} -I "${CMAKE_CURRENT_LIST_DIR}" -I "${Protobuf_INCLUDE_DIR}" "${CMAKE_CURRENT_LIST_DIR}/test-protobuf.proto" --cpp_out ${CMAKE_BINARY_DIR} RESULT_VARIABLE RET OUTPUT_VARIABLE OUT ERROR_VARIABLE ERR)
execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} -I "${CMAKE_SOURCE_DIR}/cmake" -I "${Protobuf_INCLUDE_DIR}" "${CMAKE_SOURCE_DIR}/cmake/test-protobuf.proto" --cpp_out ${CMAKE_BINARY_DIR} RESULT_VARIABLE RET OUTPUT_VARIABLE OUT ERROR_VARIABLE ERR)
if(RET)
message(STATUS "Protobuf test generation failed: ${OUT} ${ERR}")
endif()
@@ -100,7 +100,7 @@ if(Protobuf_FOUND AND USE_DEVICE_TREZOR AND TREZOR_PYTHON)
"${CMAKE_BINARY_DIR}"
SOURCES
"${CMAKE_BINARY_DIR}/test-protobuf.pb.cc"
"${CMAKE_CURRENT_LIST_DIR}/test-protobuf.cpp"
"${CMAKE_SOURCE_DIR}/cmake/test-protobuf.cpp"
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${Protobuf_INCLUDE_DIR};${CMAKE_BINARY_DIR}"
"-DCMAKE_CXX_STANDARD=11"

View File

@@ -41,20 +41,17 @@
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
# Try to compile a test program with ccache, in order to verify if it really works. (needed on exotic setups)
# Create a temporary file with a simple program.
set(TEMP_CPP_FILE "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/test-program.cpp")
set(TEMP_CPP_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test-program.cpp")
file(WRITE "${TEMP_CPP_FILE}" "int main() { return 0; }")
# And run the found ccache on it.
execute_process(COMMAND "${CCACHE_FOUND}" "${CMAKE_CXX_COMPILER}" "${TEMP_CPP_FILE}" RESULT_VARIABLE RET)
if (${RET} EQUAL 0)
# Success
message(STATUS "Found usable ccache: ${CCACHE_FOUND}")
message("found usable ccache: ${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND}")
else()
message(STATUS "Found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
endif()
message("found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
endif()
else()
message(STATUS "ccache NOT found! Please install it for faster rebuilds.")
message("ccache NOT found!")
endif()

View File

@@ -134,7 +134,7 @@ if ( LibUSB_FOUND )
try_compile(LibUSB_COMPILE_TEST_PASSED
${CMAKE_BINARY_DIR}
"${CMAKE_CURRENT_LIST_DIR}/test-libusb-version.c"
"${CMAKE_SOURCE_DIR}/cmake/test-libusb-version.c"
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${LibUSB_INCLUDE_DIRS}"
"-DLINK_DIRECTORIES=${LibUSB_LIBRARIES}"

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -48,21 +48,29 @@ function (get_version_tag_from_git GIT)
message(STATUS "You are currently on commit ${COMMIT}")
# Get all the tags
execute_process(COMMAND "${GIT}" tag -l --points-at HEAD
execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RET
OUTPUT_VARIABLE TAG
OUTPUT_VARIABLE TAGGEDCOMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Check if we're building that tagged commit or a different one
if(TAG)
message(STATUS "You are building a tagged release")
set(VERSIONTAG "release")
set(VERSION_IS_RELEASE "true")
else()
message(STATUS "You are ahead of or behind a tagged release")
if(NOT TAGGEDCOMMIT)
message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
set(VERSIONTAG "${COMMIT}")
set(VERSION_IS_RELEASE "false")
else()
message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}")
# Check if we're building that tagged commit or a different one
if(COMMIT STREQUAL TAGGEDCOMMIT)
message(STATUS "You are building a tagged release")
set(VERSIONTAG "release")
set(VERSION_IS_RELEASE "true")
else()
message(STATUS "You are ahead of or behind a tagged release")
set(VERSIONTAG "${COMMIT}")
set(VERSION_IS_RELEASE "false")
endif()
endif()
endif()

View File

@@ -1,72 +0,0 @@
# Copyright (c) 2014-2020, The Monero Project
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CLANG_TIDY.html
# This module sets the following variables:
# CMAKE_C_CLANG_TIDY
# CMAKE_CXX_CLANG_TIDY
# when clang-tidy is found in PATH. Afterwards, the code is being linted by the tool.
# The checks to be enabled can be manipulated with the variable MONERO_CLANG_TIDY_CHECKS
macro (monero_clang_tidy LANGUAGE)
set(TOOL_NAME "clang-tidy")
set(MONERO_CLANG_TIDY_MIN_VERSION "3.6")
if(${CMAKE_VERSION} VERSION_LESS "${MONERO_CLANG_TIDY_MIN_VERSION}")
message(FATAL_ERROR "Sorry, ${TOOL_NAME} is available for CMake from version ${MONERO_CLANG_TIDY_MIN_VERSION}")
else()
message(STATUS "Trying to enable ${TOOL_NAME}")
find_program(MONERO_CLANG_BIN ${TOOL_NAME})
if(NOT MONERO_CLANG_BIN)
message(FATAL_ERROR "${TOOL_NAME} not found! Try running: sudo apt install ${TOOL_NAME}")
else()
message(STATUS "Found ${MONERO_CLANG_BIN}")
set(MONERO_CLANG_TIDY_CHECKS
-header-filter=.; # By default the headers are excluded. This line enables them.
-checks=*; # Currently enabling all checks
# An example of selectively enabling checks:
#-checks=bugprone-*,cppcoreguidelines-avoid-goto # Have to be in one line :(
)
# Current list of checks is avaibale under:
# https://clang.llvm.org/extra/clang-tidy/
if (${LANGUAGE} STREQUAL "C")
set(CMAKE_C_CLANG_TIDY
${MONERO_CLANG_BIN}; # Mind the semicolon
${MONERO_CLANG_TIDY_CHECKS}
)
elseif (${LANGUAGE} STREQUAL "CXX")
set(CMAKE_CXX_CLANG_TIDY
${MONERO_CLANG_BIN}; # Mind the semicolon
${MONERO_CLANG_TIDY_CHECKS}
)
else()
message(FATAL_ERROR "${TOOL_NAME}: Unsupported language: ${LANGUAGE}")
endif()
endif()
endif()
endmacro()

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -28,7 +28,7 @@
function (write_version tag)
set(VERSIONTAG "${tag}" CACHE STRING "The tag portion of the Monero software version" FORCE)
configure_file("${CMAKE_CURRENT_LIST_DIR}/../src/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
configure_file("${CMAKE_SOURCE_DIR}/src/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
endfunction ()
find_package(Git QUIET)

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -26,6 +26,5 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
monero_enable_coverage()
add_subdirectory(epee)

View File

@@ -27,7 +27,6 @@ brew "miniupnpc"
brew "readline"
brew "ldns"
brew "expat"
brew "ccache"
brew "doxygen"
brew "graphviz"
brew "libunwind-headers"

View File

@@ -0,0 +1,18 @@
version: '1.0'
steps:
init_submodules:
title: Init Submodules
commands:
- git submodule update --init --recursive
image: codefreshio/git-image:latest
working_directory: ${{main_clone}}
BuildingDockerImage:
title: Building Docker Image
type: build
image_name: monero
working_directory: ./
tag: '${{CF_BRANCH_TAG_NORMALIZED}}'
dockerfile: Dockerfile
build_arguments:
- NPROC=1

View File

@@ -10,8 +10,8 @@ HOST ?= $(BUILD)
PATCHES_PATH = $(BASEDIR)/patches
BASEDIR = $(CURDIR)
HASH_LENGTH:=11
DOWNLOAD_CONNECT_TIMEOUT:=30
DOWNLOAD_RETRIES:=5
DOWNLOAD_CONNECT_TIMEOUT:=10
DOWNLOAD_RETRIES:=3
HOST_ID_SALT ?= salt
BUILD_ID_SALT ?= salt

View File

@@ -1,6 +1,6 @@
package=boost
$(package)_version=1_64_0
$(package)_download_path=https://downloads.sourceforge.net/project/boost/boost/1.64.0/
$(package)_download_path=https://dl.bintray.com/boostorg/release/1.64.0/source/
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_sha256_hash=7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332
$(package)_dependencies=libiconv

View File

@@ -1,6 +1,6 @@
package=expat
$(package)_version=2.2.4
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_4
$(package)_download_path=https://downloads.sourceforge.net/project/expat/expat/$($(package)_version)
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=03ad85db965f8ab2d27328abcf0bc5571af6ec0a414874b2066ee3fdd372019e

View File

@@ -1,9 +1,9 @@
package=native_ds_store
$(package)_version=1.1.0
$(package)_download_path=https://github.com/al45tair/ds_store/archive/
$(package)_download_file=v$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=a9f4c0755c6be7224ff7029e188dd262e830bb81e801424841db9eb0780ec8ed
$(package)_download_path=https://bitbucket.org/al45tair/ds_store/get
$(package)_download_file=v$($(package)_version).tar.bz2
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=921596764d71d1bbd3297a90ef6d286f718794d667e4f81d91d14053525d64c1
$(package)_install_libdir=$(build_prefix)/lib/python/dist-packages
$(package)_dependencies=native_biplist

View File

@@ -1,9 +1,9 @@
package=native_mac_alias
$(package)_version=1.1.0
$(package)_download_path=https://github.com/al45tair/mac_alias/archive/
$(package)_download_file=v$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=b10cb44ecb64fc25283fae7a9cf365d2829377d84e37b9c21100aca8757509be
$(package)_download_path=https://bitbucket.org/al45tair/mac_alias/get
$(package)_download_file=v$($(package)_version).tar.bz2
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=87ad827e66790028361e43fc754f68ed041a9bdb214cca03c853f079b04fb120
$(package)_install_libdir=$(build_prefix)/lib/python/dist-packages
$(package)_patches=python3.patch

View File

@@ -1,31 +1,36 @@
package=openssl
$(package)_version=1.1.1k
$(package)_download_path=https://www.openssl.org/source
$(package)_version=1.0.2r
$(package)_download_path=https://ftp.openssl.org/source/old/1.0.2
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
$(package)_sha256_hash=ae51d08bba8a83958e894946f15303ff894d75c2b8bbd44a852b64e3fe11d0d6
$(package)_patches=fix_arflags.patch
define $(package)_set_vars
$(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
$(package)_config_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_config_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
$(package)_build_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native"
$(package)_build_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native"
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl
$(package)_config_opts+=no-capieng
$(package)_config_opts+=no-dso
$(package)_config_opts+=no-dtls1
$(package)_config_opts+=no-ec_nistp_64_gcc_128
$(package)_config_opts+=no-gost
$(package)_config_opts+=no-gmp
$(package)_config_opts+=no-heartbeats
$(package)_config_opts+=no-jpake
$(package)_config_opts+=no-krb5
$(package)_config_opts+=no-libunbound
$(package)_config_opts+=no-md2
$(package)_config_opts+=no-rc5
$(package)_config_opts+=no-rdrand
$(package)_config_opts+=no-rfc3779
$(package)_config_opts+=no-rsax
$(package)_config_opts+=no-sctp
$(package)_config_opts+=no-sha0
$(package)_config_opts+=no-shared
$(package)_config_opts+=no-ssl-trace
$(package)_config_opts+=no-ssl2
$(package)_config_opts+=no-ssl3
$(package)_config_opts+=no-static_engine
$(package)_config_opts+=no-store
$(package)_config_opts+=no-unit-test
$(package)_config_opts+=no-weak-ssl-ciphers
$(package)_config_opts+=no-zlib
@@ -37,8 +42,8 @@ $(package)_config_opts_x86_64_linux=linux-x86_64
$(package)_config_opts_i686_linux=linux-generic32
$(package)_config_opts_arm_linux=linux-generic32
$(package)_config_opts_aarch64_linux=linux-generic64
$(package)_config_opts_arm_android=--static android-arm
$(package)_config_opts_aarch64_android=--static android-arm64
$(package)_config_opts_arm_android=--static android-armv7 no-asm
$(package)_config_opts_aarch64_android=--static android no-asm
$(package)_config_opts_riscv64_linux=linux-generic64
$(package)_config_opts_mipsel_linux=linux-generic32
$(package)_config_opts_mips_linux=linux-generic32
@@ -50,8 +55,10 @@ $(package)_config_opts_x86_64_freebsd=BSD-x86_64
endef
define $(package)_preprocess_cmds
sed -i.old 's|"engines", "apps", "test", "util", "tools", "fuzz"|"engines", "tools"|' Configure && \
sed -i -e 's|cflags --sysroot.*",|cflags",|' Configurations/15-android.conf
sed -i.old "/define DATE/d" util/mkbuildinf.pl && \
sed -i.old "s|engines apps test|engines|" Makefile.org && \
sed -i -e "s/-mandroid //" Configure && \
patch < $($(package)_patch_dir)/fix_arflags.patch
endef
define $(package)_config_cmds
@@ -63,7 +70,7 @@ define $(package)_build_cmds
endef
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) -j1 install_sw
$(MAKE) INSTALL_PREFIX=$($(package)_staging_dir) -j1 install_sw
endef
define $(package)_postprocess_cmds

View File

@@ -1,18 +1,18 @@
PACKAGE=qt
$(package)_version=5.15.1
$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules
$(package)_suffix=everywhere-src-$($(package)_version).tar.xz
$(package)_version=5.7.1
$(package)_download_path=http://linorg.usp.br/Qt/archive/qt/5.7/5.7.1/submodules
$(package)_suffix=opensource-src-$($(package)_version).tar.gz
$(package)_file_name=qtbase-$($(package)_suffix)
$(package)_sha256_hash=33960404d579675b7210de103ed06a72613bfc4305443e278e2d32a3eb1f3d8c
$(package)_sha256_hash=95f83e532d23b3ddbde7973f380ecae1bac13230340557276f75f2e37984e410
$(package)_build_subdir=qtbase
$(package)_qt_libs=corelib
$(package)_patches=fix_qt_pkgconfig.patch fix_no_printer.patch fix_rcc_determinism.patch no-xlib.patch
$(package)_patches=pidlist_absolute.patch fix_qt_pkgconfig.patch qfixed-coretext.patch
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
$(package)_qttranslations_sha256_hash=46e0c0e3a511fbcc803a4146204062e47f6ed43b34d98a3c27372a03b8746bd8
$(package)_qttranslations_sha256_hash=3a15aebd523c6d89fb97b2d3df866c94149653a26d27a00aac9b6d3020bc5a1d
$(package)_qttools_file_name=qttools-$($(package)_suffix)
$(package)_qttools_sha256_hash=c98ee5f0f980bf68cbf0c94d62434816a92441733de50bd9adbe9b9055f03498
$(package)_qttools_sha256_hash=22d67de915cb8cd93e16fdd38fa006224ad9170bd217c2be1e53045a8dd02f0f
$(package)_extra_sources = $($(package)_qttranslations_file_name)
$(package)_extra_sources += $($(package)_qttools_file_name)
@@ -24,26 +24,28 @@ $(package)_config_opts += -bindir $(build_prefix)/bin
$(package)_config_opts += -c++std c++11
$(package)_config_opts += -confirm-license
$(package)_config_opts += -dbus-runtime
$(package)_config_opts += -hostprefix $(build_prefix)
$(package)_config_opts += -no-compile-examples
$(package)_config_opts += -no-alsa
$(package)_config_opts += -no-audio-backend
$(package)_config_opts += -no-cups
$(package)_config_opts += -no-egl
$(package)_config_opts += -no-eglfs
$(package)_config_opts += -no-evdev
$(package)_config_opts += -no-gui
$(package)_config_opts += -no-feature-style-windowsmobile
$(package)_config_opts += -no-feature-style-windowsce
$(package)_config_opts += -no-freetype
$(package)_config_opts += -no-gif
$(package)_config_opts += -no-glib
$(package)_config_opts += -no-gstreamer
$(package)_config_opts += -no-icu
$(package)_config_opts += -no-ico
$(package)_config_opts += -no-iconv
$(package)_config_opts += -no-kms
$(package)_config_opts += -no-linuxfb
$(package)_config_opts += -no-libjpeg
$(package)_config_opts += -no-libudev
$(package)_config_opts += -no-mitshm
$(package)_config_opts += -no-mtdev
$(package)_config_opts += -no-pulseaudio
$(package)_config_opts += -no-openvg
$(package)_config_opts += -no-reduce-relocations
$(package)_config_opts += -no-qml-debug
$(package)_config_opts += -no-sql-db2
$(package)_config_opts += -no-sql-ibase
$(package)_config_opts += -no-sql-oci
@@ -54,6 +56,8 @@ $(package)_config_opts += -no-sql-psql
$(package)_config_opts += -no-sql-sqlite
$(package)_config_opts += -no-sql-sqlite2
$(package)_config_opts += -no-use-gold-linker
$(package)_config_opts += -no-xinput2
$(package)_config_opts += -no-xrender
$(package)_config_opts += -nomake examples
$(package)_config_opts += -nomake tests
$(package)_config_opts += -opensource
@@ -61,46 +65,25 @@ $(package)_config_opts += -no-openssl
$(package)_config_opts += -optimized-qmake
$(package)_config_opts += -pch
$(package)_config_opts += -pkg-config
$(package)_config_opts += -prefix $(host_prefix)
$(package)_config_opts += -no-libpng
$(package)_config_opts += -no-libjpeg
$(package)_config_opts += -qt-pcre
$(package)_config_opts += -qt-harfbuzz
$(package)_config_opts += -no-zlib
$(package)_config_opts += -reduce-exports
$(package)_config_opts += -static
$(package)_config_opts += -silent
$(package)_config_opts += -v
$(package)_config_opts += -no-feature-bearermanagement
$(package)_config_opts += -no-feature-colordialog
$(package)_config_opts += -no-feature-dial
$(package)_config_opts += -no-feature-filesystemwatcher
$(package)_config_opts += -no-feature-fontcombobox
$(package)_config_opts += -no-feature-ftp
$(package)_config_opts += -no-feature-image_heuristic_mask
$(package)_config_opts += -no-feature-keysequenceedit
$(package)_config_opts += -no-feature-lcdnumber
$(package)_config_opts += -no-feature-pdf
$(package)_config_opts += -no-feature-printdialog
$(package)_config_opts += -no-feature-printer
$(package)_config_opts += -no-feature-printpreviewdialog
$(package)_config_opts += -no-feature-printpreviewwidget
$(package)_config_opts += -no-feature-sessionmanager
$(package)_config_opts += -no-feature-sql
$(package)_config_opts += -no-feature-statemachine
$(package)_config_opts += -no-feature-syntaxhighlighter
$(package)_config_opts += -no-feature-textbrowser
$(package)_config_opts += -no-feature-textodfwriter
$(package)_config_opts += -no-feature-topleveldomain
$(package)_config_opts += -no-feature-udpsocket
$(package)_config_opts += -no-feature-undocommand
$(package)_config_opts += -no-feature-undogroup
$(package)_config_opts += -no-feature-undostack
$(package)_config_opts += -no-feature-undoview
$(package)_config_opts += -no-feature-vnc
$(package)_config_opts += -no-feature-wizard
$(package)_config_opts_linux = -no-fontconfig
$(package)_config_opts_linux += -no-opengl
$(package)_config_opts_linux += -no-xcb
$(package)_config_opts_linux += -no-feature-xlib
$(package)_config_opts += -no-feature-printdialog
$(package)_config_opts += -no-gui
$(package)_config_opts += -no-freetype
$(package)_config_opts += -no-sm
$(package)_config_opts += -no-fontconfig
$(package)_config_opts += -no-opengl
$(package)_config_opts += -no-xkb
$(package)_config_opts += -no-xcb
$(package)_config_opts += -no-xshape
$(package)_build_env = QT_RCC_TEST=1
endef
define $(package)_fetch_cmds
@@ -125,24 +108,14 @@ endef
define $(package)_preprocess_cmds
sed -i.old "s|FT_Get_Font_Format|FT_Get_X11_Font_Format|" qtbase/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp && \
sed -i.old "s|updateqm.commands = \$$$$\$$$$LRELEASE|updateqm.commands = $($(package)_extract_dir)/qttools/bin/lrelease|" qttranslations/translations/translations.pro && \
sed -i.old "/updateqm.depends =/d" qttranslations/translations/translations.pro && \
sed -i.old "s/src_plugins.depends = src_sql src_network/src_plugins.depends = src_network/" qtbase/src/src.pro && \
cp -r qtbase/mkspecs/linux-arm-gnueabi-g++ qtbase/mkspecs/bitcoin-linux-g++ && \
sed -i.old "s/arm-linux-gnueabi-/$(host)-/g" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \
patch -p1 -i $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \
patch -p1 -i $($(package)_patch_dir)/fix_no_printer.patch && \
patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \
patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \
patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \
echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \
echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \
echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \
patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \
echo "QMAKE_LINK_OBJECT_MAX = 10" >> qtbase/mkspecs/win32-g++/qmake.conf && \
echo "QMAKE_LINK_OBJECT_SCRIPT = object_script" >> qtbase/mkspecs/win32-g++/qmake.conf && \
sed -i.old "s|QMAKE_CFLAGS += |!host_build: QMAKE_CFLAGS = $($(package)_cflags) $($(package)_cppflags) |" qtbase/mkspecs/win32-g++/qmake.conf && \
sed -i.old "s|QMAKE_CXXFLAGS += |!host_build: QMAKE_CXXFLAGS = $($(package)_cxxflags) $($(package)_cppflags) |" qtbase/mkspecs/win32-g++/qmake.conf && \
sed -i.old "0,/^QMAKE_LFLAGS_/s|^QMAKE_LFLAGS_|!host_build: QMAKE_LFLAGS = $($(package)_ldflags)\n&|" qtbase/mkspecs/win32-g++/qmake.conf && \
sed -i.old "s/LIBRARY_PATH/(CROSS_)?\0/g" qtbase/mkspecs/features/toolchain.prf
echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf
endef
define $(package)_config_cmds

View File

@@ -0,0 +1,24 @@
--- Makefile.org.O 2019-02-26 14:20:20.000000000 +0000
+++ Makefile.org 2019-11-15 13:05:54.370086856 +0000
@@ -63,8 +63,8 @@
PEX_LIBS=
EX_LIBS=
EXE_EXT=
-ARFLAGS=
-AR=ar $(ARFLAGS) r
+ARFLAGS= r
+AR=ar $(ARFLAGS)
RANLIB= ranlib
RC= windres
NM= nm
--- Configure.O 2019-02-26 14:20:20.000000000 +0000
+++ Configure 2019-11-16 07:43:14.933990774 +0000
@@ -1251,7 +1251,7 @@
my $shared_extension = $fields[$idx_shared_extension];
my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
my $ar = $ENV{'AR'} || "ar";
-my $arflags = $fields[$idx_arflags];
+my $arflags = $ENV{'ARFLAGS'} || $fields[$idx_arflags];
my $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
my $multilib = $fields[$idx_multilib];

View File

@@ -1,19 +0,0 @@
--- x/qtbase/src/plugins/platforms/cocoa/qprintengine_mac_p.h
+++ y/qtbase/src/plugins/platforms/cocoa/qprintengine_mac_p.h
@@ -52,6 +52,7 @@
//
#include <QtCore/qglobal.h>
+#include <qpa/qplatformprintdevice.h>
#ifndef QT_NO_PRINTER
--- x/qtbase/src/plugins/plugins.pro
+++ y/qtbase/src/plugins/plugins.pro
@@ -9,6 +9,3 @@ qtHaveModule(gui) {
!android:qtConfig(library): SUBDIRS *= generic
}
qtHaveModule(widgets): SUBDIRS += styles
-
-!winrt:qtHaveModule(printsupport): \
- SUBDIRS += printsupport

View File

@@ -1,11 +1,11 @@
--- old/qtbase/mkspecs/features/qt_module.prf
+++ new/qtbase/mkspecs/features/qt_module.prf
@@ -269,7 +269,7 @@ load(qt_installs)
@@ -245,7 +245,7 @@
load(qt_targets)
# this builds on top of qt_common
-!internal_module:if(unix|mingw):!if(darwin:debug_and_release:CONFIG(debug, debug|release)) {
+if(unix|mingw):!if(darwin:debug_and_release:CONFIG(debug, debug|release)) {
-!internal_module:!lib_bundle:if(unix|mingw) {
+unix|mingw {
CONFIG += create_pc
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
host_build: \

View File

@@ -1,15 +0,0 @@
--- old/qtbase/src/tools/rcc/rcc.cpp
+++ new/qtbase/src/tools/rcc/rcc.cpp
@@ -207,7 +207,11 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
if (lib.formatVersion() >= 2) {
// last modified time stamp
const QDateTime lastModified = m_fileInfo.lastModified();
- lib.writeNumber8(quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0));
+ quint64 lastmod = quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0);
+ static const quint64 sourceDate = 1000 * qgetenv("QT_RCC_SOURCE_DATE_OVERRIDE").toULongLong();
+ if (sourceDate != 0)
+ lastmod = sourceDate;
+ lib.writeNumber8(lastmod);
if (text || pass1)
lib.writeChar('\n');
}

View File

@@ -1,69 +0,0 @@
From 9563cef873ae82e06f60708d706d054717e801ce Mon Sep 17 00:00:00 2001
From: Carl Dong <contact@carldong.me>
Date: Thu, 18 Jul 2019 17:22:05 -0400
Subject: [PATCH] Wrap xlib related code blocks in #if's
They are not necessary to compile QT.
---
qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp b/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp
index 7c62c2e2b3..c05c6c0a07 100644
--- a/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -49,7 +49,9 @@
#include <QtGui/QWindow>
#include <QtGui/QBitmap>
#include <QtGui/private/qguiapplication_p.h>
+#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
#include <X11/cursorfont.h>
+#endif
#include <xcb/xfixes.h>
#include <xcb/xcb_image.h>
@@ -391,6 +393,7 @@ void QXcbCursor::changeCursor(QCursor *cursor, QWindow *window)
xcb_flush(xcb_connection());
}
+#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
static int cursorIdForShape(int cshape)
{
int cursorId = 0;
@@ -444,6 +447,7 @@ static int cursorIdForShape(int cshape)
}
return cursorId;
}
+#endif
xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
{
@@ -556,7 +560,9 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape)
xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
{
xcb_connection_t *conn = xcb_connection();
+#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
int cursorId = cursorIdForShape(cshape);
+#endif
xcb_cursor_t cursor = XCB_NONE;
// Try Xcursor first
@@ -586,6 +592,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
// Non-standard X11 cursors are created from bitmaps
cursor = createNonStandardCursor(cshape);
+#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
// Create a glpyh cursor if everything else failed
if (!cursor && cursorId) {
cursor = xcb_generate_id(conn);
@@ -593,6 +600,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
cursorId, cursorId + 1,
0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0);
}
+#endif
if (cursor && cshape >= 0 && cshape < Qt::LastCursor && connection()->hasXFixes()) {
const char *name = cursorNames[cshape].front();
---
2.22.0

View File

@@ -0,0 +1,37 @@
diff -dur old/qtbase/src/plugins/platforms/windows/qwindowscontext.h new/qtbase/src/plugins/platforms/windows/qwindowscontext.h
--- old/qtbase/src/plugins/platforms/windows/qwindowscontext.h
+++ new/qtbase/src/plugins/platforms/windows/qwindowscontext.h
@@ -136,10 +136,18 @@
inline void init();
typedef HRESULT (WINAPI *SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **);
+#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3)
+ typedef HRESULT (WINAPI *SHGetKnownFolderIDList)(const GUID &, DWORD, HANDLE, ITEMIDLIST **);
+#else
typedef HRESULT (WINAPI *SHGetKnownFolderIDList)(const GUID &, DWORD, HANDLE, PIDLIST_ABSOLUTE *);
+#endif
typedef HRESULT (WINAPI *SHGetStockIconInfo)(int , int , _SHSTOCKICONINFO *);
typedef HRESULT (WINAPI *SHGetImageList)(int, REFIID , void **);
+#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3)
+ typedef HRESULT (WINAPI *SHCreateItemFromIDList)(const ITEMIDLIST *, REFIID, void **);
+#else
typedef HRESULT (WINAPI *SHCreateItemFromIDList)(PCIDLIST_ABSOLUTE, REFIID, void **);
+#endif
SHCreateItemFromParsingName sHCreateItemFromParsingName;
SHGetKnownFolderIDList sHGetKnownFolderIDList;
diff -dur old/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp new/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
--- old/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ new/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1016,7 +1016,11 @@
qWarning() << __FUNCTION__ << ": Invalid CLSID: " << url.path();
return Q_NULLPTR;
}
+#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3)
+ ITEMIDLIST *idList;
+#else
PIDLIST_ABSOLUTE idList;
+#endif
HRESULT hr = QWindowsContext::shell32dll.sHGetKnownFolderIDList(uuid, 0, 0, &idList);
if (FAILED(hr)) {
qErrnoWarning("%s: SHGetKnownFolderIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString()));

View File

@@ -0,0 +1,34 @@
From dbdd5f0ffbce52c8b789ed09f1aa3f1da6c02e23 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Date: Fri, 30 Mar 2018 11:58:16 -0700
Subject: [PATCH] QCoreTextFontEngine: Fix build with Xcode 9.3
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Error message:
.../qfontengine_coretext.mm:827:20: error: qualified reference to
'QFixed' is a constructor name rather than a type in this context
return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
Change-Id: Iebe26b3b087a16b10664208fc8851cbddb47f043
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
---
src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git old/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm new/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 25ff69d877d..98b753eff96 100644
--- old/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ new/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -824,7 +824,7 @@ void QCoreTextFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, gl
QFixed QCoreTextFontEngine::emSquareSize() const
{
- return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
+ return QFixed(int(CTFontGetUnitsPerEm(ctfont)));
}
QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
--
2.16.3

View File

@@ -1,6 +1,5 @@
# Set the system name to one of Android, Darwin, FreeBSD, Linux, or Windows
SET(CMAKE_SYSTEM_NAME @depends@)
SET(CMAKE_SYSTEM_PROCESSOR @arch@)
SET(CMAKE_BUILD_TYPE @release_type@)
OPTION(STATIC "Link libraries statically" ON)
@@ -24,7 +23,6 @@ SET(Readline_INCLUDE_DIR @prefix@/include)
SET(Readline_LIBRARY @prefix@/lib/libreadline.a)
SET(Terminfo_LIBRARY @prefix@/lib/libtinfo.a)
SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
@@ -57,7 +55,7 @@ SET(Boost_NO_SYSTEM_PATHS ON)
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_STATIC_RUNTIME ON)
SET(OPENSSL_ROOT_DIR @prefix@)
SET(OpenSSL_DIR @prefix@/lib)
SET(ARCHITECTURE @arch@)
# for libraries and headers in the target directories
@@ -65,14 +63,14 @@ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR} CACHE STRING "" FORCE)
# specify the cross compiler to be used. Darwin uses clang provided by the SDK.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_C_COMPILER @prefix@/native/bin/clang)
SET(CMAKE_C_COMPILER_TARGET x86_64-apple-darwin11)
SET(CMAKE_CXX_COMPILER @prefix@/native/bin/clang++ -stdlib=libc++)
SET(CMAKE_CXX_COMPILER_TARGET x86_64-apple-darwin11)
SET(CMAKE_ASM_COMPILER_TARGET x86_64-apple-darwin11)
SET(CMAKE_ASM-ATT_COMPILER_TARGET x86_64-apple-darwin11)
SET(_CMAKE_TOOLCHAIN_PREFIX x86_64-apple-darwin11-)
SET(APPLE True)
SET(BUILD_TAG "mac-x64")

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 2.8)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_DEBUG 1)
find_package(Boost COMPONENTS system filesystem thread date_time chrono regex )

View File

@@ -112,7 +112,7 @@ namespace epee
explicit byte_slice(std::string&& buffer);
//! Convert `stream` into a slice with zero allocations.
explicit byte_slice(byte_stream&& stream, bool shrink = true);
explicit byte_slice(byte_stream&& stream) noexcept;
byte_slice(byte_slice&& source) noexcept;
~byte_slice() noexcept = default;

View File

@@ -58,6 +58,7 @@ namespace epee
byte_buffer buffer_; //! Beginning of buffer
std::uint8_t* next_write_; //! Current write position
const std::uint8_t* end_; //! End of buffer
std::size_t increase_size_; //! Minimum buffer size increase
//! \post `requested <= available()`
void overflow(const std::size_t requested);
@@ -74,17 +75,29 @@ namespace epee
using char_type = std::uint8_t;
using Ch = char_type;
//! \return Default minimum size increase on buffer overflow
static constexpr std::size_t default_increase() noexcept { return 4096; }
//! Increase internal buffer by at least `byte_stream_increase` bytes.
byte_stream() noexcept
: byte_stream(default_increase())
{}
//! Increase internal buffer by at least `increase` bytes.
explicit byte_stream(const std::size_t increase) noexcept
: buffer_(nullptr),
next_write_(nullptr),
end_(nullptr)
end_(nullptr),
increase_size_(increase)
{}
byte_stream(byte_stream&& rhs) noexcept;
~byte_stream() noexcept = default;
byte_stream& operator=(byte_stream&& rhs) noexcept;
//! \return The minimum increase size on buffer overflow
std::size_t increase_size() const noexcept { return increase_size_; }
const std::uint8_t* data() const noexcept { return buffer_.get(); }
std::uint8_t* tellp() const noexcept { return next_write_; }
std::size_t available() const noexcept { return end_ - next_write_; }
@@ -104,9 +117,6 @@ namespace epee
check(more);
}
//! Reset write position, but do not release internal memory. \post `size() == 0`.
void clear() noexcept { next_write_ = buffer_.get(); }
/*! Copy `length` bytes starting at `ptr` to end of stream.
\throw std::range_error If exceeding max size_t value.
\throw std::bad_alloc If allocation fails. */
@@ -175,7 +185,7 @@ namespace epee
void put_n(const std::uint8_t ch, const std::size_t count)
{
check(count);
std::memset(tellp(), ch, count);
std::memset(tellp(), count, ch);
next_write_ += count;
}

View File

@@ -543,31 +543,6 @@ eof:
return it->second.second;
}
std::vector<std::string> get_command_list(const std::vector<std::string>& keywords = std::vector<std::string>())
{
std::vector<std::string> list;
list.reserve(m_command_handlers.size());
for(auto const& x:m_command_handlers)
{
bool take = true;
for(auto const& y:keywords)
{
bool in_usage = x.second.second.first.find(y) != std::string::npos;
bool in_description = x.second.second.second.find(y) != std::string::npos;
if (!(in_usage || in_description))
{
take = false;
break;
}
}
if (take)
{
list.push_back(x.first);
}
}
return list;
}
void set_handler(const std::string& cmd, const callback& hndlr, const std::string& usage = "", const std::string& description = "")
{
lookup::mapped_type & vt = m_command_handlers[cmd];

View File

@@ -24,23 +24,211 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _FILE_IO_UTILS_H_
#define _FILE_IO_UTILS_H_
#include <string>
#include <ctime>
#include <fstream>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#ifdef WIN32
#include <windows.h>
#include "string_tools.h"
#endif
// On Windows there is a problem with non-ASCII characters in path and file names
// as far as support by the standard components used is concerned:
// The various file stream classes, e.g. std::ifstream and std::ofstream, are
// part of the GNU C++ Library / libstdc++. On the most basic level they use the
// fopen() call as defined / made accessible to programs compiled within MSYS2
// by the stdio.h header file maintained by the MinGW project.
// The critical point: The implementation of fopen() is part of MSVCRT, the
// Microsoft Visual C/C++ Runtime Library, and this method does NOT offer any
// Unicode support.
// Monero code that would want to continue to use the normal file stream classes
// but WITH Unicode support could therefore not solve this problem on its own,
// but 2 different projects from 2 different maintaining groups would need changes
// in this particular direction - something probably difficult to achieve and
// with a long time to wait until all new versions / releases arrive.
// Implemented solution approach: Circumvent the problem by stopping to use std
// file stream classes on Windows and directly use Unicode-capable WIN32 API
// calls. Most of the code doing so is concentrated in this header file here.
namespace epee
{
namespace file_io_utils
{
bool is_file_exist(const std::string& path);
bool save_string_to_file(const std::string& path_to_file, const std::string& str);
bool get_file_time(const std::string& path_to_file, time_t& ft);
bool set_file_time(const std::string& path_to_file, const time_t& ft);
bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000);
bool append_string_to_file(const std::string& path_to_file, const std::string& str);
bool get_file_size(const std::string& path_to_file, uint64_t &size);
inline
bool is_file_exist(const std::string& path)
{
boost::filesystem::path p(path);
return boost::filesystem::exists(p);
}
inline
bool save_string_to_file(const std::string& path_to_file, const std::string& str)
{
#ifdef WIN32
std::wstring wide_path;
try { wide_path = string_tools::utf8_to_utf16(path_to_file); } catch (...) { return false; }
HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE)
return false;
DWORD bytes_written;
DWORD bytes_to_write = (DWORD)str.size();
BOOL result = WriteFile(file_handle, str.data(), bytes_to_write, &bytes_written, NULL);
CloseHandle(file_handle);
if (bytes_written != bytes_to_write)
result = FALSE;
return result;
#else
try
{
std::ofstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
fstream << str;
fstream.close();
return true;
}
catch(...)
{
return false;
}
#endif
}
inline
bool get_file_time(const std::string& path_to_file, time_t& ft)
{
boost::system::error_code ec;
ft = boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ec);
if(!ec)
return true;
else
return false;
}
inline
bool set_file_time(const std::string& path_to_file, const time_t& ft)
{
boost::system::error_code ec;
boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ft, ec);
if(!ec)
return true;
else
return false;
}
inline
bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000)
{
#ifdef WIN32
std::wstring wide_path;
try { wide_path = string_tools::utf8_to_utf16(path_to_file); } catch (...) { return false; }
HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE)
return false;
DWORD file_size = GetFileSize(file_handle, NULL);
if ((file_size == INVALID_FILE_SIZE) || (uint64_t)file_size > (uint64_t)max_size) {
CloseHandle(file_handle);
return false;
}
target_str.resize(file_size);
DWORD bytes_read;
BOOL result = ReadFile(file_handle, &target_str[0], file_size, &bytes_read, NULL);
CloseHandle(file_handle);
if (bytes_read != file_size)
result = FALSE;
return result;
#else
try
{
std::ifstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
std::ifstream::pos_type file_size = fstream.tellg();
if((uint64_t)file_size > (uint64_t)max_size) // ensure a large domain for comparison, and negative -> too large
return false;//don't go crazy
size_t file_size_t = static_cast<size_t>(file_size);
target_str.resize(file_size_t);
fstream.seekg (0, std::ios::beg);
fstream.read((char*)target_str.data(), target_str.size());
fstream.close();
return true;
}
catch(...)
{
return false;
}
#endif
}
inline
bool append_string_to_file(const std::string& path_to_file, const std::string& str)
{
// No special Windows implementation because so far not used in Monero code
try
{
std::ofstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file.c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::app);
fstream << str;
fstream.close();
return true;
}
catch(...)
{
return false;
}
}
inline
bool get_file_size(const std::string& path_to_file, uint64_t &size)
{
#ifdef WIN32
std::wstring wide_path;
try { wide_path = string_tools::utf8_to_utf16(path_to_file); } catch (...) { return false; }
HANDLE file_handle = CreateFileW(wide_path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE)
return false;
LARGE_INTEGER file_size;
BOOL result = GetFileSizeEx(file_handle, &file_size);
CloseHandle(file_handle);
if (result) {
size = file_size.QuadPart;
}
return size;
#else
try
{
std::ifstream fstream;
fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
size = fstream.tellg();
fstream.close();
return true;
}
catch(...)
{
return false;
}
#endif
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2020, The Monero Project
// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -32,7 +32,6 @@
#ifdef __cplusplus
#include <array>
#include <cstddef>
extern "C" {
#endif

View File

@@ -28,11 +28,9 @@
#pragma once
#include <boost/utility/value_init.hpp>
#include <boost/shared_ptr.hpp>
#include <limits>
#include <functional>
#include <vector>
#include <boost/thread.hpp>
#include <boost/utility/value_init.hpp>
namespace epee
{
#define STD_TRY_BEGIN() try {
@@ -97,15 +95,16 @@ namespace misc_utils
return memcmp(&_Left, &_Right, sizeof(_Left)) < 0;
}
bool sleep_no_w(long ms );
template <typename T>
T get_mid(const T &a, const T &b)
{
//returns the average of two numbers; overflow safe and works with at least all integral and floating point types
//(a+b)/2 = (a/2) + (b/2) + ((a - 2*(a/2)) + (b - 2*(b/2)))/2
return (a/2) + (b/2) + ((a - 2*(a/2)) + (b - 2*(b/2)))/2;
}
inline
bool sleep_no_w(long ms )
{
boost::this_thread::sleep(
boost::get_system_time() +
boost::posix_time::milliseconds( std::max<long>(ms,0) ) );
return true;
}
template<class type_vec_type>
type_vec_type median(std::vector<type_vec_type> &v)
@@ -123,7 +122,7 @@ namespace misc_utils
return v[n];
}else
{//2, 4, 6...
return get_mid<type_vec_type>(v[n-1],v[n]);
return (v[n-1] + v[n])/2;
}
}

View File

@@ -41,7 +41,7 @@
#define MAX_LOG_FILES 50
#define MCLOG_TYPE(level, cat, color, type, x) do { \
if (el::Loggers::allowed(level, cat)) { \
if (ELPP->vRegistry()->allowed(level, cat)) { \
el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
} \
} while (0)
@@ -89,7 +89,7 @@
#define IFLOG(level, cat, color, type, init, x) \
do { \
if (el::Loggers::allowed(level, cat)) { \
if (ELPP->vRegistry()->allowed(level, cat)) { \
init; \
el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
} \

View File

@@ -47,7 +47,7 @@
#endif
#include <iostream>
#include <ctime>
#include <boost/lexical_cast.hpp>
#pragma once
namespace epee
@@ -115,7 +115,15 @@ namespace misc_utils
}
std::string get_thread_string_id();
inline std::string get_thread_string_id()
{
#if defined(_WIN32)
return boost::lexical_cast<std::string>(GetCurrentThreadId());
#elif defined(__GNUC__)
return boost::lexical_cast<std::string>(pthread_self());
#endif
}
inline bool get_gmt_time(time_t t, struct tm &tm)
{

View File

@@ -64,13 +64,12 @@ namespace http
abstract_http_client() {}
virtual ~abstract_http_client() {}
bool set_server(const std::string& address, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect);
virtual bool set_proxy(const std::string& address);
virtual void set_server(std::string host, std::string port, boost::optional<login> user, ssl_options_t ssl_options = ssl_support_t::e_ssl_support_autodetect) = 0;
virtual void set_auto_connect(bool auto_connect) = 0;
virtual bool connect(std::chrono::milliseconds timeout) = 0;
virtual bool disconnect() = 0;
virtual bool is_connected(bool *ssl = NULL) = 0;
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
virtual uint64_t get_bytes_sent() const = 0;

View File

@@ -48,9 +48,12 @@
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp> //! \TODO Convert to std::shared_ptr
#include <boost/enable_shared_from_this.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/thread/thread.hpp>
#include <memory>
#include "byte_slice.h"
#include "net_utils_base.h"
#include "syncobj.h"
@@ -265,12 +268,6 @@ namespace net_utils
template<class t_callback>
bool connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeot, const t_callback &cb, const std::string& bind_ip = "0.0.0.0", epee::net_utils::ssl_support_t ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_autodetect);
boost::asio::ssl::context& get_ssl_context() noexcept
{
assert(m_state != nullptr);
return m_state->ssl_context;
}
typename t_protocol_handler::config_type& get_config_object()
{
assert(m_state != nullptr); // always set in constructor

View File

@@ -40,9 +40,8 @@
#include <boost/date_time/posix_time/posix_time.hpp> // TODO
#include <boost/thread/condition_variable.hpp> // TODO
#include <boost/make_shared.hpp>
#include <boost/thread.hpp>
#include "warnings.h"
#include "string_tools_lexical.h"
#include "string_tools.h"
#include "misc_language.h"
#include "net/local_ip.h"
#include "pragma_comp_defs.h"
@@ -208,6 +207,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
buffer_ssl_init_fill = 0;
if (is_income && m_ssl_support != epee::net_utils::ssl_support_t::e_ssl_support_disabled)
socket().async_receive(boost::asio::buffer(buffer_),
boost::asio::socket_base::message_peek,
strand_.wrap(
std::bind(&connection<t_protocol_handler>::handle_receive, self,
std::placeholders::_1,
@@ -270,6 +270,8 @@ PRAGMA_WARNING_DISABLE_VS(4355)
//_dbg3("[sock " << socket().native_handle() << "] add_ref, m_peer_number=" << mI->m_peer_number);
CRITICAL_REGION_LOCAL(self->m_self_refs_lock);
//_dbg3("[sock " << socket().native_handle() << "] add_ref 2, m_peer_number=" << mI->m_peer_number);
if(m_was_shutdown)
return false;
++m_reference_count;
m_self_ref = std::move(self);
return true;
@@ -332,9 +334,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
TRY_ENTRY();
//_info("[sock " << socket().native_handle() << "] Async read calledback.");
if (m_was_shutdown)
return;
if (!e)
{
double current_speed_down;
@@ -361,9 +360,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
CRITICAL_REGION_LOCAL( epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_in );
delay = epee::net_utils::network_throttle_manager::get_global_throttle_in().get_sleep_time_after_tick( bytes_transferred );
}
if (m_was_shutdown)
return;
delay *= 0.5;
long int ms = (long int)(delay * 100);
@@ -435,9 +431,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
std::size_t bytes_transferred)
{
TRY_ENTRY();
if (m_was_shutdown) return;
if (e)
{
// offload the error case
@@ -445,11 +438,13 @@ PRAGMA_WARNING_DISABLE_VS(4355)
return;
}
reset_timer(get_timeout_from_bytes_read(bytes_transferred), false);
buffer_ssl_init_fill += bytes_transferred;
MTRACE("we now have " << buffer_ssl_init_fill << "/" << get_ssl_magic_size() << " bytes needed to detect SSL");
if (buffer_ssl_init_fill < get_ssl_magic_size())
if (buffer_ssl_init_fill <= get_ssl_magic_size())
{
socket().async_receive(boost::asio::buffer(buffer_.data() + buffer_ssl_init_fill, buffer_.size() - buffer_ssl_init_fill),
boost::asio::socket_base::message_peek,
strand_.wrap(
boost::bind(&connection<t_protocol_handler>::handle_receive, connection<t_protocol_handler>::shared_from_this(),
boost::asio::placeholders::error,
@@ -475,7 +470,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
if (m_ssl_support == epee::net_utils::ssl_support_t::e_ssl_support_enabled)
{
// Handshake
if (!handshake(boost::asio::ssl::stream_base::server, boost::asio::const_buffer(buffer_.data(), buffer_ssl_init_fill)))
if (!handshake(boost::asio::ssl::stream_base::server))
{
MERROR("SSL handshake failed");
boost::interprocess::ipcdetail::atomic_write32(&m_want_close_connection, 1);
@@ -490,11 +485,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
return;
}
}
else
{
handle_read(e, buffer_ssl_init_fill);
return;
}
async_read_some(boost::asio::buffer(buffer_),
strand_.wrap(
@@ -561,7 +551,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
{ // LOCK: chunking
epee::critical_region_t<decltype(m_chunking_lock)> send_guard(m_chunking_lock); // *** critical ***
MDEBUG("do_send() will SPLIT into small chunks, from packet="<<message_size<<" B for ptr="<<(const void*)message_data);
MDEBUG("do_send() will SPLIT into small chunks, from packet="<<message_size<<" B for ptr="<<message_data);
// 01234567890
// ^^^^ (pos=0, len=4) ; pos:=pos+len, pos=4
// ^^^^ (pos=4, len=4) ; pos:=pos+len, pos=8
@@ -574,14 +564,14 @@ PRAGMA_WARNING_DISABLE_VS(4355)
while (!message.empty()) {
byte_slice chunk = message.take_slice(chunksize_good);
MDEBUG("chunk_start="<<(void*)chunk.data()<<" ptr="<<(const void*)message_data<<" pos="<<(chunk.data() - message_data));
MDEBUG("chunk_start="<<(void*)chunk.data()<<" ptr="<<message_data<<" pos="<<(chunk.data() - message_data));
MDEBUG("part of " << message.size() << ": pos="<<(chunk.data() - message_data) << " len="<<chunk.size());
bool ok = do_send_chunk(std::move(chunk)); // <====== ***
all_ok = all_ok && ok;
if (!all_ok) {
MDEBUG("do_send() DONE ***FAILED*** from packet="<<message_size<<" B for ptr="<<(const void*)message_data);
MDEBUG("do_send() DONE ***FAILED*** from packet="<<message_size<<" B for ptr="<<message_data);
MDEBUG("do_send() SEND was aborted in middle of big package - this is mostly harmless "
<< " (e.g. peer closed connection) but if it causes trouble tell us at #monero-dev. " << message_size);
return false; // partial failure in sending
@@ -589,7 +579,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
// (in catch block, or uniq pointer) delete buf;
} // each chunk
MDEBUG("do_send() DONE SPLIT from packet="<<message_size<<" B for ptr="<<(const void*)message_data);
MDEBUG("do_send() DONE SPLIT from packet="<<message_size<<" B for ptr="<<message_data);
MDEBUG("do_send() m_connection_type = " << m_connection_type);
@@ -661,8 +651,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
m_send_que_lock.lock();
_dbg1("sleep for queue: " << ms);
if (m_was_shutdown)
return false;
if (retry > retry_limit) {
MWARNING("send que size is more than ABSTRACT_SERVER_SEND_QUE_MAX_COUNT(" << ABSTRACT_SERVER_SEND_QUE_MAX_COUNT << "), shutting down connection");
@@ -760,8 +748,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
template<class t_protocol_handler>
void connection<t_protocol_handler>::reset_timer(boost::posix_time::milliseconds ms, bool add)
{
const auto tms = ms.total_milliseconds();
if (tms < 0 || (add && tms == 0))
if (ms.total_milliseconds() < 0)
{
MWARNING("Ignoring negative timeout " << ms);
return;

View File

@@ -8,7 +8,7 @@
// ! (how ever if in some wonderful juristdictions that is not the case, then why not make another sub-class withat that members and licence it as epee part)
// ! Working on above premise, IF this is valid in your juristdictions, then consider this code as released as:
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -132,10 +132,10 @@ class connection_basic { // not-templated base class for rapid developmet of som
ssl_support_t get_ssl_support() const { return m_ssl_support; }
void disable_ssl() { m_ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_disabled; }
bool handshake(boost::asio::ssl::stream_base::handshake_type type, boost::asio::const_buffer buffer = {})
bool handshake(boost::asio::ssl::stream_base::handshake_type type)
{
//m_state != nullptr verified in constructor
return m_state->ssl_options().handshake(socket_, type, buffer);
return m_state->ssl_options().handshake(socket_, type);
}
template<typename MutableBufferSequence, typename ReadHandler>

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -27,13 +27,14 @@
#pragma once
#include "memwipe.h"
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <boost/utility/string_ref.hpp>
#include <string>
#include <utility>
#include <list>
#include "memwipe.h"
#include "string_tools.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
@@ -65,9 +66,34 @@ namespace net_utils
typedef std::list<std::pair<std::string, std::string> > fields_list;
std::string get_value_from_fields_list(const std::string& param_name, const net_utils::http::fields_list& fields);
inline
std::string get_value_from_fields_list(const std::string& param_name, const net_utils::http::fields_list& fields)
{
fields_list::const_iterator it = fields.begin();
for(; it != fields.end(); it++)
if(!string_tools::compare_no_case(param_name, it->first))
break;
std::string get_value_from_uri_line(const std::string& param_name, const std::string& uri);
if(it==fields.end())
return std::string();
return it->second;
}
inline
std::string get_value_from_uri_line(const std::string& param_name, const std::string& uri)
{
std::string buff = "([\\?|&])";
buff += param_name + "=([^&]*)";
boost::regex match_param(buff.c_str(), boost::regex::icase | boost::regex::normal);
boost::smatch result;
if(boost::regex_search(uri, result, match_param, boost::match_default) && result[0].matched)
{
return result[2];
}
return std::string();
}
static inline void add_field(std::string& out, const boost::string_ref name, const boost::string_ref value)
{

View File

@@ -30,6 +30,7 @@
#include <ctype.h>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/optional/optional.hpp>
#include <boost/utility/string_ref.hpp>
//#include <mbstring.h>
@@ -45,7 +46,6 @@
#endif
#include "string_tools.h"
#include "string_tools_lexical.h"
#include "reg_exp_definer.h"
#include "abstract_http_client.h"
#include "http_base.h"
@@ -233,7 +233,7 @@ namespace net_utils
}
//---------------------------------------------------------------------------
inline bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
inline bool invoke(const boost::string_ref uri, const boost::string_ref method, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
{
CRITICAL_REGION_LOCAL(m_lock);
if(!is_connected())
@@ -885,6 +885,14 @@ namespace net_utils
}
};
typedef http_simple_client_template<blocked_mode_client> http_simple_client;
class http_simple_client_factory : public http_client_factory
{
public:
std::unique_ptr<abstract_http_client> create() override {
return std::unique_ptr<epee::net_utils::http::abstract_http_client>(new epee::net_utils::http::http_simple_client());
}
};
}
}
}

View File

@@ -42,17 +42,8 @@
MINFO("HTTP [" << m_conn_context.m_remote_address.host_str() << "] " << query_info.m_http_method_str << " " << query_info.m_URI); \
response.m_response_code = 200; \
response.m_response_comment = "Ok"; \
try \
{ \
if(!handle_http_request_map(query_info, response, m_conn_context)) \
{response.m_response_code = 404;response.m_response_comment = "Not found";} \
} \
catch (const std::exception &e) \
{ \
MERROR(m_conn_context << "Exception in handle_http_request_map: " << e.what()); \
response.m_response_code = 500; \
response.m_response_comment = "Internal Server Error"; \
} \
if(!handle_http_request_map(query_info, response, m_conn_context)) \
{response.m_response_code = 404;response.m_response_comment = "Not found";} \
return true; \
}
@@ -74,21 +65,13 @@
uint64_t ticks = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::request> req; \
bool parse_res = epee::serialization::load_t_from_json(static_cast<command_type::request&>(req), query_info.m_body); \
if (!parse_res) \
{ \
MERROR("Failed to parse json: \r\n" << query_info.m_body); \
response_info.m_response_code = 400; \
response_info.m_response_comment = "Bad request"; \
return true; \
} \
CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse json: \r\n" << query_info.m_body); \
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\
MINFO(m_conn_context << "calling " << s_pattern); \
bool res = false; \
try { res = callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), &m_conn_context)) \
{ \
MERROR(m_conn_context << "Failed to " << #callback_f << "()"); \
response_info.m_response_code = 500; \
response_info.m_response_comment = "Internal Server Error"; \
return true; \
@@ -110,30 +93,20 @@
uint64_t ticks = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::request> req; \
bool parse_res = epee::serialization::load_t_from_binary(static_cast<command_type::request&>(req), epee::strspan<uint8_t>(query_info.m_body)); \
if (!parse_res) \
{ \
MERROR("Failed to parse bin body data, body size=" << query_info.m_body.size()); \
response_info.m_response_code = 400; \
response_info.m_response_comment = "Bad request"; \
return true; \
} \
CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse bin body data, body size=" << query_info.m_body.size()); \
uint64_t ticks1 = misc_utils::get_tick_count(); \
boost::value_initialized<command_type::response> resp;\
MINFO(m_conn_context << "calling " << s_pattern); \
bool res = false; \
try { res = callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "()"); } \
if (!res) \
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), &m_conn_context)) \
{ \
MERROR(m_conn_context << "Failed to " << #callback_f << "()"); \
response_info.m_response_code = 500; \
response_info.m_response_comment = "Internal Server Error"; \
return true; \
} \
uint64_t ticks2 = misc_utils::get_tick_count(); \
epee::byte_slice buffer; \
epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), buffer, 64 * 1024); \
epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), response_info.m_body); \
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
response_info.m_body.assign(reinterpret_cast<const char*>(buffer.data()), buffer.size()); \
response_info.m_mime_tipe = " application/octet-stream"; \
response_info.m_header_info.m_content_type = " application/octet-stream"; \
MDEBUG( s_pattern << "() processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms"); \
@@ -211,10 +184,7 @@
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
MINFO(m_conn_context << "Calling RPC method " << method_name); \
bool res = false; \
try { res = callback_f(req.params, resp.result, fail_resp.error, &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
if(!callback_f(req.params, resp.result, fail_resp.error, &m_conn_context)) \
{ \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
@@ -233,10 +203,7 @@
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
MINFO(m_conn_context << "calling RPC method " << method_name); \
bool res = false; \
try { res = callback_f(req.params, resp.result, fail_resp.error, response_info, &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
if(!callback_f(req.params, resp.result, fail_resp.error, response_info, &m_conn_context)) \
{ \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
@@ -250,10 +217,7 @@
{ \
PREPARE_OBJECTS_FROM_JSON(command_type) \
MINFO(m_conn_context << "calling RPC method " << method_name); \
bool res = false; \
try { res = callback_f(req.params, resp.result, &m_conn_context); } \
catch (const std::exception &e) { MERROR(m_conn_context << "Failed to " << #callback_f << "(): " << e.what()); } \
if (!res) \
if(!callback_f(req.params, resp.result, &m_conn_context)) \
{ \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
fail_resp.jsonrpc = "2.0"; \

View File

@@ -31,7 +31,7 @@
#include <cstdint>
#include "byte_stream.h"
#include "byte_slice.h"
#include "net_utils_base.h"
#include "span.h"
@@ -39,7 +39,6 @@
namespace epee
{
class byte_slice;
namespace levin
{
#pragma pack(push)
@@ -73,8 +72,7 @@ namespace levin
#define LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED 0
#define LEVIN_INITIAL_MAX_PACKET_SIZE 256*1024 // 256 KiB before handshake
#define LEVIN_DEFAULT_MAX_PACKET_SIZE 100000000 //100MB by default after handshake
#define LEVIN_DEFAULT_MAX_PACKET_SIZE 100000000 //100MB by default
#define LEVIN_PACKET_REQUEST 0x00000001
#define LEVIN_PACKET_RESPONSE 0x00000002
@@ -84,12 +82,11 @@ namespace levin
#define LEVIN_PROTOCOL_VER_0 0
#define LEVIN_PROTOCOL_VER_1 1
template<class t_connection_context = net_utils::connection_context_base>
struct levin_commands_handler
{
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, byte_stream& buff_out, t_connection_context& context)=0;
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_connection_context& context)=0;
virtual int notify(int command, const epee::span<const uint8_t> in_buff, t_connection_context& context)=0;
virtual void callback(t_connection_context& context){};
@@ -127,41 +124,12 @@ namespace levin
}
}
//! Provides space for levin (p2p) header, so that payload can be sent without copy
class message_writer
{
byte_slice finalize(uint32_t command, uint32_t flags, uint32_t return_code, bool expect_response);
public:
using header = bucket_head2;
explicit message_writer(std::size_t reserve = 8192);
message_writer(const message_writer&) = delete;
message_writer(message_writer&&) = default;
~message_writer() = default;
message_writer& operator=(const message_writer&) = delete;
message_writer& operator=(message_writer&&) = default;
//! \return Size of payload (excludes header size).
std::size_t payload_size() const noexcept
{
return buffer.size() < sizeof(header) ? 0 : buffer.size() - sizeof(header);
}
byte_slice finalize_invoke(uint32_t command) { return finalize(command, LEVIN_PACKET_REQUEST, 0, true); }
byte_slice finalize_notify(uint32_t command) { return finalize(command, LEVIN_PACKET_REQUEST, 0, false); }
byte_slice finalize_response(uint32_t command, uint32_t return_code)
{
return finalize(command, LEVIN_PACKET_RESPONSE, return_code, false);
}
//! Has space for levin header until a finalize method is used
byte_stream buffer;
};
//! \return Intialized levin header.
bucket_head2 make_header(uint32_t command, uint64_t msg_size, uint32_t flags, bool expect_response) noexcept;
//! \return A levin notification message.
byte_slice make_notify(int command, epee::span<const std::uint8_t> payload);
/*! Generate a dummy levin message.
\param noise_bytes Total size of the returned `byte_slice`.
@@ -171,11 +139,12 @@ namespace levin
/*! Generate 1+ levin messages that are identical to the noise message size.
\param noise_size Each levin message will be identical to this value.
\param noise Each levin message will be identical to the size of this
message. The bytes from this message will be used for padding.
\return `nullptr` if `noise.size()` is less than the levin header size.
Otherwise, a levin notification message OR 2+ levin fragment messages.
Each message is `noise.size()` in length. */
byte_slice make_fragmented_notify(const std::size_t noise_size, int command, message_writer message);
byte_slice make_fragmented_notify(const byte_slice& noise, int command, epee::span<const std::uint8_t> payload);
}
}

View File

@@ -51,21 +51,6 @@
#define MIN_BYTES_WANTED 512
#endif
template<typename context_t>
void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, const char* category)
{
MCINFO("net.p2p.traffic", context << bytes << " bytes " << (sent ? "sent" : "received") << (error ? "/corrupt" : "")
<< " for category " << category << " initiated by " << (initiator ? "us" : "peer"));
}
template<typename context_t>
void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, int command)
{
char buf[32];
snprintf(buf, sizeof(buf), "command-%u", command);
on_levin_traffic(context, initiator, sent, error, bytes, buf);
}
namespace epee
{
namespace levin
@@ -99,14 +84,14 @@ class async_protocol_handler_config
public:
typedef t_connection_context connection_context;
uint64_t m_initial_max_packet_size;
uint64_t m_max_packet_size;
uint64_t m_max_packet_size;
uint64_t m_invoke_timeout;
int invoke(int command, message_writer in_msg, std::string& buff_out, boost::uuids::uuid connection_id);
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, boost::uuids::uuid connection_id);
template<class callback_t>
int invoke_async(int command, message_writer in_msg, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED);
int invoke_async(int command, const epee::span<const uint8_t> in_buff, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED);
int notify(int command, const epee::span<const uint8_t> in_buff, boost::uuids::uuid connection_id);
int send(epee::byte_slice message, const boost::uuids::uuid& connection_id);
bool close(boost::uuids::uuid connection_id);
bool update_connection_context(const t_connection_context& contxt);
@@ -120,7 +105,7 @@ public:
size_t get_in_connections_count();
void set_handler(levin_commands_handler<t_connection_context>* handler, void (*destroy)(levin_commands_handler<t_connection_context>*) = NULL);
async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_initial_max_packet_size(LEVIN_INITIAL_MAX_PACKET_SIZE), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_invoke_timeout(LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_invoke_timeout(LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
{}
~async_protocol_handler_config() { set_handler(NULL, NULL); }
void del_out_connections(size_t count);
@@ -136,17 +121,12 @@ class async_protocol_handler
{
std::string m_fragment_buffer;
bool send_message(byte_slice message)
bool send_message(uint32_t command, epee::span<const uint8_t> in_buff, uint32_t flags, bool expect_response)
{
if (message.size() < sizeof(message_writer::header))
const bucket_head2 head = make_header(command, in_buff.size(), flags, expect_response);
if(!m_pservice_endpoint->do_send(byte_slice{as_byte_span(head), in_buff}))
return false;
message_writer::header head;
std::memcpy(std::addressof(head), message.data(), sizeof(head));
if(!m_pservice_endpoint->do_send(std::move(message)))
return false;
on_levin_traffic(m_connection_context, true, true, false, head.m_cb, head.m_command);
MDEBUG(m_connection_context << "LEVIN_PACKET_SENT. [len=" << head.m_cb
<< ", flags" << head.m_flags
<< ", r?=" << head.m_have_to_return_data
@@ -165,6 +145,7 @@ public:
stream_state_body
};
std::atomic<bool> m_deletion_initiated;
std::atomic<bool> m_protocol_released;
volatile uint32_t m_invoke_buf_ready;
@@ -181,7 +162,6 @@ public:
net_utils::i_service_endpoint* m_pservice_endpoint;
config_type& m_config;
t_connection_context& m_connection_context;
std::atomic<uint64_t> m_max_packet_size;
net_utils::buffer m_cache_in_buffer;
stream_state m_state;
@@ -309,12 +289,12 @@ public:
m_current_head(bucket_head2()),
m_pservice_endpoint(psnd_hndlr),
m_config(config),
m_connection_context(conn_context),
m_max_packet_size(config.m_initial_max_packet_size),
m_connection_context(conn_context),
m_cache_in_buffer(4 * 1024),
m_state(stream_state_head)
{
m_close_called = 0;
m_deletion_initiated = false;
m_protocol_released = false;
m_wait_count = 0;
m_oponent_protocol_ver = 0;
@@ -327,6 +307,7 @@ public:
try
{
m_deletion_initiated = true;
if(m_connection_initialized)
{
m_config.del_connection(this);
@@ -418,14 +399,13 @@ public:
}
// these should never fail, but do runtime check for safety
const uint64_t max_packet_size = m_max_packet_size;
CHECK_AND_ASSERT_MES(max_packet_size >= m_cache_in_buffer.size(), false, "Bad m_cache_in_buffer.size()");
CHECK_AND_ASSERT_MES(max_packet_size - m_cache_in_buffer.size() >= m_fragment_buffer.size(), false, "Bad m_cache_in_buffer.size() + m_fragment_buffer.size()");
CHECK_AND_ASSERT_MES(m_config.m_max_packet_size >= m_cache_in_buffer.size(), false, "Bad m_cache_in_buffer.size()");
CHECK_AND_ASSERT_MES(m_config.m_max_packet_size - m_cache_in_buffer.size() >= m_fragment_buffer.size(), false, "Bad m_cache_in_buffer.size() + m_fragment_buffer.size()");
// flipped to subtraction; prevent overflow since m_max_packet_size is variable and public
if(cb > max_packet_size - m_cache_in_buffer.size() - m_fragment_buffer.size())
if(cb > m_config.m_max_packet_size - m_cache_in_buffer.size() - m_fragment_buffer.size())
{
MWARNING(m_connection_context << "Maximum packet size exceed!, m_max_packet_size = " << max_packet_size
MWARNING(m_connection_context << "Maximum packet size exceed!, m_max_packet_size = " << m_config.m_max_packet_size
<< ", packet received " << m_cache_in_buffer.size() + cb
<< ", connection will be closed.");
return false;
@@ -450,7 +430,7 @@ public:
//async call scenario
boost::shared_ptr<invoke_response_handler_base> response_handler = m_invoke_response_handlers.front();
response_handler->reset_timer();
MDEBUG(m_connection_context << "LEVIN_PACKET partial msg received. len=" << cb << ", current total " << m_cache_in_buffer.size() << "/" << m_current_head.m_cb << " (" << (100.0f * m_cache_in_buffer.size() / (m_current_head.m_cb ? m_current_head.m_cb : 1)) << "%)");
MDEBUG(m_connection_context << "LEVIN_PACKET partial msg received. len=" << cb);
}
}
break;
@@ -485,14 +465,6 @@ public:
temp = std::move(m_fragment_buffer);
m_fragment_buffer.clear();
std::memcpy(std::addressof(m_current_head), std::addressof(temp[0]), sizeof(bucket_head2));
const size_t max_bytes = m_connection_context.get_max_bytes(m_current_head.m_command);
if(m_current_head.m_cb > std::min<size_t>(max_packet_size, max_bytes))
{
MERROR(m_connection_context << "Maximum packet size exceed!, m_max_packet_size = " << std::min<size_t>(max_packet_size, max_bytes)
<< ", packet header received " << m_current_head.m_cb << ", command " << m_current_head.m_command
<< ", connection will be closed.");
return false;
}
buff_to_invoke = {reinterpret_cast<const uint8_t*>(temp.data()) + sizeof(bucket_head2), temp.size() - sizeof(bucket_head2)};
}
@@ -542,17 +514,23 @@ public:
{
if(m_current_head.m_have_to_return_data)
{
levin::message_writer return_message{32 * 1024};
std::string return_buff;
const uint32_t return_code = m_config.m_pcommands_handler->invoke(
m_current_head.m_command, buff_to_invoke, return_message.buffer, m_connection_context
m_current_head.m_command, buff_to_invoke, return_buff, m_connection_context
);
// peer_id remains unset if dropped
if (m_current_head.m_command == m_connection_context.handshake_command() && m_connection_context.handshake_complete())
m_max_packet_size = m_config.m_max_packet_size;
bucket_head2 head = make_header(m_current_head.m_command, return_buff.size(), LEVIN_PACKET_RESPONSE, false);
head.m_return_code = SWAP32LE(return_code);
return_buff.insert(0, reinterpret_cast<const char*>(&head), sizeof(head));
if(!send_message(return_message.finalize_response(m_current_head.m_command, return_code)))
if(!m_pservice_endpoint->do_send(byte_slice{std::move(return_buff)}))
return false;
MDEBUG(m_connection_context << "LEVIN_PACKET_SENT. [len=" << head.m_cb
<< ", flags" << head.m_flags
<< ", r?=" << head.m_have_to_return_data
<<", cmd = " << head.m_command
<< ", ver=" << head.m_protocol_version);
}
else
m_config.m_pcommands_handler->notify(m_current_head.m_command, buff_to_invoke, m_connection_context);
@@ -599,11 +577,10 @@ public:
m_cache_in_buffer.erase(sizeof(bucket_head2));
m_state = stream_state_body;
m_oponent_protocol_ver = m_current_head.m_protocol_version;
const size_t max_bytes = m_connection_context.get_max_bytes(m_current_head.m_command);
if(m_current_head.m_cb > std::min<size_t>(max_packet_size, max_bytes))
if(m_current_head.m_cb > m_config.m_max_packet_size)
{
LOG_ERROR_CC(m_connection_context, "Maximum packet size exceed!, m_max_packet_size = " << std::min<size_t>(max_packet_size, max_bytes)
<< ", packet header received " << m_current_head.m_cb << ", command " << m_current_head.m_command
LOG_ERROR_CC(m_connection_context, "Maximum packet size exceed!, m_max_packet_size = " << m_config.m_max_packet_size
<< ", packet header received " << m_current_head.m_cb
<< ", connection will be closed.");
return false;
}
@@ -629,7 +606,7 @@ public:
}
template<class callback_t>
bool async_invoke(int command, message_writer in_msg, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
bool async_invoke(int command, const epee::span<const uint8_t> in_buff, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
{
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler(
boost::bind(&async_protocol_handler::finish_outer_call, this));
@@ -640,15 +617,24 @@ public:
int err_code = LEVIN_OK;
do
{
if(m_deletion_initiated)
{
err_code = LEVIN_ERROR_CONNECTION_DESTROYED;
break;
}
CRITICAL_REGION_LOCAL(m_call_lock);
if(m_deletion_initiated)
{
err_code = LEVIN_ERROR_CONNECTION_DESTROYED;
break;
}
boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0);
CRITICAL_REGION_BEGIN(m_invoke_response_handlers_lock);
if (command == m_connection_context.handshake_command())
m_max_packet_size = m_config.m_max_packet_size;
if(!send_message(in_msg.finalize_invoke(command)))
if(!send_message(command, in_buff, LEVIN_PACKET_REQUEST, true))
{
LOG_ERROR_CC(m_connection_context, "Failed to do_send");
err_code = LEVIN_ERROR_CONNECTION;
@@ -674,19 +660,22 @@ public:
return true;
}
int invoke(int command, message_writer in_msg, std::string& buff_out)
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out)
{
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler(
boost::bind(&async_protocol_handler::finish_outer_call, this));
if(m_deletion_initiated)
return LEVIN_ERROR_CONNECTION_DESTROYED;
CRITICAL_REGION_LOCAL(m_call_lock);
if(m_deletion_initiated)
return LEVIN_ERROR_CONNECTION_DESTROYED;
boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0);
if (command == m_connection_context.handshake_command())
m_max_packet_size = m_config.m_max_packet_size;
if (!send_message(in_msg.finalize_invoke(command)))
if (!send_message(command, in_buff, LEVIN_PACKET_REQUEST, true))
{
LOG_ERROR_CC(m_connection_context, "Failed to send request");
return LEVIN_ERROR_CONNECTION;
@@ -695,7 +684,7 @@ public:
uint64_t ticks_start = misc_utils::get_tick_count();
size_t prev_size = 0;
while(!boost::interprocess::ipcdetail::atomic_read32(&m_invoke_buf_ready) && !m_protocol_released)
while(!boost::interprocess::ipcdetail::atomic_read32(&m_invoke_buf_ready) && !m_deletion_initiated && !m_protocol_released)
{
if(m_cache_in_buffer.size() - prev_size >= MIN_BYTES_WANTED)
{
@@ -712,7 +701,7 @@ public:
return LEVIN_ERROR_CONNECTION_DESTROYED;
}
if(m_protocol_released)
if(m_deletion_initiated || m_protocol_released)
return LEVIN_ERROR_CONNECTION_DESTROYED;
CRITICAL_REGION_BEGIN(m_local_inv_buff_lock);
@@ -723,9 +712,31 @@ public:
return m_invoke_result_code;
}
/*! Sends `message` without adding a levin header. The message must have been
created with `make_noise_notify`, `make_fragmented_notify`, or
`message_writer::finalize_notify`. See additional instructions for
int notify(int command, const epee::span<const uint8_t> in_buff)
{
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler(
boost::bind(&async_protocol_handler::finish_outer_call, this));
if(m_deletion_initiated)
return LEVIN_ERROR_CONNECTION_DESTROYED;
CRITICAL_REGION_LOCAL(m_call_lock);
if(m_deletion_initiated)
return LEVIN_ERROR_CONNECTION_DESTROYED;
if (!send_message(command, in_buff, LEVIN_PACKET_REQUEST, false))
{
LOG_ERROR_CC(m_connection_context, "Failed to send notify message");
return -1;
}
return 1;
}
/*! Sends `message` without adding a levin header. The message must have
been created with `make_notify`, `make_noise_notify` or
`make_fragmented_notify`. See additional instructions for
`make_fragmented_notify`.
\return 1 on success */
@@ -735,11 +746,17 @@ public:
boost::bind(&async_protocol_handler::finish_outer_call, this)
);
if (!send_message(std::move(message)))
if(m_deletion_initiated)
return LEVIN_ERROR_CONNECTION_DESTROYED;
const std::size_t length = message.size();
if (!m_pservice_endpoint->do_send(std::move(message)))
{
LOG_ERROR_CC(m_connection_context, "Failed to send message, dropping it");
return -1;
}
MDEBUG(m_connection_context << "LEVIN_PACKET_SENT. [len=" << (length - sizeof(bucket_head2)) << ", r?=0]");
return 1;
}
//------------------------------------------------------------------------------------------
@@ -760,32 +777,36 @@ void async_protocol_handler_config<t_connection_context>::del_connection(async_p
template<class t_connection_context>
void async_protocol_handler_config<t_connection_context>::delete_connections(size_t count, bool incoming)
{
std::vector<typename connections_map::mapped_type> connections;
auto scope_exit_handler = misc_utils::create_scope_leave_handler([&connections]{
for (auto &aph: connections)
aph->finish_outer_call();
});
std::vector <boost::uuids::uuid> connections;
CRITICAL_REGION_BEGIN(m_connects_lock);
for (auto& c: m_connects)
{
if (c.second->m_connection_context.m_is_income == incoming)
if (c.second->start_outer_call())
connections.push_back(c.second);
connections.push_back(c.first);
}
// close random connections from the provided set
// TODO or better just keep removing random elements (performance)
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle(connections.begin(), connections.end(), std::default_random_engine(seed));
for (size_t i = 0; i < connections.size() && i < count; ++i)
m_connects.erase(connections[i]->get_connection_id());
while (count > 0 && connections.size() > 0)
{
try
{
auto i = connections.end() - 1;
async_protocol_handler<t_connection_context> *conn = m_connects.at(*i);
del_connection(conn);
conn->close();
connections.erase(i);
}
catch (const std::out_of_range &e)
{
MWARNING("Connection not found in m_connects, continuing");
}
--count;
}
CRITICAL_REGION_END();
for (size_t i = 0; i < connections.size() && i < count; ++i)
connections[i]->close();
}
//------------------------------------------------------------------------------------------
template<class t_connection_context>
@@ -829,53 +850,41 @@ int async_protocol_handler_config<t_connection_context>::find_and_lock_connectio
}
//------------------------------------------------------------------------------------------
template<class t_connection_context>
int async_protocol_handler_config<t_connection_context>::invoke(int command, message_writer in_msg, std::string& buff_out, boost::uuids::uuid connection_id)
int async_protocol_handler_config<t_connection_context>::invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, boost::uuids::uuid connection_id)
{
async_protocol_handler<t_connection_context>* aph;
int r = find_and_lock_connection(connection_id, aph);
return LEVIN_OK == r ? aph->invoke(command, std::move(in_msg), buff_out) : r;
return LEVIN_OK == r ? aph->invoke(command, in_buff, buff_out) : r;
}
//------------------------------------------------------------------------------------------
template<class t_connection_context> template<class callback_t>
int async_protocol_handler_config<t_connection_context>::invoke_async(int command, message_writer in_msg, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout)
int async_protocol_handler_config<t_connection_context>::invoke_async(int command, const epee::span<const uint8_t> in_buff, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout)
{
async_protocol_handler<t_connection_context>* aph;
int r = find_and_lock_connection(connection_id, aph);
return LEVIN_OK == r ? aph->async_invoke(command, std::move(in_msg), cb, timeout) : r;
return LEVIN_OK == r ? aph->async_invoke(command, in_buff, cb, timeout) : r;
}
//------------------------------------------------------------------------------------------
template<class t_connection_context> template<class callback_t>
bool async_protocol_handler_config<t_connection_context>::foreach_connection(const callback_t &cb)
{
std::vector<typename connections_map::mapped_type> conn;
auto scope_exit_handler = misc_utils::create_scope_leave_handler([&conn]{
for (auto &aph: conn)
aph->finish_outer_call();
});
CRITICAL_REGION_BEGIN(m_connects_lock);
conn.reserve(m_connects.size());
for (auto &e: m_connects)
if (e.second->start_outer_call())
conn.push_back(e.second);
CRITICAL_REGION_END()
for (auto &aph: conn)
if (!cb(aph->get_context_ref()))
CRITICAL_REGION_LOCAL(m_connects_lock);
for(auto& c: m_connects)
{
async_protocol_handler<t_connection_context>* aph = c.second;
if(!cb(aph->get_context_ref()))
return false;
}
return true;
}
//------------------------------------------------------------------------------------------
template<class t_connection_context> template<class callback_t>
bool async_protocol_handler_config<t_connection_context>::for_connection(const boost::uuids::uuid &connection_id, const callback_t &cb)
{
async_protocol_handler<t_connection_context>* aph = nullptr;
if (find_and_lock_connection(connection_id, aph) != LEVIN_OK)
CRITICAL_REGION_LOCAL(m_connects_lock);
async_protocol_handler<t_connection_context>* aph = find_connection(connection_id);
if (!aph)
return false;
auto scope_exit_handler = misc_utils::create_scope_leave_handler(
boost::bind(&async_protocol_handler<t_connection_context>::finish_outer_call, aph));
if(!cb(aph->get_context_ref()))
return false;
return true;
@@ -920,6 +929,14 @@ void async_protocol_handler_config<t_connection_context>::set_handler(levin_comm
}
//------------------------------------------------------------------------------------------
template<class t_connection_context>
int async_protocol_handler_config<t_connection_context>::notify(int command, const epee::span<const uint8_t> in_buff, boost::uuids::uuid connection_id)
{
async_protocol_handler<t_connection_context>* aph;
int r = find_and_lock_connection(connection_id, aph);
return LEVIN_OK == r ? aph->notify(command, in_buff) : r;
}
//------------------------------------------------------------------------------------------
template<class t_connection_context>
int async_protocol_handler_config<t_connection_context>::send(byte_slice message, const boost::uuids::uuid& connection_id)
{
async_protocol_handler<t_connection_context>* aph;
@@ -930,14 +947,12 @@ int async_protocol_handler_config<t_connection_context>::send(byte_slice message
template<class t_connection_context>
bool async_protocol_handler_config<t_connection_context>::close(boost::uuids::uuid connection_id)
{
async_protocol_handler<t_connection_context>* aph = nullptr;
if (find_and_lock_connection(connection_id, aph) != LEVIN_OK)
CRITICAL_REGION_LOCAL(m_connects_lock);
async_protocol_handler<t_connection_context>* aph = find_connection(connection_id);
if (!aph)
return false;
auto scope_exit_handler = misc_utils::create_scope_leave_handler(
boost::bind(&async_protocol_handler<t_connection_context>::finish_outer_call, aph));
if (!aph->close())
return false;
CRITICAL_REGION_LOCAL(m_connects_lock);
m_connects.erase(connection_id);
return true;
}

View File

@@ -28,6 +28,8 @@
#pragma once
#include <string>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/ip/address_v6.hpp>
#include "int-util.h"
// IP addresses are kept in network byte order
@@ -38,6 +40,30 @@ namespace epee
{
namespace net_utils
{
inline
bool is_ipv6_local(const std::string& ip)
{
auto addr = boost::asio::ip::address_v6::from_string(ip);
// ipv6 link-local unicast addresses are fe80::/10
bool is_link_local = addr.is_link_local();
auto addr_bytes = addr.to_bytes();
// ipv6 unique local unicast addresses start with fc00::/7 -- (fcXX or fdXX)
bool is_unique_local_unicast = (addr_bytes[0] == 0xfc || addr_bytes[0] == 0xfd);
return is_link_local || is_unique_local_unicast;
}
inline
bool is_ipv6_loopback(const std::string& ip)
{
// ipv6 loopback is ::1
return boost::asio::ip::address_v6::from_string(ip).is_loopback();
}
inline
bool is_ip_local(uint32_t ip)
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2019-2020, The Monero Project
// Copyright (c) 2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -44,7 +44,6 @@
#include <boost/lambda/lambda.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/system/error_code.hpp>
#include <boost/utility/string_ref.hpp>
#include <functional>
#include "net/net_utils_base.h"
#include "net/net_ssl.h"
@@ -179,7 +178,7 @@ namespace net_utils
// SSL Options
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_enabled || m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
{
if (!m_ssl_options.handshake(*m_ssl_socket, boost::asio::ssl::stream_base::client, {}, addr, timeout))
if (!m_ssl_options.handshake(*m_ssl_socket, boost::asio::ssl::stream_base::client, addr, timeout))
{
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
{
@@ -281,7 +280,7 @@ namespace net_utils
inline
bool send(const boost::string_ref buff, std::chrono::milliseconds timeout)
bool send(const std::string& buff, std::chrono::milliseconds timeout)
{
try
@@ -299,7 +298,7 @@ namespace net_utils
// object is used as a callback and will update the ec variable when the
// operation completes. The blocking_udp_client.cpp example shows how you
// can use boost::bind rather than boost::lambda.
async_write(buff.data(), buff.size(), ec);
async_write(buff.c_str(), buff.size(), ec);
// Block until the asynchronous operation has completed.
while (ec == boost::asio::error::would_block)

View File

@@ -24,9 +24,12 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
#pragma once
#include "http_base.h"
#include "reg_exp_definer.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
@@ -35,8 +38,173 @@ namespace epee
{
namespace net_utils
{
bool parse_uri(const std::string uri, http::uri_content& content);
bool parse_url_ipv6(const std::string url_str, http::url_content& content);
bool parse_url(const std::string url_str, http::url_content& content);
inline bool parse_uri_query(const std::string& query, std::list<std::pair<std::string, std::string> >& params)
{
enum state
{
st_param_name,
st_param_val
};
state st = st_param_name;
std::string::const_iterator start_it = query.begin();
std::pair<std::string, std::string> e;
for(std::string::const_iterator it = query.begin(); it != query.end(); it++)
{
switch(st)
{
case st_param_name:
if(*it == '=')
{
e.first.assign(start_it, it);
start_it = it;++start_it;
st = st_param_val;
}
break;
case st_param_val:
if(*it == '&')
{
e.second.assign(start_it, it);
start_it = it;++start_it;
params.push_back(e);
e.first.clear();e.second.clear();
st = st_param_name;
}
break;
default:
LOG_ERROR("Unknown state " << (int)st);
return false;
}
}
if(st == st_param_name)
{
if(start_it != query.end())
{
e.first.assign(start_it, query.end());
params.push_back(e);
}
}else
{
if(start_it != query.end())
e.second.assign(start_it, query.end());
if(e.first.size())
params.push_back(e);
}
return true;
}
inline
bool parse_uri(const std::string uri, http::uri_content& content)
{
///iframe_test.html?api_url=http://api.vk.com/api.php&api_id=3289090&api_settings=1&viewer_id=562964060&viewer_type=0&sid=0aad8d1c5713130f9ca0076f2b7b47e532877424961367d81e7fa92455f069be7e21bc3193cbd0be11895&secret=368ebbc0ef&access_token=668bc03f43981d883f73876ffff4aa8564254b359cc745dfa1b3cde7bdab2e94105d8f6d8250717569c0a7&user_id=0&group_id=0&is_app_user=1&auth_key=d2f7a895ca5ff3fdb2a2a8ae23fe679a&language=0&parent_language=0&ad_info=ElsdCQBaQlxiAQRdFUVUXiN2AVBzBx5pU1BXIgZUJlIEAWcgAUoLQg==&referrer=unknown&lc_name=9834b6a3&hash=
content.m_query_params.clear();
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^([^?#]*)(\\?([^#]*))?(#(.*))?", boost::regex::icase | boost::regex::normal);
boost::smatch result;
if(!(boost::regex_search(uri, result, rexp_match_uri, boost::match_default) && result[0].matched))
{
LOG_PRINT_L1("[PARSE URI] regex not matched for uri: " << uri);
content.m_path = uri;
return true;
}
if(result[1].matched)
{
content.m_path = result[1];
}
if(result[3].matched)
{
content.m_query = result[3];
}
if(result[5].matched)
{
content.m_fragment = result[5];
}
if(content.m_query.size())
{
parse_uri_query(content.m_query, content.m_query_params);
}
return true;
}
inline
bool parse_url_ipv6(const std::string url_str, http::url_content& content)
{
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^((.*?)://)?(\\[(.*)\\](:(\\d+))?)(.*)?", boost::regex::icase | boost::regex::normal);
// 12 3 4 5 6 7
content.port = 0;
boost::smatch result;
if(!(boost::regex_search(url_str, result, rexp_match_uri, boost::match_default) && result[0].matched))
{
LOG_PRINT_L1("[PARSE URI] regex not matched for uri: " << rexp_match_uri);
//content.m_path = uri;
return false;
}
if(result[2].matched)
{
content.schema = result[2];
}
if(result[4].matched)
{
content.host = result[4];
}
else // if host not matched, matching should be considered failed
{
return false;
}
if(result[6].matched)
{
content.port = boost::lexical_cast<uint64_t>(result[6]);
}
if(result[7].matched)
{
content.uri = result[7];
return parse_uri(result[7], content.m_uri_content);
}
return true;
}
inline
bool parse_url(const std::string url_str, http::url_content& content)
{
if (parse_url_ipv6(url_str, content)) return true;
///iframe_test.html?api_url=http://api.vk.com/api.php&api_id=3289090&api_settings=1&viewer_id=562964060&viewer_type=0&sid=0aad8d1c5713130f9ca0076f2b7b47e532877424961367d81e7fa92455f069be7e21bc3193cbd0be11895&secret=368ebbc0ef&access_token=668bc03f43981d883f73876ffff4aa8564254b359cc745dfa1b3cde7bdab2e94105d8f6d8250717569c0a7&user_id=0&group_id=0&is_app_user=1&auth_key=d2f7a895ca5ff3fdb2a2a8ae23fe679a&language=0&parent_language=0&ad_info=ElsdCQBaQlxiAQRdFUVUXiN2AVBzBx5pU1BXIgZUJlIEAWcgAUoLQg==&referrer=unknown&lc_name=9834b6a3&hash=
//STATIC_REGEXP_EXPR_1(rexp_match_uri, "^([^?#]*)(\\?([^#]*))?(#(.*))?", boost::regex::icase | boost::regex::normal);
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^((.*?)://)?(([^/:]*)(:(\\d+))?)(.*)?", boost::regex::icase | boost::regex::normal);
// 12 34 5 6 7
content.port = 0;
boost::smatch result;
if(!(boost::regex_search(url_str, result, rexp_match_uri, boost::match_default) && result[0].matched))
{
LOG_PRINT_L1("[PARSE URI] regex not matched for uri: " << rexp_match_uri);
//content.m_path = uri;
return true;
}
if(result[2].matched)
{
content.schema = result[2];
}
if(result[4].matched)
{
content.host = result[4];
}
if(result[6].matched)
{
content.port = boost::lexical_cast<uint64_t>(result[6]);
}
if(result[7].matched)
{
content.uri = result[7];
return parse_uri(result[7], content.m_uri_content);
}
return true;
}
}
}

View File

@@ -36,7 +36,6 @@
#include <boost/utility/string_ref.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/system/error_code.hpp>
#define SSL_FINGERPRINT_SIZE 32
@@ -133,7 +132,6 @@ namespace net_utils
bool handshake(
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
boost::asio::ssl::stream_base::handshake_type type,
boost::asio::const_buffer buffer = {},
const std::string& host = {},
std::chrono::milliseconds timeout = std::chrono::seconds(15)) const;
};
@@ -145,9 +143,6 @@ namespace net_utils
bool create_ec_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert);
bool create_rsa_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert);
//! Store private key for `ssl` at `base + ".key"` unencrypted and certificate for `ssl` at `base + ".crt"`.
boost::system::error_code store_ssl_keys(boost::asio::ssl::context& ssl, const boost::filesystem::path& base);
}
}

View File

@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief implementaion for throttling of connection (count and rate-limit speed etc)
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -2,7 +2,7 @@
/// @author rfree (current maintainer in monero.cc project)
/// @brief interface for throttling of connection (count and rate-limit speed etc)
// Copyright (c) 2014-2020, The Monero Project
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
@@ -44,7 +44,10 @@
#include <boost/shared_ptr.hpp>
#include <atomic>
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/thread/thread.hpp>
@@ -60,6 +63,7 @@
#include <boost/utility/value_init.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp>
#include "misc_language.h"
#include "pragma_comp_defs.h"
#include <sstream>

View File

@@ -29,7 +29,6 @@
#define _REG_EXP_DEFINER_H_
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/regex.hpp>
#include "syncobj.h"
namespace epee

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2019-2020, The Monero Project
// Copyright (c) 2019, The Monero Project
//
// All rights reserved.
//
@@ -34,8 +34,6 @@
#pragma once
#include "misc_language.h"
#include <stdlib.h>
#include <stdint.h>
@@ -141,6 +139,7 @@ public:
rolling_median_t(rolling_median_t &&m)
{
free(data);
memcpy(this, &m, sizeof(rolling_median_t));
m.data = NULL;
}
@@ -227,7 +226,7 @@ public:
Item v = data[heap[0]];
if (minCt < maxCt)
{
v = get_mid<Item>(v, data[heap[-1]]);
v = (v + data[heap[-1]]) / 2;
}
return v;
}

View File

@@ -73,8 +73,7 @@ public: \
template<bool is_store, class t_storage> \
bool serialize_map(t_storage& stg, typename t_storage::hsection hparent_section) \
{ \
decltype(*this) &this_ref = *this; \
(void) this_ref; // Suppress unused var warnings. Sometimes this var is used, sometimes not.
decltype(*this) &this_ref = *this;
#define KV_SERIALIZE_N(varialble, val_name) \
epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name);

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2020, The Monero Project
// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//
@@ -31,6 +31,7 @@
#include <algorithm>
#include <cstdint>
#include <memory>
#include <string>
#include <type_traits>
namespace epee
@@ -166,11 +167,10 @@ namespace epee
}
//! make a span from a std::string
template<typename T, typename U>
span<const T> strspan(const U&s) noexcept
template<typename T>
span<const T> strspan(const std::string &s) noexcept
{
static_assert(std::is_same<typename U::value_type, char>(), "unexpected source type");
static_assert(std::is_same<T, char>() || std::is_same<T, unsigned char>() || std::is_same<T, int8_t>() || std::is_same<T, uint8_t>(), "Unexpected destination type");
static_assert(std::is_same<T, char>() || std::is_same<T, unsigned char>() || std::is_same<T, int8_t>() || std::is_same<T, uint8_t>(), "Unexpected type");
return {reinterpret_cast<const T*>(s.data()), s.size()};
}
}

View File

@@ -29,7 +29,6 @@
#include <boost/utility/string_ref.hpp>
#include <chrono>
#include <string>
#include "byte_slice.h"
#include "portable_storage_template_helper.h"
#include "net/http_base.h"
#include "net/http_server_handlers_map2.h"
@@ -75,12 +74,12 @@ namespace epee
template<class t_request, class t_response, class t_transport>
bool invoke_http_bin(const boost::string_ref uri, const t_request& out_struct, t_response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref method = "POST")
{
byte_slice req_param;
if(!serialization::store_t_to_binary(out_struct, req_param, 16 * 1024))
std::string req_param;
if(!serialization::store_t_to_binary(out_struct, req_param))
return false;
const http::http_response_info* pri = NULL;
if(!transport.invoke(uri, method, boost::string_ref{reinterpret_cast<const char*>(req_param.data()), req_param.size()}, timeout, std::addressof(pri)))
if(!transport.invoke(uri, method, req_param, timeout, std::addressof(pri)))
{
LOG_PRINT_L1("Failed to invoke http request to " << uri);
return false;
@@ -98,12 +97,7 @@ namespace epee
return false;
}
static const constexpr epee::serialization::portable_storage::limits_t default_http_bin_limits = {
65536 * 3, // objects
65536 * 3, // fields
65536 * 3, // strings
};
return serialization::load_t_from_binary(result_struct, epee::strspan<uint8_t>(pri->m_body), &default_http_bin_limits);
return serialization::load_t_from_binary(result_struct, epee::strspan<uint8_t>(pri->m_body));
}
template<class t_request, class t_response, class t_transport>

View File

@@ -27,29 +27,29 @@
#pragma once
#include "portable_storage_template_helper.h"
#include <boost/utility/string_ref.hpp>
#include <boost/utility/value_init.hpp>
#include <functional>
#include "byte_slice.h"
#include "span.h"
#include "net/levin_base.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
template<typename context_t>
void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, const char *category);
template<typename context_t>
void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, int command);
namespace
{
static const constexpr epee::serialization::portable_storage::limits_t default_levin_limits = {
8192, // objects
16384, // fields
16384, // strings
};
template<typename context_t>
void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, const char *category)
{
MCINFO("net.p2p.traffic", context << bytes << " bytes " << (sent ? "sent" : "received") << (error ? "/corrupt" : "")
<< " for category " << category << " initiated by " << (initiator ? "us" : "peer"));
}
template<typename context_t>
void on_levin_traffic(const context_t &context, bool initiator, bool sent, bool error, size_t bytes, int command)
{
char buf[32];
snprintf(buf, sizeof(buf), "command-%u", command);
return on_levin_traffic(context, initiator, sent, error, bytes, buf);
}
}
namespace epee
@@ -75,7 +75,7 @@ namespace epee
return false;
}
serialization::portable_storage stg_ret;
if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits))
if(!stg_ret.load_from_binary(buff_to_recv))
{
LOG_ERROR("Failed to load_from_binary on command " << command);
return false;
@@ -110,18 +110,18 @@ namespace epee
const boost::uuids::uuid &conn_id = context.m_connection_id;
typename serialization::portable_storage stg;
out_struct.store(stg);
levin::message_writer to_send{16 * 1024};
std::string buff_to_recv;
stg.store_to_binary(to_send.buffer);
std::string buff_to_send, buff_to_recv;
stg.store_to_binary(buff_to_send);
int res = transport.invoke(command, std::move(to_send), buff_to_recv, conn_id);
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
int res = transport.invoke(command, buff_to_send, buff_to_recv, conn_id);
if( res <=0 )
{
LOG_PRINT_L1("Failed to invoke command " << command << " return code " << res);
return false;
}
typename serialization::portable_storage stg_ret;
if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits))
if(!stg_ret.load_from_binary(buff_to_recv))
{
on_levin_traffic(context, true, false, true, buff_to_recv.size(), command);
LOG_ERROR("Failed to load_from_binary on command " << command);
@@ -137,9 +137,10 @@ namespace epee
const boost::uuids::uuid &conn_id = context.m_connection_id;
typename serialization::portable_storage stg;
const_cast<t_arg&>(out_struct).store(stg);//TODO: add true const support to searilzation
levin::message_writer to_send{16 * 1024};
stg.store_to_binary(to_send.buffer);
int res = transport.invoke_async(command, std::move(to_send), conn_id, [cb, command](int code, const epee::span<const uint8_t> buff, typename t_transport::connection_context& context)->bool
std::string buff_to_send;
stg.store_to_binary(buff_to_send);
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
int res = transport.invoke_async(command, epee::strspan<uint8_t>(buff_to_send), conn_id, [cb, command](int code, const epee::span<const uint8_t> buff, typename t_transport::connection_context& context)->bool
{
t_result result_struct = AUTO_VAL_INIT(result_struct);
if( code <=0 )
@@ -151,7 +152,7 @@ namespace epee
return false;
}
serialization::portable_storage stg_ret;
if(!stg_ret.load_from_binary(buff, &default_levin_limits))
if(!stg_ret.load_from_binary(buff))
{
on_levin_traffic(context, true, false, true, buff.size(), command);
LOG_ERROR("Failed to load_from_binary on command " << command);
@@ -183,10 +184,11 @@ namespace epee
const boost::uuids::uuid &conn_id = context.m_connection_id;
serialization::portable_storage stg;
out_struct.store(stg);
levin::message_writer to_send;
stg.store_to_binary(to_send.buffer);
std::string buff_to_send;
stg.store_to_binary(buff_to_send);
int res = transport.send(to_send.finalize_notify(command), conn_id);
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
int res = transport.notify(command, epee::strspan<uint8_t>(buff_to_send), conn_id);
if(res <=0 )
{
MERROR("Failed to notify command " << command << " return code " << res);
@@ -197,10 +199,10 @@ namespace epee
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
template<class t_owner, class t_in_type, class t_out_type, class t_context, class callback_t>
int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, byte_stream& buff_out, callback_t cb, t_context& context )
int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, callback_t cb, t_context& context )
{
serialization::portable_storage strg;
if(!strg.load_from_binary(in_buff, &default_levin_limits))
if(!strg.load_from_binary(in_buff))
{
on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load_from_binary in command " << command);
@@ -225,6 +227,7 @@ namespace epee
LOG_ERROR("Failed to store_to_binary in command" << command);
return -1;
}
on_levin_traffic(context, false, true, false, buff_out.size(), command);
return res;
}
@@ -233,7 +236,7 @@ namespace epee
int buff_to_t_adapter(t_owner* powner, int command, const epee::span<const uint8_t> in_buff, callback_t cb, t_context& context)
{
serialization::portable_storage strg;
if(!strg.load_from_binary(in_buff, &default_levin_limits))
if(!strg.load_from_binary(in_buff))
{
on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load_from_binary in notify " << command);
@@ -251,7 +254,7 @@ namespace epee
}
#define CHAIN_LEVIN_INVOKE_MAP2(context_type) \
int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_stream& buff_out, context_type& context) \
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, context_type& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
@@ -260,13 +263,13 @@ namespace epee
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type) \
int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
{ \
bool handled = false; epee::byte_stream fake_str; \
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
bool handled = false; std::string fake_str;\
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
}
#define CHAIN_LEVIN_INVOKE_MAP() \
int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_stream& buff_out, epee::net_utils::connection_context_base& context) \
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, epee::net_utils::connection_context_base& context) \
{ \
bool handled = false; \
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
@@ -286,9 +289,8 @@ namespace epee
}
#define BEGIN_INVOKE_MAP2(owner_type) \
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, epee::byte_stream& buff_out, t_context& context, bool& handled) \
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
{ \
try { \
typedef owner_type internal_owner_type_name;
#define HANDLE_INVOKE2(command_id, func, type_name_in, typename_out) \
@@ -334,13 +336,7 @@ namespace epee
LOG_ERROR("Unknown command:" << command); \
on_levin_traffic(context, false, false, true, in_buff.size(), "invalid-command"); \
return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED; \
} \
catch (const std::exception &e) { \
MERROR("Error in handle_invoke_map: " << e.what()); \
return LEVIN_ERROR_CONNECTION_TIMEDOUT; /* seems kinda appropriate */ \
} \
}
}
}

View File

@@ -28,8 +28,13 @@
#pragma once
#include <boost/utility/string_ref_fwd.hpp>
#include <string>
#include <algorithm>
#include <boost/utility/string_ref.hpp>
#include "misc_log_ex.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "serialization"
namespace epee
{
@@ -92,7 +97,46 @@ namespace misc_utils
return lut[(uint8_t)c] & 1;
}
std::string transform_to_escape_sequence(const std::string& src);
inline std::string transform_to_escape_sequence(const std::string& src)
{
static const char escaped[] = "\b\f\n\r\t\v\"\\/";
std::string::const_iterator it = std::find_first_of(src.begin(), src.end(), escaped, escaped + sizeof(escaped));
if (it == src.end())
return src;
std::string res;
res.reserve(2 * src.size());
res.assign(src.begin(), it);
for(; it!=src.end(); ++it)
{
switch(*it)
{
case '\b': //Backspace (ascii code 08)
res+="\\b"; break;
case '\f': //Form feed (ascii code 0C)
res+="\\f"; break;
case '\n': //New line
res+="\\n"; break;
case '\r': //Carriage return
res+="\\r"; break;
case '\t': //Tab
res+="\\t"; break;
case '\v': //Vertical tab
res+="\\v"; break;
//case '\'': //Apostrophe or single quote
// res+="\\'"; break;
case '"': //Double quote
res+="\\\""; break;
case '\\': //Backslash caracter
res+="\\\\"; break;
case '/': //Backslash caracter
res+="\\/"; break;
default:
res.push_back(*it);
}
}
return res;
}
/*
\b Backspace (ascii code 08)
@@ -106,7 +150,98 @@ namespace misc_utils
\\ Backslash character
*/
void match_string2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val);
inline void match_string2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val)
{
bool escape_mode = false;
std::string::const_iterator it = star_end_string;
++it;
std::string::const_iterator fi = it;
while (fi != buf_end && ((lut[(uint8_t)*fi] & 32)) == 0)
++fi;
val.assign(it, fi);
it = fi;
for(;it != buf_end;it++)
{
if(escape_mode/*prev_ch == '\\'*/)
{
switch(*it)
{
case 'b': //Backspace (ascii code 08)
val.push_back(0x08);break;
case 'f': //Form feed (ascii code 0C)
val.push_back(0x0C);break;
case 'n': //New line
val.push_back('\n');break;
case 'r': //Carriage return
val.push_back('\r');break;
case 't': //Tab
val.push_back('\t');break;
case 'v': //Vertical tab
val.push_back('\v');break;
case '\'': //Apostrophe or single quote
val.push_back('\'');break;
case '"': //Double quote
val.push_back('"');break;
case '\\': //Backslash character
val.push_back('\\');break;
case '/': //Slash character
val.push_back('/');break;
case 'u': //Unicode code point
if (buf_end - it < 4)
{
ASSERT_MES_AND_THROW("Invalid Unicode escape sequence");
}
else
{
uint32_t dst = 0;
for (int i = 0; i < 4; ++i)
{
const unsigned char tmp = isx[(unsigned char)*++it];
CHECK_AND_ASSERT_THROW_MES(tmp != 0xff, "Bad Unicode encoding");
dst = dst << 4 | tmp;
}
// encode as UTF-8
if (dst <= 0x7f)
{
val.push_back(dst);
}
else if (dst <= 0x7ff)
{
val.push_back(0xc0 | (dst >> 6));
val.push_back(0x80 | (dst & 0x3f));
}
else if (dst <= 0xffff)
{
val.push_back(0xe0 | (dst >> 12));
val.push_back(0x80 | ((dst >> 6) & 0x3f));
val.push_back(0x80 | (dst & 0x3f));
}
else
{
ASSERT_MES_AND_THROW("Unicode code point is out or range");
}
}
break;
default:
val.push_back(*it);
LOG_PRINT_L0("Unknown escape sequence :\"\\" << *it << "\"");
}
escape_mode = false;
}else if(*it == '"')
{
star_end_string = it;
return;
}else if(*it == '\\')
{
escape_mode = true;
}
else
{
val.push_back(*it);
}
}
ASSERT_MES_AND_THROW("Failed to match string in json entry: " << std::string(star_end_string, buf_end));
}
inline bool match_string(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val)
{
try
@@ -120,7 +255,42 @@ namespace misc_utils
return false;
}
}
void match_number2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val, bool& is_float_val, bool& is_signed_val);
inline void match_number2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val, bool& is_float_val, bool& is_signed_val)
{
val.clear();
uint8_t float_flag = 0;
is_signed_val = false;
size_t chars = 0;
std::string::const_iterator it = star_end_string;
if (it != buf_end && *it == '-')
{
is_signed_val = true;
++chars;
++it;
}
for(;it != buf_end;it++)
{
const uint8_t flags = lut[(uint8_t)*it];
if (flags & 16)
{
float_flag |= flags;
++chars;
}
else
{
val = boost::string_ref(&*star_end_string, chars);
if(val.size())
{
star_end_string = --it;
is_float_val = !!(float_flag & 2);
return;
}
else
ASSERT_MES_AND_THROW("wrong number in json entry: " << std::string(star_end_string, buf_end));
}
}
ASSERT_MES_AND_THROW("wrong number in json entry: " << std::string(star_end_string, buf_end));
}
inline bool match_number(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val)
{
try
@@ -134,7 +304,25 @@ namespace misc_utils
return false;
}
}
void match_word2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val);
inline void match_word2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val)
{
val.clear();
for(std::string::const_iterator it = star_end_string;it != buf_end;it++)
{
if (!(lut[(uint8_t)*it] & 4))
{
val = boost::string_ref(&*star_end_string, std::distance(star_end_string, it));
if(val.size())
{
star_end_string = --it;
return;
}else
ASSERT_MES_AND_THROW("failed to match word number in json entry: " << std::string(star_end_string, buf_end));
}
}
ASSERT_MES_AND_THROW("failed to match word number in json entry: " << std::string(star_end_string, buf_end));
}
inline bool match_word(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val)
{
try
@@ -147,8 +335,44 @@ namespace misc_utils
return false;
}
}
bool match_word_with_extrasymb(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val);
bool match_word_til_equal_mark(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string::const_iterator& word_end);
inline bool match_word_with_extrasymb(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string& val)
{
val.clear();
for(std::string::const_iterator it = star_end_string;it != buf_end;it++)
{
if(!isalnum(*it) && *it != '-' && *it != '_')
{
val.assign(star_end_string, it);
if(val.size())
{
star_end_string = --it;
return true;
}else
return false;
}
}
return false;
}
inline bool match_word_til_equal_mark(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string::const_iterator& word_end)
{
word_end = star_end_string;
for(std::string::const_iterator it = star_end_string;it != buf_end;it++)
{
if(isspace(*it))
{
continue;
}else if( *it == '=' )
{
star_end_string = it;
word_end = it;
return true;
}
}
return false;
}
}
}
}

View File

@@ -24,19 +24,24 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
#include "portable_storage_base.h"
#include "portable_storage_val_converters.h"
#include "misc_log_ex.h"
#include "span.h"
#include <type_traits>
#include <boost/mpl/contains.hpp>
#include "misc_language.h"
#include "portable_storage_base.h"
#include "portable_storage_to_bin.h"
#include "portable_storage_from_bin.h"
#include "portable_storage_to_json.h"
#include "portable_storage_from_json.h"
#include "portable_storage_val_converters.h"
#include "span.h"
#include "int-util.h"
namespace epee
{
class byte_slice;
class byte_stream;
namespace serialization
{
/************************************************************************/
@@ -49,13 +54,6 @@ namespace epee
typedef epee::serialization::harray harray;
typedef storage_entry meta_entry;
struct limits_t
{
size_t n_objects;
size_t n_fields;
size_t n_strings; // not counting field names
};
portable_storage(){}
virtual ~portable_storage(){}
hsection open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist = false);
@@ -85,14 +83,9 @@ namespace epee
bool delete_entry(const std::string& pentry_name, hsection hparent_section = nullptr);
//-------------------------------------------------------------------------------
bool store_to_binary(byte_slice& target, std::size_t initial_buffer_size = 8192);
bool store_to_binary(byte_stream& ss);
bool load_from_binary(const epee::span<const uint8_t> target, const limits_t *limits = nullptr);
bool load_from_binary(const std::string& target, const limits_t *limits = nullptr)
{
return load_from_binary(epee::strspan<uint8_t>(target), limits);
}
bool store_to_binary(binarybuffer& target);
bool load_from_binary(const epee::span<const uint8_t> target);
bool load_from_binary(const std::string& target) { return load_from_binary(epee::strspan<uint8_t>(target)); }
template<class trace_policy>
bool dump_as_xml(std::string& targetObj, const std::string& root_name = "");
bool dump_as_json(std::string& targetObj, size_t indent = 0, bool insert_newlines = true);
@@ -117,13 +110,99 @@ namespace epee
};
#pragma pack(pop)
};
inline
bool portable_storage::dump_as_json(std::string& buff, size_t indent, bool insert_newlines)
{
TRY_ENTRY();
std::stringstream ss;
epee::serialization::dump_as_json(ss, m_root, indent, insert_newlines);
buff = ss.str();
return true;
CATCH_ENTRY("portable_storage::dump_as_json", false)
}
inline
bool portable_storage::load_from_json(const std::string& source)
{
TRY_ENTRY();
return json::load_from_json(source, *this);
CATCH_ENTRY("portable_storage::load_from_json", false)
}
template<class trace_policy>
bool portable_storage::dump_as_xml(std::string& targetObj, const std::string& root_name)
{
return false;//TODO: don't think i ever again will use xml - ambiguous and "overtagged" format
}
}
inline
bool portable_storage::store_to_binary(binarybuffer& target)
{
TRY_ENTRY();
std::stringstream ss;
storage_block_header sbh = AUTO_VAL_INIT(sbh);
sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA);
sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB);
sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER;
ss.write((const char*)&sbh, sizeof(storage_block_header));
pack_entry_to_buff(ss, m_root);
target = ss.str();
return true;
CATCH_ENTRY("portable_storage::store_to_binary", false)
}
inline
bool portable_storage::load_from_binary(const epee::span<const uint8_t> source)
{
m_root.m_entries.clear();
if(source.size() < sizeof(storage_block_header))
{
LOG_ERROR("portable_storage: wrong binary format, packet size = " << source.size() << " less than expected sizeof(storage_block_header)=" << sizeof(storage_block_header));
return false;
}
storage_block_header* pbuff = (storage_block_header*)source.data();
if(pbuff->m_signature_a != SWAP32LE(PORTABLE_STORAGE_SIGNATUREA) ||
pbuff->m_signature_b != SWAP32LE(PORTABLE_STORAGE_SIGNATUREB)
)
{
LOG_ERROR("portable_storage: wrong binary format - signature mismatch");
return false;
}
if(pbuff->m_ver != PORTABLE_STORAGE_FORMAT_VER)
{
LOG_ERROR("portable_storage: wrong binary format - unknown format ver = " << pbuff->m_ver);
return false;
}
TRY_ENTRY();
throwable_buffer_reader buf_reader(source.data()+sizeof(storage_block_header), source.size()-sizeof(storage_block_header));
buf_reader.read(m_root);
return true;//TODO:
CATCH_ENTRY("portable_storage::load_from_binary", false);
}
//---------------------------------------------------------------------------------------------------------------
inline
hsection portable_storage::open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist)
{
TRY_ENTRY();
hparent_section = hparent_section ? hparent_section:&m_root;
storage_entry* pentry = find_storage_entry(section_name, hparent_section);
if(!pentry)
{
if(!create_if_notexist)
return nullptr;
return insert_new_section(section_name, hparent_section);
}
CHECK_AND_ASSERT(pentry , nullptr);
//check that section_entry we find is real "CSSection"
if(pentry->type() != typeid(section))
{
if(create_if_notexist)
*pentry = storage_entry(section());//replace
else
return nullptr;
}
return &boost::get<section>(*pentry);
CATCH_ENTRY("portable_storage::open_section", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
template<class to_type>
struct get_value_visitor: boost::static_visitor<void>
{
@@ -149,6 +228,20 @@ namespace epee
//CATCH_ENTRY("portable_storage::template<>get_value", false);
}
//---------------------------------------------------------------------------------------------------------------
inline
bool portable_storage::get_value(const std::string& value_name, storage_entry& val, hsection hparent_section)
{
//TRY_ENTRY();
if(!hparent_section) hparent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, hparent_section);
if(!pentry)
return false;
val = *pentry;
return true;
//CATCH_ENTRY("portable_storage::template<>get_value", false);
}
//---------------------------------------------------------------------------------------------------------------
template<class t_value>
bool portable_storage::set_value(const std::string& value_name, t_value&& v, hsection hparent_section)
{
@@ -170,18 +263,40 @@ namespace epee
CATCH_ENTRY("portable_storage::template<>set_value", false);
}
//---------------------------------------------------------------------------------------------------------------
inline
storage_entry* portable_storage::find_storage_entry(const std::string& pentry_name, hsection psection)
{
TRY_ENTRY();
CHECK_AND_ASSERT(psection, nullptr);
auto it = psection->m_entries.find(pentry_name);
if(it == psection->m_entries.end())
return nullptr;
return &it->second;
CATCH_ENTRY("portable_storage::find_storage_entry", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
template<class entry_type>
storage_entry* portable_storage::insert_new_entry_get_storage_entry(const std::string& pentry_name, hsection psection, entry_type&& entry)
{
static_assert(std::is_rvalue_reference<entry_type&&>(), "unexpected copy of value");
TRY_ENTRY();
CHECK_AND_ASSERT(psection, nullptr);
CHECK_AND_ASSERT(!pentry_name.empty(), nullptr);
auto ins_res = psection->m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
return &ins_res.first->second;
CATCH_ENTRY("portable_storage::insert_new_entry_get_storage_entry", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
inline
hsection portable_storage::insert_new_section(const std::string& pentry_name, hsection psection)
{
TRY_ENTRY();
storage_entry* pse = insert_new_entry_get_storage_entry(pentry_name, psection, section());
if(!pse) return nullptr;
return &boost::get<section>(*pse);
CATCH_ENTRY("portable_storage::insert_new_section", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
template<class to_type>
struct get_first_value_visitor: boost::static_visitor<bool>
{
@@ -235,6 +350,7 @@ namespace epee
}
};
template<class t_value>
bool portable_storage::get_next_value(harray hval_array, t_value& target)
{
@@ -292,5 +408,83 @@ namespace epee
return true;
CATCH_ENTRY("portable_storage::insert_next_value", false);
}
//---------------------------------------------------------------------------------------------------------------
//sections
inline
harray portable_storage::get_first_section(const std::string& sec_name, hsection& h_child_section, hsection hparent_section)
{
TRY_ENTRY();
if(!hparent_section) hparent_section = &m_root;
storage_entry* pentry = find_storage_entry(sec_name, hparent_section);
if(!pentry)
return nullptr;
if(pentry->type() != typeid(array_entry))
return nullptr;
array_entry& ar_entry = boost::get<array_entry>(*pentry);
if(ar_entry.type() != typeid(array_entry_t<section>))
return nullptr;
array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(ar_entry);
section* psec = sec_array.get_first_val();
if(!psec)
return nullptr;
h_child_section = psec;
return &ar_entry;
CATCH_ENTRY("portable_storage::get_first_section", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
inline
bool portable_storage::get_next_section(harray hsec_array, hsection& h_child_section)
{
TRY_ENTRY();
CHECK_AND_ASSERT(hsec_array, false);
if(hsec_array->type() != typeid(array_entry_t<section>))
return false;
array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(*hsec_array);
h_child_section = sec_array.get_next_val();
if(!h_child_section)
return false;
return true;
CATCH_ENTRY("portable_storage::get_next_section", false);
}
//---------------------------------------------------------------------------------------------------------------
inline
harray portable_storage::insert_first_section(const std::string& sec_name, hsection& hinserted_childsection, hsection hparent_section)
{
TRY_ENTRY();
if(!hparent_section) hparent_section = &m_root;
storage_entry* pentry = find_storage_entry(sec_name, hparent_section);
if(!pentry)
{
pentry = insert_new_entry_get_storage_entry(sec_name, hparent_section, array_entry(array_entry_t<section>()));
if(!pentry)
return nullptr;
}
if(pentry->type() != typeid(array_entry))
*pentry = storage_entry(array_entry(array_entry_t<section>()));
array_entry& ar_entry = boost::get<array_entry>(*pentry);
if(ar_entry.type() != typeid(array_entry_t<section>))
ar_entry = array_entry(array_entry_t<section>());
array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(ar_entry);
hinserted_childsection = &sec_array.insert_first_val(section());
return &ar_entry;
CATCH_ENTRY("portable_storage::insert_first_section", nullptr);
}
//---------------------------------------------------------------------------------------------------------------
inline
bool portable_storage::insert_next_section(harray hsec_array, hsection& hinserted_childsection)
{
TRY_ENTRY();
CHECK_AND_ASSERT(hsec_array, false);
CHECK_AND_ASSERT_MES(hsec_array->type() == typeid(array_entry_t<section>),
false, "unexpected type(not 'section') in insert_next_section, type: " << hsec_array->type().name());
array_entry_t<section>& sec_array = boost::get<array_entry_t<section>>(*hsec_array);
hinserted_childsection = &sec_array.insert_next_value(section());
return true;
CATCH_ENTRY("portable_storage::insert_next_section", false);
}
//---------------------------------------------------------------------------------------------------------------
}
}

View File

@@ -29,10 +29,10 @@
#pragma once
#include <boost/variant.hpp>
#include <boost/any.hpp>
#include <string>
#include <vector>
#include <deque>
#include <map>
#define PORTABLE_STORAGE_SIGNATUREA 0x01011101
#define PORTABLE_STORAGE_SIGNATUREB 0x01020101 // bender's nightmare

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2019-2020, The Monero Project
// Copyright (c) 2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -29,7 +29,6 @@
#pragma once
#include "misc_language.h"
#include "misc_log_ex.h"
#include "portable_storage_base.h"
#include "portable_storage_bin_utils.h"
@@ -43,24 +42,6 @@ namespace epee
{
namespace serialization
{
template<typename T>
struct ps_min_bytes {
static constexpr const size_t strict = 4096; // actual low bound
};
template<> struct ps_min_bytes<uint64_t> { static constexpr const size_t strict = 8; };
template<> struct ps_min_bytes<int64_t> { static constexpr const size_t strict = 8; };
template<> struct ps_min_bytes<uint32_t> { static constexpr const size_t strict = 4; };
template<> struct ps_min_bytes<int32_t> { static constexpr const size_t strict = 4; };
template<> struct ps_min_bytes<uint16_t> { static constexpr const size_t strict = 2; };
template<> struct ps_min_bytes<int16_t> { static constexpr const size_t strict = 2; };
template<> struct ps_min_bytes<uint8_t> { static constexpr const size_t strict = 1; };
template<> struct ps_min_bytes<int8_t> { static constexpr const size_t strict = 1; };
template<> struct ps_min_bytes<double> { static constexpr const size_t strict = 8; };
template<> struct ps_min_bytes<bool> { static constexpr const size_t strict = 1; };
template<> struct ps_min_bytes<std::string> { static constexpr const size_t strict = 2; };
template<> struct ps_min_bytes<section> { static constexpr const size_t strict = 1; };
template<> struct ps_min_bytes<array_entry> { static constexpr const size_t strict = 1; };
struct throwable_buffer_reader
{
throwable_buffer_reader(const void* ptr, size_t sz);
@@ -80,9 +61,6 @@ namespace epee
void read(section& sec);
void read(std::string& str);
void read(array_entry &ae);
template<class t_type>
size_t min_bytes() const;
void set_limits(size_t objects, size_t fields, size_t strings);
private:
struct recursuion_limitation_guard
{
@@ -103,13 +81,6 @@ namespace epee
const uint8_t* m_ptr;
size_t m_count;
size_t m_recursion_count;
size_t m_objects;
size_t m_fields;
size_t m_strings;
size_t max_objects;
size_t max_fields;
size_t max_strings;
};
inline throwable_buffer_reader::throwable_buffer_reader(const void* ptr, size_t sz)
@@ -121,12 +92,6 @@ namespace epee
m_ptr = (uint8_t*)ptr;
m_count = sz;
m_recursion_count = 0;
m_objects = 0;
m_fields = 0;
m_strings = 0;
max_objects = std::numeric_limits<size_t>::max();
max_fields = std::numeric_limits<size_t>::max();
max_strings = std::numeric_limits<size_t>::max();
}
inline
void throwable_buffer_reader::read(void* target, size_t count)
@@ -143,7 +108,6 @@ namespace epee
RECURSION_LIMITATION();
uint8_t name_len = 0;
read(name_len);
CHECK_AND_ASSERT_THROW_MES(name_len > 0, "Section name is missing");
sce_name.resize(name_len);
read((void*)sce_name.data(), name_len);
}
@@ -174,18 +138,7 @@ namespace epee
//for pod types
array_entry_t<type_name> sa;
size_t size = read_varint();
CHECK_AND_ASSERT_THROW_MES(size <= m_count / ps_min_bytes<type_name>::strict, "Size sanity check failed");
if (std::is_same<type_name, section>())
{
CHECK_AND_ASSERT_THROW_MES(size <= max_objects - m_objects, "Too many objects");
m_objects += size;
}
else if (std::is_same<type_name, std::string>())
{
CHECK_AND_ASSERT_THROW_MES(size <= max_strings - m_strings, "Too many strings");
m_strings += size;
}
CHECK_AND_ASSERT_THROW_MES(size <= m_count, "Size sanity check failed");
sa.reserve(size);
//TODO: add some optimization here later
while(size--)
@@ -251,8 +204,6 @@ namespace epee
inline storage_entry throwable_buffer_reader::read_se<std::string>()
{
RECURSION_LIMITATION();
CHECK_AND_ASSERT_THROW_MES(m_strings + 1 <= max_strings, "Too many strings");
m_strings += 1;
return storage_entry(read<std::string>());
}
@@ -261,8 +212,6 @@ namespace epee
inline storage_entry throwable_buffer_reader::read_se<section>()
{
RECURSION_LIMITATION();
CHECK_AND_ASSERT_THROW_MES(m_objects < max_objects, "Too many objects");
++m_objects;
section s;//use extra variable due to vs bug, line "storage_entry se(section()); " can't be compiled in visual studio
storage_entry se(std::move(s));
section& section_entry = boost::get<section>(se);
@@ -314,16 +263,12 @@ namespace epee
RECURSION_LIMITATION();
sec.m_entries.clear();
size_t count = read_varint();
CHECK_AND_ASSERT_THROW_MES(count <= max_fields - m_fields, "Too many object fields");
m_fields += count;
while(count--)
{
//read section name string
std::string sec_name;
read_sec_name(sec_name);
const auto insert_loc = sec.m_entries.lower_bound(sec_name);
CHECK_AND_ASSERT_THROW_MES(insert_loc == sec.m_entries.end() || insert_loc->first != sec_name, "duplicate key: " << sec_name);
sec.m_entries.emplace_hint(insert_loc, std::move(sec_name), load_storage_entry());
sec.m_entries.emplace(std::move(sec_name), load_storage_entry());
}
}
inline
@@ -344,12 +289,5 @@ namespace epee
RECURSION_LIMITATION();
CHECK_AND_ASSERT_THROW_MES(false, "Reading array entry is not supported");
}
inline
void throwable_buffer_reader::set_limits(size_t objects, size_t fields, size_t strings)
{
max_objects = objects;
max_fields = fields;
max_strings = strings;
}
}
}

View File

@@ -26,7 +26,6 @@
#pragma once
#include <boost/lexical_cast.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include "parserse_base_utils.h"
#include "file_io_utils.h"

View File

@@ -28,16 +28,12 @@
#include <string>
#include "byte_slice.h"
#include "parserse_base_utils.h" /// TODO: (mj-xmr) This will be reduced in an another PR
#include "parserse_base_utils.h"
#include "portable_storage.h"
#include "file_io_utils.h"
#include "span.h"
namespace epee
{
class byte_stream;
namespace serialization
{
//-----------------------------------------------------------------------------------------------------------
@@ -88,10 +84,10 @@ namespace epee
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
bool load_t_from_binary(t_struct& out, const epee::span<const uint8_t> binary_buff, const epee::serialization::portable_storage::limits_t *limits = NULL)
bool load_t_from_binary(t_struct& out, const epee::span<const uint8_t> binary_buff)
{
portable_storage ps;
bool rs = ps.load_from_binary(binary_buff, limits);
bool rs = ps.load_from_binary(binary_buff);
if(!rs)
return false;
@@ -115,28 +111,19 @@ namespace epee
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
bool store_t_to_binary(t_struct& str_in, byte_slice& binary_buff, size_t initial_buffer_size = 8192)
{
portable_storage ps;
str_in.store(ps);
return ps.store_to_binary(binary_buff, initial_buffer_size);
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
byte_slice store_t_to_binary(t_struct& str_in, size_t initial_buffer_size = 8192)
{
byte_slice binary_buff;
store_t_to_binary(str_in, binary_buff, initial_buffer_size);
return binary_buff;
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
bool store_t_to_binary(t_struct& str_in, byte_stream& binary_buff)
bool store_t_to_binary(t_struct& str_in, std::string& binary_buff, size_t indent = 0)
{
portable_storage ps;
str_in.store(ps);
return ps.store_to_binary(binary_buff);
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
std::string store_t_to_binary(t_struct& str_in, size_t indent = 0)
{
std::string binary_buff;
store_t_to_binary(str_in, binary_buff, indent);
return binary_buff;
}
}
}

View File

@@ -32,7 +32,6 @@
#include "misc_language.h"
#include "portable_storage_base.h"
#include "portable_storage_bin_utils.h"
#include "misc_log_ex.h"
namespace epee
{
@@ -212,7 +211,6 @@ namespace epee
for(const section_pair& se: sec.m_entries)
{
CHECK_AND_ASSERT_THROW_MES(se.first.size() < std::numeric_limits<uint8_t>::max(), "storage_entry_name is too long: " << se.first.size() << ", val: " << se.first);
CHECK_AND_ASSERT_THROW_MES(!se.first.empty(), "storage_entry_name is empty");
uint8_t len = static_cast<uint8_t>(se.first.size());
strm.write((const char*)&len, sizeof(len));
strm.write(se.first.data(), size_t(len));

View File

@@ -28,17 +28,12 @@
#pragma once
#include <time.h>
#include <boost/regex.hpp>
#include "misc_language.h"
#include "portable_storage_base.h"
#include "parserse_base_utils.h"
#include "warnings.h"
#include "misc_log_ex.h"
#include <boost/lexical_cast.hpp>
#include <typeinfo>
#include <iomanip>
namespace epee
{

View File

@@ -24,16 +24,33 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _STRING_TOOLS_H_
#define _STRING_TOOLS_H_
#include "hex.h"
#include "mlocker.h"
// Previously pulled in by ASIO, further cleanup still required ...
#ifdef _WIN32
# include <winsock2.h>
# include <windows.h>
#endif
#include <boost/utility/string_ref.hpp>
#include <sstream>
#include <string.h>
#include <locale>
#include <cstdlib>
#include <string>
#include <cstdint>
#include <type_traits>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/utility/string_ref.hpp>
#include "misc_log_ex.h"
#include "storages/parserse_base_utils.h"
#include "hex.h"
#include "memwipe.h"
#include "mlocker.h"
#include "span.h"
#include "warnings.h"
#ifndef OUT
#define OUT
@@ -57,28 +74,182 @@ namespace string_tools
{
return from_hex::to_string(res, s);
}
std::string get_ip_string_from_int32(uint32_t ip);
bool get_ip_int32_from_string(uint32_t& ip, const std::string& ip_str);
bool parse_peer_from_string(uint32_t& ip, uint16_t& port, const std::string& addres);
std::string num_to_string_fast(int64_t val);
bool compare_no_case(const std::string& str1, const std::string& str2);
std::string& get_current_module_name();
std::string& get_current_module_folder();
#ifdef _WIN32
std::string get_current_module_path();
#endif
bool set_module_name_and_folder(const std::string& path_to_process_);
bool trim_left(std::string& str);
bool trim_right(std::string& str);
//----------------------------------------------------------------------------
inline std::string& trim(std::string& str)
PUSH_WARNINGS
DISABLE_GCC_WARNING(maybe-uninitialized)
template<class XType>
inline bool get_xtype_from_string(OUT XType& val, const std::string& str_id)
{
trim_left(str);
trim_right(str);
return str;
if (std::is_integral<XType>::value && !std::numeric_limits<XType>::is_signed && !std::is_same<XType, bool>::value)
{
for (char c : str_id)
{
if (!epee::misc_utils::parse::isdigit(c))
return false;
}
}
try
{
val = boost::lexical_cast<XType>(str_id);
return true;
}
catch(const std::exception& /*e*/)
{
//const char* pmsg = e.what();
return false;
}
catch(...)
{
return false;
}
return true;
}
POP_WARNINGS
//----------------------------------------------------------------------------
template<class XType>
inline bool xtype_to_string(const XType& val, std::string& str)
{
try
{
str = boost::lexical_cast<std::string>(val);
}
catch(...)
{
return false;
}
return true;
}
//----------------------------------------------------------------------------
std::string get_ip_string_from_int32(uint32_t ip);
//----------------------------------------------------------------------------
bool get_ip_int32_from_string(uint32_t& ip, const std::string& ip_str);
//----------------------------------------------------------------------------
inline bool parse_peer_from_string(uint32_t& ip, uint16_t& port, const std::string& addres)
{
//parse ip and address
std::string::size_type p = addres.find(':');
std::string ip_str, port_str;
if(p == std::string::npos)
{
port = 0;
ip_str = addres;
}
else
{
ip_str = addres.substr(0, p);
port_str = addres.substr(p+1, addres.size());
}
if(!get_ip_int32_from_string(ip, ip_str))
{
return false;
}
if(p != std::string::npos && !get_xtype_from_string(port, port_str))
{
return false;
}
return true;
}
inline std::string num_to_string_fast(int64_t val)
{
/*
char buff[30] = {0};
i64toa_s(val, buff, sizeof(buff)-1, 10);
return buff;*/
return boost::lexical_cast<std::string>(val);
}
//----------------------------------------------------------------------------
template<typename T>
inline std::string to_string_hex(const T &val)
{
static_assert(std::is_arithmetic<T>::value, "only arithmetic types");
std::stringstream ss;
ss << std::hex << val;
std::string s;
ss >> s;
return s;
}
//----------------------------------------------------------------------------
inline bool compare_no_case(const std::string& str1, const std::string& str2)
{
return !boost::iequals(str1, str2);
}
//----------------------------------------------------------------------------
inline std::string& get_current_module_name()
{
static std::string module_name;
return module_name;
}
//----------------------------------------------------------------------------
inline std::string& get_current_module_folder()
{
static std::string module_folder;
return module_folder;
}
//----------------------------------------------------------------------------
#ifdef _WIN32
inline std::string get_current_module_path()
{
char pname [5000] = {0};
GetModuleFileNameA( NULL, pname, sizeof(pname));
pname[sizeof(pname)-1] = 0; //be happy ;)
return pname;
}
#endif
//----------------------------------------------------------------------------
inline bool set_module_name_and_folder(const std::string& path_to_process_)
{
std::string path_to_process = path_to_process_;
#ifdef _WIN32
path_to_process = get_current_module_path();
#endif
std::string::size_type a = path_to_process.rfind( '\\' );
if(a == std::string::npos )
{
a = path_to_process.rfind( '/' );
}
if ( a != std::string::npos )
{
get_current_module_name() = path_to_process.substr(a+1, path_to_process.size());
get_current_module_folder() = path_to_process.substr(0, a);
return true;
}else
return false;
}
//----------------------------------------------------------------------------
inline bool trim_left(std::string& str)
{
for(std::string::iterator it = str.begin(); it!= str.end() && isspace(static_cast<unsigned char>(*it));)
str.erase(str.begin());
return true;
}
//----------------------------------------------------------------------------
inline bool trim_right(std::string& str)
{
for(std::string::reverse_iterator it = str.rbegin(); it!= str.rend() && isspace(static_cast<unsigned char>(*it));)
str.erase( --((it++).base()));
return true;
}
//----------------------------------------------------------------------------
inline std::string& trim(std::string& str)
{
trim_left(str);
trim_right(str);
return str;
}
//----------------------------------------------------------------------------
inline std::string trim(const std::string& str_)
{
@@ -87,8 +258,18 @@ namespace string_tools
trim_right(str);
return str;
}
std::string pad_string(std::string s, size_t n, char c = ' ', bool prepend = false);
//----------------------------------------------------------------------------
inline std::string pad_string(std::string s, size_t n, char c = ' ', bool prepend = false)
{
if (s.size() < n)
{
if (prepend)
s = std::string(n - s.size(), c) + s;
else
s.append(n - s.size(), c);
}
return s;
}
//----------------------------------------------------------------------------
template<class t_pod_type>
std::string pod_to_hex(const t_pod_type& s)
@@ -115,25 +296,64 @@ namespace string_tools
{
return hex_to_pod(hex_str, unwrap(s));
}
//----------------------------------------------------------------------------
template<typename T>
inline std::string to_string_hex(const T &val)
{
static_assert(std::is_arithmetic<T>::value, "only arithmetic types");
std::stringstream ss;
ss << std::hex << val;
std::string s;
ss >> s;
return s;
}
//----------------------------------------------------------------------------
bool validate_hex(uint64_t length, const std::string& str);
std::string get_extension(const std::string& str);
std::string cut_off_extension(const std::string& str);
//----------------------------------------------------------------------------
inline std::string get_extension(const std::string& str)
{
std::string res;
std::string::size_type pos = str.rfind('.');
if(std::string::npos == pos)
return res;
res = str.substr(pos+1, str.size()-pos);
return res;
}
//----------------------------------------------------------------------------
inline std::string cut_off_extension(const std::string& str)
{
std::string res;
std::string::size_type pos = str.rfind('.');
if(std::string::npos == pos)
return str;
res = str.substr(0, pos);
return res;
}
//----------------------------------------------------------------------------
#ifdef _WIN32
std::wstring utf8_to_utf16(const std::string& str);
std::string utf16_to_utf8(const std::wstring& wstr);
inline std::wstring utf8_to_utf16(const std::string& str)
{
if (str.empty())
return {};
int wstr_size = MultiByteToWideChar(CP_UTF8, 0, &str[0], str.size(), NULL, 0);
if (wstr_size == 0)
{
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
}
std::wstring wstr(wstr_size, wchar_t{});
if (!MultiByteToWideChar(CP_UTF8, 0, &str[0], str.size(), &wstr[0], wstr_size))
{
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
}
return wstr;
}
inline std::string utf16_to_utf8(const std::wstring& wstr)
{
if (wstr.empty())
return {};
int str_size = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr.size(), NULL, 0, NULL, NULL);
if (str_size == 0)
{
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
}
std::string str(str_size, char{});
if (!WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr.size(), &str[0], str_size, NULL, NULL))
{
throw std::runtime_error(std::error_code(GetLastError(), std::system_category()).message());
}
return str;
}
#endif
}
}

View File

@@ -1,91 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Andrey N. Sabelnikov nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _STRING_TOOLS_LEXICAL_H_
#define _STRING_TOOLS_LEXICAL_H_
#include "warnings.h"
#include "storages/parserse_base_utils.h"
#include <boost/lexical_cast.hpp> // A heavy header, that was extracted from the rest
#ifndef OUT
#define OUT
#endif
namespace epee
{
namespace string_tools
{
PUSH_WARNINGS
DISABLE_GCC_WARNING(maybe-uninitialized)
template<class XType>
inline bool get_xtype_from_string(OUT XType& val, const std::string& str_id)
{
if (std::is_integral<XType>::value && !std::numeric_limits<XType>::is_signed && !std::is_same<XType, bool>::value)
{
for (char c : str_id)
{
if (!epee::misc_utils::parse::isdigit(c))
return false;
}
}
try
{
val = boost::lexical_cast<XType>(str_id);
return true;
}
catch(const std::exception& /*e*/)
{
//const char* pmsg = e.what();
return false;
}
catch(...)
{
return false;
}
return true;
}
POP_WARNINGS
template<class XType>
inline bool xtype_to_string(const XType& val, std::string& str)
{
try
{
str = boost::lexical_cast<std::string>(val);
}
catch(...)
{
return false;
}
return true;
}
}
}
#endif //_STRING_TOOLS_LEXICAL_H_

View File

@@ -28,6 +28,8 @@
#ifndef _TINY_INI_H_
#define _TINY_INI_H_
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include "string_tools.h"
namespace epee
@@ -35,8 +37,20 @@ namespace epee
namespace tiny_ini
{
bool get_param_value(const std::string& param_name, const std::string& ini_entry, std::string& res);
inline std::string get_param_value(const std::string& param_name, const std::string& ini_entry)
inline
bool get_param_value(const std::string& param_name, const std::string& ini_entry, std::string& res)
{
std::string expr_str = std::string() + "^("+ param_name +") *=(.*?)$";
const boost::regex match_ini_entry( expr_str, boost::regex::icase | boost::regex::normal);
boost::smatch result;
if(!boost::regex_search(ini_entry, result, match_ini_entry, boost::match_default))
return false;
res = result[2];
string_tools::trim(res);
return true;
}
inline
std::string get_param_value(const std::string& param_name, const std::string& ini_entry)
{
std::string buff;
get_param_value(param_name, ini_entry, buff);

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2020, The Monero Project
// Copyright (c) 2017-2019, The Monero Project
//
// All rights reserved.
//

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2014-2020, The Monero Project
# Copyright (c) 2014-2019, The Monero Project
#
# All rights reserved.
#
@@ -26,25 +26,13 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set(EPEE_INCLUDE_DIR_BASE "${CMAKE_CURRENT_SOURCE_DIR}/../include")
# Add headers to the file list, to be able to search for them and autosave in IDEs.
monero_find_all_headers(EPEE_HEADERS_PUBLIC "${EPEE_INCLUDE_DIR_BASE}")
monero_add_library(epee byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp parserse_base_utils.cpp
add_library(epee STATIC byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp
wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp
int-util.cpp portable_storage.cpp
misc_language.cpp
misc_os_dependent.cpp
file_io_utils.cpp
net_parse_helpers.cpp
http_base.cpp
tiny_ini.cpp
${EPEE_HEADERS_PUBLIC}
)
int-util.cpp)
if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
monero_add_library(epee_readline readline_buffer.cpp)
add_library(epee_readline STATIC readline_buffer.cpp)
endif()
if(HAVE_C11)
@@ -72,9 +60,8 @@ target_link_libraries(epee
${Boost_CHRONO_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_REGEX_LIBRARY}
${OPENSSL_LIBRARIES}
PRIVATE
${OPENSSL_LIBRARIES}
${EXTRA_LIBRARIES})
if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
@@ -84,9 +71,3 @@ if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
PRIVATE
${GNU_READLINE_LIBRARY})
endif()
target_include_directories(epee
PUBLIC
"${EPEE_INCLUDE_DIR_BASE}"
"${OPENSSL_INCLUDE_DIR}")

View File

@@ -1,7 +1,6 @@
#include "net/abstract_http_client.h"
#include "net/http_base.h"
#include "net/net_parse_helpers.h"
#include "misc_log_ex.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.http"
@@ -138,11 +137,6 @@ namespace http
set_server(std::move(parsed.host), std::to_string(parsed.port), std::move(user), std::move(ssl_options));
return true;
}
bool epee::net_utils::http::abstract_http_client::set_proxy(const std::string& address)
{
return false;
}
}
}
}

View File

@@ -36,11 +36,6 @@
#include "byte_slice.h"
#include "byte_stream.h"
namespace
{
const std::size_t page_size = 4096;
}
namespace epee
{
struct byte_slice_data
@@ -151,7 +146,7 @@ namespace epee
: byte_slice()
{
std::size_t space_needed = 0;
for (const auto& source : sources)
for (const auto source : sources)
space_needed += source.size();
if (space_needed)
@@ -160,7 +155,7 @@ namespace epee
span<std::uint8_t> out{reinterpret_cast<std::uint8_t*>(storage.get() + 1), space_needed};
portion_ = {out.data(), out.size()};
for (const auto& source : sources)
for (const auto source : sources)
{
std::memcpy(out.data(), source.data(), source.size());
if (out.remove_prefix(source.size()) < source.size())
@@ -178,27 +173,16 @@ namespace epee
: byte_slice(adapt_buffer{}, std::move(buffer))
{}
byte_slice::byte_slice(byte_stream&& stream, const bool shrink)
byte_slice::byte_slice(byte_stream&& stream) noexcept
: storage_(nullptr), portion_(stream.data(), stream.size())
{
if (portion_.size())
if (stream.size())
{
byte_buffer buf;
if (shrink && page_size <= stream.available())
{
buf = byte_buffer_resize(stream.take_buffer(), portion_.size());
if (!buf)
throw std::bad_alloc{};
portion_ = {buf.get(), portion_.size()};
}
else // no need to shrink buffer
buf = stream.take_buffer();
std::uint8_t* const data = buf.release() - sizeof(raw_byte_slice);
std::uint8_t* const data = stream.take_buffer().release() - sizeof(raw_byte_slice);
new (data) raw_byte_slice{};
storage_.reset(reinterpret_cast<raw_byte_slice*>(data));
}
else // empty stream
else
portion_ = nullptr;
}

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