fix: Use baseclass.extend() for mitmproxy API module

LuCI requires modules to use baseclass.extend() pattern.
Fixed "factory yields invalid constructor" error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-10 15:19:08 +01:00
parent 7ec09af2e0
commit c457da5632

View File

@ -1,4 +1,5 @@
'use strict'; 'use strict';
'require baseclass';
'require rpc'; 'require rpc';
var callMitmproxy = rpc.declare({ var callMitmproxy = rpc.declare({
@ -59,7 +60,7 @@ var callClearData = rpc.declare({
method: 'clear_data' method: 'clear_data'
}); });
return { return baseclass.extend({
getStatus: function() { getStatus: function() {
return callMitmproxy().catch(function() { return callMitmproxy().catch(function() {
return { running: false, enabled: false }; return { running: false, enabled: false };
@ -117,12 +118,13 @@ return {
}, },
getAllData: function() { getAllData: function() {
var self = this;
return Promise.all([ return Promise.all([
this.getStatus(), self.getStatus(),
this.getConfig(), self.getConfig(),
this.getStats(), self.getStats(),
this.getTopHosts(10), self.getTopHosts(10),
this.getCaInfo() self.getCaInfo()
]).then(function(results) { ]).then(function(results) {
return { return {
status: results[0], status: results[0],
@ -148,4 +150,4 @@ return {
if (num >= 1000) return (num / 1000).toFixed(1) + 'K'; if (num >= 1000) return (num / 1000).toFixed(1) + 'K';
return num.toString(); return num.toString();
} }
}; });