ggtech 10.0.0 → 10.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/view-port-logs.js +0 -124
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ggtech",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/view-port-logs.js DELETED
@@ -1,124 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const logFile = path.join(__dirname, 'port-4444-requests.log');
5
-
6
- function viewLogs() {
7
- try {
8
- if (!fs.existsSync(logFile)) {
9
- console.log('No port 4444 log file found.');
10
- return;
11
- }
12
-
13
- const logContent = fs.readFileSync(logFile, 'utf8');
14
- const lines = logContent.trim().split('\n').filter(line => line.trim());
15
-
16
- console.log(`Found ${lines.length} requests to port 4444:`);
17
- console.log('='.repeat(60));
18
-
19
- lines.forEach((line, index) => {
20
- try {
21
- const entry = JSON.parse(line);
22
- console.log(`\nRequest ${index + 1}:`);
23
- console.log(` Timestamp: ${entry.timestamp}`);
24
- console.log(` Method: ${entry.method}`);
25
- console.log(` URL: ${entry.url}`);
26
- console.log(` IP: ${entry.ip}`);
27
- console.log(` User Agent: ${entry.userAgent}`);
28
- console.log(` Hostname: ${entry.hostname}`);
29
- console.log(` Username: ${entry.username}`);
30
- console.log(` Path: ${entry.currentPath}`);
31
-
32
- if (entry.queryParams && Object.keys(entry.queryParams).length > 0) {
33
- console.log(` Query Params:`, entry.queryParams);
34
- }
35
-
36
- if (entry.body) {
37
- console.log(` Body: ${entry.body}`);
38
- }
39
-
40
- if (entry.headers && entry.headers.authorization) {
41
- console.log(` Authorization: ${entry.headers.authorization}`);
42
- }
43
-
44
- } catch (error) {
45
- console.log(` Raw: ${line}`);
46
- }
47
- });
48
-
49
- console.log('\n' + '='.repeat(60));
50
- console.log(`Total requests: ${lines.length}`);
51
-
52
- } catch (error) {
53
- console.error('Error reading logs:', error.message);
54
- }
55
- }
56
-
57
- function clearLogs() {
58
- try {
59
- if (fs.existsSync(logFile)) {
60
- fs.writeFileSync(logFile, '');
61
- console.log('Port 4444 logs cleared.');
62
- } else {
63
- console.log('No log file found.');
64
- }
65
- } catch (error) {
66
- console.error('Error clearing logs:', error.message);
67
- }
68
- }
69
-
70
- function getStats() {
71
- try {
72
- if (!fs.existsSync(logFile)) {
73
- console.log('No log file found.');
74
- return;
75
- }
76
-
77
- const logContent = fs.readFileSync(logFile, 'utf8');
78
- const lines = logContent.trim().split('\n').filter(line => line.trim());
79
-
80
- const stats = {
81
- totalRequests: lines.length,
82
- uniqueIPs: new Set(),
83
- methods: {},
84
- userAgents: new Set()
85
- };
86
-
87
- lines.forEach(line => {
88
- try {
89
- const entry = JSON.parse(line);
90
- stats.uniqueIPs.add(entry.ip);
91
- stats.methods[entry.method] = (stats.methods[entry.method] || 0) + 1;
92
- stats.userAgents.add(entry.userAgent);
93
- } catch (error) {
94
- // Skip invalid entries
95
- }
96
- });
97
-
98
- console.log('Port 4444 Request Statistics:');
99
- console.log('='.repeat(40));
100
- console.log(`Total Requests: ${stats.totalRequests}`);
101
- console.log(`Unique IPs: ${stats.uniqueIPs.size}`);
102
- console.log(`Methods:`, stats.methods);
103
- console.log(`Unique User Agents: ${stats.userAgents.size}`);
104
-
105
- } catch (error) {
106
- console.error('Error reading stats:', error.message);
107
- }
108
- }
109
-
110
- // Command line interface
111
- const command = process.argv[2];
112
-
113
- switch (command) {
114
- case 'clear':
115
- clearLogs();
116
- break;
117
- case 'stats':
118
- getStats();
119
- break;
120
- case 'view':
121
- default:
122
- viewLogs();
123
- break;
124
- }