stratum password

This commit is contained in:
Ben 2024-01-13 11:06:01 -05:00
parent ef344f236d
commit 794af8d7b7
7 changed files with 33 additions and 10 deletions

View File

@ -63,7 +63,7 @@ void STRATUM_V1_parse(StratumApiV1Message *message, const char *stratum_json);
void STRATUM_V1_free_mining_notify(mining_notify *params);
int STRATUM_V1_authenticate(int socket, const char *username);
int STRATUM_V1_authenticate(int socket, const char *username, const char *pass);
void STRATUM_V1_configure_version_rolling(int socket, uint32_t * version_mask);

View File

@ -304,11 +304,11 @@ int STRATUM_V1_suggest_difficulty(int socket, uint32_t difficulty)
return 1;
}
int STRATUM_V1_authenticate(int socket, const char *username)
int STRATUM_V1_authenticate(int socket, const char *username, const char *pass)
{
char authorize_msg[BUFFER_SIZE];
sprintf(authorize_msg, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"x\"]}\n",
send_uid++, username);
sprintf(authorize_msg, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}\n",
send_uid++, username, pass);
debug_stratum_tx(authorize_msg);
write(socket, authorize_msg, strlen(authorize_msg));
@ -344,11 +344,17 @@ void STRATUM_V1_configure_version_rolling(int socket, uint32_t * version_mask)
line = STRATUM_V1_receive_jsonrpc_line(socket);
ESP_LOGI(TAG, "Received result %s", line);
StratumApiV1Message stratum_api_v1_message;
STRATUM_V1_parse(&stratum_api_v1_message, line);
if (stratum_api_v1_message.method == MINING_SET_VERSION_MASK || stratum_api_v1_message.method == STRATUM_RESULT_VERSION_MASK) {
*version_mask = stratum_api_v1_message.version_mask;
ESP_LOGI(TAG, "Set version mask: %08lx", *version_mask);
cJSON * result = cJSON_GetObjectItem(line, "result");
if (result != NULL)
{
cJSON * version_rolling_enabled = cJSON_GetObjectItem(result, "version-rolling");
if (cJSON_IsBool(version_rolling_enabled) && cJSON_IsTrue(version_rolling_enabled)){
cJSON * mask = cJSON_GetObjectItem(result, "version-rolling.mask");
uint32_t version_mask = strtoul(mask->valuestring, NULL, 16);
ESP_LOGI(TAG, "Set version mask: %08lx", version_mask);
}
}
free(line);

View File

@ -28,6 +28,10 @@
<label>Stratum User: </label>
<input formControlName="stratumUser" type="text">
</div>
<div class="form-group">
<label>Stratum Password: </label>
<input formControlName="stratumPassword" type="password">
</div>
<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1366">

View File

@ -58,6 +58,7 @@ export class EditComponent implements OnInit {
Validators.max(65353)
]],
stratumUser: [info.stratumUser, [Validators.required]],
stratumPassword: ['password', [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['password'],
coreVoltage: [info.coreVoltage, [Validators.required]],
@ -107,6 +108,9 @@ export class EditComponent implements OnInit {
if (form.wifiPass === 'password') {
delete form.wifiPass;
}
if (form.stratumPassword === 'password') {
delete form.stratumPassword;
}
this.systemService.updateSystem(this.uri, form)
.pipe(this.loadingService.lockUIUntilComplete())

View File

@ -64,6 +64,7 @@ export class SettingsComponent {
Validators.max(65353)
]],
stratumUser: [info.stratumUser, [Validators.required]],
stratumPassword: ['password', [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['password'],
coreVoltage: [info.coreVoltage, [Validators.required]],
@ -112,6 +113,9 @@ export class SettingsComponent {
if (form.wifiPass === 'password') {
delete form.wifiPass;
}
if (form.stratumPassword === 'password') {
delete form.stratumPassword;
}
this.systemService.updateSystem(undefined, form)
.pipe(this.loadingService.lockUIUntilComplete())

View File

@ -264,6 +264,9 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
if ((item = cJSON_GetObjectItem(root, "stratumUser")) != NULL) {
nvs_config_set_string(NVS_CONFIG_STRATUM_USER, item->valuestring);
}
if ((item = cJSON_GetObjectItem(root, "stratumPassword")) != NULL) {
nvs_config_set_string(NVS_CONFIG_STRATUM_PASS, item->valuestring);
}
if ((item = cJSON_GetObjectItem(root, "stratumPort")) != NULL) {
nvs_config_set_u16(NVS_CONFIG_STRATUM_PORT, item->valueint);
}

View File

@ -110,7 +110,9 @@ void stratum_task(void * pvParameters)
STRATUM_V1_suggest_difficulty(GLOBAL_STATE->sock, STRATUM_DIFFICULTY);
char * username = nvs_config_get_string(NVS_CONFIG_STRATUM_USER, STRATUM_USER);
STRATUM_V1_authenticate(GLOBAL_STATE->sock, username);
char * password = nvs_config_get_string(NVS_CONFIG_STRATUM_PASS, STRATUM_PW);
STRATUM_V1_authenticate(GLOBAL_STATE->sock, username, password);
free(password);
free(username);
ESP_LOGI(TAG, "Extranonce: %s", GLOBAL_STATE->extranonce_str);