Merge pull request #1 from netfoundry/remove-vpn-plugin
remove the win10 vpn plugin stuff
@@ -1,477 +0,0 @@
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace ZitiBackgroundTask
|
||||
{
|
||||
public enum Protocol
|
||||
{
|
||||
TCP = 6,
|
||||
UDP = 17,
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// This class encapsulates all the IP header fields and provides a mechanism
|
||||
/// to set and get the details of them through a parameterized contructor
|
||||
/// and public properties respectively.
|
||||
/// </summary>
|
||||
class IpHeader
|
||||
{
|
||||
// Eight bits for version and header length.
|
||||
public byte _versionAndHeaderLength;
|
||||
// Eight bits for differentiated services (TOS).
|
||||
public byte _differentiatedServices;
|
||||
// Sixteen bits for total length of the datagram (header + message).
|
||||
public ushort _totalLength;
|
||||
// Sixteen bits for identification.
|
||||
public ushort _identification;
|
||||
// Eight bits for flags and fragmentation offset.
|
||||
public ushort _flagsAndOffset;
|
||||
// Eight bits for TTL (Time To Live).
|
||||
public byte _ttl;
|
||||
// Eight bits for the underlying protocol.
|
||||
public byte _protocol;
|
||||
// Sixteen bits containing the checksum of the header
|
||||
// (checksum can be negative so taken as short).
|
||||
public short _checksum;
|
||||
// Thirty two bit source IP Address.
|
||||
internal uint _sourceIPAddress;
|
||||
// Thirty two bit destination IP Address.
|
||||
internal uint _destinationIPAddress;
|
||||
// Header length.
|
||||
public byte _headerLength;
|
||||
// Data carried by the datagram.
|
||||
public byte[] _ipData = default;//new byte[2 << 15];
|
||||
|
||||
public void WriteTo(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("_vionAndHeaderLength: " + _versionAndHeaderLength);
|
||||
writer.WriteLine("ByDifferentiatedServices: " + _differentiatedServices);
|
||||
writer.WriteLine("UsTotalLength: " + _totalLength);
|
||||
writer.WriteLine("UsIdentification: " + _identification);
|
||||
writer.WriteLine("usFlagsAndOffset: " + _flagsAndOffset);
|
||||
writer.WriteLine("_ttl: " + _ttl);
|
||||
writer.WriteLine("_protocol: " + _protocol);
|
||||
writer.WriteLine("SChecksum: " + _checksum);
|
||||
writer.WriteLine("UiSourceIPAddress: " + _sourceIPAddress);
|
||||
writer.WriteLine("UiDestinationIPAddress: " + _destinationIPAddress);
|
||||
writer.WriteLine("_headerLength: " + _headerLength);
|
||||
writer.WriteLine("As Hex: ");
|
||||
writer.WriteLine(BinaryVisualiser.FormatAsHex(Data, _totalLength));
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
public void WriteTo(System.IO.Stream stream)
|
||||
{/*
|
||||
write(stream, _versionAndHeaderLength);
|
||||
write(stream, _differentiatedServices);
|
||||
write(stream, _totalLength);
|
||||
write(stream, _identification);
|
||||
write(stream, _fagsAndOffset);
|
||||
write(stream, _ttl);
|
||||
write(stream, _protocol);
|
||||
write(stream, SChecksum);
|
||||
write(stream, _sourceIPAddress);
|
||||
write(stream, _destinationIPAddress);
|
||||
write(stream, _headerLength);
|
||||
writeIpData(stream);*/
|
||||
|
||||
System.IO.BinaryWriter writer = new BinaryWriter(stream);
|
||||
writer.Write(_versionAndHeaderLength);
|
||||
writer.Write(_differentiatedServices);
|
||||
writer.Write(_totalLength);
|
||||
writer.Write(_identification);
|
||||
writer.Write(_flagsAndOffset);
|
||||
writer.Write(_ttl);
|
||||
writer.Write(_protocol);
|
||||
writer.Write(_checksum);
|
||||
writer.Write(_sourceIPAddress);
|
||||
writer.Write(_destinationIPAddress);
|
||||
writer.Write(_headerLength);
|
||||
writer.Write(_ipData, 0, MessageLength);
|
||||
writer.Flush();
|
||||
}
|
||||
/*
|
||||
private void write(BinaryWriter target, byte toWrite)
|
||||
{
|
||||
target.WriteByte(toWrite);
|
||||
}
|
||||
private void write(BinaryWriter target, ushort toWrite)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(toWrite);
|
||||
target.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
private void write(BinaryWriter target, short toWrite)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(toWrite);
|
||||
target.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
private void write(BinaryWriter target, uint toWrite)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(toWrite);
|
||||
target.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
private void writeIpData(BinaryWriter target)
|
||||
{
|
||||
target.Write(ByIPData, 0, MessageLength);
|
||||
}*/
|
||||
|
||||
private byte[] _ipPacket = new byte[2 << 15]; //65535 is the biggest packet possible
|
||||
|
||||
private IpHeader()
|
||||
{
|
||||
//private use only
|
||||
}
|
||||
|
||||
public IpHeader([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray()]
|
||||
byte[] byBuffer, int nReceived) : this(byBuffer, 0, nReceived)
|
||||
{
|
||||
}
|
||||
|
||||
public IpHeader(System.IO.Stream stream)
|
||||
{
|
||||
BinaryReader binaryReader = new BinaryReader(stream);
|
||||
}
|
||||
|
||||
public IpHeader([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray()]
|
||||
byte[] byBuffer, int position, int nReceived) :
|
||||
this(new BinaryReader(new MemoryStream(byBuffer, position, nReceived - position)))
|
||||
{/*
|
||||
// Create MemoryStream out of the received bytes.
|
||||
MemoryStream memoryStream = new MemoryStream(byBuffer, position, nReceived - position);
|
||||
// Next we create a BinaryReader out of the MemoryStream.
|
||||
BinaryReader binaryReader = new BinaryReader(memoryStream);
|
||||
|
||||
return new IpHeader(binaryReader);*/
|
||||
}
|
||||
|
||||
public IpHeader(BinaryReader binaryReader)
|
||||
{
|
||||
this.initialize(binaryReader);
|
||||
}
|
||||
|
||||
private void initialize(BinaryReader binaryReader)
|
||||
{
|
||||
try
|
||||
{
|
||||
// The first eight bits of the IP header contain the version and
|
||||
// header length so we read them.
|
||||
_versionAndHeaderLength = binaryReader.ReadByte();
|
||||
// The next eight bits contain the Differentiated services.
|
||||
_differentiatedServices = binaryReader.ReadByte();
|
||||
// Next eight bits hold the total length of the datagram.
|
||||
_totalLength = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Next sixteen have the identification bytes.
|
||||
_identification = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Next sixteen bits contain the flags and fragmentation offset.
|
||||
_flagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Next eight bits have the TTL value.
|
||||
_ttl = binaryReader.ReadByte();
|
||||
// Next eight represnts the protocol encapsulated in the datagram.
|
||||
_protocol = binaryReader.ReadByte();
|
||||
// Next sixteen bits contain the checksum of the header.
|
||||
_checksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// Next thirty two bits have the source IP address.
|
||||
_sourceIPAddress = (uint)(binaryReader.ReadInt32());
|
||||
// Next thirty two hold the destination IP address.
|
||||
_destinationIPAddress = (uint)(binaryReader.ReadInt32());
|
||||
// Now we calculate the header length.
|
||||
_headerLength = _versionAndHeaderLength;
|
||||
// The last four bits of the version and header length field contain the
|
||||
// header length, we perform some simple binary airthmatic operations to
|
||||
// extract them.
|
||||
_headerLength <<= 4;
|
||||
_headerLength >>= 4;
|
||||
// Multiply by four to get the exact header length.
|
||||
_headerLength *= 4;
|
||||
// Copy the data carried by the data gram into another array so that
|
||||
// according to the protocol being carried in the IP datagram
|
||||
_ipData = binaryReader.ReadBytes(_totalLength - _headerLength);
|
||||
/* Array.Copy(byBuffer, _headerLength, _ipData, 0,
|
||||
_totalLength - _headerLength);*/
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
VPNHelper.LogLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] IpPacket
|
||||
{
|
||||
get { return _ipPacket; }
|
||||
}
|
||||
|
||||
public string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
// Calculate the IP version. The four bits of the IP header
|
||||
// contain the IP version.
|
||||
if ((_versionAndHeaderLength >> 4) == 4)
|
||||
{
|
||||
return "IP v4";
|
||||
}
|
||||
else if ((_versionAndHeaderLength >> 4) == 6)
|
||||
{
|
||||
return "IP v6";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string HeaderLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _headerLength.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public ushort MessageLength
|
||||
{
|
||||
get
|
||||
{
|
||||
// MessageLength = Total length of the datagram - Header length.
|
||||
return (ushort)(_totalLength - _headerLength);
|
||||
}
|
||||
}
|
||||
|
||||
public string DifferentiatedServices
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the differentiated services in hexadecimal format.
|
||||
return string.Format("0x{0:x2} ({1})", _differentiatedServices,
|
||||
_differentiatedServices);
|
||||
}
|
||||
}
|
||||
|
||||
public string Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
// The first three bits of the flags and fragmentation field
|
||||
// represent the flags (which indicate whether the data is
|
||||
// fragmented or not).
|
||||
int nFlags = _flagsAndOffset >> 13;
|
||||
if (nFlags == 2)
|
||||
{
|
||||
return "Don't fragment";
|
||||
}
|
||||
else if (nFlags == 1)
|
||||
{
|
||||
return "More fragments to come";
|
||||
}
|
||||
else
|
||||
{
|
||||
return nFlags.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FragmentationOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
// The last thirteen bits of the flags and fragmentation field
|
||||
// contain the fragmentation offset.
|
||||
int nOffset = _flagsAndOffset << 3;
|
||||
nOffset >>= 3;
|
||||
return nOffset.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string TTL
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ttl.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public Protocol ProtocolType
|
||||
{
|
||||
get
|
||||
{
|
||||
// The protocol field represents the protocol in the data portion
|
||||
// of the datagram.
|
||||
if (_protocol == 6) // A value of six represents the TCP protocol.
|
||||
{
|
||||
return Protocol.TCP;
|
||||
}
|
||||
else if (_protocol == 17) // Seventeen for UDP.
|
||||
{
|
||||
return Protocol.UDP;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Protocol.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Checksum
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the checksum in hexadecimal format.
|
||||
return string.Format("0x{0:x2}", _checksum);
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress SourceAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return new IPAddress(_sourceIPAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress DestinationAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return new IPAddress(_destinationIPAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public ushort TotalLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _totalLength;
|
||||
}
|
||||
}
|
||||
|
||||
public string Identification
|
||||
{
|
||||
get
|
||||
{
|
||||
return _identification.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ipData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string ToLoooongString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.Append("Checksum: ");
|
||||
b.Append(this.Checksum);
|
||||
//b.Append("Data: ");
|
||||
//b.Append(this.Data);
|
||||
b.Append(" DestinationAddress: ");
|
||||
b.Append(this.DestinationAddress);
|
||||
b.Append(" DifferentiatedServices: ");
|
||||
b.Append(this.DifferentiatedServices);
|
||||
b.Append(" Flags: ");
|
||||
b.Append(this.Flags);
|
||||
b.Append(" FragmentationOffset: ");
|
||||
b.Append(this.FragmentationOffset);
|
||||
b.Append(" HeaderLength: ");
|
||||
b.Append(this.HeaderLength);
|
||||
b.Append(" Identification: ");
|
||||
b.Append(this.Identification);
|
||||
b.Append(" MessageLength: ");
|
||||
b.Append(this.MessageLength);
|
||||
b.Append(" ProtocolType: ");
|
||||
b.Append(this.ProtocolType);
|
||||
b.Append(" ChecksumIP: ");
|
||||
b.Append(this.Checksum);
|
||||
b.Append(" SourceAddress: ");
|
||||
b.Append(this.SourceAddress);
|
||||
b.Append(" TTL: ");
|
||||
b.Append(this.TTL);
|
||||
b.Append(" TotalLength: ");
|
||||
b.Append(this.TotalLength);
|
||||
b.Append(" Version: ");
|
||||
b.Append(this.Version);
|
||||
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<IpHeader> FromStream(Stream stream)
|
||||
{
|
||||
IpHeader header = new IpHeader();
|
||||
|
||||
byte[] _ipPacket = header._ipPacket;
|
||||
int readResult = stream.Read(_ipPacket, 0, 4);
|
||||
while (readResult > 0)
|
||||
{
|
||||
byte[] pktBytes = new byte[2] { _ipPacket[2], _ipPacket[3] };
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(pktBytes);
|
||||
}
|
||||
|
||||
ushort utotalIpPacketLen = BitConverter.ToUInt16(pktBytes, 0);
|
||||
|
||||
int totalIpPacketLen = utotalIpPacketLen - 4;
|
||||
readResult = stream.Read(_ipPacket, 4, totalIpPacketLen);
|
||||
if (readResult > 0)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(_ipPacket))
|
||||
using (BinaryReader br = new BinaryReader(ms))
|
||||
{
|
||||
header.initialize(br);
|
||||
}
|
||||
}
|
||||
|
||||
yield return header;
|
||||
|
||||
header = new IpHeader();
|
||||
_ipPacket = header._ipPacket;
|
||||
readResult = stream.Read(_ipPacket, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class Hex
|
||||
{
|
||||
public static byte[] StringToByteArrayFastest(string hex)
|
||||
{
|
||||
if (hex.Length % 2 == 1)
|
||||
throw new Exception("The binary key cannot have an odd number of digits");
|
||||
|
||||
byte[] arr = new byte[hex.Length >> 1];
|
||||
|
||||
for (int i = 0; i < hex.Length >> 1; ++i)
|
||||
{
|
||||
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static int GetHexVal(char hex)
|
||||
{
|
||||
int val = (int)hex;
|
||||
//For uppercase A-F letters:
|
||||
return val - (val < 58 ? 48 : 55);
|
||||
//For lowercase a-f letters:
|
||||
//return val - (val < 58 ? 48 : 87);
|
||||
//Or the two combined, but a bit slower:
|
||||
//return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ZitiBackgroundTask")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ZitiBackgroundTask")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using Windows.Networking.Vpn;
|
||||
|
||||
namespace NetFoundry.VPN
|
||||
{
|
||||
public sealed class VPNHelper
|
||||
{
|
||||
|
||||
public static void ConnectReal()
|
||||
{
|
||||
|
||||
}
|
||||
public void ConnectDebug()
|
||||
{
|
||||
|
||||
}
|
||||
public static void LogLine(string text, VpnChannel channel)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("__X___: " + Environment.CurrentManagedThreadId + ":" +
|
||||
channel?.GetHashCode() + ":" + text);
|
||||
}
|
||||
|
||||
public static void LogLine(string text)
|
||||
{
|
||||
LogLine(text, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7393400B-5F2D-493C-BC39-AB3198A9749F}</ProjectGuid>
|
||||
<OutputType>winmdobj</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NetFoundry.VPN</RootNamespace>
|
||||
<AssemblyName>ZitiBackgroundTask</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\debugging\DebugTcpServer.cs" />
|
||||
<Compile Include="src\util\BinaryVisualiser.cs" />
|
||||
<Compile Include="src\ip\ICMP.cs" />
|
||||
<Compile Include="src\ip\IpHeader.cs" />
|
||||
<Compile Include="src\ip\Packet.cs" />
|
||||
<Compile Include="src\ip\Protocol.cs" />
|
||||
<Compile Include="src\ip\TCP.cs" />
|
||||
<Compile Include="src\ip\UDP.cs" />
|
||||
<Compile Include="src\util\LogHelper.cs" />
|
||||
<Compile Include="src\ziti\Controller.cs" />
|
||||
<Compile Include="src\ip\DnsHeader.cs" />
|
||||
<Compile Include="src\util\HexHelper.cs" />
|
||||
<Compile Include="src\ip\TcpHeader.cs" />
|
||||
<Compile Include="src\ip\UdpHeader.cs" />
|
||||
<Compile Include="src\VPNTask.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="src\VpnPluginContext.cs" />
|
||||
<Compile Include="src\VpnPluginState.cs" />
|
||||
<Compile Include="src\ZitiVPNPlugin.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.8</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Portable.BouncyCastle">
|
||||
<Version>1.8.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.ApplicationModel.Background;
|
||||
using Windows.Networking;
|
||||
using Windows.Networking.Sockets;
|
||||
using Windows.Networking.Vpn;
|
||||
using Windows.Storage.Streams;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using NetFoundry.VPN.Util;
|
||||
|
||||
|
||||
namespace NetFoundry.VPN
|
||||
{
|
||||
public sealed class VPNTask : IBackgroundTask
|
||||
{
|
||||
|
||||
internal static IVpnPlugIn ziti = null;
|
||||
private static object lockobj = new object();
|
||||
|
||||
public void Run(IBackgroundTaskInstance taskInstance)
|
||||
{
|
||||
var backgroundTaskDeferral = taskInstance.GetDeferral();
|
||||
try
|
||||
{
|
||||
taskInstance.Canceled += TaskInstance_Canceled;
|
||||
VpnChannel.ProcessEventAsync(GetPlugin(), taskInstance.TriggerDetails);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogLine("An exception occurred. " + e.Message);
|
||||
LogHelper.LogLine(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
backgroundTaskDeferral.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
|
||||
{
|
||||
LogHelper.LogLine("TaskInstance_Canceled_a_" + sender.ToString());
|
||||
LogHelper.LogLine("TaskInstance_Canceled_b_" + reason.ToString());
|
||||
|
||||
VpnChannel.ProcessEventAsync(GetPlugin(), sender.TriggerDetails);
|
||||
|
||||
LogHelper.LogLine("TaskInstance_Canceled - done. it has been triggered");
|
||||
}
|
||||
|
||||
public static IVpnPlugIn GetPlugin()
|
||||
{
|
||||
lock (lockobj) {
|
||||
if (ziti == null)
|
||||
{
|
||||
LogHelper.LogLine("singleton ziti plugin created");
|
||||
ziti = new ZitiVPNPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
return ziti;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Windows.Networking;
|
||||
using Windows.Networking.Sockets;
|
||||
using Windows.Networking.Vpn;
|
||||
|
||||
namespace NetFoundry.VPN
|
||||
{
|
||||
public sealed class VpnPluginContext
|
||||
{
|
||||
internal static VpnPluginContext CURRENT_CONTEXT = new VpnPluginContext();
|
||||
|
||||
public static VpnPluginContext GetActiveContext()
|
||||
{
|
||||
return CURRENT_CONTEXT;
|
||||
}
|
||||
public static void ResetActiveContext()
|
||||
{
|
||||
CURRENT_CONTEXT = new VpnPluginContext();
|
||||
}
|
||||
|
||||
internal IReadOnlyList<HostName> assignedClientIPv4list = null;
|
||||
internal IReadOnlyList<HostName> assignedClientIPv6list = null;
|
||||
internal VpnDomainNameAssignment vpnDomainNameAssignmenta = new VpnDomainNameAssignment();
|
||||
internal VpnRouteAssignment vpnRouteAssignmenta = new VpnRouteAssignment { ExcludeLocalSubnets = false };
|
||||
|
||||
internal const uint VPN_MTU = 0x4000;//0xFF00; //16 * 1024; //(2 << 15) - 1;
|
||||
|
||||
//internal const uint VPN_MAX_FRAME = 0xFF00; // 16* 1024; // * 32; //(2 << 15) - 1;
|
||||
internal const uint VPN_MAX_FRAME = 0x00F0; // 16* 1024; // * 32; //(2 << 15) - 1;
|
||||
|
||||
internal List<string> suffixes = new List<string>();
|
||||
internal List<string> fqdns = new List<string>();
|
||||
internal List<VpnRoute> routes = new List<VpnRoute>();
|
||||
internal List<string> ipsToCapture = new List<string>();
|
||||
|
||||
private HostName dns { get; set; }
|
||||
public HostName DnsServer
|
||||
{
|
||||
get
|
||||
{
|
||||
return dns;
|
||||
}
|
||||
set
|
||||
{
|
||||
dns = value;
|
||||
//dnsServers.Clear();
|
||||
//dnsServers.Add(dns);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSuffix(string suffix)
|
||||
{
|
||||
suffixes.Add(suffix);
|
||||
}
|
||||
public void addFQDN(string suffix)
|
||||
{
|
||||
fqdns.Add(suffix);
|
||||
}
|
||||
/* Maybe implement this some day
|
||||
public void AddCIDR(string ip)
|
||||
{
|
||||
string[] parts = ip.Split('/');
|
||||
if (parts.Length != 2)
|
||||
{
|
||||
throw new Exception("Invalid CIDR format supplied.");
|
||||
}
|
||||
routes.Add(new VpnRoute(new HostName(parts[0]), Byte.Parse(parts[1])));
|
||||
}*/
|
||||
|
||||
public void AddIP(string ip)
|
||||
{
|
||||
ipsToCapture.Add(ip);
|
||||
routes.Add(new VpnRoute(new HostName(ip), 32));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace NetFoundry.VPN
|
||||
{
|
||||
enum VpnPluginState
|
||||
{
|
||||
Disconnected,
|
||||
Connecting,
|
||||
Connected,
|
||||
Disconnecting
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Networking.Vpn;
|
||||
using Windows.Networking.Sockets;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.Networking;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel.Background;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using Buffer = System.Buffer;
|
||||
using NetFoundry.VPN.IP;
|
||||
using NetFoundry.VPN.Util;
|
||||
|
||||
namespace NetFoundry.VPN
|
||||
{
|
||||
public sealed class ZitiVPNPlugin : IVpnPlugIn
|
||||
{
|
||||
internal static int DESIRED_PORT = 8900;
|
||||
internal static string DESIRED_HOST = "192.168.1.114";
|
||||
StreamSocket tcpTransport = null;
|
||||
|
||||
VpnPluginContext vpnContext = VpnPluginContext.GetActiveContext();
|
||||
|
||||
public ZitiVPNPlugin()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
//start up a server that listens locally and just emits what it receives
|
||||
NetFoundry.VPN.Debugging.DebugTcpServer.Start();
|
||||
});
|
||||
}
|
||||
|
||||
public void Connect(VpnChannel channel)
|
||||
{
|
||||
try
|
||||
{
|
||||
HostName tcpHostname = new HostName(DESIRED_HOST);
|
||||
string tcpPort = DESIRED_PORT.ToString();
|
||||
tcpTransport = new StreamSocket();
|
||||
tcpTransport.ConnectAsync(tcpHostname, tcpPort).AsTask().Wait(); //this will succeed... proving you CAN connect...
|
||||
tcpTransport.CancelIOAsync().AsTask().Wait();
|
||||
tcpTransport.Dispose(); //close/dispose of the connection
|
||||
|
||||
tcpTransport = new StreamSocket();
|
||||
channel.AssociateTransport(tcpTransport, null);
|
||||
tcpTransport.ConnectAsync(tcpHostname, tcpPort).AsTask().Wait(); //fails with "no host is known". AssociateTransport is 'doing something'
|
||||
|
||||
string desiredIP = "169.254.100.101";
|
||||
|
||||
VpnDomainNameAssignment vpnDomainNameAssignment = new VpnDomainNameAssignment();
|
||||
|
||||
List<HostName> dnsServers = new List<HostName>();
|
||||
dnsServers.Add(vpnContext.DnsServer);
|
||||
|
||||
List<HostName> proxyServers = new List<HostName>();
|
||||
//proxyServers not used yet
|
||||
|
||||
foreach (string suf in vpnContext.suffixes)
|
||||
{
|
||||
addSuffix(vpnDomainNameAssignment, suf, dnsServers, proxyServers);
|
||||
}
|
||||
|
||||
foreach (string fqdn in vpnContext.fqdns)
|
||||
{
|
||||
addFQDN(vpnDomainNameAssignment, fqdn, dnsServers, proxyServers);
|
||||
}
|
||||
|
||||
var vpnRouteAssignment = new VpnRouteAssignment { ExcludeLocalSubnets = false };
|
||||
var inclusionRoutes = vpnRouteAssignment.Ipv4InclusionRoutes;
|
||||
foreach (VpnRoute route in vpnContext.routes)
|
||||
{
|
||||
LogHelper.LogLine("Adding an included route: " + route, channel);
|
||||
inclusionRoutes.Add(route);
|
||||
}
|
||||
|
||||
VpnInterfaceId vpnInterfaceId = null;
|
||||
|
||||
channel.StartWithMainTransport(
|
||||
new[] { new HostName(desiredIP) }, //this will only succeed if the ip is not 'localhost', 'hostname', '127.0.0.1' etc. must be 'off machine'
|
||||
vpnContext.assignedClientIPv6list,
|
||||
vpnInterfaceId,
|
||||
vpnRouteAssignment,
|
||||
vpnDomainNameAssignment,
|
||||
VpnPluginContext.VPN_MTU,
|
||||
VpnPluginContext.VPN_MAX_FRAME,
|
||||
false,
|
||||
tcpTransport);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSuffix(VpnDomainNameAssignment domainNameAssignment, string suffix, IEnumerable<HostName> dnsServers, IEnumerable<HostName> proxyServers)
|
||||
{
|
||||
var vdni1 = new VpnDomainNameInfo(suffix, VpnDomainNameType.Suffix, dnsServers, proxyServers);
|
||||
domainNameAssignment.DomainNameList.Add(vdni1);
|
||||
}
|
||||
public void addFQDN(VpnDomainNameAssignment domainNameAssignment, string suffix, IEnumerable<HostName> dnsServers, IEnumerable<HostName> proxyServers)
|
||||
{
|
||||
var vdni1 = new VpnDomainNameInfo(suffix, VpnDomainNameType.FullyQualified, dnsServers, proxyServers);
|
||||
domainNameAssignment.DomainNameList.Add(vdni1);
|
||||
}
|
||||
|
||||
public async void Disconnect(VpnChannel channel)
|
||||
{
|
||||
VpnPluginContext.ResetActiveContext();
|
||||
try
|
||||
{
|
||||
await tcpTransport?.CancelIOAsync();
|
||||
tcpTransport?.Dispose();
|
||||
}catch(Exception e)
|
||||
{
|
||||
LogHelper.LogLine("bad stuff: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetKeepAlivePayload(VpnChannel channel, out VpnPacketBuffer keepAlivePacket)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Encapsulate(VpnChannel channel, VpnPacketBufferList packets, VpnPacketBufferList encapulatedPackets)
|
||||
{
|
||||
while (packets?.Size > 0)
|
||||
{
|
||||
var packet = packets.RemoveAtBegin();
|
||||
VpnAppId packetAppId = packet.AppId;
|
||||
Windows.Storage.Streams.Buffer packetBuffer = packet.Buffer;
|
||||
DataReader fromBuffer = DataReader.FromBuffer(packetBuffer);
|
||||
uint fromBufferUnconsumedBufferLength = fromBuffer.UnconsumedBufferLength;
|
||||
byte[] bytes = new byte[fromBufferUnconsumedBufferLength];
|
||||
fromBuffer.ReadBytes(bytes);
|
||||
|
||||
int bytesRead = bytes.Count();
|
||||
|
||||
|
||||
IpHeader ipHeader = new IpHeader(bytes, bytesRead);
|
||||
string sourcePort = "0";
|
||||
string destPort = "0";
|
||||
|
||||
// Now according to the protocol being carried by the IP datagram we parse
|
||||
// the data field of the datagram.
|
||||
switch (ipHeader.Protocol)
|
||||
{
|
||||
case Protocol.TCP:
|
||||
TcpHeader tcpHeader = new TcpHeader(ipHeader.Data, ipHeader.MessageLength, ipHeader);
|
||||
|
||||
// If the port is equal to 53 then the underlying protocol is DNS.
|
||||
// Note: DNS can use either TCP or UDP hence checking is done twice.
|
||||
if (tcpHeader.DestinationPort == "53" || tcpHeader.SourcePort == "53")
|
||||
{
|
||||
//DnsHeader dnsHeader = new DnsHeader(ipHeader.Data, (int)ipHeader.MessageLength);
|
||||
//dnsHeader.PrintDebug();
|
||||
//LogLine(dnsHeader.ToString());
|
||||
}
|
||||
|
||||
sourcePort = tcpHeader.SourcePort;
|
||||
destPort = tcpHeader.DestinationPort;
|
||||
|
||||
|
||||
LogHelper.LogLine("ENCAP: " + tcpHeader.ToShortString());
|
||||
LogHelper.LogLine("ENCAP: " + tcpHeader.ToLoooongString());
|
||||
//LogLine("ENCAP: " + BinaryVisualiser.FormatAsHex(ipHeader.Data, ipHeader.MessageLength));
|
||||
LogHelper.LogLine("ENCAP: TOTAL BYTES:" + bytesRead + "\n" +
|
||||
BinaryVisualiser.FormatAsHex(bytes, bytesRead));
|
||||
|
||||
break;
|
||||
case Protocol.UDP:
|
||||
UdpHeader udpHeader = new UdpHeader(ipHeader.Data, (int)ipHeader.MessageLength);
|
||||
//TreeNode udpNode = MakeUDPTreeNode(udpHeader);
|
||||
//rootNode.Nodes.Add(udpNode);
|
||||
// If the port is equal to 53 then the underlying protocol is DNS.
|
||||
// Note: DNS can use either TCP or UDP, thats the reason
|
||||
// why the checking has been done twice.
|
||||
if (udpHeader.DestinationPort == "53" || udpHeader.SourcePort == "53")
|
||||
{
|
||||
//DnsHeader dnsHeader = new DnsHeader(ipHeader.Data, (int)ipHeader.MessageLength);
|
||||
//dnsHeader.PrintDebug();
|
||||
//LogLine(dnsHeader.ToString());
|
||||
}
|
||||
|
||||
sourcePort = udpHeader.SourcePort;
|
||||
destPort = udpHeader.DestinationPort;
|
||||
break;
|
||||
default:
|
||||
LogHelper.LogLine("THE PACKET WAS NOT TCP NOR UDP: Protocol = " + ipHeader.Protocol.GetName());
|
||||
break;
|
||||
}
|
||||
|
||||
string msg = null;
|
||||
|
||||
|
||||
if (vpnContext.ipsToCapture.Contains(ipHeader.DestinationAddress.ToString()))
|
||||
{
|
||||
msg = string.Format("SUCCESS!!!! type:{0}. from {1}:{3} to {2}:{4}", ipHeader.Protocol,
|
||||
ipHeader.SourceAddress, ipHeader.DestinationAddress, sourcePort, destPort);
|
||||
encapulatedPackets.Append(packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = string.Format("refusing to send {4} from {0}:{2} to {1}:{3}", ipHeader.SourceAddress,
|
||||
ipHeader.DestinationAddress, sourcePort, destPort, ipHeader.Protocol);
|
||||
|
||||
}
|
||||
|
||||
LogHelper.LogLine(msg, channel);
|
||||
}
|
||||
}
|
||||
|
||||
public void Decapsulate(VpnChannel channel, VpnPacketBuffer encapBuffer, VpnPacketBufferList decapsulatedPackets, VpnPacketBufferList controlPacketsToSend)
|
||||
{
|
||||
try
|
||||
{
|
||||
var buf = channel.GetVpnReceivePacketBuffer();
|
||||
|
||||
|
||||
if (encapBuffer.Buffer.Length > buf.Buffer.Capacity)
|
||||
{
|
||||
LogHelper.LogLine(
|
||||
"DROPPING PACKET!!! " + encapBuffer.Buffer.Length +
|
||||
" bytes. This is bigger than the buffer capacity of: " + encapBuffer.Buffer.Length, channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytes = encapBuffer.Buffer.ToArray();
|
||||
|
||||
LogHelper.LogLine("DECAP: OVERALL PAYLOAD:" + bytes.Length + "\n" +
|
||||
BinaryVisualiser.FormatAsHex(bytes, bytes.Length));
|
||||
|
||||
|
||||
int srcOffset = 0;
|
||||
foreach (IpHeader h in IpHeader.FromStream(new MemoryStream(bytes)))
|
||||
{
|
||||
if (buf == null)
|
||||
{
|
||||
buf = channel.GetVpnReceivePacketBuffer();
|
||||
}
|
||||
|
||||
TcpHeader tcpHeader = new TcpHeader(h.Data, h.MessageLength, h);
|
||||
|
||||
LogHelper.LogLine("DECAP: " + tcpHeader.ToShortString());
|
||||
LogHelper.LogLine("DECAP: " + tcpHeader.ToLoooongString());
|
||||
LogHelper.LogLine("DECAP: TOTAL BYTES:" + h.TotalLength + "\n" +
|
||||
BinaryVisualiser.FormatAsHex(h.IpPacket, h.TotalLength));
|
||||
|
||||
encapBuffer.Buffer.CopyTo((uint)srcOffset, buf.Buffer, 0, h.TotalLength);
|
||||
|
||||
buf.Buffer.Length = h.TotalLength;
|
||||
|
||||
decapsulatedPackets.Append(buf);
|
||||
buf = null;
|
||||
srcOffset += h.TotalLength;
|
||||
}
|
||||
|
||||
if (encapBuffer != null) return;
|
||||
|
||||
int remainingBytes = (int)encapBuffer.Buffer.Length;
|
||||
Span<byte> bytesAsSpan = new Span<byte>(bytes);
|
||||
System.IO.Stream stream = encapBuffer.Buffer.AsStream();
|
||||
|
||||
while (remainingBytes > 0)
|
||||
{
|
||||
IpHeader ipHeader = new IpHeader(stream);
|
||||
|
||||
LogHelper.LogLine(ipHeader.ToLoooongString());
|
||||
LogHelper.LogLine(BinaryVisualiser.FormatAsHex(bytes, ipHeader.TotalLength));
|
||||
|
||||
encapBuffer.Buffer.CopyTo((uint)srcOffset, buf.Buffer, 0, ipHeader.TotalLength);
|
||||
buf.Buffer.Length = ipHeader.TotalLength;
|
||||
decapsulatedPackets.Append(buf);
|
||||
|
||||
srcOffset += ipHeader.TotalLength;
|
||||
remainingBytes -= ipHeader.TotalLength;
|
||||
|
||||
buf = channel.GetVpnReceivePacketBuffer(); //get a new buffer...
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogLine("exception???? " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.IP
|
||||
{
|
||||
internal sealed class IpHeader
|
||||
{
|
||||
const ushort fragmentOffsetMask = 0b0001_1111_1111_1111; // 13 bits for fragment offset
|
||||
|
||||
// The entire IP packet
|
||||
private byte[] networkBytes;
|
||||
|
||||
public IpHeader(byte[] networkBytes)
|
||||
{
|
||||
this.networkBytes = networkBytes;
|
||||
|
||||
using (MemoryStream ms = new MemoryStream(networkBytes))
|
||||
using (BinaryReader br = new BinaryReader(ms))
|
||||
{
|
||||
initialize(br);
|
||||
}
|
||||
}
|
||||
|
||||
private void initialize(BinaryReader networkBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
// see https://tools.ietf.org/html/rfc791#page-11
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// |Version| IHL |Type of Service| Total Length |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Identification |Flags| Fragment Offset |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Time to Live | Protocol | Header Checksum |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Source Address |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Destination Address |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Options | Padding |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
//
|
||||
// Example Internet Datagram Header
|
||||
|
||||
// byte 1 - The first eight bits of the IP header contain the version and
|
||||
// header length. read the byte and then shift it to get the version
|
||||
// and header len
|
||||
byte versionAndHeaderLength = networkBytes.ReadByte();
|
||||
|
||||
VersionAsInt = versionAndHeaderLength >> 4; // shift the byte to get the bits we want
|
||||
|
||||
// Calculate the IP version. The four bits of the IP header
|
||||
// contain the IP version.
|
||||
if (VersionAsInt == 4)
|
||||
{
|
||||
Version = "IP v4";
|
||||
}
|
||||
else if (VersionAsInt == 6)
|
||||
{
|
||||
Version = "IP v6";
|
||||
}
|
||||
else
|
||||
{
|
||||
Version = "Unknown";
|
||||
}
|
||||
|
||||
// ip header length is contained in the last 4 bytes...
|
||||
//mask off the first 4 bytes and then per the spec the result
|
||||
//is a 4 bit field tells us the length of the IP header in 32 bit increments (4 bytes)
|
||||
HeaderLength = (versionAndHeaderLength & 0xF) * 4;
|
||||
|
||||
// byte 2
|
||||
TypeOfService = networkBytes.ReadByte();
|
||||
|
||||
// bytes 3, 4
|
||||
TotalLength = (ushort)IPAddress.NetworkToHostOrder(networkBytes.ReadInt16());
|
||||
|
||||
// bytes 5, 6 - identification bytes.
|
||||
Identification = (ushort)IPAddress.NetworkToHostOrder(networkBytes.ReadInt16());
|
||||
|
||||
// bytes 7, 8 - flags and fragment offset
|
||||
ushort flagsAndFragmentOffset = (ushort)IPAddress.NetworkToHostOrder(networkBytes.ReadInt16());
|
||||
Flags = (byte)(flagsAndFragmentOffset >> 13); // shift 13 bits to get the first 3
|
||||
FragmentOffset = (ushort)(flagsAndFragmentOffset & fragmentOffsetMask); //mask the lower 13 bits
|
||||
|
||||
// byte 9
|
||||
TimeToLive = networkBytes.ReadByte();
|
||||
|
||||
// byte 10
|
||||
Protocol = (Protocol)networkBytes.ReadByte();
|
||||
|
||||
// byte 11, 12
|
||||
HeaderChecksum = (ushort)IPAddress.NetworkToHostOrder(networkBytes.ReadInt16());
|
||||
|
||||
// bytes 13 - 16
|
||||
SourceAddress = new IPAddress(networkBytes.ReadBytes(4));
|
||||
|
||||
// bytes 17 - 20
|
||||
DestinationAddress = new IPAddress(networkBytes.ReadBytes(4));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ZitiBackgroundTask.ZitiVPNPlugin.LogLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// first 4 bits of the first byte. using int for convinience with other apis
|
||||
public int VersionAsInt { get; set; }
|
||||
public string Version { get; set; }
|
||||
|
||||
// last 4 bits of the first byte is the total HeaderLength length. using int for convinience with other apis
|
||||
public int HeaderLength { get; set; }
|
||||
|
||||
// 1 byte
|
||||
public byte TypeOfService { get; set; }
|
||||
|
||||
// 2 bytes
|
||||
public ushort TotalLength { get; set; }
|
||||
|
||||
// 2 bytes
|
||||
public ushort Identification { get; set; }
|
||||
|
||||
// 3 bits - byte closest thing
|
||||
public byte Flags { get; set; }
|
||||
|
||||
// 13 bits - ushort closest thing...
|
||||
public ushort FragmentOffset { get; set; }
|
||||
|
||||
// 1 byte
|
||||
public int TimeToLive { get; set; }
|
||||
|
||||
// 1 byte
|
||||
public Protocol Protocol { get; set; }
|
||||
|
||||
// 2 bytes
|
||||
public ushort HeaderChecksum { get; set; }
|
||||
|
||||
// 4 bytes
|
||||
public IPAddress SourceAddress { get; set; }
|
||||
|
||||
// 4 bytes
|
||||
public IPAddress DestinationAddress { get; set; }
|
||||
|
||||
// 4 bytes
|
||||
public byte[] Options { get; set; }
|
||||
|
||||
/*
|
||||
public ushort MessageLength
|
||||
{
|
||||
get
|
||||
{
|
||||
// MessageLength = Total length of the datagram - Header length.
|
||||
return (ushort)(_totalLength - _headerLength);
|
||||
}
|
||||
}
|
||||
|
||||
public string DifferentiatedServices
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the differentiated services in hexadecimal format.
|
||||
return string.Format("0x{0:x2} ({1})", _differentiatedServices, _differentiatedServices);
|
||||
}
|
||||
}
|
||||
|
||||
public string Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
// The first three bits of the flags and fragmentation field
|
||||
// represent the flags (which indicate whether the data is
|
||||
// fragmented or not).
|
||||
int nFlags = _flagsAndOffset >> 13;
|
||||
if (nFlags == 2)
|
||||
{
|
||||
return "Don't fragment";
|
||||
}
|
||||
else if (nFlags == 1)
|
||||
{
|
||||
return "More fragments to come";
|
||||
}
|
||||
else
|
||||
{
|
||||
return nFlags.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FragmentationOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
// The last thirteen bits of the flags and fragmentation field
|
||||
// contain the fragmentation offset.
|
||||
int nOffset = _flagsAndOffset << 3;
|
||||
nOffset >>= 3;
|
||||
return nOffset.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string TTL
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ttl.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public Protocol ProtocolType
|
||||
{
|
||||
get
|
||||
{
|
||||
// The protocol field represents the protocol in the data portion
|
||||
// of the datagram.
|
||||
if (_protocol == 6) // A value of six represents the TCP protocol.
|
||||
{
|
||||
return Protocol.TCP;
|
||||
}
|
||||
else if (_protocol == 17) // Seventeen for UDP.
|
||||
{
|
||||
return Protocol.UDP;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Protocol.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Checksum
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the checksum in hexadecimal format.
|
||||
return string.Format("0x{0:x2}", _checksum);
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress SourceAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return new IPAddress(_sourceIPAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress DestinationAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return new IPAddress(_destinationIPAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public string Identification
|
||||
{
|
||||
get
|
||||
{
|
||||
return _identification.ToString();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.IP
|
||||
{
|
||||
internal class Packet
|
||||
{
|
||||
internal IpHeader ipHeader;
|
||||
internal byte[] bytes;
|
||||
|
||||
internal Packet()
|
||||
{
|
||||
//for the subclasses...
|
||||
}
|
||||
|
||||
public Packet([ReadOnlyArray]byte[] networkBytes)
|
||||
{
|
||||
ipHeader = new IpHeader(networkBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace ZitiBackgroundTask.Ziti
|
||||
{
|
||||
public sealed class IpPacket
|
||||
{
|
||||
private NetFoundry.IP.Packet ipPacket;
|
||||
|
||||
public IpPacket([ReadOnlyArray]byte[] networkBytes)
|
||||
{
|
||||
ipPacket = new NetFoundry.IP.Packet(networkBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.IP
|
||||
{
|
||||
internal enum Protocol
|
||||
{
|
||||
//see https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers
|
||||
Unknown = -1,
|
||||
HOPOPT = 0, //IPv6 Hop-by-Hop Option
|
||||
ICMP = 1, //Internet Control Message Protocol
|
||||
IGMP = 2, //Internet Group Management Protocol
|
||||
GGP = 3, //Gateway-to-Gateway Protocol
|
||||
IP_in_IP = 4, //IP in IP (encapsulation)
|
||||
ST = 5, //Internet Stream Protocol
|
||||
TCP = 6, //Transmission Control Protocol
|
||||
CBT = 7, //Core-based trees
|
||||
EGP = 8, //Exterior Gateway Protocol
|
||||
IGP = 9, //Interior Gateway Protocol (any private interior gateway (used by Cisco for their IGRP))
|
||||
BBN_RCC_MON = 10, //BBN RCC Monitoring
|
||||
NVP_II = 11, //Network Voice Protocol
|
||||
PUP = 12, //Xerox PUP
|
||||
ARGUS = 13, //ARGUS
|
||||
EMCON = 14, //EMCON
|
||||
XNET = 15, //Cross Net Debugger
|
||||
CHAOS = 16, //Chaos
|
||||
UDP = 17, //User Datagram Protocol
|
||||
MUX = 18, //Multiplexing
|
||||
DCN_MEAS = 19, //DCN Measurement Subsystems
|
||||
HMP = 20, //Host Monitoring Protocol
|
||||
PRM = 21, //Packet Radio Measurement
|
||||
XNS_IDP = 22, //XEROX NS IDP
|
||||
TRUNK_1 = 23, //Trunk-1
|
||||
TRUNK_2 = 24, //Trunk-2
|
||||
LEAF_1 = 25, //Leaf-1
|
||||
LEAF_2 = 26, //Leaf-2
|
||||
RDP = 27, //Reliable Data Protocol
|
||||
IRTP = 28, //Internet Reliable Transaction Protocol
|
||||
ISO_TP4 = 29, //ISO Transport Protocol Class 4
|
||||
NETBLT = 30, //Bulk Data Transfer Protocol
|
||||
MFE_NSP = 31, //MFE Network Services Protocol
|
||||
MERIT_INP = 32, //MERIT Internodal Protocol
|
||||
DCCP = 33, //Datagram Congestion Control Protocol
|
||||
THIRD_PARTY_CONNECT = 34, //Third Party Connect Protocol
|
||||
IDPR = 35, //Inter-Domain Policy Routing Protocol
|
||||
XTP = 36, //Xpress Transport Protocol
|
||||
DDP = 37, //Datagram Delivery Protocol
|
||||
IDPR_CMTP = 38, //IDPR Control Message Transport Protocol
|
||||
TPplusplus = 39, //TP++ Transport Protocol
|
||||
IL = 40, //IL Transport Protocol
|
||||
IPv6 = 41, //IPv6 Encapsulation
|
||||
SDRP = 42, //Source Demand Routing Protocol
|
||||
IPv6_Route = 43, //Routing Header for IPv6
|
||||
IPv6_Frag = 44, //Fragment Header for IPv6
|
||||
IDRP = 45, //Inter-Domain Routing Protocol
|
||||
RSVP = 46, //Resource Reservation Protocol
|
||||
GREs = 47, //Generic Routing Encapsulation
|
||||
DSR = 48, //Dynamic Source Routing Protocol
|
||||
BNA = 49, //Burroughs Network Architecture
|
||||
ESP = 50, //Encapsulating Security Payload
|
||||
AH = 51, //Authentication Header
|
||||
I_NLSP = 52, //Integrated Net Layer Security Protocol
|
||||
SwIPe = 53, //SwIPe
|
||||
NARP = 54, //NBMA Address Resolution Protocol
|
||||
MOBILE = 55, //IP Mobility (Min Encap)
|
||||
TLSP = 56, //Transport Layer Security Protocol (using Kryptonet key management)
|
||||
SKIP = 57, //Simple Key-Management for Internet Protocol
|
||||
IPv6_ICMP = 58, //ICMP for IPv6
|
||||
IPv6_NoNxt = 59, //No Next Header for IPv6
|
||||
IPv6_Opts = 60, //Destination Options for IPv6
|
||||
HOST_INTERNAL_PROTOCOL = 61, //Any host internal protocol
|
||||
CFTP = 62, //CFTP
|
||||
LOCAL_NETWORK = 63, //Any local network
|
||||
SAT_EXPAK = 64, //SATNET and Backroom EXPAK
|
||||
KRYPTOLAN = 65, //Kryptolan
|
||||
RVD = 66, //MIT Remote Virtual Disk Protocol
|
||||
IPPC = 67, //Internet Pluribus Packet Core
|
||||
DISTRIBUTED_FS = 68, //Any distributed file system
|
||||
SAT_MON = 69, //SATNET Monitoring
|
||||
VISA = 70, //VISA Protocol
|
||||
IPCU = 71, //Internet Packet Core Utility
|
||||
CPNX = 72, //Computer Protocol Network Executive
|
||||
CPHB = 73, //Computer Protocol Heart Beat
|
||||
WSN = 74, //Wang Span Network
|
||||
PVP = 75, //Packet Video Protocol
|
||||
BR_SAT_MON = 76, //Backroom SATNET Monitoring
|
||||
SUN_ND = 77, //SUN ND PROTOCOL-Temporary
|
||||
WB_MON = 78, //WIDEBAND Monitoring
|
||||
WB_EXPAK = 79, //WIDEBAND EXPAK
|
||||
ISO_IP = 80, //International Organization for Standardization Internet Protocol
|
||||
VMTP = 81, //Versatile Message Transaction Protocol
|
||||
SECURE_VMTP = 82, //Secure Versatile Message Transaction Protocol
|
||||
VINES = 83, //VINES
|
||||
TTP = 84, //TTP
|
||||
IPTM = 84, //Internet Protocol Traffic Manager
|
||||
NSFNET_IGP = 85, //NSFNET-IGP
|
||||
DGP = 86, //Dissimilar Gateway Protocol
|
||||
TCF = 87, //TCF
|
||||
EIGRP = 88, //EIGRP
|
||||
OSPF = 89, //Open Shortest Path First
|
||||
Sprite_RPC = 90, //Sprite RPC Protocol
|
||||
LARP = 91, //Locus Address Resolution Protocol
|
||||
MTP = 92, //Multicast Transport Protocol
|
||||
AX_25 = 93, //AX.25
|
||||
OS = 94, //KA9Q NOS compatible IP over IP tunneling
|
||||
MICP = 95, //Mobile Internetworking Control Protocol
|
||||
SCC_SP = 96, //Semaphore Communications Sec. Pro
|
||||
ETHERIP = 97, //Ethernet-within-IP Encapsulation
|
||||
ENCAP = 98, //Encapsulation Header
|
||||
PRIVATE_ENCRYPTION = 99, //Any private encryption scheme
|
||||
GMTP = 100, //GMTP
|
||||
IFMP = 101, //Ipsilon Flow Management Protocol
|
||||
PNNI = 102, //PNNI over IP
|
||||
PIM = 103, //Protocol Independent Multicast
|
||||
ARIS = 104, //IBM's ARIS (Aggregate Route IP Switching) Protocol
|
||||
SCPS = 105, //SCPS (Space Communications Protocol Standards)
|
||||
QNX = 106, //QNX
|
||||
ACTIVE_NETWORKS = 107, //Active Networks
|
||||
IPComp = 108, //IP Payload Compression Protocol
|
||||
SNP = 109, //Sitara Networks Protocol
|
||||
Compaq_Peer = 110, //Compaq Peer Protocol
|
||||
IPX_in_IP = 111, //IPX in IP
|
||||
VRRP = 112, //Virtual Router Redundancy Protocol, Common Address Redundancy Protocol (not IANA assigned)
|
||||
PGM = 113, //PGM Reliable Transport Protocol
|
||||
ANY_HOP = 114, //Any 0-hop protocol
|
||||
L2TP = 115, //Layer Two Tunneling Protocol Version 3
|
||||
DDX = 116, //D-II Data Exchange (DDX)
|
||||
IATP = 117, //Interactive Agent Transfer Protocol
|
||||
STP = 118, //Schedule Transfer Protocol
|
||||
SRP = 119, //SpectraLink Radio Protocol
|
||||
UTI = 120, //Universal Transport Interface Protocol
|
||||
SMP = 121, //Simple Message Protocol
|
||||
SM = 122, //Simple Multicast Protocol
|
||||
PTP = 123, //Performance Transparency Protocol
|
||||
IS_IS_over_IPv4 = 124, //Intermediate System to Intermediate System (IS-IS) Protocol over IPv4
|
||||
FIRE = 125, //Flexible Intra-AS Routing Environment
|
||||
CRTP = 126, //Combat Radio Transport Protocol
|
||||
CRUDP = 127, //Combat Radio User Datagram
|
||||
SSCOPMCE = 128, //Service-Specific Connection-Oriented Protocol in a Multilink and Connectionless Environment
|
||||
IPLT = 129, //
|
||||
SPS = 130, //Secure Packet Shield
|
||||
PIPE = 131, //Private IP Encapsulation within IP
|
||||
SCTP = 132, //Stream Control Transmission Protocol
|
||||
FC = 133, //Fibre Channel
|
||||
RSVP_E2E_IGNORE = 134, //Reservation Protocol (RSVP) End-to-End Ignore
|
||||
Mobility_Header = 135, //Mobility Extension Header for IPv6
|
||||
UDPLite = 136, //Lightweight User Datagram Protocol
|
||||
MPLS_in_IP = 137, //Multiprotocol Label Switching Encapsulated in IP
|
||||
manet = 138, //MANET Protocols
|
||||
HIP = 139, //Host Identity Protocol
|
||||
Shim6 = 140, //Site Multihoming by IPv6 Intermediation
|
||||
WESP = 141, //Wrapped Encapsulating Security Payload
|
||||
ROHC = 142, //Robust Header Compression
|
||||
|
||||
//Unassigned = 143 - 252, //
|
||||
//Use for experimentation and testing = 253 - 254, //
|
||||
Reserved = 255, //
|
||||
};
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.IP
|
||||
{
|
||||
internal sealed class Tcp : Packet
|
||||
{
|
||||
private Tcp()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.IP
|
||||
{
|
||||
internal sealed class Udp : Packet
|
||||
{
|
||||
|
||||
private Udp()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// This code is adapted from a sample found at the URL
|
||||
// "http://blogs.msdn.com/b/jmanning/archive/2004/12/19/325699.aspx"
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace NetFoundry.VPN.Debugging
|
||||
{
|
||||
public sealed class DebugTcpServer
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
DebugTcpServer.Start();
|
||||
Console.WriteLine("listening. press any key to quit");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static bool started = false;
|
||||
public static void Start()
|
||||
{
|
||||
started = false;
|
||||
if (started) return;
|
||||
started = true;
|
||||
|
||||
Console.WriteLine("Starting echo server...");
|
||||
|
||||
TcpListener listener = new TcpListener(IPAddress.Loopback, ZitiVPNPlugin.DESIRED_PORT);
|
||||
listener.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
TcpClient client = listener.AcceptTcpClient();
|
||||
System.Threading.Tasks.Task.Run(() =>
|
||||
{
|
||||
NetworkStream stream = client.GetStream();
|
||||
StreamWriter writer = new StreamWriter(stream, Encoding.ASCII) { AutoFlush = true };
|
||||
StreamReader reader = new StreamReader(stream, Encoding.ASCII);
|
||||
|
||||
try
|
||||
{
|
||||
string inputLine = "";
|
||||
while (inputLine != null)
|
||||
{
|
||||
inputLine = reader.ReadLine();
|
||||
writer.WriteLine("Echoing string: " + inputLine);
|
||||
Console.WriteLine("Echoing string: " + inputLine);
|
||||
}
|
||||
}
|
||||
catch { /* don't really care at this point */}
|
||||
Console.WriteLine("Server saw disconnect from client.");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
/// <summary>
|
||||
/// This class encapsulates all the DNS header fields and provides a mechanism
|
||||
/// to set and get the details of them through a parameterized contructor
|
||||
/// and public properties respectively.
|
||||
/// </summary>
|
||||
internal sealed class DnsHeader
|
||||
{
|
||||
public void PrintDebug()
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("DNS");
|
||||
System.Diagnostics.Debug.WriteLine(" Identification: " + Identification);
|
||||
System.Diagnostics.Debug.WriteLine(" Flags: " + Flags);
|
||||
System.Diagnostics.Debug.WriteLine(" Questions: " + TotalQuestions);
|
||||
System.Diagnostics.Debug.WriteLine(" Answer RRs: " + TotalAnswerRRs);
|
||||
System.Diagnostics.Debug.WriteLine(" Authority RRs: " + TotalAuthorityRRs);
|
||||
System.Diagnostics.Debug.WriteLine(" Additional RRs: " + TotalAdditionalRRs);
|
||||
}
|
||||
|
||||
// Sixteen bits for identification.
|
||||
private ushort UsIdentification;
|
||||
// Sixteen bits for DNS flags.
|
||||
private ushort UsFlags;
|
||||
// Sixteen bits indicating the number of entries in the questions list.
|
||||
private ushort UsTotalQuestions;
|
||||
// Sixteen bits indicating the number of entries in the answer
|
||||
// resource record list.
|
||||
private ushort UsTotalAnswerRRs;
|
||||
// Sixteen bits indicating the number of entries in the authority
|
||||
// resource record list.
|
||||
private ushort UsTotalAuthorityRRs;
|
||||
// Sixteen bits indicating the number of entries in the additional
|
||||
// resource record list.
|
||||
private ushort UsTotalAdditionalRRs;
|
||||
|
||||
public DnsHeader([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray()] byte[]byBuffer, int nReceived)
|
||||
{
|
||||
|
||||
// Create MemoryStream out of the received bytes.
|
||||
MemoryStream memoryStream = new MemoryStream(byBuffer, 0, nReceived);
|
||||
// Next we create a BinaryReader out of the MemoryStream.
|
||||
BinaryReader binaryReader = new BinaryReader(memoryStream);
|
||||
// First sixteen bits are for identification.
|
||||
UsIdentification = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Next sixteen contain the flags.
|
||||
UsFlags = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// Read the total numbers of questions in the quesion list.
|
||||
UsTotalQuestions = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Read the total number of answers in the answer list.
|
||||
UsTotalAnswerRRs = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Read the total number of entries in the authority list.
|
||||
UsTotalAuthorityRRs = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// Total number of entries in the additional resource record list.
|
||||
UsTotalAdditionalRRs = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
}
|
||||
|
||||
public string Identification
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("0x{0:x2}", UsIdentification);
|
||||
}
|
||||
}
|
||||
|
||||
public string Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("0x{0:x2}", UsFlags);
|
||||
}
|
||||
}
|
||||
|
||||
public string TotalQuestions
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsTotalQuestions.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string TotalAnswerRRs
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsTotalAnswerRRs.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string TotalAuthorityRRs
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsTotalAuthorityRRs.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string TotalAdditionalRRs
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsTotalAdditionalRRs.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
internal sealed class Icmp : Packet
|
||||
{
|
||||
|
||||
private Icmp() { }
|
||||
}
|
||||
}
|
||||
@@ -1,360 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
|
||||
using NetFoundry.VPN.Util;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
internal sealed class IpHeader
|
||||
{
|
||||
const ushort fragmentOffsetMask = 0b0001_1111_1111_1111; // 13 bits for fragment offset
|
||||
|
||||
// The entire IP packet
|
||||
private byte[] networkBytes;
|
||||
|
||||
public IpHeader(byte[] networkBytes) : this(networkBytes, 0, networkBytes.Length)
|
||||
{
|
||||
}
|
||||
|
||||
private IpHeader()
|
||||
{
|
||||
//private use only
|
||||
}
|
||||
|
||||
public IpHeader([ReadOnlyArray()] byte[] networkBytes, int nReceived) : this(networkBytes, 0, nReceived)
|
||||
{
|
||||
}
|
||||
|
||||
public IpHeader(System.IO.Stream stream)
|
||||
{
|
||||
BinaryReader binaryReader = new BinaryReader(stream);
|
||||
}
|
||||
|
||||
public IpHeader([ReadOnlyArray()] byte[] networkBytes, int position, int nReceived) /*: this(new BinaryReader(new MemoryStream(networkBytes, position, nReceived - position)))
|
||||
*/
|
||||
{
|
||||
this.networkBytes = networkBytes;
|
||||
|
||||
using (MemoryStream ms = new MemoryStream(networkBytes))
|
||||
using (BinaryReader br = new BinaryReader(ms))
|
||||
{
|
||||
initialize(br);
|
||||
}
|
||||
}
|
||||
|
||||
private IpHeader(BinaryReader binaryReader)
|
||||
{
|
||||
this.initialize(binaryReader);
|
||||
}
|
||||
|
||||
private void initialize(BinaryReader bytesAsReader)
|
||||
{
|
||||
try
|
||||
{
|
||||
// see https://tools.ietf.org/html/rfc791#page-11
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// |Version| IHL |Type of Service| Total Length |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Identification |Flags| Fragment Offset |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Time to Live | Protocol | Header Checksum |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Source Address |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Destination Address |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Options | Padding |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
//
|
||||
// Example Internet Datagram Header
|
||||
|
||||
// byte 1 - The first eight bits of the IP header contain the version and
|
||||
// header length. read the byte and then shift it to get the version
|
||||
// and header len
|
||||
byte versionAndHeaderLength = bytesAsReader.ReadByte();
|
||||
|
||||
VersionAsInt = versionAndHeaderLength >> 4; // shift the byte to get the bits we want
|
||||
|
||||
// Calculate the IP version. The four bits of the IP header
|
||||
// contain the IP version.
|
||||
if (VersionAsInt == 4)
|
||||
{
|
||||
Version = "IP v4";
|
||||
}
|
||||
else if (VersionAsInt == 6)
|
||||
{
|
||||
Version = "IP v6";
|
||||
}
|
||||
else
|
||||
{
|
||||
Version = "Unknown";
|
||||
}
|
||||
|
||||
// ip header length is contained in the last 4 bytes...
|
||||
//mask off the first 4 bytes and then per the spec the result
|
||||
//is a 4 bit field tells us the length of the IP header in 32 bit increments (4 bytes)
|
||||
HeaderLength = (versionAndHeaderLength & 0xF) * 4;
|
||||
|
||||
// byte 2
|
||||
TypeOfService = bytesAsReader.ReadByte();
|
||||
|
||||
// bytes 3, 4
|
||||
TotalLength = (ushort)IPAddress.NetworkToHostOrder(bytesAsReader.ReadInt16());
|
||||
|
||||
// bytes 5, 6 - identification bytes.
|
||||
Identification = (ushort)IPAddress.NetworkToHostOrder(bytesAsReader.ReadInt16());
|
||||
|
||||
// bytes 7, 8 - flags and fragment offset
|
||||
ushort flagsAndFragmentOffset = (ushort)IPAddress.NetworkToHostOrder(bytesAsReader.ReadInt16());
|
||||
Flags = (byte)(flagsAndFragmentOffset >> 13); // shift 13 bits to get the first 3
|
||||
FragmentOffset = (ushort)(flagsAndFragmentOffset & fragmentOffsetMask); //mask the lower 13 bits
|
||||
|
||||
// byte 9
|
||||
TimeToLive = bytesAsReader.ReadByte();
|
||||
|
||||
// byte 10
|
||||
Protocol = (Protocol)bytesAsReader.ReadByte();
|
||||
|
||||
// byte 11, 12
|
||||
HeaderChecksum = (ushort)IPAddress.NetworkToHostOrder(bytesAsReader.ReadInt16());
|
||||
|
||||
// bytes 13 - 16
|
||||
SourceAddress = new IPAddress(bytesAsReader.ReadBytes(4));
|
||||
|
||||
// bytes 17 - 20
|
||||
DestinationAddress = new IPAddress(bytesAsReader.ReadBytes(4));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.LogLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// first 4 bits of the first byte. using int for convinience with other apis
|
||||
public int VersionAsInt { get; set; }
|
||||
/*int _version;
|
||||
public int Version
|
||||
{
|
||||
get { return _version; }
|
||||
set { _version = value; }
|
||||
}*/
|
||||
public string Version { get; set; }
|
||||
|
||||
/*
|
||||
public byte _headerLength;
|
||||
// last 4 bits of the first byte is the total HeaderLength length. using int for convinience with other apis
|
||||
public byte HeaderLength
|
||||
{
|
||||
get { return _headerLength; }
|
||||
set { _headerLength = value; }
|
||||
}*/
|
||||
public int HeaderLength { get; set; }
|
||||
|
||||
// 1 byte
|
||||
public byte TypeOfService { get; set; }
|
||||
|
||||
// 2 bytes
|
||||
public ushort TotalLength { get; set; }
|
||||
|
||||
// 2 bytes
|
||||
public ushort Identification { get; set; }
|
||||
|
||||
// 3 bits - byte closest thing
|
||||
public byte Flags { get; set; }
|
||||
|
||||
// 13 bits - ushort closest thing...
|
||||
public ushort FragmentOffset { get; set; }
|
||||
|
||||
// 1 byte
|
||||
public int TimeToLive { get; set; }
|
||||
|
||||
// 1 byte
|
||||
public Protocol Protocol { get; set; }
|
||||
|
||||
// 2 bytes
|
||||
public ushort HeaderChecksum { get; set; }
|
||||
|
||||
// 4 bytes
|
||||
public IPAddress SourceAddress { get; set; }
|
||||
|
||||
// 4 bytes
|
||||
public IPAddress DestinationAddress { get; set; }
|
||||
|
||||
// 4 bytes
|
||||
public byte[] Options { get; set; }
|
||||
|
||||
public ushort MessageLength
|
||||
{
|
||||
get
|
||||
{
|
||||
// MessageLength = Total length of the datagram - Header length.
|
||||
return (ushort)(TotalLength - HeaderLength);
|
||||
}
|
||||
}
|
||||
|
||||
public string DifferentiatedServices
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the differentiated services in hexadecimal format.
|
||||
return string.Format("0x{0:x2} ({1})", DifferentiatedServices, DifferentiatedServices);
|
||||
}
|
||||
}
|
||||
|
||||
/*public string Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
// The first three bits of the flags and fragmentation field
|
||||
// represent the flags (which indicate whether the data is
|
||||
// fragmented or not).
|
||||
int nFlags = _flagsAndOffset >> 13;
|
||||
if (nFlags == 2)
|
||||
{
|
||||
return "Don't fragment";
|
||||
}
|
||||
else if (nFlags == 1)
|
||||
{
|
||||
return "More fragments to come";
|
||||
}
|
||||
else
|
||||
{
|
||||
return nFlags.ToString();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public string FragmentationOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
// The last thirteen bits of the flags and fragmentation field
|
||||
// contain the fragmentation offset.
|
||||
int nOffset = Flags << 3;
|
||||
nOffset >>= 3;
|
||||
return nOffset.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string TTL
|
||||
{
|
||||
get
|
||||
{
|
||||
return TTL.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string Checksum
|
||||
{
|
||||
get
|
||||
{
|
||||
// Returns the checksum in hexadecimal format.
|
||||
return string.Format("0x{0:x2}", Checksum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return networkBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string ToLoooongString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.Append("Checksum: ");
|
||||
b.Append(this.Checksum);
|
||||
//b.Append("Data: ");
|
||||
//b.Append(this.Data);
|
||||
b.Append(" DestinationAddress: ");
|
||||
b.Append(this.DestinationAddress);
|
||||
b.Append(" DifferentiatedServices: ");
|
||||
b.Append(this.DifferentiatedServices);
|
||||
b.Append(" Flags: ");
|
||||
b.Append(this.Flags);
|
||||
b.Append(" FragmentationOffset: ");
|
||||
b.Append(this.FragmentationOffset);
|
||||
b.Append(" HeaderLength: ");
|
||||
b.Append(this.HeaderLength);
|
||||
b.Append(" Identification: ");
|
||||
b.Append(this.Identification);
|
||||
b.Append(" MessageLength: ");
|
||||
b.Append(this.MessageLength);
|
||||
b.Append(" ProtocolType: ");
|
||||
b.Append(this.Protocol.GetName());
|
||||
b.Append(" ChecksumIP: ");
|
||||
b.Append(this.Checksum);
|
||||
b.Append(" SourceAddress: ");
|
||||
b.Append(this.SourceAddress);
|
||||
b.Append(" TTL: ");
|
||||
b.Append(this.TTL);
|
||||
b.Append(" TotalLength: ");
|
||||
b.Append(this.TotalLength);
|
||||
b.Append(" Version: ");
|
||||
b.Append(this.Version);
|
||||
|
||||
return b.ToString();
|
||||
}
|
||||
public byte[] IpPacket
|
||||
{
|
||||
get { return networkBytes; }
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<IpHeader> FromStream(Stream stream)
|
||||
{
|
||||
IpHeader header = new IpHeader();
|
||||
|
||||
byte[] _ipPacket = header.networkBytes;
|
||||
int readResult = stream.Read(_ipPacket, 0, 4);
|
||||
while (readResult > 0)
|
||||
{
|
||||
byte[] pktBytes = new byte[2] { _ipPacket[2], _ipPacket[3] };
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(pktBytes);
|
||||
}
|
||||
|
||||
ushort utotalIpPacketLen = BitConverter.ToUInt16(pktBytes, 0);
|
||||
|
||||
int totalIpPacketLen = utotalIpPacketLen - 4;
|
||||
readResult = stream.Read(_ipPacket, 4, totalIpPacketLen);
|
||||
if (readResult > 0)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(_ipPacket))
|
||||
using (BinaryReader br = new BinaryReader(ms))
|
||||
{
|
||||
header.initialize(br);
|
||||
}
|
||||
}
|
||||
|
||||
yield return header;
|
||||
|
||||
header = new IpHeader();
|
||||
_ipPacket = header.networkBytes;
|
||||
readResult = stream.Read(_ipPacket, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteTo(System.IO.Stream stream)
|
||||
{
|
||||
stream.Write(networkBytes, 0, TotalLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
internal class Packet
|
||||
{
|
||||
internal IpHeader ipHeader;
|
||||
|
||||
internal Packet()
|
||||
{
|
||||
//for the subclasses...
|
||||
}
|
||||
|
||||
public Packet([ReadOnlyArray]byte[] networkBytes)
|
||||
{
|
||||
ipHeader = new IpHeader(networkBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
internal static class ProtocolExtensionMethod
|
||||
{
|
||||
internal static string GetName(this Protocol theEnum)
|
||||
{
|
||||
return Enum.GetName(typeof(Protocol), theEnum);
|
||||
}
|
||||
}
|
||||
|
||||
internal enum Protocol
|
||||
{
|
||||
//see https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers
|
||||
Unknown = -1,
|
||||
HOPOPT = 0, //IPv6 Hop-by-Hop Option
|
||||
ICMP = 1, //Internet Control Message Protocol
|
||||
IGMP = 2, //Internet Group Management Protocol
|
||||
GGP = 3, //Gateway-to-Gateway Protocol
|
||||
IP_in_IP = 4, //IP in IP (encapsulation)
|
||||
ST = 5, //Internet Stream Protocol
|
||||
TCP = 6, //Transmission Control Protocol
|
||||
CBT = 7, //Core-based trees
|
||||
EGP = 8, //Exterior Gateway Protocol
|
||||
IGP = 9, //Interior Gateway Protocol (any private interior gateway (used by Cisco for their IGRP))
|
||||
BBN_RCC_MON = 10, //BBN RCC Monitoring
|
||||
NVP_II = 11, //Network Voice Protocol
|
||||
PUP = 12, //Xerox PUP
|
||||
ARGUS = 13, //ARGUS
|
||||
EMCON = 14, //EMCON
|
||||
XNET = 15, //Cross Net Debugger
|
||||
CHAOS = 16, //Chaos
|
||||
UDP = 17, //User Datagram Protocol
|
||||
MUX = 18, //Multiplexing
|
||||
DCN_MEAS = 19, //DCN Measurement Subsystems
|
||||
HMP = 20, //Host Monitoring Protocol
|
||||
PRM = 21, //Packet Radio Measurement
|
||||
XNS_IDP = 22, //XEROX NS IDP
|
||||
TRUNK_1 = 23, //Trunk-1
|
||||
TRUNK_2 = 24, //Trunk-2
|
||||
LEAF_1 = 25, //Leaf-1
|
||||
LEAF_2 = 26, //Leaf-2
|
||||
RDP = 27, //Reliable Data Protocol
|
||||
IRTP = 28, //Internet Reliable Transaction Protocol
|
||||
ISO_TP4 = 29, //ISO Transport Protocol Class 4
|
||||
NETBLT = 30, //Bulk Data Transfer Protocol
|
||||
MFE_NSP = 31, //MFE Network Services Protocol
|
||||
MERIT_INP = 32, //MERIT Internodal Protocol
|
||||
DCCP = 33, //Datagram Congestion Control Protocol
|
||||
THIRD_PARTY_CONNECT = 34, //Third Party Connect Protocol
|
||||
IDPR = 35, //Inter-Domain Policy Routing Protocol
|
||||
XTP = 36, //Xpress Transport Protocol
|
||||
DDP = 37, //Datagram Delivery Protocol
|
||||
IDPR_CMTP = 38, //IDPR Control Message Transport Protocol
|
||||
TPplusplus = 39, //TP++ Transport Protocol
|
||||
IL = 40, //IL Transport Protocol
|
||||
IPv6 = 41, //IPv6 Encapsulation
|
||||
SDRP = 42, //Source Demand Routing Protocol
|
||||
IPv6_Route = 43, //Routing Header for IPv6
|
||||
IPv6_Frag = 44, //Fragment Header for IPv6
|
||||
IDRP = 45, //Inter-Domain Routing Protocol
|
||||
RSVP = 46, //Resource Reservation Protocol
|
||||
GREs = 47, //Generic Routing Encapsulation
|
||||
DSR = 48, //Dynamic Source Routing Protocol
|
||||
BNA = 49, //Burroughs Network Architecture
|
||||
ESP = 50, //Encapsulating Security Payload
|
||||
AH = 51, //Authentication Header
|
||||
I_NLSP = 52, //Integrated Net Layer Security Protocol
|
||||
SwIPe = 53, //SwIPe
|
||||
NARP = 54, //NBMA Address Resolution Protocol
|
||||
MOBILE = 55, //IP Mobility (Min Encap)
|
||||
TLSP = 56, //Transport Layer Security Protocol (using Kryptonet key management)
|
||||
SKIP = 57, //Simple Key-Management for Internet Protocol
|
||||
IPv6_ICMP = 58, //ICMP for IPv6
|
||||
IPv6_NoNxt = 59, //No Next Header for IPv6
|
||||
IPv6_Opts = 60, //Destination Options for IPv6
|
||||
HOST_INTERNAL_PROTOCOL = 61, //Any host internal protocol
|
||||
CFTP = 62, //CFTP
|
||||
LOCAL_NETWORK = 63, //Any local network
|
||||
SAT_EXPAK = 64, //SATNET and Backroom EXPAK
|
||||
KRYPTOLAN = 65, //Kryptolan
|
||||
RVD = 66, //MIT Remote Virtual Disk Protocol
|
||||
IPPC = 67, //Internet Pluribus Packet Core
|
||||
DISTRIBUTED_FS = 68, //Any distributed file system
|
||||
SAT_MON = 69, //SATNET Monitoring
|
||||
VISA = 70, //VISA Protocol
|
||||
IPCU = 71, //Internet Packet Core Utility
|
||||
CPNX = 72, //Computer Protocol Network Executive
|
||||
CPHB = 73, //Computer Protocol Heart Beat
|
||||
WSN = 74, //Wang Span Network
|
||||
PVP = 75, //Packet Video Protocol
|
||||
BR_SAT_MON = 76, //Backroom SATNET Monitoring
|
||||
SUN_ND = 77, //SUN ND PROTOCOL-Temporary
|
||||
WB_MON = 78, //WIDEBAND Monitoring
|
||||
WB_EXPAK = 79, //WIDEBAND EXPAK
|
||||
ISO_IP = 80, //International Organization for Standardization Internet Protocol
|
||||
VMTP = 81, //Versatile Message Transaction Protocol
|
||||
SECURE_VMTP = 82, //Secure Versatile Message Transaction Protocol
|
||||
VINES = 83, //VINES
|
||||
TTP = 84, //TTP
|
||||
IPTM = 84, //Internet Protocol Traffic Manager
|
||||
NSFNET_IGP = 85, //NSFNET-IGP
|
||||
DGP = 86, //Dissimilar Gateway Protocol
|
||||
TCF = 87, //TCF
|
||||
EIGRP = 88, //EIGRP
|
||||
OSPF = 89, //Open Shortest Path First
|
||||
Sprite_RPC = 90, //Sprite RPC Protocol
|
||||
LARP = 91, //Locus Address Resolution Protocol
|
||||
MTP = 92, //Multicast Transport Protocol
|
||||
AX_25 = 93, //AX.25
|
||||
OS = 94, //KA9Q NOS compatible IP over IP tunneling
|
||||
MICP = 95, //Mobile Internetworking Control Protocol
|
||||
SCC_SP = 96, //Semaphore Communications Sec. Pro
|
||||
ETHERIP = 97, //Ethernet-within-IP Encapsulation
|
||||
ENCAP = 98, //Encapsulation Header
|
||||
PRIVATE_ENCRYPTION = 99, //Any private encryption scheme
|
||||
GMTP = 100, //GMTP
|
||||
IFMP = 101, //Ipsilon Flow Management Protocol
|
||||
PNNI = 102, //PNNI over IP
|
||||
PIM = 103, //Protocol Independent Multicast
|
||||
ARIS = 104, //IBM's ARIS (Aggregate Route IP Switching) Protocol
|
||||
SCPS = 105, //SCPS (Space Communications Protocol Standards)
|
||||
QNX = 106, //QNX
|
||||
ACTIVE_NETWORKS = 107, //Active Networks
|
||||
IPComp = 108, //IP Payload Compression Protocol
|
||||
SNP = 109, //Sitara Networks Protocol
|
||||
Compaq_Peer = 110, //Compaq Peer Protocol
|
||||
IPX_in_IP = 111, //IPX in IP
|
||||
VRRP = 112, //Virtual Router Redundancy Protocol, Common Address Redundancy Protocol (not IANA assigned)
|
||||
PGM = 113, //PGM Reliable Transport Protocol
|
||||
ANY_HOP = 114, //Any 0-hop protocol
|
||||
L2TP = 115, //Layer Two Tunneling Protocol Version 3
|
||||
DDX = 116, //D-II Data Exchange (DDX)
|
||||
IATP = 117, //Interactive Agent Transfer Protocol
|
||||
STP = 118, //Schedule Transfer Protocol
|
||||
SRP = 119, //SpectraLink Radio Protocol
|
||||
UTI = 120, //Universal Transport Interface Protocol
|
||||
SMP = 121, //Simple Message Protocol
|
||||
SM = 122, //Simple Multicast Protocol
|
||||
PTP = 123, //Performance Transparency Protocol
|
||||
IS_IS_over_IPv4 = 124, //Intermediate System to Intermediate System (IS-IS) Protocol over IPv4
|
||||
FIRE = 125, //Flexible Intra-AS Routing Environment
|
||||
CRTP = 126, //Combat Radio Transport Protocol
|
||||
CRUDP = 127, //Combat Radio User Datagram
|
||||
SSCOPMCE = 128, //Service-Specific Connection-Oriented Protocol in a Multilink and Connectionless Environment
|
||||
IPLT = 129, //
|
||||
SPS = 130, //Secure Packet Shield
|
||||
PIPE = 131, //Private IP Encapsulation within IP
|
||||
SCTP = 132, //Stream Control Transmission Protocol
|
||||
FC = 133, //Fibre Channel
|
||||
RSVP_E2E_IGNORE = 134, //Reservation Protocol (RSVP) End-to-End Ignore
|
||||
Mobility_Header = 135, //Mobility Extension Header for IPv6
|
||||
UDPLite = 136, //Lightweight User Datagram Protocol
|
||||
MPLS_in_IP = 137, //Multiprotocol Label Switching Encapsulated in IP
|
||||
manet = 138, //MANET Protocols
|
||||
HIP = 139, //Host Identity Protocol
|
||||
Shim6 = 140, //Site Multihoming by IPv6 Intermediation
|
||||
WESP = 141, //Wrapped Encapsulating Security Payload
|
||||
ROHC = 142, //Robust Header Compression
|
||||
|
||||
//Unassigned = 143 - 252, //
|
||||
//Use for experimentation and testing = 253 - 254, //
|
||||
Reserved = 255, //
|
||||
};
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
internal sealed class Tcp : Packet
|
||||
{
|
||||
private Tcp()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NetFoundry.VPN.Util;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
/// <summary>
|
||||
/// This class encapsulates all the TCP header fields and provides a mechanism
|
||||
/// to set and get the details of them through a parameterized contructor
|
||||
/// and public properties respectively.
|
||||
/// </summary>
|
||||
sealed class TcpHeader
|
||||
{
|
||||
private IpHeader ipHeader = null;
|
||||
|
||||
// Sixteen bits for the source port number.
|
||||
private ushort _sourcePort;
|
||||
// Sixteen bits for the destination port number.
|
||||
private ushort _destinationPort;
|
||||
// Thirty two bits for the sequence number.
|
||||
private uint _sequenceNumber = 555;
|
||||
// Thirty two bits for the acknowledgement number.
|
||||
private uint _acknowledgementNumber = 555;
|
||||
// Sixteen bits for flags and data offset.
|
||||
private ushort _dataOffsetAndFlags = 555;
|
||||
// Sixteen bits for the window size.
|
||||
private ushort _window = 555;
|
||||
// Sixteen bits for the checksum, (checksum can be negative so taken as short).
|
||||
private short _checksum = 555;
|
||||
// Sixteen bits for the urgent pointer.
|
||||
private ushort _urgentPointer;
|
||||
// Header length.
|
||||
private byte _headerLength;
|
||||
// Length of the data being carried.
|
||||
private ushort _messageLength;
|
||||
// Data carried by the TCP packet.
|
||||
private byte[] _tcpData = new byte[2 << 15];
|
||||
|
||||
|
||||
internal void WriteTo(System.IO.Stream stream)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TcpHeader([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray()] byte[] byBuffer, int nReceived, IpHeader ipHeader)
|
||||
{
|
||||
this.ipHeader = ipHeader;
|
||||
try
|
||||
{
|
||||
// Create MemoryStream out of the received bytes.
|
||||
MemoryStream memoryStream = new MemoryStream(byBuffer, 0, nReceived);
|
||||
// Next we create a BinaryReader out of the MemoryStream.
|
||||
BinaryReader binaryReader = new BinaryReader(memoryStream);
|
||||
// The first sixteen bits contain the source port.
|
||||
_sourcePort = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// The next sixteen contain the destiination port.
|
||||
_destinationPort = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// Next thirty two have the sequence number.
|
||||
_sequenceNumber = (uint)IPAddress.NetworkToHostOrder(binaryReader.ReadInt32());
|
||||
// Next thirty two have the acknowledgement number.
|
||||
_acknowledgementNumber = (uint)IPAddress.NetworkToHostOrder(binaryReader.ReadInt32());
|
||||
// The next sixteen bits hold the flags and the data offset.
|
||||
_dataOffsetAndFlags = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// The next sixteen contain the window size.
|
||||
_window = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// In the next sixteen we have the checksum.
|
||||
_checksum = (short)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// The following sixteen contain the urgent pointer.
|
||||
_urgentPointer = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// The data offset indicates where the data begins, so using it we
|
||||
// calculate the header length.
|
||||
_headerLength = (byte)(_dataOffsetAndFlags >> 12);
|
||||
_headerLength *= 4;
|
||||
// Message length = Total length of the TCP packet - Header length.
|
||||
_messageLength = (ushort)(nReceived - _headerLength);
|
||||
// Copy the TCP data into the data buffer.
|
||||
Array.Copy(byBuffer, _headerLength, _tcpData, 0,
|
||||
nReceived - _headerLength);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.LogLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string ToShortString()
|
||||
{
|
||||
string src = ipHeader.SourceAddress.MapToIPv4().ToString();
|
||||
string dst = ipHeader.DestinationAddress.MapToIPv4().ToString();
|
||||
|
||||
return string.Format("tcp from {0}:{1} to {2}:{3}. payload: {4}. ", src, SourcePort, dst, DestinationPort, MessageLength);
|
||||
}
|
||||
|
||||
public string ToLoooongString()
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
//b.Append(ipHeader.ToLoooongString());
|
||||
b.Append(" SequenceNumber: ");
|
||||
b.Append(this.SequenceNumber);
|
||||
b.Append(" AckNo: ");
|
||||
b.Append(this.AcknowledgementNumber);
|
||||
b.Append(" ChecksumTCP: ");
|
||||
b.Append(this.Checksum);
|
||||
//b.Append("Data: ");
|
||||
//b.Append(this.Data);
|
||||
b.Append(" DestinationPort: ");
|
||||
b.Append(this.DestinationPort);
|
||||
b.Append(" Flags: ");
|
||||
b.Append(this.Flags);
|
||||
b.Append(" HeaderLength: ");
|
||||
b.Append(this.HeaderLength);
|
||||
b.Append(" MessageLength: ");
|
||||
b.Append(this.MessageLength);
|
||||
b.Append(" SourcePort: ");
|
||||
b.Append(this.SourcePort);
|
||||
b.Append(" UrgentPointer: ");
|
||||
b.Append(this.UrgentPointer);
|
||||
b.Append(" WindowSize: ");
|
||||
b.Append(this.WindowSize);
|
||||
|
||||
return b.ToString();
|
||||
}
|
||||
|
||||
public void WriteTo(TextWriter writer)
|
||||
{/*
|
||||
writer.WriteLine("ByVersionAndHeaderLength: " + ByVersionAndHeaderLength);
|
||||
writer.WriteLine("ByDifferentiatedServices: " + ByDifferentiatedServices);
|
||||
writer.WriteLine("UsTotalLength: " + UsTotalLength);
|
||||
writer.WriteLine("UsIdentification: " + UsIdentification);
|
||||
writer.WriteLine("usFlagsAndOffset: " + usFlagsAndOffset);
|
||||
writer.WriteLine("ByTTL: " + ByTTL);
|
||||
writer.WriteLine("ByProtocol: " + ByProtocol);
|
||||
writer.WriteLine("SChecksum: " + SChecksum);
|
||||
writer.WriteLine("UiSourceIPAddress: " + _sourceIPAddress);
|
||||
writer.WriteLine("UiDestinationIPAddress: " + UiDestinationIPAddress);
|
||||
writer.WriteLine("ByHeaderLength: " + ByHeaderLength);
|
||||
writer.WriteLine("As Hex: ");
|
||||
writer.WriteLine(BinaryVisualiser.FormatAsHex(Data, UsTotalLength));*/
|
||||
writer.WriteLine("NOT IMPLEMENTED YET");
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string SourcePort
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sourcePort.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string DestinationPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return _destinationPort.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string SequenceNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sequenceNumber.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string AcknowledgementNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
// If the ACK flag is set then only we have a valid value in the
|
||||
// acknowlegement field, so check for it beore returning anything.
|
||||
if ((_dataOffsetAndFlags & 0x10) != 0)
|
||||
{
|
||||
return _acknowledgementNumber.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string HeaderLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _headerLength.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string WindowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return _window.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string UrgentPointer
|
||||
{
|
||||
get
|
||||
{
|
||||
// If the URG flag is set then only we have a valid value in the urgent
|
||||
// pointer field, so check for it beore returning anything.
|
||||
if ((_dataOffsetAndFlags & 0x20) != 0)
|
||||
{
|
||||
return _urgentPointer.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
// The last six bits of data offset and flags contain the control bits.
|
||||
// First we extract the flags.
|
||||
int nFlags = _dataOffsetAndFlags & 0x3F;
|
||||
string strFlags = string.Format("0x{0:x2} (", nFlags);
|
||||
// Now we start looking whether individual bits are set or not.
|
||||
if ((nFlags & 0x01) != 0)
|
||||
{
|
||||
strFlags += "FIN, ";
|
||||
}
|
||||
if ((nFlags & 0x02) != 0)
|
||||
{
|
||||
strFlags += "SYN, ";
|
||||
}
|
||||
if ((nFlags & 0x04) != 0)
|
||||
{
|
||||
strFlags += "RST, ";
|
||||
}
|
||||
if ((nFlags & 0x08) != 0)
|
||||
{
|
||||
strFlags += "PSH, ";
|
||||
}
|
||||
if ((nFlags & 0x10) != 0)
|
||||
{
|
||||
strFlags += "ACK, ";
|
||||
}
|
||||
if ((nFlags & 0x20) != 0)
|
||||
{
|
||||
strFlags += "URG";
|
||||
}
|
||||
strFlags += ")";
|
||||
|
||||
if (strFlags.Contains("()"))
|
||||
{
|
||||
strFlags = strFlags.Remove(strFlags.Length - 3);
|
||||
}
|
||||
else if (strFlags.Contains(", )"))
|
||||
{
|
||||
strFlags = strFlags.Remove(strFlags.Length - 3, 2);
|
||||
}
|
||||
return strFlags;
|
||||
}
|
||||
}
|
||||
|
||||
public string Checksum
|
||||
{
|
||||
get
|
||||
{
|
||||
// Return the checksum in hexadecimal format.
|
||||
return string.Format("0x{0:x2}", _checksum);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tcpData;
|
||||
}
|
||||
}
|
||||
|
||||
public ushort MessageLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _messageLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
internal sealed class Udp : Packet
|
||||
{
|
||||
|
||||
private Udp()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace NetFoundry.VPN.IP
|
||||
{
|
||||
/// <summary>
|
||||
/// This class encapsulates all the UDP header fields and provides a mechanism
|
||||
/// to set and get the details of them through a parameterized contructor
|
||||
/// and public properties respectively.
|
||||
/// </summary>
|
||||
public sealed class UdpHeader
|
||||
{
|
||||
// Sixteen bits for the source port number.
|
||||
private ushort UsSourcePort;
|
||||
// Sixteen bits for the destination port number.
|
||||
private ushort UsDestinationPort;
|
||||
// Length of the UDP header.
|
||||
private ushort UsLength;
|
||||
// Sixteen bits for the checksum (checksum can be negative so taken as short).
|
||||
private short SChecksum;
|
||||
// Data carried by the UDP packet.
|
||||
private byte[] ByUDPData = new byte[4096];
|
||||
|
||||
public UdpHeader([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray()] byte[] byBuffer, int nReceived)
|
||||
{
|
||||
// Create MemoryStream out of the received bytes.
|
||||
MemoryStream memoryStream = new MemoryStream(byBuffer, 0, nReceived);
|
||||
// Next we create a BinaryReader out of the MemoryStream.
|
||||
BinaryReader binaryReader = new BinaryReader(memoryStream);
|
||||
// The first sixteen bits contain the source port.
|
||||
UsSourcePort = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// The next sixteen bits contain the destination port.
|
||||
UsDestinationPort = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// The next sixteen bits contain the length of the UDP packet.
|
||||
UsLength = (ushort)IPAddress.NetworkToHostOrder(
|
||||
binaryReader.ReadInt16());
|
||||
// The next sixteen bits contain the checksum.
|
||||
SChecksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
|
||||
// Copy the data carried by the UDP packet into the data buffer.
|
||||
Array.Copy(byBuffer, 8, ByUDPData, 0, nReceived - 8);
|
||||
}
|
||||
|
||||
public string SourcePort
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsSourcePort.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string DestinationPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsDestinationPort.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public string Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return UsLength.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
public string Checksum
|
||||
{
|
||||
get
|
||||
{
|
||||
// Return the checksum in hexadecimal format.
|
||||
return string.Format("0x{0:x2}", SChecksum);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return ByUDPData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.Util
|
||||
{
|
||||
public static class BinaryVisualiser
|
||||
{
|
||||
public static string FormatAsHex([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArrayAttribute]
|
||||
byte[] dataAsBytes, int len)
|
||||
{
|
||||
ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(dataAsBytes);
|
||||
|
||||
byte ReplaceControlCharacterWithDot(byte character)
|
||||
=> character < 31 || character >= 127 ? (byte)46 /* dot */ : character;
|
||||
|
||||
byte[] ReplaceControlCharactersWithDots(byte[] characters)
|
||||
=> characters.Select(ReplaceControlCharacterWithDot).ToArray();
|
||||
|
||||
var result = new StringBuilder();
|
||||
const int lineWidth = 16;
|
||||
for (var pos = 0; pos < len;)
|
||||
{
|
||||
var line = data.Slice(pos, Math.Min(lineWidth, data.Length - pos)).ToArray();
|
||||
var asHex = string.Join(" ",
|
||||
line.Select(v => v.ToString("X2", System.Globalization.CultureInfo.InvariantCulture)));
|
||||
asHex += new string(' ', lineWidth * 3 - 1 - asHex.Length);
|
||||
var asCharacters = Encoding.ASCII.GetString(ReplaceControlCharactersWithDots(line));
|
||||
result.Append(FormattableString.Invariant($"{pos:X4} {asHex} {asCharacters}\n"));
|
||||
if (line.Length > 0)
|
||||
{
|
||||
pos += line.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetFoundry.VPN.Util
|
||||
{
|
||||
public sealed class HexHelper
|
||||
{
|
||||
|
||||
public static string FormatAsHex([ReadOnlyArrayAttribute] byte[] dataAsBytes, int len)
|
||||
{
|
||||
return FormatAsHex(dataAsBytes, len, 16);
|
||||
}
|
||||
|
||||
public static string FormatAsHex([ReadOnlyArrayAttribute] byte[] dataAsBytes, int len, byte lineWidth)
|
||||
{
|
||||
ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(dataAsBytes);
|
||||
|
||||
byte ReplaceControlCharacterWithDot(byte character)
|
||||
=> character < 31 || character >= 127 ? (byte)46 /* dot */ : character;
|
||||
|
||||
byte[] ReplaceControlCharactersWithDots(byte[] characters)
|
||||
=> characters.Select(ReplaceControlCharacterWithDot).ToArray();
|
||||
|
||||
var result = new StringBuilder();
|
||||
//const int lineWidth = 16;
|
||||
for (var pos = 0; pos < len;)
|
||||
{
|
||||
var howManyBytes = Math.Min(lineWidth, len - pos);
|
||||
var line = data.Slice(pos, howManyBytes).ToArray();
|
||||
var asHex = string.Join(" ",
|
||||
line.Select(v => v.ToString("X2", System.Globalization.CultureInfo.InvariantCulture)));
|
||||
asHex += new string(' ', lineWidth * 3 - 1 - asHex.Length);
|
||||
var asCharacters = Encoding.ASCII.GetString(ReplaceControlCharactersWithDots(line));
|
||||
result.Append(FormattableString.Invariant($"{pos:X4} {asHex} {asCharacters}\n"));
|
||||
if (line.Length > 0)
|
||||
{
|
||||
pos += line.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString().Remove(result.Length - 1);
|
||||
}
|
||||
|
||||
public static byte[] FromDelimitedString(string hex, char delimiter)
|
||||
{
|
||||
string[] strBytes = hex.Split(delimiter);
|
||||
byte[] bytes = new byte[strBytes.Length];
|
||||
int i = 0;
|
||||
foreach(string b in strBytes)
|
||||
{
|
||||
bytes[i++] = Byte.Parse(b);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static byte[] FromString(string hex)
|
||||
{
|
||||
if (hex.Length % 2 == 1)
|
||||
throw new Exception("The binary key cannot have an odd number of digits");
|
||||
int hexLen = hex.Length / 2;
|
||||
byte[] bytes = new byte[hexLen];
|
||||
for(int i = 0; i < hexLen; i++)
|
||||
{
|
||||
string strByte = hex.Substring(i * 2, 2);
|
||||
Debug.WriteLine("READ: " + strByte);
|
||||
bytes[i] = Byte.Parse(strByte, System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static int GetHexVal(char hex)
|
||||
{
|
||||
int val = (int)hex;
|
||||
//For uppercase A-F letters:
|
||||
return val - (val < 58 ? 48 : 55);
|
||||
//For lowercase a-f letters:
|
||||
//return val - (val < 58 ? 48 : 87);
|
||||
//Or the two combined, but a bit slower:
|
||||
//return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Windows.Networking.Vpn;
|
||||
|
||||
namespace NetFoundry.VPN.Util
|
||||
{
|
||||
public sealed class LogHelper
|
||||
{
|
||||
private const string locator = "__X__";
|
||||
public static void LogLine(string msg)
|
||||
{
|
||||
Debug.WriteLine(string.Format("${0} ${1}: ${2}", locator, Environment.CurrentManagedThreadId, msg));
|
||||
}
|
||||
public static void LogLine(string text, VpnChannel channel)
|
||||
{
|
||||
LogLine(channel?.GetHashCode() + ":" + text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using bc = Org.BouncyCastle;
|
||||
using Org.BouncyCastle.OpenSsl;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Security;
|
||||
using Org.BouncyCastle.Pkcs;
|
||||
|
||||
namespace NetFoundry.VPN.Ziti
|
||||
{
|
||||
internal class Controller
|
||||
{
|
||||
private static HttpClient httpClient = null;
|
||||
static string URL = "https://demo.ziti.netfoundry.io:1080/";
|
||||
|
||||
internal static void GetServices()
|
||||
{
|
||||
string json = @"";
|
||||
bc.X509.X509Certificate x509Cert = null;
|
||||
bc.X509.X509Certificate x509CaCert = null;
|
||||
AsymmetricCipherKeyPair ackp = null;
|
||||
|
||||
dynamic thing = JsonConvert.DeserializeObject(json);
|
||||
string key = CleanPkiNode(thing.id.key?.ToString());
|
||||
string cert = CleanPkiNode(thing.id.cert?.ToString());
|
||||
string ca = CleanPkiNode(thing.id.ca?.ToString());
|
||||
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
using (var keyReader = new StringReader(key))
|
||||
{
|
||||
ackp = (AsymmetricCipherKeyPair)new PemReader(keyReader).ReadObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(cert))
|
||||
{
|
||||
using (var certReader = new StringReader(cert))
|
||||
{
|
||||
x509Cert = (bc.X509.X509Certificate)new PemReader(certReader).ReadObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ca))
|
||||
{
|
||||
using (var caReader = new StringReader(ca))
|
||||
{
|
||||
x509CaCert = (bc.X509.X509Certificate)new PemReader(caReader).ReadObject();
|
||||
}
|
||||
}
|
||||
|
||||
var csharpCert = CreateDotNetCertificate(x509Cert, ackp);
|
||||
|
||||
var cch = new HttpClientHandler();
|
||||
|
||||
cch.ClientCertificates.Add(csharpCert);
|
||||
cch.ClientCertificateOptions = ClientCertificateOption.Manual;
|
||||
httpClient = new HttpClient(new LoggingHandler(cch))
|
||||
{
|
||||
BaseAddress = new Uri($"{URL}")
|
||||
};
|
||||
}
|
||||
internal static X509Certificate createCertificate()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static string CleanPkiNode(string source)
|
||||
{
|
||||
if (source == null) return null;
|
||||
if (source.StartsWith("pem:"))
|
||||
{
|
||||
return source.Substring("pem:".Length);
|
||||
}
|
||||
else if (source.StartsWith("file://"))
|
||||
{
|
||||
throw new Exception("File pki not supported currently");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unexpected pki?");
|
||||
}
|
||||
}
|
||||
private static X509Certificate CreateDotNetCertificate(Org.BouncyCastle.X509.X509Certificate certificate,
|
||||
AsymmetricCipherKeyPair keyPair)
|
||||
{
|
||||
Pkcs12Store store = new Pkcs12Store();
|
||||
string friendlyName = new Guid().ToString();
|
||||
X509CertificateEntry certificateEntry = new X509CertificateEntry(certificate);
|
||||
store.SetCertificateEntry(friendlyName, certificateEntry);
|
||||
store.SetKeyEntry(friendlyName, new AsymmetricKeyEntry(keyPair.Private), new[] { certificateEntry });
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
store.Save(stream, null, new SecureRandom());
|
||||
|
||||
return new X509Certificate2(stream.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
internal class LoggingHandler : DelegatingHandler
|
||||
{
|
||||
public LoggingHandler(HttpMessageHandler innerHandler) : base(innerHandler)
|
||||
{
|
||||
}
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(
|
||||
HttpRequestMessage request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Request: {request}");
|
||||
try
|
||||
{
|
||||
// base.SendAsync calls the inner handler
|
||||
var response = await base.SendAsync(request, cancellationToken);
|
||||
System.Diagnostics.Debug.WriteLine($"Response: {response}");
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to get response: {ex}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Networking.Vpn;
|
||||
|
||||
namespace ZitiBackgroundTask.Ziti.Route
|
||||
{
|
||||
internal class Intercept
|
||||
{
|
||||
public string ServiceName { get; set; }
|
||||
|
||||
public string DomainName { get; set; }
|
||||
|
||||
public VpnDomainNameType DomainType { get; set; }
|
||||
|
||||
public int Port { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZitiBackgroundTask.Ziti.Route;
|
||||
|
||||
namespace ZitiBackgroundTask
|
||||
{
|
||||
internal class RouteInformation
|
||||
{
|
||||
private static ObservableCollection<Intercept> _interceptsObservable = new ObservableCollection<Intercept>();
|
||||
|
||||
public static ObservableCollection<Intercept> Intercepts
|
||||
{
|
||||
get { return _interceptsObservable; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -9,54 +9,55 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ZitiTunneler.Properties {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if ((resourceMan == null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ZitiTunneler.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ZitiTunneler.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ZitiTunneler.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings:global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>ZitiTunneler</RootNamespace>
|
||||
<AssemblyName>ZitiTunneler</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<Page
|
||||
x:Class="TestUWPApp.AddIdentity"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:TestUWPApp"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
|
||||
<Grid x:Name="OuterGrid" >
|
||||
<Grid.Background>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFFF0D49"/>
|
||||
<GradientStop Color="#FF0273FB" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Grid.Background>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -1,7 +0,0 @@
|
||||
<Application
|
||||
x:Class="TestUWPApp.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:TestUWPApp">
|
||||
|
||||
</Application>
|
||||
@@ -1,100 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace TestUWPApp
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (e.PrelaunchActivated == false)
|
||||
{
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -1,66 +0,0 @@
|
||||
<Page
|
||||
x:Class="TestUWPApp.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:TestUWPApp"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="Page_SizeChanged" Loaded="Page_Loaded">
|
||||
|
||||
<Grid x:Name="OuterGrid" >
|
||||
|
||||
<Grid.Background>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<LinearGradientBrush.RelativeTransform>
|
||||
<CompositeTransform CenterY="0.5" CenterX="0.5" Rotation="151"/>
|
||||
</LinearGradientBrush.RelativeTransform>
|
||||
<GradientStop Color="#FFFF0D49"/>
|
||||
<GradientStop Color="#FF0273FB" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Grid.Background>
|
||||
<Button Content="Button" Margin="42,43,0,0" VerticalAlignment="Top" Click="Button_Click" Width="130" Height="51"/>
|
||||
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="Layer_1" Canvas.Left="0" Canvas.Top="0" Width="109.5" Height="178.3">
|
||||
<Canvas.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</Canvas.RenderTransform>
|
||||
<Canvas.Resources/>
|
||||
<!--Unknown tag: metadata-->
|
||||
<!--Unknown tag: sodipodi:namedview-->
|
||||
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path3715" Fill="#FFFFFF" Data="M56.4 0L0 85.8l32 20.9l5.3-8.1L54 178.3l55.5-86.3L78.4 71.7l-5.3 8.2L56.4 0z M81.7 86.1l13.7 9.2l-36.5 55.9 L42.1 71.3L28.5 92.1l-13.4-8.8l36.7-56.1l16.6 79.2L81.7 86.1z"/>
|
||||
</Canvas>
|
||||
<TextBox x:Name="txtIdentityPath" HorizontalAlignment="Center" Margin="0,407,0,0" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="354"/>
|
||||
<TextBox x:Name="txtIdentityName" HorizontalAlignment="Center" Margin="0,444,0,0" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="354"/>
|
||||
<Button x:Name="btnImportIdentity" Content="Import" Margin="292,481,0,0" VerticalAlignment="Top" Click="ImportIdentity_Click"/>
|
||||
<Grid x:Name="OuterGrid_Copy" >
|
||||
|
||||
<Grid.Background>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<LinearGradientBrush.RelativeTransform>
|
||||
<CompositeTransform CenterY="0.5" CenterX="0.5" Rotation="151"/>
|
||||
</LinearGradientBrush.RelativeTransform>
|
||||
<GradientStop Color="#FFFF0D49"/>
|
||||
<GradientStop Color="#FF0273FB" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Grid.Background>
|
||||
<Button Content="Button" Margin="42,43,0,0" VerticalAlignment="Top" Click="Button_Click" Width="130" Height="51"/>
|
||||
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x:Name="Layer_2" Canvas.Left="0" Canvas.Top="0" Width="109.5" Height="178.3">
|
||||
<Canvas.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</Canvas.RenderTransform>
|
||||
<!--Unknown tag: metadata-->
|
||||
<!--Unknown tag: sodipodi:namedview-->
|
||||
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="path1" Fill="#FFFFFF" Data="M56.4 0L0 85.8l32 20.9l5.3-8.1L54 178.3l55.5-86.3L78.4 71.7l-5.3 8.2L56.4 0z M81.7 86.1l13.7 9.2l-36.5 55.9 L42.1 71.3L28.5 92.1l-13.4-8.8l36.7-56.1l16.6 79.2L81.7 86.1z"/>
|
||||
</Canvas>
|
||||
<TextBox x:Name="txtIdentityPath1" HorizontalAlignment="Center" Margin="0,407,0,0" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="354"/>
|
||||
<TextBox x:Name="txtIdentityName1" HorizontalAlignment="Center" Margin="0,444,0,0" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="354"/>
|
||||
<Button x:Name="btnImportIdentity1" Content="Import" Margin="292,481,0,0" VerticalAlignment="Top" Click="ImportIdentity_Click"/>
|
||||
<Button x:Name="btnConnect" Content="Connect" Margin="272,583,0,0" VerticalAlignment="Top" Click="Connect_Click"/>
|
||||
<Button x:Name="btnDisconnect" Content="Disconnect" Margin="172,583,0,0" VerticalAlignment="Top" Click="Disconnect_Click"/>
|
||||
<Button x:Name="btnConnect2" Content="Connect2" Margin="272,183,0,0" VerticalAlignment="Top" Click="Connect2_Click"/>
|
||||
<Button x:Name="btnDisconnect2" Content="Disconnect2" Margin="172,183,0,0" VerticalAlignment="Top" Click="Disconnect2_Click"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -1,606 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using Windows.UI.Notifications;
|
||||
using Windows.UI.ViewManagement;
|
||||
using Microsoft.Toolkit.Uwp.Notifications; // Notifications library
|
||||
using Microsoft.QueryStringDotNET;
|
||||
|
||||
using Windows.Networking;
|
||||
using Windows.Networking.Vpn;
|
||||
using NetFoundry.VPN;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using NetFoundry.VPN.Util;
|
||||
|
||||
// QueryString.NET
|
||||
|
||||
namespace TestUWPApp
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
static string PROFILE_NAME = "NetFoundry VPN Plugin";
|
||||
|
||||
private static readonly Color ColorRequired = new Color() {R = 255};
|
||||
private static readonly string _defaultIdentityPath = "Path to identity *";
|
||||
private static readonly string _defaultIdentityName = "Path to identity *";
|
||||
private static string _keyIdentities = "identites";
|
||||
|
||||
private ApplicationDataContainer localSettings = null;
|
||||
private ApplicationDataContainer identities = null;
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.txtIdentityPath.Text = _defaultIdentityPath;
|
||||
this.txtIdentityName.Text = _defaultIdentityName;
|
||||
|
||||
localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
||||
identities = localSettings.CreateContainer(_keyIdentities, ApplicationDataCreateDisposition.Always);
|
||||
|
||||
ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(400, 600));
|
||||
|
||||
ApplicationView.PreferredLaunchViewSize = new Size(400, 600);
|
||||
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
|
||||
}
|
||||
|
||||
private bool isConnected = false;
|
||||
|
||||
// In a real app, these would be initialized with actual data
|
||||
string title = "Andrew sent you a picture";
|
||||
string content = "Check this out, Happy Canyon in Utah!";
|
||||
string image = "https://picsum.photos/360/202?image=883";
|
||||
string logo = "ms-appdata:///local/Andrew.jpg";
|
||||
private string containerName = "NetFoundry Windows Client";
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string input = "blah";
|
||||
|
||||
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
|
||||
ApplicationDataContainer container =
|
||||
localSettings.CreateContainer(containerName, ApplicationDataCreateDisposition.Always);
|
||||
|
||||
if (container.Containers.ContainsKey(_keyIdentities))
|
||||
{
|
||||
DisplaySimpleToast("Ziti is active!", "Click or tap here to connect one or more identity.",3);
|
||||
// DisplayNoIdentiesToast();
|
||||
container.DeleteContainer(_keyIdentities);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplaySimpleToast("Ziti Status - no enrollments", "Ziti has no successfully enrolled identites.", 3);
|
||||
// DisplayNoIdentiesToast();
|
||||
ApplicationDataContainer identities =
|
||||
container.CreateContainer(_keyIdentities, ApplicationDataCreateDisposition.Always);
|
||||
identities.Values["identity1"] = "this is some json or something";
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayNoIdentiesToast()
|
||||
{
|
||||
// Construct the visuals of the toast
|
||||
ToastVisual visual = new ToastVisual()
|
||||
{
|
||||
BindingGeneric = new ToastBindingGeneric()
|
||||
{
|
||||
Children =
|
||||
{
|
||||
new AdaptiveText()
|
||||
{
|
||||
Text = title
|
||||
},
|
||||
|
||||
new AdaptiveText()
|
||||
{
|
||||
Text = content
|
||||
},
|
||||
|
||||
new AdaptiveImage()
|
||||
{
|
||||
Source = image
|
||||
}
|
||||
},
|
||||
|
||||
AppLogoOverride = new ToastGenericAppLogo()
|
||||
{
|
||||
Source = logo,
|
||||
HintCrop = ToastGenericAppLogoCrop.Circle
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// In a real app, these would be initialized with actual data
|
||||
int conversationId = 384928;
|
||||
|
||||
string toastReply = new QueryString()
|
||||
{
|
||||
{
|
||||
"action", "reply"
|
||||
},
|
||||
{"conversationId", conversationId.ToString()}
|
||||
|
||||
}.ToString();
|
||||
|
||||
string toastLike = new QueryString()
|
||||
{
|
||||
{"action", "like"},
|
||||
{"conversationId", conversationId.ToString()}
|
||||
|
||||
}.ToString();
|
||||
|
||||
string toastView = new QueryString()
|
||||
{
|
||||
{"action", "viewImage"},
|
||||
{"imageUrl", image}
|
||||
|
||||
}.ToString();
|
||||
|
||||
string toastLaunch = new QueryString()
|
||||
{
|
||||
{"action", "viewConversation"},
|
||||
{"conversationId", conversationId.ToString()}
|
||||
|
||||
}.ToString();
|
||||
// Construct the actions for the toast (inputs and buttons)
|
||||
ToastActionsCustom actions = new ToastActionsCustom()
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
new ToastTextBox("tbReply")
|
||||
{
|
||||
PlaceholderContent = "Type a response"
|
||||
}
|
||||
},
|
||||
|
||||
Buttons =
|
||||
{
|
||||
new ToastButton("Reply", toastReply)
|
||||
{
|
||||
ActivationType = ToastActivationType.Background,
|
||||
ImageUri = "Assets/alert.png",
|
||||
|
||||
// Reference the text box's ID in order to
|
||||
// place this button next to the text box
|
||||
TextBoxId = "tbReply"
|
||||
},
|
||||
|
||||
new ToastButton("Like", toastLike)
|
||||
{
|
||||
ActivationType = ToastActivationType.Background
|
||||
},
|
||||
|
||||
new ToastButton("View", toastView)
|
||||
}
|
||||
};
|
||||
|
||||
// Now we can construct the final toast content
|
||||
ToastContent toastContent = new ToastContent()
|
||||
{
|
||||
Visual = visual,
|
||||
Actions = actions,
|
||||
|
||||
// Arguments when the user taps body of toast
|
||||
Launch = toastLaunch
|
||||
};
|
||||
|
||||
// And create the toast notification
|
||||
var toast = new ToastNotification(toastContent.GetXml());
|
||||
|
||||
toast.ExpirationTime = DateTime.Now.AddMinutes(20);
|
||||
toast.Tag = "Connected Identities";
|
||||
toast.Group = "NetFoundry Windows Client";
|
||||
|
||||
|
||||
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
||||
}
|
||||
|
||||
|
||||
private void DisplayPickIdentitesToast()
|
||||
{
|
||||
// Construct the visuals of the toast
|
||||
ToastVisual visual = new ToastVisual()
|
||||
{
|
||||
BindingGeneric = new ToastBindingGeneric()
|
||||
{
|
||||
Children =
|
||||
{
|
||||
new AdaptiveText()
|
||||
{
|
||||
Text = title
|
||||
},
|
||||
|
||||
new AdaptiveText()
|
||||
{
|
||||
Text = content
|
||||
},
|
||||
|
||||
new AdaptiveImage()
|
||||
{
|
||||
Source = image
|
||||
}
|
||||
},
|
||||
|
||||
AppLogoOverride = new ToastGenericAppLogo()
|
||||
{
|
||||
Source = logo,
|
||||
HintCrop = ToastGenericAppLogoCrop.Circle
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// In a real app, these would be initialized with actual data
|
||||
int conversationId = 384928;
|
||||
|
||||
string toastReply = new QueryString()
|
||||
{
|
||||
{
|
||||
"action", "reply"
|
||||
},
|
||||
{"conversationId", conversationId.ToString()}
|
||||
|
||||
}.ToString();
|
||||
|
||||
string toastLike = new QueryString()
|
||||
{
|
||||
{"action", "like"},
|
||||
{"conversationId", conversationId.ToString()}
|
||||
|
||||
}.ToString();
|
||||
|
||||
string toastView = new QueryString()
|
||||
{
|
||||
{"action", "viewImage"},
|
||||
{"imageUrl", image}
|
||||
|
||||
}.ToString();
|
||||
|
||||
string toastLaunch = new QueryString()
|
||||
{
|
||||
{"action", "viewConversation"},
|
||||
{"conversationId", conversationId.ToString()}
|
||||
|
||||
}.ToString();
|
||||
|
||||
|
||||
ToastButton tb = new ToastButton("Reply", toastReply)
|
||||
{
|
||||
ActivationType = ToastActivationType.Background,
|
||||
ImageUri = "Assets/alert.png",
|
||||
|
||||
// Reference the text box's ID in order to
|
||||
// place this button next to the text box
|
||||
TextBoxId = "tbReply",
|
||||
|
||||
};
|
||||
|
||||
string toastHeaderId = "";
|
||||
string toastHeaderTitle = "NetFoundry Toast Header";
|
||||
string toastHeaderArguments = "NetFoundry arguments";
|
||||
ToastHeader th = new ToastHeader(toastHeaderId, toastHeaderTitle, toastHeaderArguments)
|
||||
{
|
||||
};
|
||||
|
||||
// Construct the actions for the toast (inputs and buttons)
|
||||
ToastActionsCustom actions = new ToastActionsCustom()
|
||||
{
|
||||
Inputs =
|
||||
{
|
||||
new ToastTextBox("tbReply")
|
||||
{
|
||||
PlaceholderContent = "Type a response"
|
||||
}
|
||||
},
|
||||
|
||||
Buttons =
|
||||
{
|
||||
new ToastButton("Reply", toastReply)
|
||||
{
|
||||
ActivationType = ToastActivationType.Background,
|
||||
ImageUri = "Assets/Reply.png",
|
||||
|
||||
// Reference the text box's ID in order to
|
||||
// place this button next to the text box
|
||||
TextBoxId = "tbReply"
|
||||
},
|
||||
|
||||
new ToastButton("Like", toastLike)
|
||||
{
|
||||
ActivationType = ToastActivationType.Background
|
||||
},
|
||||
|
||||
new ToastButton("View", toastView)
|
||||
}
|
||||
};
|
||||
|
||||
// Now we can construct the final toast content
|
||||
ToastContent toastContent = new ToastContent()
|
||||
{
|
||||
Visual = visual,
|
||||
Actions = actions,
|
||||
|
||||
// Arguments when the user taps body of toast
|
||||
Launch = toastLaunch
|
||||
};
|
||||
|
||||
// And create the toast notification
|
||||
var toast = new ToastNotification(toastContent.GetXml());
|
||||
|
||||
toast.ExpirationTime = DateTime.Now.AddSeconds(2);
|
||||
toast.Tag = "18365";
|
||||
toast.Group = "wallPosts";
|
||||
|
||||
|
||||
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void DisplaySimpleToast(string title, string content, int secondsToDisplay)
|
||||
{
|
||||
Windows.UI.Notifications.ToastNotificationManager.History.Clear();
|
||||
|
||||
// Construct the visuals of the toast
|
||||
ToastVisual visual = new ToastVisual()
|
||||
{
|
||||
BindingGeneric = new ToastBindingGeneric()
|
||||
{
|
||||
Children =
|
||||
{
|
||||
new AdaptiveText()
|
||||
{
|
||||
Text = title
|
||||
},
|
||||
|
||||
new AdaptiveText()
|
||||
{
|
||||
Text = content
|
||||
} /*,
|
||||
|
||||
new AdaptiveImage()
|
||||
{
|
||||
Source = image
|
||||
}*/
|
||||
},
|
||||
|
||||
AppLogoOverride = new ToastGenericAppLogo()
|
||||
{
|
||||
Source = "Assets/ZitiLogo.png", //logo,
|
||||
HintCrop = ToastGenericAppLogoCrop.Circle
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Now we can construct the final toast content
|
||||
ToastContent toastContent = new ToastContent()
|
||||
{
|
||||
Visual = visual,
|
||||
};
|
||||
|
||||
// And create the toast notification
|
||||
var toast = new ToastNotification(toastContent.GetXml());
|
||||
|
||||
toast.ExpirationTime = DateTime.Now.AddSeconds(secondsToDisplay);
|
||||
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
||||
}
|
||||
|
||||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
OuterGrid.Height = this.Height;
|
||||
OuterGrid.Width = this.Width;
|
||||
}
|
||||
|
||||
public async void SaveIdentity(string name, string path)
|
||||
{
|
||||
identities.Values[name] = path;
|
||||
}
|
||||
|
||||
public async void SaveIdentity(Enrollment enrollment)
|
||||
{
|
||||
// serialize JSON to a string
|
||||
string json = JsonConvert.SerializeObject(enrollment);
|
||||
|
||||
// write string to a file
|
||||
var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(enrollment.Name);
|
||||
await FileIO.WriteTextAsync(file, json);
|
||||
}
|
||||
|
||||
public async Task<string> ReadIdentity(string name)
|
||||
{
|
||||
StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(name);
|
||||
|
||||
string txt = await FileIO.ReadTextAsync(file);
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
private void ImportIdentity_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
byte[] hexBytes = File.ReadAllBytes(@"v:\temp\ip-data2.txt");
|
||||
string hexString = Encoding.UTF8.GetString(hexBytes);
|
||||
string hexStringa = @"blah";
|
||||
byte[] bytes = null;
|
||||
|
||||
|
||||
bool skip = true;
|
||||
if (skip) return;
|
||||
|
||||
string identityName = txtIdentityName.Text;
|
||||
string identityPath = txtIdentityName.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(identityName))
|
||||
{
|
||||
MarkFieldRequired(txtIdentityName, _defaultIdentityName);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(identityPath))
|
||||
{
|
||||
MarkFieldRequired(txtIdentityPath, _defaultIdentityPath);
|
||||
}
|
||||
|
||||
SaveIdentity(identityName, identityPath);
|
||||
}
|
||||
|
||||
private void MarkFieldRequired(TextBox txtBox, string text)
|
||||
{
|
||||
txtBox.Foreground = new SolidColorBrush(ColorRequired);
|
||||
txtBox.Text = text;
|
||||
}
|
||||
|
||||
private async void Connect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
var (agent, profile) = await GetInstalledVpnProfile();
|
||||
if (profile == null)
|
||||
{
|
||||
// Create a new profile automatically
|
||||
var newProfile = new VpnPlugInProfile()
|
||||
{
|
||||
AlwaysOn = false,
|
||||
ProfileName = PROFILE_NAME,
|
||||
RequireVpnClientAppUI = false,
|
||||
VpnPluginPackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName,
|
||||
RememberCredentials = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<(VpnManagementAgent Agent, IVpnProfile Profile)> GetInstalledVpnProfile()
|
||||
{
|
||||
var agent = new VpnManagementAgent();
|
||||
var profiles = await agent.GetProfilesAsync();
|
||||
var lowerProfileName = PROFILE_NAME.ToLower();
|
||||
var profile = profiles.FirstOrDefault(p => p.ProfileName.ToLower() == lowerProfileName);
|
||||
return (agent, profile);
|
||||
}
|
||||
|
||||
private async void Disconnect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
VpnManagementAgent mgr = new VpnManagementAgent(); //get the 'vpn manager'
|
||||
var profs = await mgr.GetProfilesAsync(); //get the profiles from the local machine
|
||||
|
||||
VpnPlugInProfile nf = getVpnPlugin(profs, PROFILE_NAME); //find our "netfoundry one"
|
||||
//nf.ServerUris[0].AbsoluteUri;
|
||||
|
||||
//ziti://192.168.1.31:8900
|
||||
if (nf != null)
|
||||
{
|
||||
VpnManagementErrorStatus deleteStatus = await mgr.DeleteProfileAsync(nf);
|
||||
LogHelper.LogLine("result of DELETE: " + deleteStatus);
|
||||
if (deleteStatus != VpnManagementErrorStatus.Ok)
|
||||
{
|
||||
//do something here maybe
|
||||
}
|
||||
}
|
||||
|
||||
VpnPlugInProfile pluginProfile = new Windows.Networking.Vpn.VpnPlugInProfile()
|
||||
{
|
||||
ProfileName = PROFILE_NAME,
|
||||
RequireVpnClientAppUI = false,
|
||||
VpnPluginPackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName,
|
||||
RememberCredentials = false
|
||||
};
|
||||
pluginProfile.ServerUris.Add(new Uri("ziti://11.22.33.44:1234"));
|
||||
VpnManagementErrorStatus addStatus = await mgr.AddProfileFromObjectAsync(pluginProfile);
|
||||
LogHelper.LogLine("result of ADD: " + addStatus);
|
||||
if (addStatus != VpnManagementErrorStatus.Ok)
|
||||
{
|
||||
//do something here maybe
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private VpnPlugInProfile getVpnPlugin(IReadOnlyList<IVpnProfile> profs, string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) return null;
|
||||
name = name.Trim();
|
||||
|
||||
foreach (Windows.Networking.Vpn.IVpnProfile prof in profs)
|
||||
{
|
||||
VpnPlugInProfile p = prof as VpnPlugInProfile;
|
||||
LogHelper.LogLine("COUNT: " + p.ServerUris.Count);
|
||||
//ZitiBackgroundTask.ZitiVPNPlugin.LogLine(prof.ProfileName);
|
||||
if (p != null)
|
||||
{
|
||||
if (name == p.ProfileName.Trim())
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// ZitiVPNPlugin.SetContext(this);
|
||||
}
|
||||
|
||||
private async void Disconnect2_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
VpnManagementAgent mgr = new VpnManagementAgent(); //get the 'vpn manager'
|
||||
var profs = await mgr.GetProfilesAsync(); //get the profiles from the local machine
|
||||
|
||||
VpnPlugInProfile nf = getVpnPlugin(profs, PROFILE_NAME); //find our "netfoundry one"
|
||||
|
||||
if (nf != null)
|
||||
{
|
||||
VpnManagementErrorStatus status = await mgr.DisconnectProfileAsync(nf);
|
||||
LogHelper.LogLine("result of DisconnectProfileAsync: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
private async void Connect2_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
VpnPluginContext vpnContext = VpnPluginContext.GetActiveContext();
|
||||
|
||||
vpnContext.DnsServer = new HostName("192.168.1.114");
|
||||
|
||||
vpnContext.addSuffix("yahoo.com");
|
||||
vpnContext.addFQDN("wttr.in");
|
||||
vpnContext.addFQDN("eth0.ziti");
|
||||
vpnContext.AddIP("5.9.243.187" /*wttr.in*/);
|
||||
vpnContext.AddIP("169.254.0.1" /*some FAKE SERVICE that woudl be given to the tunneler*/);
|
||||
//vpnContext.AddIP("5.132.162.27" /*eth0.me*/);
|
||||
|
||||
VpnManagementAgent mgr = new VpnManagementAgent(); //get the 'vpn manager'
|
||||
var profs = await mgr.GetProfilesAsync(); //get the profiles from the local machine
|
||||
|
||||
VpnPlugInProfile nf = getVpnPlugin(profs, PROFILE_NAME); //find our "netfoundry one"
|
||||
if(nf != null)
|
||||
{
|
||||
VpnManagementErrorStatus status = await mgr.ConnectProfileAsync(nf);
|
||||
LogHelper.LogLine("result of connect: " + status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Enrollment
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string EnrollmentAsJson { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
|
||||
<Identity Name="NetFoundryPkg0401" Publisher="CN=cd" Version="0.9.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="bb2bd65f-fe0a-49e8-aeea-bd101b4d7146" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>Netfoundry Client 0401</DisplayName>
|
||||
<PublisherDisplayName>NetFoundry</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="ZitiUWPClient.App">
|
||||
<uap:VisualElements DisplayName="NetFoundry VPN Client - Apr 1 2020" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="This is the description of the app" BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
|
||||
</uap:DefaultTile>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
<Extensions>
|
||||
<Extension Category="windows.backgroundTasks" EntryPoint="NetFoundry.VPN.VPNTask" Executable="$targetnametoken$.exe">
|
||||
<BackgroundTasks>
|
||||
<uap:Task Type="vpnClient" />
|
||||
</BackgroundTasks>
|
||||
</Extension>
|
||||
</Extensions>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<Capability Name="internetClientServer" />
|
||||
<Capability Name="privateNetworkClientServer" />
|
||||
<rescap:Capability Name="networkingVpnProvider" />
|
||||
<rescap:Capability Name="confirmAppClose" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
@@ -1,29 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ZitiUWPClient")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ZitiUWPClient")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
@@ -1,31 +0,0 @@
|
||||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|
||||
@@ -1,196 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{F327E612-2CC2-42EF-93EB-DF12A5D1599E}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>zZitiUWPClient</RootNamespace>
|
||||
<AssemblyName>zZitiUWPClient</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
||||
<PackageCertificateKeyFile>App1_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>false</UseDotNetNativeToolchain>
|
||||
<EnableGatekeeperAnalysis>false</EnableGatekeeperAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="App1_TemporaryKey.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="AddIdentity.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BouncyCastle.NetCore">
|
||||
<Version>1.8.5</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.8</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
|
||||
<Version>5.1.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="QueryString.NET">
|
||||
<Version>1.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZitiBackgroundTask\ZitiBackgroundTask.csproj">
|
||||
<Project>{7393400b-5f2d-493c-bc39-ab3198a9749f}</Project>
|
||||
<Name>ZitiBackgroundTask</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -8,10 +8,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiBackgroundTask", "ZitiBackgroundTask\ZitiBackgroundTask.csproj", "{7393400B-5F2D-493C-BC39-AB3198A9749F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiUWPClient", "ZitiUWPClient\ZitiUWPClient.csproj", "{F327E612-2CC2-42EF-93EB-DF12A5D1599E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiTunneler", "ZitiTunneler\ZitiTunneler.csproj", "{FA4291EA-A97E-4854-959F-91EE7B330B37}"
|
||||
EndProject
|
||||
Global
|
||||
@@ -28,54 +24,6 @@ Global
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x64.Build.0 = Debug|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x86.Build.0 = Debug|x86
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM.Build.0 = Release|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x64.ActiveCfg = Release|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x64.Build.0 = Release|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x86.ActiveCfg = Release|x86
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x86.Build.0 = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|Any CPU.Deploy.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x64.Build.0 = Debug|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x86.Build.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM.Build.0 = Release|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM64.Deploy.0 = Release|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x64.ActiveCfg = Release|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x64.Build.0 = Release|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x64.Deploy.0 = Release|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x86.ActiveCfg = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x86.Build.0 = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x86.Deploy.0 = Release|x86
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
|
||||