mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-03 04:22:09 +08:00
Pin to Pass
This commit is contained in:
@@ -123,15 +123,15 @@ def main():
|
||||
|
||||
while True:
|
||||
glxyauth_file = GALAXY_DIR / "glxyauth"
|
||||
galaxy_pin = glxyauth_file.read_text().strip() if glxyauth_file.exists() else None
|
||||
is_paired = galaxy_pin and len(galaxy_pin) == 64
|
||||
galaxy_password_hash = glxyauth_file.read_text().strip() if glxyauth_file.exists() else None
|
||||
is_paired = galaxy_password_hash and len(galaxy_password_hash) == 64
|
||||
|
||||
if is_paired:
|
||||
if process is None or process.poll() is not None:
|
||||
if process is not None:
|
||||
print(f"Galaxy: frpc exited with code {process.returncode}. Restarting...")
|
||||
|
||||
print("Galaxy: PIN set. Preparing frpc tunnel...")
|
||||
print("Galaxy: Password set. Preparing frpc tunnel...")
|
||||
if not setup_frpc():
|
||||
print("Galaxy: FRPC setup failed. Retrying later...")
|
||||
time.sleep(10)
|
||||
@@ -175,7 +175,7 @@ customDomains = ["auth-{dongle_id}.devices.local"]
|
||||
)
|
||||
else:
|
||||
if process is not None and process.poll() is None:
|
||||
print("Galaxy: PIN cleared. Stopping frpc tunnel...")
|
||||
print("Galaxy: Password cleared. Stopping frpc tunnel...")
|
||||
cleanup_frpc()
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
@@ -261,11 +261,11 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
|
||||
pair_galaxy = new ButtonControl(tr("Galaxy"), tr("Pair"), tr("Pair your device with Galaxy for remote access to The Pond."));
|
||||
connect(pair_galaxy, &ButtonControl::clicked, [=]() {
|
||||
std::string current_pin = util::read_file("/data/galaxy/glxyauth");
|
||||
if (current_pin.empty()) {
|
||||
QString new_pin = InputDialog::getText(tr("Enter 6-digit PIN"), this, tr("Please enter a 6-digit PIN to secure your Galaxy access."), false, 6);
|
||||
if (!new_pin.isEmpty()) {
|
||||
std::string hash = QCryptographicHash::hash(new_pin.toUtf8(), QCryptographicHash::Sha256).toHex().toStdString();
|
||||
std::string current_password = util::read_file("/data/galaxy/glxyauth");
|
||||
if (current_password.empty()) {
|
||||
QString new_password = InputDialog::getText(tr("Enter Password"), this, tr("Please enter a password to secure your Galaxy access. (Min 6 characters)"), false, 6);
|
||||
if (!new_password.isEmpty()) {
|
||||
std::string hash = QCryptographicHash::hash(new_password.toUtf8(), QCryptographicHash::Sha256).toHex().toStdString();
|
||||
util::create_directories("/data/galaxy", 0775);
|
||||
util::write_file("/data/galaxy/glxyauth", hash.data(), hash.size(), O_WRONLY | O_CREAT | O_TRUNC);
|
||||
pair_galaxy->setText(tr("Unpair"));
|
||||
|
||||
Reference in New Issue
Block a user