8000 Maintenance by trusthat · Pull Request #7 · tyranid/CANAPE.Core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Maintenance #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CANAPE.Cli.Lib/ConsoleUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using CANAPE.DataFrames;
using CANAPE.Utils;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using CANAPE.DataFrames;

namespace CANAPE.Cli
{
Expand Down Expand Up @@ -96,7 +96,7 @@ private static bool GetEffectiveColorMode()
{
return _supports_ansi_color && EnableColor;
}

public static void WritePacket(LogPacket packet)
{
Console.Out.WriteLine(PacketUtils.ConvertPacketToString(packet, GetEffectiveColorMode()));
Expand All @@ -110,17 +110,17 @@ public static void WritePackets(IEnumerable<LogPacket> packets)
}
}

public static void WritePacket(DataFrame frame)
{
Console.Out.WriteLine(PacketUtils.ConvertPacketToString(frame));
}
public static void WritePacket(DataFrame frame)
{
Console.Out.WriteLine(PacketUtils.ConvertPacketToString(frame));
}

public static void WritePackets(IEnumerable<DataFrame> packets)
{
public static void WritePackets(IEnumerable<DataFrame> packets)
{
foreach (DataFrame packet in packets)
{
WritePacket(packet);
}
}
{
WritePacket(packet);
}
}
}
}
18 changes: 9 additions & 9 deletions CANAPE.Cli.Lib/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using CANAPE.Net.Templates;
using CANAPE.Utils;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using McMaster.Extensions.CommandLineUtils;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -70,7 +70,7 @@ private static ScriptOptions CreateScriptOptions(string filename, IEnumerable<st
{
resolve_paths.Add(Path.GetDirectoryName(filename));
}

Type template_type = typeof(FixedProxyTemplate);
SourceFileResolver resolver = new SourceFileResolver(include_dirs.Concat(resolve_paths), base_path);
ScriptMetadataResolver metadata_resolver = ScriptMetadataResolver.Default
Expand All @@ -80,7 +80,7 @@ private static ScriptOptions CreateScriptOptions(string filename, IEnumerable<st
"CANAPE.Utils", "CANAPE.Nodes", "CANAPE.Net.Utils",
"CANAPE.DataFrames", "CANAPE.Net.Templates.Factories",
"CANAPE.Net.Templates", "CANAPE.Security.Cryptography.X509Certificates")
.WithReferences(template_type.GetTypeInfo().Assembly,
.WithReferences(template_type.GetTypeInfo().Assembly,
typeof(EntryPoint).GetTypeInfo().Assembly)
.WithSourceResolver(resolver)
.WithMetadataResolver(metadata_resolver);
Expand All @@ -98,7 +98,7 @@ private async static Task RunConsole(IEnumerable<string> include_dirs, IEnumerab
var options = CreateScriptOptions(null, include_dirs, metadata_dirs);
var state = await CSharpScript.RunAsync("static void quit() { Environment.Exit(0); }", options);
Console.WriteLine("Type quit() to exit the console");

while (true)
{
StringBuilder current_line = new StringBuilder();
Expand All @@ -124,7 +124,7 @@ private async static Task RunConsole(IEnumerable<string> include_dirs, IEnumerab
}
}

private static ScriptRunner<object> CompileScript(string filename,
private static ScriptRunner<object> CompileScript(string filename,
IEnumerable<string> include_dirs,
IEnumerable<string> metadata_dirs)
{
Expand All @@ -141,8 +141,8 @@ private static ScriptRunner<object> CompileScript(string filename,
}
}

private async static Task RunScript(string filename,
IEnumerable<string> include_dirs,
private async static Task RunScript(string filename,
IEnumerable<string> include_dirs,
IEnumerable<string> metadata_dirs,
IEnumerable<string> args)
{
Expand All @@ -169,7 +169,7 @@ public static int Main(string[] args)
Logger.SystemLogger = LogUtils.GetLogger(Console.Error);
Console.Error.WriteLine("CANAPE.Cli (c) 2017 James Forshaw, 2014 Context Information Security.");
CommandLineApplication app = new CommandLineApplication(false);

CommandArgument script = app.Argument("script", "Specify a script file to run.");
CommandOption compile = app.Option(
"-c | --compile", "Compile script file only.",
Expand All @@ -193,7 +193,7 @@ public static int Main(string[] args)
IEnumerable<string> include_dirs = include.HasValue() ? include.Values.Select(p => Path.GetFullPath(p)) : new string[0];
IEnumerable<string> metadata_dirs = libs.HasValue() ? libs.Values.Select(p => Path.GetFullPath(p)) : new string[0];

ConsoleUtils.EnableColor = color.HasValue();
ConsoleUtils.EnableColor = color.HasValue();
if (verbose.HasValue())
{
Logger.SystemLogger.LogLevel = Logger.LogEntryType.All;
Expand Down
2 changes: 1 addition & 1 deletion CANAPE.Cli.Lib/NetGraphUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static string ToDot(NetGraphFactory netgraph)
if (!node.Enabled)
{
attrs.Add("style=dotted");
}
}

if (attrs.Count > 0)
{
Expand Down
11 changes: 5 additions & 6 deletions CANAPE.Cli.Lib/PacketUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using CANAPE.DataFrames;
using CANAPE.Nodes;
using CANAPE.Utils;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -151,7 +150,7 @@ private static string GetHeader(LogPacket p)
return String.Format("Time {0} - Tag '{1}' - Network '{2}'",
p.Timestamp.ToString(), p.Tag, p.Network);
}

/// <summary>
/// Convert a packet to a hex string format
/// </summary>
Expand Down Expand Up @@ -188,10 +187,10 @@ public static string ConvertPacketToString(DataFrame p)
return ConvertTextPacketToString(p);
}
else
{
return ConvertBinaryPacketToString(p);
}
}
{
return ConvertBinaryPacketToString(p);
}
}

private static ColorValue PickContrastingColor(ColorValue color)
{
Expand Down
2 changes: 1 addition & 1 deletion CANAPE.Cli/CANAPE.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.0; netcoreapp2.0; net471</TargetFrameworks>
<TargetFrameworks>netcoreapp7.0; net48</TargetFrameworks>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Command Line Interface CANAPE.Core network library.</Description>
Expand Down
1 change: 0 additions & 1 deletion CANAPE.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;

namespace CANAPE.Cli
{
Expand Down
9 changes: 4 additions & 5 deletions CANAPE.Net.Protocols/Endpoint/EchoDataEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using CANAPE.DataAdapters;
using CANAPE.DataFrames;
using CANAPE.Nodes;
using CANAPE.Utils;

namespace CANAPE.Net.Protocols.Endpoint
{
Expand All @@ -39,7 +38,7 @@ public class EchoDataEndpointConfig
/// Echo data endpoint.
/// </summary>
public class EchoDataEndpoint : BasePersistDataEndpoint<EchoDataEndpointConfig>
{
{
/// <summary>
/// Run the specified adapter.
/// </summary>
Expand All @@ -49,8 +48,8 @@ public override void Run(IDataAdapter adapter)
{
DataFrame frame = adapter.Read();

while(frame != null)
{
while (frame != null)
{
if (Config.ConvertToBasic)
{
frame = frame.ToArray().ToDataFrame();
Expand All @@ -59,7 +58,7 @@ public override void Run(IDataAdapter adapter)
adapter.Write(frame);

frame = adapter.Read();
}
}
}

/// <summary>
Expand Down
23 changes: 11 additions & 12 deletions CANAPE.Net.Protocols/Parser/DNSPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using CANAPE.DataFrames;
using CANAPE.Utils;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -307,7 +306,7 @@ public class CNameDNSRR : DNSRRBase
/// <summary>
/// The CNAME
/// </summary>
public string CName { get; set; }
public string CName { get; set; }

/// <summary>
/// Constructor
Expand All @@ -334,7 +333,7 @@ public CNameDNSRR()
/// <param name="stringCache">The string cache</param>
public override void WriteData(DataWriter writer, Dictionary<string, int> stringCache)
{
WriteString(CName, writer, stringCache);
WriteString(CName, writer, stringCache);
}
}

Expand Down Expand Up @@ -426,7 +425,7 @@ public AAAADNSRR()
/// <param name="writer">The writer</param>
/// <param name="stringCache">The string cache</param>
public override void WriteData(DataWriter writer, Dictionary<string, int> stringCache)
{
{
if (Address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
{
throw new ArgumentException("Must provide a IPv6 address for a AAAA record");
Expand Down Expand Up @@ -629,7 +628,7 @@ private static DNSRRBase ReadResourceRecord(byte[] data, DataReader reader)
rr.Class = cls;
rr.Type = type;
rr.TimeToLive = ttl;

return rr;
}

Expand All @@ -647,12 +646,12 @@ private static DNSRRBase[] ReadResourceRecords(byte[] data, DataReader reader, i

private static bool GetBooleanFlag(ushort flags, int pos)
{
return ((flags >> (15-pos)) & 1) == 1;
return ((flags >> (15 - pos)) & 1) == 1;
}

private static int GetFlagValue(ushort flags, int pos)
{
return (flags >> (15-pos-3)) & 0xF;
return (flags >> (15 - pos - 3)) & 0xF;
}

private static ushort SetBooleanFlag(ushort flags, int pos, bool value)
Expand All @@ -669,7 +668,7 @@ private static ushort SetBooleanFlag(ushort flags, int pos, bool value)

private static ushort SetFlagValue(ushort flags, int pos, int val)
{
return (ushort)(flags | (val << (15 - pos - 3)));
return (ushort)(flags | (val << (15 - pos - 3)));
}

/// <summary>
Expand Down Expand Up @@ -703,7 +702,7 @@ public static DNSPacket FromArray(byte[] data)
if (qdcount > 0)
{
DNSQuestion[] questions = new DNSQuestion[qdcount];

for (int i = 0; i < qdcount; i++)
{
questions[i] = ReadQuestion(data, reader);
Expand All @@ -713,7 +712,7 @@ public static DNSPacket FromArray(byte[] data)
}

if (ancount > 0)
{
{
ret.Answers = ReadResourceRecords(data, reader, ancount);
}

Expand Down Expand Up @@ -767,7 +766,7 @@ private static void WriteStringPart(string value, DataWriter writer, Dictionary<
{
WriteStringPart(null, writer, stringCache);
}
}
}
}
}

Expand Down Expand Up @@ -842,5 +841,5 @@ public byte[] ToArray()

return stm.ToArray();
}
}
}
}
6 changes: 3 additions & 3 deletions CANAPE.Net.Protocols/Parser/HttpDataChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ private bool FilterHeader(string name, string value)
if (!CanSendBody() || FinalChunk)
{
return true;
}
}
}

return false;
}

private void WriteHeaders(DataWriter writer)
{
{
string writeHeader = OnWriteHeader();

// null indicates that a response has no headers
Expand Down Expand Up @@ -233,7 +233,7 @@ private byte[] GetBody()
}

private void WriteBody(DataWriter writer)
{
{
byte[] body = GetBody();

if (ChunkedEncoding)
Expand Down
Loading
0