Commit graph

312 commits

Author SHA1 Message Date
hinto-janaiyo
0f51ae6873
prepare v1.0.0 2022-12-13 16:34:10 -05:00
hinto-janaiyo
2b80aa0277
v0.9.0
Fixes:
    - Up/Down only work if UI is enabled
    - Re-pushed [P2POOL_API_PATH] to popped relative path
      but only after giving the popped path to P2Pool
          1. [/tmp/gupax/p2pool/p2pool] -> [/tmp/gupax/p2pool]
          2. Give that to P2Pool
          3. [/tmp/gupax/p2pool] -> [/tmp/gupax/p2pool/local/stats]
          4. Give that to the watchdog (so it can read it)
2022-12-13 15:06:07 -05:00
hinto-janaiyo
9eb49b6dbd
p2pool/xmrig: handle custom arg [--no-color], API ip/port/path 2022-12-13 12:44:57 -05:00
hinto-janaiyo
79b0361152
helper/main: fix [Arc<Mutex>] deadlocks, add keyboard shortcuts
There was a deadlock happening between the [Helper]'s [gui_api_p2pool]
and the GUI's [gui_api_p2pool], since the locking order was different.
The watchdog loop locking order was fixed as well. This was a pain to
track down, better than a data race... I guess.

Oh and keyboard shortcuts were added in this commit too.

Comment from code:

// The ordering of these locks is _very_ important. They MUST be in sync
// with how the main GUI thread locks stuff or a deadlock will occur
// given enough time. They will eventually both want to lock the [Arc<Mutex>]
// the other thread is already locking. Yes, I figured this out the hard way,
// hence the vast amount of debug!() messages.
//
// Example of different order (BAD!):
//
// GUI Main       -> locks [p2pool] first
// Helper         -> locks [gui_api_p2pool] first
// GUI Status Tab -> trys to lock [gui_api_p2pool] -> CAN'T
// Helper         -> trys to lock [p2pool] -> CAN'T
//
// These two threads are now in a deadlock because both
// are trying to access locks the other one already has.
//
// The locking order here must be in the same chronological
// order as the main GUI thread (top to bottom).
2022-12-13 10:14:26 -05:00
hinto-janaiyo
128fa500bb
v0.9.0 (maybe) 2022-12-12 17:24:05 -05:00
hinto-janaiyo
798966d447
litter codebase with [debug!()]
The entire codebase is now littered with [debug!()] messages.
Thankfully [log] has 0 cost if you aren't using them, so regular
users won't have a runtime penalty unless they specify RUST_LOG=debug.
2022-12-12 14:50:34 -05:00
hinto-janaiyo
bf4e39c3a5
status: link helper & GUI's XMRig API 2022-12-11 22:01:37 -05:00
hinto-janaiyo
e2f6d90476
helper/sudo: small p2pool api fixes, don't allow ESC when [testing] 2022-12-11 20:44:46 -05:00
hinto-janaiyo
ede7bcb0a8
Update README.md 2022-12-11 17:22:49 -05:00
hinto-janaiyo
1e2b8f7803
xmrig/status: implement API hyper/tokio call; add [Gupax] stats 2022-12-11 15:51:07 -05:00
hinto-janaiyo
81ec266e0a
gupax: add [Auto-P2Pool/XMRig] for running at Gupax startup 2022-12-10 23:10:26 -05:00
hinto-janaiyo
b65b7a14d8
p2pool: fix [Simple] console scrollbar bug
Something todo with the height multiplier for [P2Pool Simple]'s
console was causing weird behavior when changing to other tabs.
With the console a bit bigger now, the scrollbar no longer shows
and there is less glitchy resizing when switching to other tabs.
2022-12-10 22:10:10 -05:00
hinto-janaiyo
1b999e3d9b
main/helper: change [Start] button, change [Sudo] input order 2022-12-10 21:55:57 -05:00
hinto-janaiyo
3fee0e5690
macOS: handle killing XMRig with [sudo]
Even with the parent-child relationship and direct process handle,
Gupax can't kill an XMRig spawned with [sudo] on macOS, even though
it can do it fine on Linux. So, on macOS, get the user's [sudo]
pass on the [Stop] button and summon a [sudo kill] on XMRig's PID.

This also complicates things since now we have to keep [SudoState]
somehow between a [Stop] and a [Start]. So there is macOS specific
code that now handles that.
2022-12-10 21:00:08 -05:00
hinto-janaiyo
4da775667b
windows/pty: include static [VCRUNTIME140.dll], change PTY size
Bare metal windows was complaining about this DLL, so it is now
included statically using [https://docs.rs/static_vcruntime/].
I tried statically linking everything for Windows but:
	1. It's not necessary, pretty much all DLLs needed
	   (except this one) are included in Windows 7+ by default
	2. It's a pain in the ass to build everything
	   statically, especially since Gupax needs OpenSSL.
	   (building OpenSSL on Windows == hell)

Windows/macOS were having console artifacts, escape codes and
random newlines would show up in P2Pool/XMRig output. After
thinking about it for a while, I realized I left the PTY
size to the default [24 rows/80 columns], hence the PTYs
prematurely inserting newlines and weird escape codes.

It works fine after setting it to [100/1000]. Interestingly,
Linux worked completely fine on 24/80, probably resizes internally.
2022-12-10 15:40:32 -05:00
hinto-janaiyo
929d80c61d
main: check for admin at init, good for windows, bad for unix 2022-12-09 22:06:42 -05:00
hinto-janaiyo
e7de536f18
windows: handle admin priviledge for xmrig
Please read the [src/README.md]. I hate windows so much.
2022-12-09 21:31:16 -05:00
hinto-janaiyo
965e070ff5
xmrig: fix node [Save] not change selected values 2022-12-08 22:37:50 -05:00
hinto-janaiyo
6dbf0386c4
p2pool/xmrig: add address/path check before allowing [Start] 2022-12-08 20:25:41 -05:00
hinto-janaiyo
a3802ef4f7
helper: start xmrig with sudo, implement [restart_xmrig()]
This commit takes care of correctly starting [sudo] with XMRig as
a command argument. The frontend [restart_*] function is also
implemented. In XMRig's case, the threads will sleep [3/5 seconds]
before [starting/restarting] so that [sudo] has time to open its
STDIN. This prevents premature inputs and outputting the password
to the STDOUT.
2022-12-08 18:34:31 -05:00
hinto-janaiyo
d30fb5563b
helper: optimize [String] output buffers
Instead of cloning the entirety of the process's output, this
commit adds a sort of hierarchy of string buffers:

We need:
1. The full output for stat parsing (max 1 month/56m bytes)
2. GUI output to be lightweight (max 1-2 hours/1m bytes)
3. GUI output buffered so it's on a refresh tick of 1 second

------------------------------------------------------------------
So this is the new buffer hierarchy, from low to high level:
[Process] <-> [Watchdog] <-> [Helper] <-> [GUI]
------------------------------------------------------------------
Process: Writes to 2 buffers, a FULL (stores everything) and
a BUF which is exactly the same, except this gets [mem:take]n later
Stuff gets written immediately if there is output detected.

Watchdog: [std::mem::take]'s [Process]'s BUF for itself.
Both FULL and BUF output overflows are checked in this loop.
This is done on a slightly faster tick (900ms).

Helper: Appends watchdog's BUF to GUI's already existing [String]
on a 1-second tick.

GUI: Does nothing, only locks & reads.
------------------------------------------------------------------

This means Helper's buffer will be swapped out every second, meaning
it'll almost always be empty. Process's FULL output will be the
heaviest, but is only used for backend parsing. GUI will be in the
middle. This system of buffers makes it so not every thread has to
hold it's own FULL copy of the output, in particular the GUI thread
was starting to lag a little due to loading so much output.
2022-12-08 12:29:38 -05:00
hinto-janaiyo
8281d97bc3
helper: copy p2pool functions to xmrig (todo!) 2022-12-07 20:50:14 -05:00
hinto-janaiyo
82918d4106
sudo: zeroize pass on every [ask_sudo()] call 2022-12-07 20:34:44 -05:00
hinto-janaiyo
06f19043ed
sudo: add [try_wait()] 5 second loop check for sudo 2022-12-07 20:22:41 -05:00
hinto-janaiyo
f988e4224c
main: add [zeroize] and implement sudo input/test screen for xmrig 2022-12-07 18:02:08 -05:00
hinto-janaiyo
31f23d9d58
app: check for overflowing user resolution values 2022-12-06 22:01:36 -05:00
hinto-janaiyo
9c323ec502
helper: p2pool - write directly to GUI thread on exit 2022-12-06 21:33:24 -05:00
hinto-janaiyo
33089ddca3
p2pool/app: add STDIN + clear at 56million bytes, 4:3 default ratio 2022-12-06 21:19:24 -05:00
hinto-janaiyo
05437720a2
helper: add data sync loop, add [ImgP2pool] for p2pool init data 2022-12-06 17:48:48 -05:00
hinto-janaiyo
016aeab1b6
helper: p2pool - add static [UserP2poolData] 2022-12-06 15:55:50 -05:00
hinto-janaiyo
b4a6dbec19
helper: p2pool - fix [Advanced] argument builder 2022-12-06 15:34:11 -05:00
hinto-janaiyo
9b1a815089
helper: p2pool - fix uptime, format with commas and spaces 2022-12-06 15:17:37 -05:00
hinto-janaiyo
e1829f967c
helper: p2pool - process output regardless of API file status 2022-12-06 13:23:16 -05:00
hinto-janaiyo
2a9ebd4cdf
helper: p2pool - connect major [Helper] APIs to GUI thread
Lots of stuff in this commit:
1. Implement [Start/Stop/Restart] and make it not possible for
the GUI to interact with that UI if [Helper] is doing stuff.
This prevents the obviously bad situation where [Helper] is in
the middle of spawning P2Pool, but the user is still allowed to
start it again, which would spawn another P2Pool. The main GUI
matches on the state and disables the appropriate UI so the
user can't do this.

2. Sync P2Pool's [Priv] and [Pub] output so that the GUI thread
is only rendering it once a second. All of Gupax also refreshes
at least once a second now as well.

3. Match the [ProcessState] with some colors in the GUI

4. GUI thread no longer directly starts/stops/restarts a process.
It will call a function in [Helper] that acts as a proxy.

5. The tokio [async_spawn_p2pool_watchdog()] function that was
a clone of the PTY version (but had async stuff) and all of the
related functions like the async STDOUT/STDERR reader is now
completely gone. It doesn't make sense to write the same code
twice, both [Simple] and [Advanced] will have a PTY, only
difference being the [Simple] UI won't have an input box.

6. P2Pool's exit code is now examined, either success or failure

7. Output was moved into it's own [Arc<Mutex>]. This allows for
more efficient writing/reading since before I had to lock all of
[Helper], which caused some noticable deadlocks in the GUI.

8. New [tab] field in [State<Gupax>], and GUI option to select
the tab that Gupax will start on.
2022-12-05 22:50:00 -05:00
hinto-janaiyo
1f3a472869
helper: p2pool - stdout payouts/xmr parser, priv -> pub functions 2022-12-05 14:55:50 -05:00
hinto-janaiyo
5d293054cf
helper: p2pool - fix args, basic watchdog loop, add STDOUT/STDERR handle to [Process] struct 2022-12-04 11:24:38 -05:00
hinto-janaiyo
d9d71c40d4
helper: translate priv p2pool/xmrig API into pub [Human*] structs 2022-12-03 20:12:40 -05:00
hinto-janaiyo
1a7df1e355
helper: turn [Helper] fields into [Arc]'s, add p2pool watchdog 2022-12-03 16:02:34 -05:00
hinto-janaiyo
0a8deee359
helper: add functions for p2pool/xmrig UI -> command arguments 2022-12-03 13:41:14 -05:00
hinto-janaiyo
f33207b503
main: fade in/out of black when resizing frame 2022-12-02 14:00:03 -05:00
hinto-janaiyo
bfbe0ee969
helper: map xmrig/p2pool JSON API key/values to structs for serde 2022-12-01 23:13:53 -05:00
hinto-janaiyo
cb28d705b4
helper: async read both STDOUT/STDERR in separate tokio runtime 2022-12-01 15:51:05 -05:00
hinto-janaiyo
1d8cd88309
helper: create wireframe of the [Helper::helper()] event loop 2022-11-30 22:03:49 -05:00
hinto-janaiyo
c6dad5849d
helper: add initial struct, add [HumanTime] for formatting uptime 2022-11-30 17:21:55 -05:00
hinto-janaiyo
eb4a70c483
helper: add stdout/stderr pipe threads to model 2022-11-30 16:08:06 -05:00
hinto-janaiyo
db60bc2c09
define gupax thread model (src/README.md) 2022-11-30 16:08:02 -05:00
hinto-janaiyo
212baf93ec
command: implement basic data structures, functions
This adds the basic wireframe of how processes will be handled.
The data/funcs in [command.rs] will be the API the main GUI thread
uses to talk to child processes. The process thread will loop
every 1 second to read/write the necessary data (stdout, stdin),
and handle signals from the GUI thread (kill, restart, etc).
2022-11-28 12:05:09 -05:00
hinto-janaiyo
aff46a96d0
p2pool: add sized, scrollable, selectable but not mutable console
This replaces the old mutable [TextEdit] with an immutable one
with a scroll area wrapped in a [Frame]. Passing a [&str] instead
of a [String] to [TextEdit] makes it auto-select only and not
mutable by the user. The background color is changed because the
immutable [TextEdit] has a hardcoded light gray color (same as the
general ui background).
2022-11-27 21:52:29 -05:00
hinto-janaiyo
9576a94498
main/update: add [Restart] state, set name to yellow if updated 2022-11-27 15:20:28 -05:00
hinto-janaiyo
b85dcd908d
xmrig: tls+keepalive default false (for p2pool) 2022-11-26 22:41:08 -05:00