Skip to content

Commit b3f37a0

Browse files
committed
Merge branch 'master' of https://github.com/JsOS-Team/JsOS
2 parents cabb5ba + 005bb8a commit b3f37a0

File tree

6 files changed

+119
-10
lines changed

6 files changed

+119
-10
lines changed

js/__loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
} else {
250250
/* eslint-disable max-len */
251251
evalScriptFn(
252-
`((require,exports,module,__filename,__dirname) => {${content}})(((m) => {return function require(path){require.cache=m.require.cache;require.register=m.require.register;return m.require(path)}})(global.module),global.module.exports,global.module,global.module.filename,global.module.dirname)`,
252+
`((require,exports,module,__filename,__dirname) => {${content}})(((m) => {function require(path){return m.require(path)};require.cache=m.require.cache;require.register=m.require.register;return require})(global.module),global.module.exports,global.module,global.module.filename,global.module.dirname)`,
253253
displayPath);
254254
/* eslint-enable max-len */
255255
}

js/apps/netinfo/index.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// NetInfo application
2+
// By ivan770
3+
4+
// Gonna add MAC later
5+
6+
'use strict';
7+
8+
function main (cmd, args, api, res) {
9+
const io = api.stdio;
10+
11+
if (args === 'interfaces'){
12+
const interfaces = require('../../core/net/interfaces');
13+
14+
try {
15+
var arr = interfaces.getAll();
16+
arr.forEach(function (item, i, arr) {
17+
io.writeLine(i + ': ' + item.name);
18+
});
19+
} catch (err) {
20+
io.setColor('red');
21+
io.writeLine('Unable to get network interfaces');
22+
23+
return res(1);
24+
}
25+
26+
} else if (args === '') {
27+
io.setColor('red');
28+
io.writeLine('NetInfo testing tool.');
29+
io.writeLine('Created by ivan770');
30+
io.writeLine('');
31+
io.setColor('green');
32+
io.writeLine('interfaces - Get all network interfaces');
33+
io.writeLine('stats - Get network usage stats');
34+
io.writeLine('ip - Get IPv4 addresses');
35+
} else if (args === 'stats') {
36+
const netstat = require('../../core/net/net-stat');
37+
38+
try {
39+
var receiveCount = netstat.receiveCount;
40+
var transmitCount = netstat.transmitCount;
41+
io.writeLine(`'Receive: ${receiveCount}'`);
42+
io.writeLine(`'Transmit: ${transmitCount}'`);
43+
} catch (err) {
44+
io.setColor('red');
45+
io.writeLine('Unable to get network stats');
46+
47+
return res(1);
48+
}
49+
} else if (args === 'ip'){
50+
const ip = require('../../core/net/ip4-address');
51+
52+
var IPLoopback = ip.LOOPBACK;
53+
var IPAny = ip.ANY;
54+
var IPBroadcast = ip.BROADCAST;
55+
io.writeLine(`'IPV4 Loopback: ${IPLoopback}'`);
56+
io.writeLine(`'IPV4 Any: ${IPAny}'`);
57+
io.writeLine(`'IPV4 Broadcast: ${IPBroadcast}'`);
58+
59+
/* } else if (args === 'mac') {
60+
const mac = require('../../core/net/mac-address');
61+
62+
var MACBroadcast = mac.BROADCAST;
63+
io.writeLine(`'MAC Broadcast: ${MACBroadcast}'`); */
64+
65+
} else {
66+
io.setColor('red')
67+
io.writeLine(`'Invalid argument : ${args}'`);
68+
69+
return res(1);
70+
}
71+
72+
return res(0);
73+
}
74+
75+
exports.call = main;
76+
77+
exports.commands = ['netinfo'];

js/core/stdio/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ defaultStdio.onsetbackgroundcolor = (bg) => {
4949
};
5050

5151
defaultStdio.onmoveto = (x, y) => tty.moveTo(x, y);
52+
defaultStdio.onmoveoffset = (offset) => tty.moveOffset(offset);
5253

5354
defaultStdio.onread = (cb) => tty.read(cb);
5455

js/core/stdio/interface.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class StdioInterface {
2323
this.onsetcolor = () => {};
2424
this.onsetbackgroundcolor = () => {};
2525
this.onmoveto = () => {};
26+
this.onmoveoffset = () => {};
2627

2728
this.write = this.write.bind(this);
2829
this.writeError = this.writeError.bind(this);
@@ -62,6 +63,9 @@ class StdioInterface {
6263
moveTo (x, y) {
6364
this.onmoveto(x, y);
6465
}
66+
moveOffset (offset) {
67+
this.onmoveoffset(offset);
68+
}
6569

6670
clear () {
6771
this.onclear();

package-lock.json

Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"buffer": "^4.3.0",
4747
"commander": "1.2.0",
4848
"constants-browserify": "^1.0.0",
49+
"debug": "^3.1.0",
4950
"diff_match_patch": "0.1.1",
5051
"eshttp": "git+https://github.com/JsOS-Team/eshttp.git",
5152
"event-controller": "^1.0.1",

0 commit comments

Comments
 (0)