refactor: remove and fix some hardcoded passwords.

This commit is contained in:
UpstreamData
2024-01-15 15:53:10 -07:00
parent d686cdacc8
commit 56dd1c80b5
5 changed files with 6 additions and 7 deletions

View File

@@ -16,6 +16,7 @@
from typing import List, Optional from typing import List, Optional
from pyasic import settings
from pyasic.data import HashBoard from pyasic.data import HashBoard
from pyasic.miners.backends import BMMiner from pyasic.miners.backends import BMMiner
from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPICommand from pyasic.miners.base import DataFunction, DataLocations, DataOptions, RPCAPICommand
@@ -64,7 +65,7 @@ HIVEON_DATA_LOC = DataLocations(
class Hiveon(BMMiner): class Hiveon(BMMiner):
def __init__(self, ip: str, api_ver: str = "0.0.0") -> None: def __init__(self, ip: str, api_ver: str = "0.0.0") -> None:
super().__init__(ip, api_ver) super().__init__(ip, api_ver)
self.pwd = "admin" self.pwd = settings.get("default_hive_password", "admin")
# static data # static data
self.api_type = "Hiveon" self.api_type = "Hiveon"
# data gathering locations # data gathering locations

View File

@@ -99,8 +99,6 @@ class BaseMiner(ABC):
self.api = None self.api = None
self.web = None self.web = None
self.ssh_pwd = "root"
# static data # static data
self.ip = ip self.ip = ip
self.api_type = None self.api_type = None
@@ -165,7 +163,6 @@ class BaseMiner(ABC):
@pwd.setter @pwd.setter
def pwd(self, val): def pwd(self, val):
self.ssh_pwd = val
try: try:
if self.web is not None: if self.web is not None:
self.web.pwd = val self.web.pwd = val
@@ -202,7 +199,7 @@ class BaseMiner(ABC):
str(self.ip), str(self.ip),
known_hosts=None, known_hosts=None,
username="root", username="root",
password=self.ssh_pwd, password=self.pwd,
server_host_key_algs=["ssh-rsa"], server_host_key_algs=["ssh-rsa"],
) )
return conn return conn

View File

@@ -32,7 +32,7 @@ class BaseMinerRPCAPI:
# ip address of the miner # ip address of the miner
self.ip = ipaddress.ip_address(ip) self.ip = ipaddress.ip_address(ip)
self.pwd = "admin" self.pwd = None
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
if cls is BaseMinerRPCAPI: if cls is BaseMinerRPCAPI:

View File

@@ -34,6 +34,7 @@ _settings = { # defaults
"default_bosminer_password": "root", "default_bosminer_password": "root",
"default_vnish_password": "admin", "default_vnish_password": "admin",
"default_goldshell_password": "123456789", "default_goldshell_password": "123456789",
"default_hive_password": "admin",
"socket_linger_time": 1000, "socket_linger_time": 1000,
} }

View File

@@ -25,7 +25,7 @@ class BaseWebAPI(ABC):
# ip address of the miner # ip address of the miner
self.ip = ip # ipaddress.ip_address(ip) self.ip = ip # ipaddress.ip_address(ip)
self.username = "root" self.username = "root"
self.pwd = "root" self.pwd = None
self.port = 80 self.port = 80
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):