devcode-canavar-pro 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +10 -1
- package/lib/Dashboard.js +11 -6
- package/lib/Journal.js +12 -0
- package/lib/RemoteClient.js +6 -6
- package/lib/Server.js +1 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8,7 +8,11 @@ const Server = require('./lib/Server');
|
|
|
8
8
|
function devcode(secretOrOptions) {
|
|
9
9
|
let client;
|
|
10
10
|
if (typeof secretOrOptions === 'string') {
|
|
11
|
-
|
|
11
|
+
if (secretOrOptions.startsWith('devcode:')) {
|
|
12
|
+
client = new RemoteClient(secretOrOptions);
|
|
13
|
+
} else {
|
|
14
|
+
client = new RemoteClient({ secret: secretOrOptions });
|
|
15
|
+
}
|
|
12
16
|
} else {
|
|
13
17
|
client = new RemoteClient(secretOrOptions);
|
|
14
18
|
}
|
|
@@ -17,6 +21,11 @@ function devcode(secretOrOptions) {
|
|
|
17
21
|
|
|
18
22
|
module.exports = devcode;
|
|
19
23
|
|
|
24
|
+
// Geriye dönük uyumluluk ve URI desteği
|
|
25
|
+
module.exports.connect = function (uriOrOptions) {
|
|
26
|
+
return devcode(uriOrOptions);
|
|
27
|
+
};
|
|
28
|
+
|
|
20
29
|
// Gelişmiş sunucu/yerel kullanım
|
|
21
30
|
module.exports.Server = Server; // HTTP Sunucusu
|
|
22
31
|
module.exports.Core = Core; // Veritabanı Motoru
|
package/lib/Dashboard.js
CHANGED
|
@@ -57,13 +57,18 @@ class Dashboard {
|
|
|
57
57
|
let databases = [];
|
|
58
58
|
if (clientSecret === this.masterSecret) {
|
|
59
59
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if (fs.existsSync(this.core.dataPath)) {
|
|
61
|
+
const namespaces = fs.readdirSync(this.core.dataPath).filter(f => {
|
|
62
|
+
const fp = path.join(this.core.dataPath, f);
|
|
63
|
+
return fs.existsSync(fp) && fs.statSync(fp).isDirectory();
|
|
64
|
+
});
|
|
65
|
+
namespaces.forEach(ns => {
|
|
66
|
+
this.core.listDatabases(ns).forEach(db => databases.push({ ns: ns, name: db }));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
} catch (e) { console.error('Dashboard Stats Error:', e); }
|
|
65
70
|
} else {
|
|
66
|
-
databases = this.core.listDatabases(clientSecret).map(db =>
|
|
71
|
+
databases = this.core.listDatabases(clientSecret).map(db => { return { ns: clientSecret, name: db }; });
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
const freeMem = os.freemem() / 1024 / 1024 / 1024;
|
package/lib/Journal.js
CHANGED
|
@@ -24,6 +24,18 @@ class Journal {
|
|
|
24
24
|
}) + '\n';
|
|
25
25
|
|
|
26
26
|
fs.appendFileSync(this.journalPath, logEntry);
|
|
27
|
+
|
|
28
|
+
// Global Audit Bridge for Dashboard
|
|
29
|
+
if (!global.devcodeAuditLogs) global.devcodeAuditLogs = [];
|
|
30
|
+
const ns = path.basename(path.dirname(this.journalPath)); // Extract namespace from dbPath
|
|
31
|
+
global.devcodeAuditLogs.unshift({
|
|
32
|
+
time: new Date().toLocaleTimeString(),
|
|
33
|
+
ns: ns === 'data' ? 'public' : ns.substring(0, 8),
|
|
34
|
+
db: collectionName,
|
|
35
|
+
col: 'system',
|
|
36
|
+
action: operation.toUpperCase()
|
|
37
|
+
});
|
|
38
|
+
if (global.devcodeAuditLogs.length > 50) global.devcodeAuditLogs.pop();
|
|
27
39
|
}
|
|
28
40
|
|
|
29
41
|
/**
|
package/lib/RemoteClient.js
CHANGED
|
@@ -18,12 +18,12 @@ class RemoteClient {
|
|
|
18
18
|
let host, port, secret;
|
|
19
19
|
|
|
20
20
|
if (uri) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
secret =
|
|
24
|
-
host =
|
|
25
|
-
port = parseInt(
|
|
26
|
-
}
|
|
21
|
+
const match = uri.match(/^devcode:\/\/(?:([^@]+)@)?([^:]+)(?::(\d+))?$/);
|
|
22
|
+
if (match) {
|
|
23
|
+
secret = match[1] || null;
|
|
24
|
+
host = match[2];
|
|
25
|
+
port = match[3] ? parseInt(match[3]) : CLOUD_PORT;
|
|
26
|
+
} else {
|
|
27
27
|
throw new Error("Geçersiz Connection URI! Format: devcode://secret@vds-ip:4242");
|
|
28
28
|
}
|
|
29
29
|
} else {
|
package/lib/Server.js
CHANGED
|
@@ -171,23 +171,9 @@ class Server {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
/**
|
|
175
|
-
* Audit log kaydı tutar (Circular buffer).
|
|
176
|
-
*/
|
|
177
|
-
_log(ns, db, col, action) {
|
|
178
|
-
if (!this.auditLogs) this.auditLogs = [];
|
|
179
|
-
this.auditLogs.unshift({
|
|
180
|
-
time: new Date().toLocaleTimeString(),
|
|
181
|
-
ns: ns.substring(0, 8),
|
|
182
|
-
db,
|
|
183
|
-
col,
|
|
184
|
-
action: action.toUpperCase()
|
|
185
|
-
});
|
|
186
|
-
if (this.auditLogs.length > 100) this.auditLogs.pop();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
174
|
/**
|
|
190
175
|
* Audit log kaydı tutar (Global Bridge).
|
|
176
|
+
* Dashboard ve Server aynı işlemi görüp panoda yazdırabilir.
|
|
191
177
|
*/
|
|
192
178
|
_log(ns, db, col, action) {
|
|
193
179
|
if (!global.devcodeAuditLogs) global.devcodeAuditLogs = [];
|
package/package.json
CHANGED