TP-Link-Archer-C6U
TP-Link-Archer-C6U copied to clipboard
Add Support pour Archer C3200
Hello,
I am wondering how to add the configuration for my router. I get a login failure "Login failed! Please check if your router local password is correct or try to use web encrypted password instead. Check the documentation!"
I have read other posts, it does not recognize any know router Class. The firmware follows : "Version du microprogramme :0.9.1 0.1 v004b.0 Build 160712 Rel.55313n Version du matériel :Archer C3200 v1 00000000"
I have understood that I need somehow to implement a new class. I don't know pyhton but I can learn. What I don't get is how to debug it.
I have search to understand the authenticaiton method, it adds an "Autorization" part to the cookie then reload. Please find below the JS code :
function PCSubWin() { if (isLocked == true) { return; } var auth; var $password = $("pcPassword"); var $username = $("userName"); if ($username.value == "") { addClass($username, "input-error"); $("usrTips").style.display = "inline"; $("tipsContentUsr").innerHTML = tipsText; return; } if ($password.value == "") { addClass($password, "input-error"); $("pwdTips").style.display = "inline"; $("tipsContentPwd").innerHTML = tipsText; return; } auth = "Basic " + Base64Encoding($username.value + ":" + $password.value); document.cookie = "Authorization=" + auth; window.location.reload(); }
@HaJJ-MBX Hi. Could you try the latest version?
unfortunately it's not working. My challenge is to learn Python and Github to propose a fix / a support for my router ! I am not in a hurry
Hello,
After chatgpting the issue I managed to get some insight. The C3200 router needs a base64 encoded cookie to authorize. I have downloaded the project and initialize a new C3200 class. Unfortunately it seems to break all the logic of the TPLinkRouterClass. I could rewrite everything, but I want to check first if another class is following the same pattern.
Please find below the autorize method that works.
`def build_auth_cookie(self, user: str, pwd: str) -> str: """Return the string "Basic <base64(username:password)>".""" token_bytes = f"{user}:{pwd}".encode() encoded = base64.b64encode(token_bytes).decode() return f"Basic {encoded}"
def authorize(self) -> None:
# ———————————————————————————————————————————
# Création de la session + cookie
# ———————————————————————————————————————————
session = requests.Session()
if self._logger:
self._logger.debug("Dans C3200!")
# Domaine nécessaire pour le cookie → extrait à partir de l’URL
router_host = urlparse(self.host).hostname
if not router_host:
raise ValueError(self.host & " doit contenir un host valide, ex. http://192.168.168.1")
cookie_value = self.build_auth_cookie(self.username, self.password)
session.cookies.set(
name="Authorization",
value=cookie_value,
domain=router_host,
path="/",
)
login_url = '{}/'.format(self.host)
try:
response = session.post(login_url, timeout=10)
except Exception as e:
error = "TplinkRouter - C3200 - Cannot authorize! Error - {}; Response - {}".format(e, response.text)
if self._logger:
self._logger.debug(error)
raise ClientException(error)
`
@HaJJ-MBX Hi! I cannot test it as I dont have this router