Commit graph

72 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
f33207b503
main: fade in/out of black when resizing frame 2022-12-02 14:00:03 -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
29a62f638a
app: resize only once on width diff, set static button size at init
A [must_resize] and [ctx.is_pointer_over_area()] is now used to
indicate we need a resizing. This makes it so when a user is
resizing the width of Gupax, the heavy [init_text_styles()] func
will only get called once when the user hovers over the GUI.

The button size is also now set in that function so it doesn't
have to be called in every separate tab.
2022-11-25 12:01:52 -05:00
hinto-janaiyo
4d4d2f1a42
main: implement [--reset-pools] 2022-11-24 21:06:29 -05:00
hinto-janaiyo
290db4b95b
update: sanity check p2pool/xmrig path from user before starting
Define a strict list [&str; 4] of valid path endings for p2pool/xmrig.
This prevents users (for some reason) inputting a path to some
other (maybe very important) file which Gupax would have completely
overridden with the update binary. Windows paths end with [.exe].
2022-11-24 20:51:18 -05:00
hinto-janaiyo
6af2ffcc16
Cargo update + clippy lint fixes 2022-11-23 23:03:56 -05:00
hinto-janaiyo
c25cbacb46
[Simple/Advanced] for [Gupax/XMRig] tabs 2022-11-23 16:50:15 -05:00
hinto-janaiyo
20c7542189
v0.5.0 2022-11-22 10:12:16 -05:00
hinto-janaiyo
9e03b3caad
cargo/tor/p2pool: clean deps, warn macos arti, fix node overflow
Cargo: Cleanup unused dependencies, enable some build optimizations

Tor: Arti doesn't seem to work on macOS
Even a bare Arti+Hyper request doesn't seem to work, so it's
probably not something to do with Gupax. A lot of issues only
seem to popup in a VM (OpenGL, TLS) even though on bare metal
Gupax runs fine, so Tor might work fine on real macOS but I don't
have real macOS to test it. VM macOS can't create a circuit, so,
disable by default and add a warning that it's unstable.

P2Pool: Let selected_index start at 0, and only +1 when printing
to the user, this makes the overflow math when adding/deleting a
lot more simple because selected_index will match the actual index
of the node vector
2022-11-21 17:25:38 -05:00
hinto-janaiyo
3b37ac7be3
log: date -> sec.milli since init 2022-11-20 20:26:50 -05:00
hinto-janaiyo
42c89fcdd2
node: handle [write!] error 2022-11-20 14:46:43 -05:00
hinto-janaiyo
f2852549c2
update/ping: consolidate code in *::spawn_thread() 2022-11-20 14:20:25 -05:00
hinto-janaiyo
d0ced90bb1
main/disk: get OS data path only once, pass ref for [state/node] 2022-11-20 13:31:00 -05:00
hinto-janaiyo
7a5fe24276
disk: add [ErrorState] handling for disk errors 2022-11-19 22:49:15 -05:00
hinto-janaiyo
e8c41fceb3
main: prevent overflowing p2pool manual node index 2022-11-19 13:35:28 -05:00
hinto-janaiyo
ff98b2a303
update: recreate tor client on failure in metadata loop 2022-11-19 09:43:38 -05:00
hinto-janaiyo
51df689cb0
gupax: add [FileWindow] selector for p2pool/xmrig path 2022-11-17 13:03:45 -05:00
hinto-janaiyo
addf5ad60e
update: use compiled + updated version in gupax version comparison
If the built-in compiled version of Gupax is the only version
getting compared when updating, an old Gupax instance will always
think there's a new version even if the user already updated and
the actual binaries are swapped. To prevent forcing users to
restart, the built-in compiled version gets compared as well as
the version stored in [Arc<Mutex<Version>>], which should get
updated in a successful Gupax update.
2022-11-16 21:14:21 -05:00
hinto-janaiyo
bd6f369b56
p2pool: use [Arc<Mutex<Ping>>] as intermediary for node auto-select 2022-11-16 17:41:41 -05:00
hinto-janaiyo
1b85e59530
cleanup cargo warnings 2022-11-16 14:40:25 -05:00
hinto-janaiyo
50fff5c311
main: implement [ErrorState] checks in main() 2022-11-16 14:07:27 -05:00
hinto-janaiyo
a13e6d689b
optimize [.lock()], add index counter to p2pool manual nodes 2022-11-15 21:22:15 -05:00
hinto-janaiyo
d06cb08940
implement [--reset], add [ErrorState] for fullscreen ferris error 2022-11-15 16:29:05 -05:00
hinto-janaiyo
c4311acdec
main: more strict [gupax_update_] deletion with regex 2022-11-14 22:11:00 -05:00