mirror of
https://github.com/ShiftOS-Rewind/ShiftOS.git
synced 2025-01-22 03:11:47 -05:00
yay new command
This commit is contained in:
parent
277d5c79e7
commit
2cb81352d7
3 changed files with 53 additions and 1 deletions
|
@ -102,6 +102,7 @@
|
|||
<Compile Include="Terminal\Commands\Hello.cs" />
|
||||
<Compile Include="Terminal\Commands\Help.cs" />
|
||||
<Compile Include="Terminal\Commands\sftp.cs" />
|
||||
<Compile Include="Terminal\Commands\tcpip.cs" />
|
||||
<Compile Include="Terminal\Commands\TestStory.cs" />
|
||||
<Compile Include="Terminal\TerminalBackend.cs" />
|
||||
<Compile Include="Terminal\TerminalCommand.cs" />
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace ShiftOS.Main.ShiftOS.Apps
|
|||
{
|
||||
public int TerminalID = TerminalBackend.trmTopID++; // Used so that we can have multiple instances of the terminal whilst the command begin run knowing what terminal to send the text to - very complicated ;)
|
||||
public string defaulttextBefore = "user> ";
|
||||
public string defaulttextResult = "[user@shiftos~]$> "; // NOT YET IMPLEMENTED!!!
|
||||
public string defaulttextResult = "[user@shiftos ~]$ "; // NOT YET IMPLEMENTED!!!
|
||||
public bool DoClear = false;
|
||||
public bool RunningCommand = false;
|
||||
public bool WaitingResponse = false;
|
||||
|
|
51
ShiftOS.Main/Terminal/Commands/tcpip.cs
Normal file
51
ShiftOS.Main/Terminal/Commands/tcpip.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShiftOS.Main;
|
||||
|
||||
namespace ShiftOS.Main.Terminal.Commands
|
||||
{
|
||||
public class tcpip : TerminalCommand
|
||||
{
|
||||
public override string Name { get; } = "tcpip";
|
||||
public override string Summary { get; } = "Shows a list of incoming or outgoing commands.";
|
||||
public override string Usage { get; } = "tcpip <incoming/outcoming>";
|
||||
public override bool Unlocked { get; set; } = false;
|
||||
|
||||
public override void Run(params string[] args)
|
||||
{
|
||||
var r = new Random();
|
||||
string gen = Generate(13);
|
||||
if (args.Length == 0)
|
||||
{
|
||||
WriteLine("tcpip: syntax error");
|
||||
return;
|
||||
}
|
||||
switch (args[0].ToLower())
|
||||
{
|
||||
default:
|
||||
WriteLine("tcpip: syntax error");
|
||||
break;
|
||||
case "incoming":
|
||||
WriteLine($"Incoming connections from localhost:");
|
||||
WriteLine($"IP ADDRESS v4 COMPUTER NAME");
|
||||
WriteLine($"{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(255)} {gen}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
public string Generate(int amountToGenerate)
|
||||
{
|
||||
var r = new Random();
|
||||
|
||||
string symbols = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghjklmnopqrstuvwxyz0123456789!@#$%^&*()";
|
||||
char[] array = new char[amountToGenerate];
|
||||
for (int i = 0; i < amountToGenerate; i++)
|
||||
{
|
||||
array[i] = symbols[r.Next(0, symbols.Length)];
|
||||
}
|
||||
return new string(array);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue