1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-09-20 02:09:25 +03:00

v4.03-9411-rtm

This commit is contained in:
dnobori
2014-01-07 05:40:52 +09:00
parent 52e6ca39c1
commit d1bc9c57c5
356 changed files with 29166 additions and 9153 deletions

View File

@ -45,13 +45,10 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="CoreUtil, Version=1.1.4781.28908, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\CoreUtil.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Drawing" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
@ -65,9 +62,39 @@
<Compile Include="BuildUtilCommands.cs" />
<Compile Include="BuildUtilMain.cs" />
<Compile Include="CodeSign.cs" />
<Compile Include="CoreUtil\Bmp.cs" />
<Compile Include="CoreUtil\Buf.cs" />
<Compile Include="CoreUtil\Cache.cs" />
<Compile Include="CoreUtil\Compress.cs" />
<Compile Include="CoreUtil\Console.cs" />
<Compile Include="CoreUtil\Csv.cs" />
<Compile Include="CoreUtil\Env.cs" />
<Compile Include="CoreUtil\FileIO.cs" />
<Compile Include="CoreUtil\GZip.cs" />
<Compile Include="CoreUtil\Kernel.cs" />
<Compile Include="CoreUtil\MultiLang.cs" />
<Compile Include="CoreUtil\Packer.cs" />
<Compile Include="CoreUtil\RC4.cs" />
<Compile Include="CoreUtil\ReadIni.cs" />
<Compile Include="CoreUtil\Reg.cs" />
<Compile Include="CoreUtil\Secure.cs" />
<Compile Include="CoreUtil\Stb.cs" />
<Compile Include="CoreUtil\Str.cs" />
<Compile Include="CoreUtil\Tar.cs" />
<Compile Include="CoreUtil\Thread.cs" />
<Compile Include="CoreUtil\Time.cs" />
<Compile Include="CoreUtil\Util.cs" />
<Compile Include="CoreUtil\Win32.cs" />
<Compile Include="CoreUtil\Zip.cs" />
<Compile Include="CoreUtil\ZLib.cs" />
<Compile Include="PEUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
@ -167,6 +194,12 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.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.

View File

@ -147,7 +147,7 @@ namespace BuildUtil
public static int BuildUtil(ConsoleService c, string cmdName, string str)
{
Con.WriteLine("");
Con.WriteLine("Copyright (c) SoftEther Corporation. All Rights Reserved.");
Con.WriteLine("Copyright (c) SoftEther VPN Project. All Rights Reserved.");
Con.WriteLine("");
ConsoleParam[] args =

Binary file not shown.

View File

@ -0,0 +1,188 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
namespace CoreUtil
{
public static class Bmp
{
public static Bitmap Load(string filename)
{
return Load(IO.ReadFile(filename));
}
public static Bitmap Load(byte[] data)
{
MemoryStream ms = new MemoryStream();
ms.Write(data, 0, data.Length);
ms.Seek(0, SeekOrigin.Begin);
return new Bitmap(ms);
}
public static void SaveAsBitmap(Bitmap bmp, string filename)
{
IO.SaveFile(filename, SaveAsBitmap(bmp));
}
public static byte[] SaveAsBitmap(Bitmap bmp)
{
MemoryStream ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Bmp);
return ms.ToArray();
}
public static void SaveAsJpeg(Bitmap bmp, string filename)
{
IO.SaveFile(filename, SaveAsJpeg(bmp));
}
public static byte[] SaveAsJpeg(Bitmap bmp)
{
return SaveAsJpeg(bmp, 100);
}
public static void SaveAsJpeg(Bitmap bmp, string filename, int quality)
{
IO.SaveFile(filename, SaveAsJpeg(bmp, quality));
}
public static byte[] SaveAsJpeg(Bitmap bmp, int quality)
{
EncoderParameters eps = new EncoderParameters(1);
EncoderParameter ep = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
eps.Param[0] = ep;
ImageCodecInfo info = getEncoderInfo("image/jpeg");
MemoryStream ms = new MemoryStream();
bmp.Save(ms, info, eps);
return ms.ToArray();
}
static ImageCodecInfo getEncoderInfo(string type)
{
ImageCodecInfo[] encs = ImageCodecInfo.GetImageEncoders();
foreach (ImageCodecInfo enc in encs)
{
if (Str.StrCmpi(enc.MimeType, type))
{
return enc;
}
}
return null;
}
public static Bitmap ResizeBitmap(Bitmap bmp, int width, int height)
{
Bitmap dst = new Bitmap(width, height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(dst);
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle r = new Rectangle(0, 0, width, height);
g.DrawImage(bmp, r);
return dst;
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,673 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Web.Mail;
namespace CoreUtil
{
// FIFO
public class Fifo
{
byte[] p;
int pos, size;
public int Size
{
get { return size; }
}
public byte[] Data
{
get
{
return this.p;
}
}
public int DataOffset
{
get
{
return this.pos;
}
}
public int PhysicalSize
{
get
{
return p.Length;
}
}
int reallocMemSize;
public const int FifoInitMemSize = 4096;
public const int FifoReallocMemSize = 65536;
public const int FifoReallocMemSizeSmall = 65536;
long totalWriteSize = 0, totalReadSize = 0;
public long TotalReadSize
{
get { return totalReadSize; }
}
public long TotalWriteSize
{
get { return totalWriteSize; }
}
public Fifo()
{
init(0);
}
public Fifo(int reallocMemSize)
{
init(reallocMemSize);
}
void init(int reallocMemSize)
{
if (reallocMemSize == 0)
{
reallocMemSize = FifoReallocMemSize;
}
this.size = this.pos = 0;
this.reallocMemSize = reallocMemSize;
this.p = new byte[FifoInitMemSize];
}
public void Write(Buf buf)
{
Write(buf.ByteData);
}
public void Write(byte[] src)
{
Write(src, src.Length);
}
public void SkipWrite(int size)
{
Write(null, size);
}
public void Write(byte[] src, int size)
{
Write(src, 0, size);
}
public void Write(byte[] src, int offset, int size)
{
int i, need_size;
bool realloc_flag;
i = this.size;
this.size += size;
need_size = this.pos + this.size;
realloc_flag = false;
int memsize = p.Length;
while (need_size > memsize)
{
memsize = Math.Max(memsize, FifoInitMemSize) * 3;
realloc_flag = true;
}
if (realloc_flag)
{
byte[] new_p = new byte[memsize];
Util.CopyByte(new_p, 0, this.p, 0, this.p.Length);
this.p = new_p;
}
if (src != null)
{
Util.CopyByte(this.p, this.pos + i, src, offset, size);
}
totalWriteSize += size;
}
public byte[] Read()
{
return Read(this.Size);
}
public void ReadToBuf(Buf buf, int size)
{
byte[] data = Read(size);
buf.Write(data);
}
public Buf ReadToBuf(int size)
{
byte[] data = Read(size);
return new Buf(data);
}
public byte[] Read(int size)
{
byte[] ret = new byte[size];
int read_size = Read(ret);
Array.Resize<byte>(ref ret, read_size);
return ret;
}
public int Read(byte[] dst)
{
return Read(dst, dst.Length);
}
public int SkipRead(int size)
{
return Read(null, size);
}
public int Read(byte[] dst, int size)
{
return Read(dst, 0, size);
}
public int Read(byte[] dst, int offset, int size)
{
int read_size;
read_size = Math.Min(size, this.size);
if (read_size == 0)
{
return 0;
}
if (dst != null)
{
Util.CopyByte(dst, offset, this.p, this.pos, size);
}
this.pos += read_size;
this.size -= read_size;
if (this.size == 0)
{
this.pos = 0;
}
if (this.pos >= FifoInitMemSize &&
this.p.Length >= this.reallocMemSize &&
(this.p.Length / 2) > this.size)
{
byte[] new_p;
int new_size;
new_size = Math.Max(this.p.Length / 2, FifoInitMemSize);
new_p = new byte[new_size];
Util.CopyByte(new_p, 0, this.p, this.pos, this.size);
this.p = new_p;
this.pos = 0;
}
totalReadSize += read_size;
return read_size;
}
}
public class Buf
{
MemoryStream buf;
public Buf()
{
init(new byte[0]);
}
public Buf(byte[] data)
{
init(data);
}
void init(byte[] data)
{
buf = new MemoryStream();
Write(data);
SeekToBegin();
}
public void Clear()
{
buf.SetLength(0);
}
public void WriteByte(byte data)
{
byte[] a = new byte[1] { data };
Write(a);
}
public void Write(byte[] data)
{
buf.Write(data, 0, data.Length);
}
public void Write(byte[] data, int pos, int len)
{
buf.Write(data, pos, len);
}
public uint Size
{
get
{
return (uint)buf.Length;
}
}
public uint Pos
{
get
{
return (uint)buf.Position;
}
}
public byte[] ByteData
{
get
{
return buf.ToArray();
}
}
public byte this[uint i]
{
get
{
return buf.GetBuffer()[i];
}
set
{
buf.GetBuffer()[i] = value;
}
}
public byte[] Read()
{
return Read(this.Size);
}
public byte[] Read(uint size)
{
byte[] tmp = new byte[size];
int i = buf.Read(tmp, 0, (int)size);
byte[] ret = new byte[i];
Array.Copy(tmp, 0, ret, 0, i);
return ret;
}
public byte ReadByte()
{
byte[] a = Read(1);
return a[0];
}
public void SeekToBegin()
{
Seek(0);
}
public void SeekToEnd()
{
Seek(0, SeekOrigin.End);
}
public void Seek(uint offset)
{
Seek(offset, SeekOrigin.Begin);
}
public void Seek(uint offset, SeekOrigin mode)
{
buf.Seek(offset, mode);
}
public ushort ReadShort()
{
byte[] data = Read(2);
if (data.Length != 2)
{
return 0;
}
if (Env.IsLittleEndian)
{
Array.Reverse(data);
}
return BitConverter.ToUInt16(data, 0);
}
public ushort RawReadShort()
{
byte[] data = Read(2);
if (data.Length != 2)
{
return 0;
}
return BitConverter.ToUInt16(data, 0);
}
public uint ReadInt()
{
byte[] data = Read(4);
if (data.Length != 4)
{
return 0;
}
if (Env.IsLittleEndian)
{
Array.Reverse(data);
}
return BitConverter.ToUInt32(data, 0);
}
public uint RawReadInt()
{
byte[] data = Read(4);
if (data.Length != 4)
{
return 0;
}
return BitConverter.ToUInt32(data, 0);
}
public ulong ReadInt64()
{
byte[] data = Read(8);
if (data.Length != 8)
{
return 0;
}
if (Env.IsLittleEndian)
{
Array.Reverse(data);
}
return BitConverter.ToUInt64(data, 0);
}
public ulong RawReadInt64()
{
byte[] data = Read(8);
if (data.Length != 8)
{
return 0;
}
return BitConverter.ToUInt64(data, 0);
}
public string ReadStr()
{
return ReadStr(false);
}
public string ReadStr(bool include_null)
{
uint len = ReadInt();
byte[] data = Read(len - (uint)(include_null ? 1 : 0));
return Str.ShiftJisEncoding.GetString(data);
}
public string ReadUniStr()
{
return ReadUniStr(false);
}
public string ReadUniStr(bool include_null)
{
uint len = ReadInt();
if (len == 0)
{
return null;
}
byte[] data = Read(len - (uint)(include_null ? 2 : 0));
return Str.Utf8Encoding.GetString(data);
}
public void WriteShort(ushort shortValue)
{
byte[] data = BitConverter.GetBytes(shortValue);
if (Env.IsLittleEndian)
{
Array.Reverse(data);
}
Write(data);
}
public void RawWriteShort(ushort shortValue)
{
byte[] data = BitConverter.GetBytes(shortValue);
Write(data);
}
public void WriteInt(uint intValue)
{
byte[] data = BitConverter.GetBytes(intValue);
if (Env.IsLittleEndian)
{
Array.Reverse(data);
}
Write(data);
}
public void RawWriteInt(uint intValue)
{
byte[] data = BitConverter.GetBytes(intValue);
Write(data);
}
public void WriteInt64(ulong int64Value)
{
byte[] data = BitConverter.GetBytes(int64Value);
if (Env.IsLittleEndian)
{
Array.Reverse(data);
}
Write(data);
}
public void RawWriteInt64(ulong int64Value)
{
byte[] data = BitConverter.GetBytes(int64Value);
Write(data);
}
public string ReadNextLineAsString()
{
return ReadNextLineAsString(Str.Utf8Encoding);
}
public string ReadNextLineAsString(Encoding encoding)
{
byte[] ret = ReadNextLineAsData();
if (ret == null)
{
return null;
}
return encoding.GetString(ret);
}
public byte[] ReadNextLineAsData()
{
if (this.Size <= this.Pos)
{
return null;
}
long pos = buf.Position;
long i;
byte[] tmp = new byte[1];
for (i = pos; i < buf.Length; i++)
{
buf.Read(tmp, 0, 1);
if (tmp[0] == 13 || tmp[0] == 10)
{
if (tmp[0] == 13)
{
if ((i + 2) < buf.Length)
{
i++;
}
}
break;
}
}
long len = i - pos;
buf.Position = pos;
byte[] ret = Read((uint)((int)len));
try
{
Seek(1, SeekOrigin.Current);
}
catch
{
}
if (ret.Length >= 1 && ret[ret.Length - 1] == 13)
{
Array.Resize<byte>(ref ret, ret.Length - 1);
}
return ret;
}
public void WriteStr(string strValue)
{
WriteStr(strValue, false);
}
public void WriteStr(string strValue, bool include_null)
{
byte[] data = Str.ShiftJisEncoding.GetBytes(strValue);
WriteInt((uint)data.Length + (uint)(include_null ? 1 : 0));
Write(data);
}
public void WriteUniStr(string strValue)
{
WriteUniStr(strValue, false);
}
public void WriteUniStr(string strValue, bool include_null)
{
byte[] data = Str.Utf8Encoding.GetBytes(strValue);
WriteInt((uint)data.Length + (uint)(include_null ? 2 : 0));
Write(data);
}
public static Buf ReadFromFile(string filename)
{
return new Buf(IO.ReadFile(filename));
}
public void WriteToFile(string filename)
{
IO.SaveFile(filename, this.ByteData);
}
public static Buf ReadFromStream(Stream st)
{
Buf ret = new Buf();
int size = 32767;
while (true)
{
byte[] tmp = new byte[size];
int i = st.Read(tmp, 0, tmp.Length);
if (i <= 0)
{
break;
}
Array.Resize<byte>(ref tmp, i);
ret.Write(tmp);
}
ret.SeekToBegin();
return ret;
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,320 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
namespace CoreUtil
{
public enum CacheType
{
UpdateExpiresWhenAccess = 0,
DoNotUpdateExpiresWhenAccess = 1,
}
public class Cache<TKey, TValue>
{
class Entry
{
DateTime createdDateTime;
public DateTime CreatedDateTime
{
get { return createdDateTime; }
}
DateTime updatedDateTime;
public DateTime UpdatedDateTime
{
get { return updatedDateTime; }
}
DateTime lastAccessedDateTime;
public DateTime LastAccessedDateTime
{
get { return lastAccessedDateTime; }
}
TKey key;
public TKey Key
{
get
{
return key;
}
}
TValue value;
public TValue Value
{
get
{
lastAccessedDateTime = Time.NowDateTime;
return this.value;
}
set
{
this.value = value;
updatedDateTime = Time.NowDateTime;
lastAccessedDateTime = Time.NowDateTime;
}
}
public Entry(TKey key, TValue value)
{
this.key = key;
this.value = value;
lastAccessedDateTime = updatedDateTime = createdDateTime = Time.NowDateTime;
}
public override int GetHashCode()
{
return key.GetHashCode();
}
public override string ToString()
{
return key.ToString() + "," + value.ToString();
}
}
public static readonly TimeSpan DefaultExpireSpan = new TimeSpan(0, 5, 0);
public const CacheType DefaultCacheType = CacheType.UpdateExpiresWhenAccess;
TimeSpan expireSpan;
public TimeSpan ExpireSpan
{
get { return expireSpan; }
}
CacheType type;
public CacheType Type
{
get { return type; }
}
Dictionary<TKey, Entry> list;
object lockObj;
public Cache()
{
init(DefaultExpireSpan, DefaultCacheType);
}
public Cache(CacheType type)
{
init(DefaultExpireSpan, type);
}
public Cache(TimeSpan expireSpan)
{
init(expireSpan, DefaultCacheType);
}
public Cache(TimeSpan expireSpan, CacheType type)
{
init(expireSpan, type);
}
void init(TimeSpan expireSpan, CacheType type)
{
this.expireSpan = expireSpan;
this.type = type;
list = new Dictionary<TKey, Entry>();
lockObj = new object();
}
public void Add(TKey key, TValue value)
{
lock (lockObj)
{
Entry e;
deleteExpired();
if (list.ContainsKey(key) == false)
{
e = new Entry(key, value);
list.Add(e.Key, e);
deleteExpired();
}
else
{
e = list[key];
e.Value = value;
}
}
}
public void Delete(TKey key)
{
lock (lockObj)
{
if (list.ContainsKey(key))
{
list.Remove(key);
}
}
}
public TValue this[TKey key]
{
get
{
lock (lockObj)
{
deleteExpired();
if (list.ContainsKey(key) == false)
{
return default(TValue);
}
return list[key].Value;
}
}
}
static long last_deleted = 0;
void deleteExpired()
{
bool do_delete = false;
long now = Tick64.Value;
long delete_inveral = expireSpan.Milliseconds / 10;
lock (lockObj)
{
if (last_deleted == 0 || now > (last_deleted + delete_inveral))
{
last_deleted = now;
do_delete = true;
}
}
if (do_delete == false)
{
return;
}
lock (lockObj)
{
List<Entry> o = new List<Entry>();
DateTime expire = Time.NowDateTime - this.expireSpan;
foreach (Entry e in list.Values)
{
if (this.type == CacheType.UpdateExpiresWhenAccess)
{
if (e.LastAccessedDateTime < expire)
{
o.Add(e);
}
}
else
{
if (e.UpdatedDateTime < expire)
{
o.Add(e);
}
}
}
foreach (Entry e in o)
{
list.Remove(e.Key);
}
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,182 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Web.Mail;
using CoreUtil.Internal;
namespace CoreUtil
{
public static class ZLib
{
public static byte[] Compress(byte[] src)
{
return Compress(src, zlibConst.Z_DEFAULT_COMPRESSION);
}
public static byte[] Compress(byte[] src, int level)
{
return Compress(src, level, false);
}
public static byte[] Compress(byte[] src, int level, bool noHeader)
{
int dstSize = src.Length * 2 + 100;
byte[] dst = new byte[dstSize];
compress2(ref dst, src, level, noHeader);
return dst;
}
public static byte[] Uncompress(byte[] src, int originalSize)
{
byte[] dst = new byte[originalSize];
uncompress(ref dst, src);
return dst;
}
static void compress2(ref byte[] dest, byte[] src, int level, bool noHeader)
{
ZStream stream = new ZStream();
stream.next_in = src;
stream.avail_in = src.Length;
stream.next_out = dest;
stream.avail_out = dest.Length;
if (noHeader == false)
{
stream.deflateInit(level);
}
else
{
stream.deflateInit(level, -15);
}
stream.deflate(zlibConst.Z_FINISH);
Array.Resize<byte>(ref dest, (int)stream.total_out);
}
static void uncompress(ref byte[] dest, byte[] src)
{
ZStream stream = new ZStream();
stream.next_in = src;
stream.avail_in = src.Length;
stream.next_out = dest;
stream.avail_out = dest.Length;
stream.inflateInit();
int err = stream.inflate(zlibConst.Z_FINISH);
if (err != zlibConst.Z_STREAM_END)
{
stream.inflateEnd();
throw new ApplicationException();
}
Array.Resize<byte>(ref dest, (int)stream.total_out);
err = stream.inflateEnd();
if (err != zlibConst.Z_OK)
{
throw new ApplicationException();
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,497 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Web.Mail;
namespace CoreUtil
{
class CsvTimeSpan
{
public DateTime StartDateTime;
public DateTime EndDateTime;
public int StartIndex;
public int NumIndex;
public CsvTimeSpan(DateTime startDateTime, DateTime endDateTime, int startIndex, int numIndex)
{
StartDateTime = startDateTime;
EndDateTime = endDateTime;
StartIndex = startIndex;
NumIndex = numIndex;
}
}
public class Csv
{
List<CsvEntry> entryList;
Encoding encoding;
static Encoding defaultEncoding = Str.ShiftJisEncoding;
public Encoding Encoding
{
get
{
return encoding;
}
set
{
this.encoding = value;
}
}
public CsvEntry First
{
get
{
return entryList[0];
}
}
public CsvEntry Last
{
get
{
return entryList[entryList.Count - 1];
}
}
public Csv()
: this(defaultEncoding)
{
}
public Csv(Encoding encoding)
{
init(null, encoding);
}
public Csv(string filename)
: this(filename, defaultEncoding)
{
}
public Csv(string filename, Encoding encoding)
{
init(Buf.ReadFromFile(filename), encoding);
}
public Csv(Buf data)
{
byte[] src = data.ByteData;
int bomSize;
Encoding enc = Str.CheckBOM(src, out bomSize);
if (bomSize >= 1)
{
src = Util.RemoveStartByteArray(src, bomSize);
}
init(new Buf(src), enc);
}
public Csv(Buf data, Encoding encoding)
{
init(data, encoding);
}
void init(Buf data, Encoding encoding)
{
if (encoding == null)
{
encoding = defaultEncoding;
}
int bomSize = 0;
Encoding enc2 = null;
if (data != null)
{
enc2 = Str.CheckBOM(data.ByteData, out bomSize);
}
if (bomSize >= 1)
{
data = new Buf(Util.RemoveStartByteArray(data.ByteData, bomSize));
}
if (enc2 != null)
{
encoding = enc2;
}
this.encoding = encoding;
entryList = new List<CsvEntry>();
if (data != null)
{
MemoryStream ms = new MemoryStream(data.ByteData);
StreamReader sr = new StreamReader(ms, this.encoding);
while (true)
{
string s = sr.ReadLine();
if (s == null)
{
break;
}
char[] sep = { ',' };
string[] strings = s.Trim().Split(sep, StringSplitOptions.None);
CsvEntry e = new CsvEntry(strings);
Add(e);
}
}
}
public override string ToString()
{
StringBuilder b = new StringBuilder();
foreach (CsvEntry e in entryList)
{
b.AppendLine(e.ToString());
}
return b.ToString();
}
public Buf ToBuf()
{
string s = ToString();
Buf b = new Buf();
byte[] bom = Str.GetBOM(this.Encoding);
if (bom != null)
{
b.Write(bom);
}
b.Write(encoding.GetBytes(s));
b.SeekToBegin();
return b;
}
public void SaveToFile(string filename)
{
File.WriteAllBytes(filename, ToBuf().ByteData);
}
public void Add(CsvEntry e)
{
entryList.Add(e);
}
public int Count
{
get
{
return entryList.Count;
}
}
public CsvEntry this[int index]
{
get
{
return entryList[index];
}
}
public IEnumerable Items
{
get
{
int i;
for (i = 0; i < entryList.Count; i++)
{
yield return entryList[i];
}
}
}
CsvCompare csvCompareMethod;
int csvCompareIndex;
Type csvCompareType;
bool csvCompareReverse;
int sortInternal(CsvEntry e1, CsvEntry e2)
{
if (csvCompareMethod != null)
{
object o1 = e1.Convert(csvCompareType, csvCompareIndex);
object o2 = e2.Convert(csvCompareType, csvCompareIndex);
return csvCompareMethod(o1, o2) * (csvCompareReverse ? -1 : 1);
}
else
{
IComparable o1 = (IComparable)e1.Convert(csvCompareType, csvCompareIndex);
IComparable o2 = (IComparable)e2.Convert(csvCompareType, csvCompareIndex);
return o1.CompareTo(o2) * (csvCompareReverse ? -1 : 1);
}
}
public void Sort(Type type)
{
Sort(null, type);
}
public void Sort(CsvCompare cmp, Type type)
{
Sort(cmp, type, false);
}
public void Sort(Type type, bool reverse)
{
Sort(null, type, reverse);
}
public void Sort(CsvCompare cmp, Type type, bool reverse)
{
Sort(cmp, 0, type, reverse);
}
public void Sort(int index, Type type)
{
Sort(null, index, type);
}
public void Sort(CsvCompare cmp, int index, Type type)
{
Sort(cmp, 0, type, false);
}
public void Sort(int index, Type type, bool reverse)
{
Sort(null, index, type, reverse);
}
public void Sort(CsvCompare cmp, int index, Type type, bool reverse)
{
csvCompareMethod = cmp;
csvCompareIndex = index;
csvCompareType = type;
csvCompareReverse = reverse;
entryList.Sort(new Comparison<CsvEntry>(sortInternal));
}
public static int CompareString(object o1, object o2)
{
string s1 = (string)o1;
string s2 = (string)o2;
return s1.CompareTo(s2);
}
public static int CompareDatetime(object o1, object o2)
{
DateTime d1 = (DateTime)o1;
DateTime d2 = (DateTime)o2;
return d1.CompareTo(d2);
}
public void SetEncoding(Encoding e)
{
this.encoding = e;
}
public Csv Clone()
{
Csv csv = new Csv(this.encoding);
foreach (CsvEntry e in entryList)
{
csv.Add(e.Clone());
}
return csv;
}
}
public delegate int CsvCompare(object o1, object o2);
public class CsvEntry
{
List<string> strings;
public CsvEntry Clone()
{
string[] array = (string[])strings.ToArray().Clone();
CsvEntry e = new CsvEntry(array);
return e;
}
public CsvEntry(params string[] elements)
{
strings = new List<string>();
foreach (string s in elements)
{
string str = s;
if (str.StartsWith("\"") && str.EndsWith("\"") && str.Length >= 2)
{
str = str.Substring(1, str.Length - 2);
}
strings.Add(str);
}
}
public string this[int index]
{
get
{
return strings[index];
}
}
public int Count
{
get
{
return strings.Count;
}
}
public override string ToString()
{
int i, num;
string ret = "";
num = strings.Count;
for (i = 0; i < num; i++)
{
string s = strings[i];
s = Str.ReplaceStr(s, ",", ".", false);
s = Str.ReplaceStr(s, "\r\n", " ", false);
s = Str.ReplaceStr(s, "\r", " ", false);
s = Str.ReplaceStr(s, "\n", " ", false);
ret += s;
if ((i + 1) < num)
{
ret += ",";
}
}
return ret;
}
Type lastType = null;
object lastObject = null;
int lastIndex = -1;
public object Convert(Type type, int index)
{
if (lastType == type && lastIndex == index)
{
return lastObject;
}
lastType = type;
lastIndex = index;
lastObject = System.Convert.ChangeType(strings[index], type);
return lastObject;
}
public DateTime ToDateTime(int index)
{
return (DateTime)Convert(typeof(DateTime), index);
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,572 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Net.Mail;
using System.Net.Mime;
using System.Reflection;
using CoreUtil;
namespace CoreUtil
{
public static class Env
{
static object lockObj = new object();
static bool inited = false;
static Env()
{
initCache();
}
static void initCache()
{
lock (lockObj)
{
if (inited == false)
{
initValues();
inited = true;
}
}
}
static string homeDir;
static public string HomeDir
{
get { return homeDir; }
}
static string exeFileName;
static public string ExeFileName
{
get { return exeFileName; }
}
static string exeFileDir;
static public string ExeFileDir
{
get { return exeFileDir; }
}
static string windowsDir;
static public string WindowsDir
{
get { return windowsDir; }
}
static string systemDir;
static public string SystemDir
{
get { return systemDir; }
}
static string tempDir;
static public string TempDir
{
get { return tempDir; }
}
static string winTempDir;
static public string WinTempDir
{
get { return winTempDir; }
}
static string windowsDrive;
static public string WindowsDrive
{
get { return windowsDrive; }
}
static string programFilesDir;
static public string ProgramFilesDir
{
get { return programFilesDir; }
}
static string personalStartMenuDir;
static public string PersonalStartMenuDir
{
get { return personalStartMenuDir; }
}
static string personalProgramsDir;
static public string PersonalProgramsDir
{
get { return personalProgramsDir; }
}
static string personalStartupDir;
static public string PersonalStartupDir
{
get { return personalStartupDir; }
}
static string personalAppDataDir;
static public string PersonalAppDataDir
{
get { return personalAppDataDir; }
}
static string personalDesktopDir;
static public string PersonalDesktopDir
{
get { return personalDesktopDir; }
}
static string myDocumentsDir;
static public string MyDocumentsDir
{
get { return myDocumentsDir; }
}
static string localAppDataDir;
static public string LocalAppDataDir
{
get { return localAppDataDir; }
}
static string userName;
static public string UserName
{
get { return userName; }
}
static string userNameEx;
static public string UserNameEx
{
get { return userNameEx; }
}
static string machineName;
static public string MachineName
{
get { return machineName; }
}
static string commandLine;
public static string CommandLine
{
get { return commandLine; }
}
public static StrToken CommandLineList
{
get
{
return new StrToken(CommandLine);
}
}
static OperatingSystem osInfo;
public static OperatingSystem OsInfo
{
get { return osInfo; }
}
static bool isNt;
public static bool IsNt
{
get { return isNt; }
}
static bool is9x;
public static bool Is9x
{
get { return is9x; }
}
static bool isCe;
public static bool IsCe
{
get { return isCe; }
}
static bool isLittleEndian;
public static bool IsLittleEndian
{
get { return Env.isLittleEndian; }
}
public static bool IsBigEndian
{
get { return !IsLittleEndian; }
}
static bool isAdmin;
public static bool IsAdmin
{
get { return Env.isAdmin; }
}
static int processId;
public static int ProcessId
{
get { return Env.processId; }
}
static string myTempDir;
public static string MyTempDir
{
get { return myTempDir; }
}
static IO lockFile;
public static bool Is64BitProcess
{
get
{
return (IntPtr.Size == 8);
}
}
public static bool Is64BitWindows
{
get
{
return Is64BitProcess || Kernel.InternalCheckIsWow64();
}
}
public static bool IsWow64
{
get
{
return Kernel.InternalCheckIsWow64();
}
}
static void initValues()
{
exeFileName = IO.RemoteLastEnMark(getMyExeFileName());
if (Str.IsEmptyStr(exeFileName) == false)
{
exeFileDir = IO.RemoteLastEnMark(Path.GetDirectoryName(exeFileName));
}
else
{
exeFileDir = "";
}
homeDir = IO.RemoteLastEnMark(Kernel.GetEnvStr("HOME"));
if (Str.IsEmptyStr(homeDir))
{
homeDir = IO.RemoteLastEnMark(Kernel.GetEnvStr("HOMEDRIVE") + Kernel.GetEnvStr("HOMEPATH"));
}
if (Str.IsEmptyStr(homeDir))
{
homeDir = CurrentDir;
}
systemDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.System));
windowsDir = IO.RemoteLastEnMark(Path.GetDirectoryName(systemDir));
tempDir = IO.RemoteLastEnMark(Path.GetTempPath());
winTempDir = IO.RemoteLastEnMark(Path.Combine(windowsDir, "Temp"));
IO.MakeDir(winTempDir);
if (windowsDir.Length >= 2 && windowsDir[1] == ':')
{
windowsDrive = windowsDir.Substring(0, 2).ToUpper();
}
else
{
windowsDrive = "C:";
}
programFilesDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
personalStartMenuDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
personalProgramsDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.Programs));
personalStartupDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.Startup));
personalAppDataDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
personalDesktopDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
myDocumentsDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
localAppDataDir = IO.RemoteLastEnMark(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
userName = Environment.UserName;
try
{
userNameEx = Environment.UserDomainName + "\\" + userName;
}
catch
{
userNameEx = userName;
}
machineName = Environment.MachineName;
commandLine = initCommandLine(Environment.CommandLine);
osInfo = Environment.OSVersion;
isNt = (osInfo.Platform == PlatformID.Win32NT);
isCe = (osInfo.Platform == PlatformID.WinCE);
is9x = !(isNt || isCe);
isLittleEndian = BitConverter.IsLittleEndian;
processId = System.Diagnostics.Process.GetCurrentProcess().Id;
isAdmin = checkIsAdmin();
initMyTempDir();
}
static void deleteUnusedTempDir()
{
DirEntry[] files;
files = IO.EnumDir(Env.tempDir);
foreach (DirEntry e in files)
{
if (e.IsFolder)
{
if (e.FileName.StartsWith("NET_", StringComparison.CurrentCultureIgnoreCase) && e.FileName.Length == 8)
{
string dirFullName = Path.Combine(Env.tempDir, e.fileName);
string lockFileName = Path.Combine(dirFullName, "LockFile.dat");
bool deleteNow = false;
try
{
IO io = IO.FileOpen(lockFileName);
io.Close();
try
{
io = IO.FileOpen(lockFileName, true);
deleteNow = true;
io.Close();
}
catch
{
}
}
catch
{
DirEntry[] files2;
deleteNow = true;
try
{
files2 = IO.EnumDir(dirFullName);
foreach (DirEntry e2 in files2)
{
if (e2.IsFolder == false)
{
string fullPath = Path.Combine(dirFullName, e2.fileName);
try
{
IO io2 = IO.FileOpen(fullPath, true);
io2.Close();
}
catch
{
deleteNow = false;
}
}
}
}
catch
{
deleteNow = false;
}
}
if (deleteNow)
{
IO.DeleteDir(dirFullName, true);
}
}
}
}
}
static void initMyTempDir()
{
try
{
deleteUnusedTempDir();
}
catch
{
}
int num = 0;
while (true)
{
byte[] rand = Secure.Rand(2);
string tmp2 = Str.ByteToStr(rand);
string tmp = Path.Combine(Env.tempDir, "NET_" + tmp2);
if (IO.IsDirExists(tmp) == false && IO.MakeDir(tmp))
{
Env.myTempDir = tmp;
break;
}
if ((num++) >= 100)
{
throw new SystemException();
}
}
string lockFileName = Path.Combine(Env.myTempDir, "LockFile.dat");
lockFile = IO.FileCreate(lockFileName);
}
static bool checkIsAdmin()
{
try
{
string name = "Vpn_Check_Admin_Key_NET_" + processId.ToString();
string teststr = Str.GenRandStr();
if (Reg.WriteStr(RegRoot.LocalMachine, "", name, teststr) == false)
{
return false;
}
try
{
string ret = Reg.ReadStr(RegRoot.LocalMachine, "", name);
if (ret == teststr)
{
return true;
}
return false;
}
finally
{
Reg.DeleteValue(RegRoot.LocalMachine, "", name);
}
}
catch
{
return false;
}
}
static string initCommandLine(string src)
{
try
{
int i;
if (src.Length >= 1 && src[0] == '\"')
{
i = src.IndexOf('\"', 1);
}
else
{
i = src.IndexOf(' ');
}
if (i == -1)
{
return "";
}
else
{
return src.Substring(i + 1).TrimStart(' ');
}
}
catch
{
return "";
}
}
static string getMyExeFileName()
{
try
{
Assembly mainAssembly = Assembly.GetEntryAssembly();
Module[] modules = mainAssembly.GetModules();
return modules[0].FullyQualifiedName;
}
catch
{
return "";
}
}
static public string CurrentDir
{
get
{
return IO.RemoteLastEnMark(Environment.CurrentDirectory);
}
}
static public string NewLine
{
get
{
return Environment.NewLine;
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,233 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.IO.Compression;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using CoreUtil.Internal;
namespace CoreUtil
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct GZipHeader
{
public byte ID1, ID2, CM, FLG;
public uint MTIME;
public byte XFL, OS;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct GZipFooter
{
public uint CRC32;
public uint ISIZE;
}
public static class GZipUtil
{
public static byte[] Decompress(byte[] gzip)
{
using (GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress))
{
const int size = 4096;
byte[] buffer = new byte[size];
using (MemoryStream memory = new MemoryStream())
{
int count = 0;
do
{
count = stream.Read(buffer, 0, size);
if (count > 0)
{
memory.Write(buffer, 0, count);
}
}
while (count > 0);
return memory.ToArray();
}
}
}
}
public class GZipPacker
{
Fifo fifo;
ZStream zs;
long currentSize;
uint crc32;
bool finished;
public bool Finished
{
get { return finished; }
}
public Fifo GeneratedData
{
get
{
return this.fifo;
}
}
public GZipPacker()
{
fifo = new Fifo();
zs = new ZStream();
zs.deflateInit(-1, -15);
this.currentSize = 0;
this.crc32 = 0xffffffff;
this.finished = false;
GZipHeader h = new GZipHeader();
h.ID1 = 0x1f;
h.ID2 = 0x8b;
h.FLG = 0;
h.MTIME = Util.DateTimeToUnixTime(DateTime.Now.ToUniversalTime());
h.XFL = 0;
h.OS = 3;
h.CM = 8;
fifo.Write(Util.StructToByte(h));
}
public void Write(byte[] data, int pos, int len, bool finish)
{
byte[] srcData = Util.ExtractByteArray(data, pos, len);
byte[] dstData = new byte[srcData.Length * 2 + 100];
if (this.finished)
{
throw new ApplicationException("already finished");
}
zs.next_in = srcData;
zs.avail_in = srcData.Length;
zs.next_in_index = 0;
zs.next_out = dstData;
zs.avail_out = dstData.Length;
zs.next_out_index = 0;
if (finish)
{
zs.deflate(zlibConst.Z_FINISH);
}
else
{
zs.deflate(zlibConst.Z_SYNC_FLUSH);
}
fifo.Write(dstData, 0, dstData.Length - zs.avail_out);
currentSize += len;
this.crc32 = ZipUtil.Crc32Next(data, pos, len, this.crc32);
if (finish)
{
this.finished = true;
this.crc32 = ~this.crc32;
GZipFooter f = new GZipFooter();
f.CRC32 = this.crc32;
f.ISIZE = (uint)(this.currentSize % 0x100000000);
fifo.Write(Util.StructToByte(f));
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,170 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Net.Mail;
using System.Net.Mime;
using System.Runtime.InteropServices;
namespace CoreUtil
{
public static class Kernel
{
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsWow64Process(
[In] IntPtr hProcess,
[Out] out bool wow64Process
);
public static bool InternalCheckIsWow64()
{
if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) ||
Environment.OSVersion.Version.Major >= 6)
{
using (Process p = Process.GetCurrentProcess())
{
bool retVal;
if (!IsWow64Process(p.Handle, out retVal))
{
return false;
}
return retVal;
}
}
else
{
return false;
}
}
public static void SleepThread(int millisec)
{
ThreadObj.Sleep(millisec);
}
public static string GetEnvStr(string name)
{
string ret = Environment.GetEnvironmentVariable(name);
if (ret == null)
{
ret = "";
}
return ret;
}
static public void SelfKill()
{
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
public static Process Run(string exeName, string args)
{
Process p = new Process();
p.StartInfo.FileName = IO.InnerFilePath(exeName);
p.StartInfo.Arguments = args;
p.Start();
return p;
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,939 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Web.Mail;
using System.Threading;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using CoreUtil;
public static class AspUtil
{
public static void Redirect(Page page, string url)
{
Redirect(page, url, true);
}
public static void Redirect(Page page, string url, bool endSession)
{
MultiLang ml = new MultiLang(page, true);
ml.Redirect(url, true);
}
public static string GetCurrentRequestUrl(Page page)
{
string s = (string)page.Request.Headers["SEISAPI_PHYSICAL_URL"];
if (Str.IsEmptyStr(s) == false)
{
string[] tokens = s.Split('?');
return tokens[0];
}
return page.Request.Path;
}
public static string GetCurrentPhysicalFilePathForUser(Page page)
{
string s = (string)page.Request.Headers["SEISAPI_ORIGINAL_FILEPATH"];
if (Str.IsEmptyStr(s) == false)
{
return s;
}
return page.Request.PhysicalPath;
}
public static string RemoveDefaultHtml(string url)
{
string tmp = url.ToLower();
if (tmp.EndsWith("/default.asp") || tmp.EndsWith("/default.aspx") || tmp.EndsWith("/default.htm") || tmp.EndsWith("/default.html"))
{
return GetUrlDirNameFromPath(url);
}
else
{
return url;
}
}
public static string GetUrlDirNameFromPath(string url)
{
string ret = "";
string[] strs = url.Split('/');
int i;
if (strs.Length >= 1)
{
for (i = 0; i < strs.Length - 1; i++)
{
ret += strs[i] + "/";
}
}
return ret;
}
public static string WebPathToFilePath(System.Web.UI.Page page, string path)
{
string appRootFilePath = page.Request.PhysicalApplicationPath;
string appRootVirtualPath = page.Request.ApplicationPath;
string ret;
path = RemoveDefaultHtml(path);
if (path.ToUpper().StartsWith(appRootVirtualPath.ToUpper()) == false)
{
return null;
}
path = path.Substring(appRootVirtualPath.Length).Replace("/", "\\");
if (path.StartsWith("\\"))
{
path = path.Substring(1);
}
ret = appRootFilePath + path;
if (ret.IndexOf("..") != -1)
{
return null;
}
if (ret.EndsWith("\\"))
{
ret = GetDefaultDocumentIfExists(ret);
}
return ret;
}
public static string GetDefaultDocumentIfExists(string dir)
{
string[] targets =
{
"default.aspx",
"default.asp",
"default.html",
"default.htm",
"index.html",
"index.htm",
};
foreach (string s in targets)
{
string name = dir + s;
if (IsFileExists(name))
{
return name;
}
}
return null;
}
public static bool IsFileExists(string name)
{
return File.Exists(name);
}
}
public class MultiLang
{
public readonly Page Page;
public readonly HttpRequest Request;
public readonly HttpResponse Response;
public readonly bool IsUrlModefied;
public readonly string OriginalUrl;
public readonly string PhysicalUrl;
public readonly bool IsFilenameModified;
public readonly string OriginalFileName;
public readonly string OriginalFilePath;
public readonly string Args;
public readonly CoreLanguageClass CurrentLanguage;
public readonly CoreLanguageClass ContentsPrintLanguage;
public readonly string CurrentLanguageCode;
public readonly bool IsCurrentLanguageSupported;
public readonly string GoogleTranslateUrl;
public readonly string OriginalFullUrl;
public readonly bool IsSSL;
public readonly string Host;
public readonly string BasicHostName;
MultiLanguageFilterStream mfs;
public readonly List<KeyValuePair<string, string>> ReplaceList;
public bool DisableFilter
{
get
{
return mfs.DisableFilter;
}
set
{
mfs.DisableFilter = value;
}
}
public readonly string HtmlBody = "";
public readonly string HtmlFileName = "";
static MultiLang()
{
CoreLanguageList.RegardsJapanAsJP = true;
}
public bool IsJapanese
{
get
{
if (this.CurrentLanguage == CoreLanguageList.Japanese)
{
return true;
}
return false;
}
}
public bool IsJapanesePrinting
{
get
{
if (this.ContentsPrintLanguage == CoreLanguageList.Japanese)
{
return true;
}
return false;
}
}
public void Redirect(string url, bool endSession)
{
url = ConvertPath(url);
if (url.StartsWith("http://") || url.StartsWith("https://") || url.StartsWith("ftp://") ||
url.StartsWith("/"))
{
}
else
{
string originalUrl = OriginalUrl;
if (originalUrl.EndsWith("/"))
{
}
else
{
int i;
for (i = originalUrl.Length - 1; i >= 0; i--)
{
if (originalUrl[i] == '/' || originalUrl[i] == '\\')
{
originalUrl = originalUrl.Substring(0, i + 1);
break;
}
}
}
url = originalUrl + url;
}
Response.Redirect(url, endSession);
}
public MultiLang(Page currentPage)
: this(currentPage, false)
{
}
public MultiLang(Page currentPage, bool fast) : this(currentPage, fast, null)
{
}
public MultiLang(Page currentPage, bool fast, string basicHostName)
: this(currentPage, fast, basicHostName, new List<KeyValuePair<string, string>>())
{
}
public MultiLang(Page currentPage, bool fast, string basicHostName, List<KeyValuePair<string, string>> replaceList)
{
this.Page = currentPage;
this.Request = Page.Request;
this.Response = Page.Response;
this.BasicHostName = basicHostName;
string tmp = Page.Request.ServerVariables["HTTPS"];
string hostRaw = Page.Request.Headers["Host"];
this.ReplaceList = replaceList;
bool isSsl = false;
string[] tokens;
string host = "";
tokens = hostRaw.Split(':');
if (tokens.Length >= 1)
{
host = tokens[0];
}
host = host.ToLower();
if (tmp != null)
{
if (tmp.Equals("on", StringComparison.InvariantCultureIgnoreCase))
{
isSsl = true;
}
}
this.IsSSL = isSsl;
this.Host = host;
this.IsUrlModefied = Str.StrToBool((string)Request.Headers["SEISAPI_MODIFIED_URL"]);
this.OriginalUrl = (string)Request.Headers["SEISAPI_ORIGINAL_URL"];
int i;
i = this.OriginalUrl.IndexOf("?");
if (i != -1)
{
this.OriginalUrl = this.OriginalUrl.Substring(0, i);
}
if (Str.IsEmptyStr(this.OriginalUrl) || this.IsUrlModefied == false)
{
this.OriginalUrl = AspUtil.RemoveDefaultHtml(AspUtil.GetCurrentRequestUrl(Page));
}
string s = (string)Request.Headers["SEISAPI_ORIGINAL_FILENAME"];
if (Str.IsEmptyStr(s) == false)
{
this.IsFilenameModified = true;
this.OriginalFileName = s;
this.OriginalFilePath = (string)Request.Headers["SEISAPI_ORIGINAL_FILEPATH"];
}
string langCode = GetCurrentLangCodeFromPath(this.OriginalUrl);
this.CurrentLanguage = CoreLanguageList.GetLanguageClassByName(langCode);
this.CurrentLanguageCode = CurrentLanguage.Name;
try
{
HtmlFileName = AspUtil.WebPathToFilePath(currentPage, AspUtil.GetCurrentRequestUrl(currentPage));
}
catch
{
}
if (this.IsFilenameModified)
{
HtmlFileName = Path.Combine(Path.GetDirectoryName(HtmlFileName), Path.GetFileName(OriginalFilePath));
}
try
{
if (fast == false)
{
HtmlBody = File.ReadAllText(HtmlFileName, Str.Utf8Encoding);
}
}
catch
{
}
PhysicalUrl = AspUtil.RemoveDefaultHtml(AspUtil.GetCurrentRequestUrl((currentPage)));
Args = currentPage.Request.ServerVariables["QUERY_STRING"];
if (CurrentLanguage == CoreLanguageList.Japanese)
{
IsCurrentLanguageSupported = true;
}
else
{
IsCurrentLanguageSupported = Str.SearchStr(HtmlBody, string.Format("<!-- ml:{0} -->", CurrentLanguage.Name), 0, false) != -1;
}
GoogleTranslateUrl = string.Format("http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=ja&tl={1}&u={0}",
HttpUtility.UrlEncode((isSsl ? "https://" : "http://") + host + this.OriginalUrl, Str.Utf8Encoding),
this.CurrentLanguageCode);
OriginalFullUrl = (isSsl ? "https://" : "http://") + host + this.OriginalUrl;
ContentsPrintLanguage = this.CurrentLanguage;
if (IsCurrentLanguageSupported == false)
{
ContentsPrintLanguage = CoreLanguageList.Japanese;
}
if (fast == false)
{
mfs = new MultiLanguageFilterStream(Response.Filter, ContentsPrintLanguage, this.CurrentLanguage, this.BasicHostName, this.ReplaceList);
mfs.Page = Page;
Response.Filter = mfs;
}
}
public string ConvertPath(string url)
{
return ConvertPath(url, this.CurrentLanguage);
}
public string ConvertPath(string url, CoreLanguageClass lang)
{
string ja = CoreLanguageList.Japanese.Name;
if (url.StartsWith("/" + ja, StringComparison.InvariantCultureIgnoreCase))
{
url = "/" + lang.Name + url.Substring(ja.Length + 1);
}
return url;
}
public string GetPathForLanguage(CoreLanguageClass lang)
{
string url = PhysicalUrl;
return ConvertPath(url, lang);
}
public string GetFullUrlForLanguage(CoreLanguageClass lang)
{
string url = (IsSSL ? "https://" : "http://") + Host + GetPathForLanguage(lang);
if (Str.IsEmptyStr(Args) == false)
{
url += "?" + Args;
}
return url;
}
public string ProcStr(string str)
{
return ProcStr(str, ContentsPrintLanguage);
}
public static string ProcStrDefault(string str)
{
return ProcStr(str, CoreLanguageClass.CurrentThreadLanguageClass);
}
public static string ProcStr(string str, CoreLanguageClass lang)
{
return ProcStr(str, lang, lang);
}
public static string ProcStr(string str, CoreLanguageClass lang, CoreLanguageClass langPure)
{
MultiLanguageFilterStream st = new MultiLanguageFilterStream(null, lang, langPure, null, null);
return st.FilterString(str);
}
public static string GetCurrentLangCodeFromPath(string str)
{
char[] sps =
{
'/', '?',
};
string[] tokens = str.Split(sps, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length >= 1)
{
return tokens[0].ToLower();
}
return CoreLanguageList.Japanese.Name;
}
}
public static class MultiString
{
public const string ChangeLanguage = "[j]Select Language[e]Select Language[/]";
public const string LanguageNotSupported = "[j]申し訳ございませんが、以下のコンテンツは現在日本語で公開されていません。[e]Unfortunately, following contents are not published in English yet. [/]";
public const string ThisIsTranslatedByMachine = "Following contents are translated automatically by Google Translate.";
public const string GoogleTranslate = "[j]Google で翻訳[e]Click here to translate the contents into English by Google Now[/]";
public const string ShowSrc = "Show the original page";
public static string GetStr(string srcStr, CoreLanguageClass lang)
{
return MultiLang.ProcStr(srcStr, lang);
}
}
public class MultiLanguageFilterStream : Stream
{
public static readonly List<KeyValuePair<string, CoreLanguageClass>> langKeys = new List<KeyValuePair<string, CoreLanguageClass>>();
public readonly List<KeyValuePair<string, string>> ReplaceList = null;
public const string TagPure = "<!-- ml:pure -->";
public const string TagEndPure = "<!-- ml:endpure -->";
public bool DisableFilter = false;
public Page Page;
static MultiLanguageFilterStream()
{
langKeys.Add(new KeyValuePair<string, CoreLanguageClass>("[j]", CoreLanguageList.Japanese));
langKeys.Add(new KeyValuePair<string, CoreLanguageClass>("[e]", CoreLanguageList.English));
langKeys.Add(new KeyValuePair<string, CoreLanguageClass>("[/]", null));
}
Stack<CoreLanguageClass> stack = new Stack<CoreLanguageClass>();
CoreLanguageClass currentBodyLanguage
{
get
{
if (stack.Count == 0)
{
return null;
}
else
{
return stack.ToArray()[0];
}
}
}
bool isLang(CoreLanguageClass lang)
{
CoreLanguageClass[] langList = stack.ToArray();
foreach (CoreLanguageClass c in langList)
{
if (c != lang)
{
return false;
}
}
return true;
}
CoreLanguageClass lastBodyLanguage
{
get
{
if (stack.Count == 0)
{
return null;
}
else
{
return stack.Peek();
}
}
}
public string FilterString(string src)
{
string[] strList = Str.DivideStringMulti(src, true,
TagPure, TagEndPure);
bool b = false;
StringBuilder ret = new StringBuilder();
foreach (string str in strList)
{
if (str == TagPure)
{
b = true;
}
else if (str == TagEndPure)
{
b = false;
}
ret.Append(filterStringInner(str, b ? this.currentLanguagePure : this.currentLanguage, this.currentLanguagePure));
}
return ret.ToString();
}
string filterStringInner(string src, CoreLanguageClass useLang, CoreLanguageClass useLangPure)
{
int i;
string ret = src;
if (Str.IsEmptyStr(basicHostName) == false)
{
ret = Str.ReplaceStr(ret, "=\"/\"", "=\"http://" + basicHostName + "/\"", false);
ret = Str.ReplaceStr(ret, "=\'/\'", "=\'http://" + basicHostName + "/\'", false);
ret = Str.ReplaceStr(ret, "=\"/" + CoreLanguageList.Japanese.Name + "/\"", "=\"http://" + basicHostName + "/" + useLangPure.Name + "/\"", false);
ret = Str.ReplaceStr(ret, "=\'/" + CoreLanguageList.Japanese.Name + "/\'", "=\'http://" + basicHostName + "/" + useLangPure.Name + "/\'", false);
}
ret = Str.ReplaceStr(ret, "=\"/" + CoreLanguageList.Japanese.Name + "/", "=\"/" + useLangPure.Name + "/", false);
ret = Str.ReplaceStr(ret, "=\'/" + CoreLanguageList.Japanese.Name + "/", "=\'/" + useLangPure.Name + "/", false);
ret = Str.ReplaceStr(ret, "_lm_" + CoreLanguageList.Japanese.Name, "_lm_" + useLang.Name, false);
if (this.ReplaceList != null)
{
foreach (KeyValuePair<string, string> p in this.ReplaceList)
{
ret = Str.ReplaceStr(ret, p.Key, p.Value, false);
}
}
StringBuilder ret2 = new StringBuilder();
int next = 0;
while (true)
{
int min = int.MaxValue;
int j = -1;
for (i = 0; i < langKeys.Count; i++)
{
int r = Str.SearchStr(ret, langKeys[i].Key, next, false);
if (r != -1)
{
if (r < min)
{
j = i;
min = r;
}
}
}
if (j != -1)
{
KeyValuePair<string, CoreLanguageClass> v = langKeys[j];
if (currentBodyLanguage == null || isLang(useLang))
{
ret2.Append(ret.Substring(next, min - next));
}
if (v.Value != null)
{
if (lastBodyLanguage == null || v.Value.Id <= lastBodyLanguage.Id)
{
stack.Push(v.Value);
}
else
{
stack.Pop();
stack.Push(v.Value);
}
}
else
{
stack.Pop();
}
next = min + v.Key.Length;
}
else
{
if (currentBodyLanguage == null || isLang(useLang))
{
ret2.Append(ret.Substring(next, ret.Length - next));
}
break;
}
}
ret = ret2.ToString();
string lang = useLangPure != CoreLanguageList.Japanese ? useLangPure.Name : "ja";
if (useLangPure != CoreLanguageList.Japanese)
{
ret = Str.ReplaceStr(ret, "<meta http-equiv=\"Content-Language\" content=\"ja\" />",
string.Format("<meta http-equiv=\"Content-Language\" content=\"{0}\" />", lang), false);
}
ret = Str.ReplaceStr(ret, "<html>", string.Format("<html lang=\"{0}\">", lang), false);
next = 0;
while (true)
{
i = Str.SearchStr(ret, "<link rel=\"stylesheet\" href=\"", next, false);
if (i == -1)
{
break;
}
next = i + 1;
int j = Str.SearchStr(ret, "/>", next, false);
if (j == -1)
{
break;
}
string linkStr = ret.Substring(i, j - i + 2 - 1);
int k = Str.SearchStr(linkStr, "href=\"", 0, false);
if (k != -1)
{
int m = Str.SearchStr(linkStr, "\"", k + 6, false);
if (m != -1)
{
string fileName = linkStr.Substring(k + 6, m - k - 6);
fileName = Str.ReplaceStr(fileName, ".css", "_" + lang + ".css", false);
string linkStr2 = string.Format("<link rel=\"stylesheet\" href=\"{0}\" type=\"text/css\" />", fileName);
ret = ret.Substring(0, j + 2) + linkStr2 + ret.Substring(j + 2);
next = j + 2 + linkStr2.Length;
}
}
}
return ret;
}
Stream baseStream;
long position;
CoreLanguageClass currentLanguage;
CoreLanguageClass currentLanguagePure;
string basicHostName;
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override void Flush()
{
baseStream.Flush();
}
public override long Length
{
get { return 0; }
}
public override long Position
{
get
{
return position;
}
set
{
position = value;
}
}
public override long Seek(long offset, SeekOrigin origin)
{
return baseStream.Seek(offset, origin);
}
public override void SetLength(long value)
{
baseStream.SetLength(value);
}
public MultiLanguageFilterStream(Stream baseStream, CoreLanguageClass currentLanguage, CoreLanguageClass currentLanguagePure, string basicHostName, List<KeyValuePair<string, string>> replaceList)
{
this.baseStream = baseStream;
this.currentLanguage = currentLanguage;
this.currentLanguagePure = currentLanguagePure;
this.basicHostName = basicHostName;
this.ReplaceList = replaceList;
}
public override int Read(byte[] buffer, int offset, int count)
{
return baseStream.Read(buffer, offset, count);
}
string savedString = "";
public override void Write(byte[] buffer, int offset, int count)
{
if (DisableFilter)
{
baseStream.Write(buffer, offset, count);
return;
}
byte[] data = new byte[count];
Buffer.BlockCopy(buffer, offset, data, 0, count);
string inSrc = savedString + ByteDataToString(data);// Str.Utf8Encoding.GetString(data);
savedString = "";
if (inSrc.Length >= 2)
{
int len = inSrc.Length;
string last2 = inSrc.Substring(len - 2, 2);
string last1 = inSrc.Substring(len - 1, 1);
if (last1 == "[")
{
inSrc = inSrc.Substring(0, len - 1);
savedString = last1;
}
else if (Str.InStr(last2, "["))
{
inSrc = inSrc.Substring(0, len - 2);
savedString = last2;
}
}
string inStr = FilterString(inSrc);
data = StringToByteData(inStr);// Str.Utf8Encoding.GetBytes(inStr);
if (data.Length >= 1)
{
baseStream.Write(data, 0, data.Length);
//byte[] t = Str.Utf8Encoding.GetBytes("" + count.ToString() + "");
//baseStream.Write(t, 0, t.Length);
}
}
public static string ByteDataToString(byte[] data)
{
StringBuilder sb = new StringBuilder();
foreach (byte b in data)
{
if (b <= 0x7f && b != (byte)('\\'))
{
sb.Append((char)b);
}
else
{
sb.Append("\\" + ((uint)b).ToString("X2"));
}
}
return sb.ToString();
}
public byte[] StringToByteData(string str)
{
int i, len;
len = str.Length;
Buf b = new Buf();
for (i = 0; i < len; i++)
{
char c = str[i];
if (c == '\\')
{
string tmp = "";
//try
{
tmp = "" + str[i + 1] + str[i + 2];
}
/*catch (Exception ex)
{
tmp += "|err=" + ex.Message + ",len=" + len + ",i=" + i + "|src=" + str + "|";
byte[] aa = Str.Utf8Encoding.GetBytes(tmp);
b.Write(aa);
}*/
i += 2;
//try
{
b.WriteByte(byte.Parse(tmp, System.Globalization.NumberStyles.HexNumber));
}
//catch
{
}
}
else
{
b.WriteByte((byte)c);
}
}
return b.ByteData;
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,202 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace CoreUtil
{
public enum PackerFileFormat
{
ZipRaw,
ZipCompressed,
Tar,
TarGZip,
}
public delegate bool ProgressDelegate(string fileNameFullPath, string fileNameRelative, int currentFileNum, int totalFileNum);
public static class Packer
{
public static byte[] PackDir(PackerFileFormat format, string rootDirPath, string appendPrefixDirName)
{
return PackDir(format, rootDirPath, appendPrefixDirName, null);
}
public static byte[] PackDir(PackerFileFormat format, string topDirPath, string appendPrefixDirName, ProgressDelegate proc)
{
string[] fileList = Directory.GetFiles(topDirPath, "*", SearchOption.AllDirectories);
List<string> relativeFileList = new List<string>();
foreach (string fileName in fileList)
{
string relativePath = IO.GetRelativeFileName(fileName, topDirPath);
if (Str.IsEmptyStr(appendPrefixDirName) == false)
{
relativePath = IO.RemoteLastEnMark(appendPrefixDirName) + "\\" + relativePath;
}
relativeFileList.Add(relativePath);
}
return PackFiles(format, fileList, relativeFileList.ToArray(), proc);
}
public static byte[] PackFiles(PackerFileFormat format, string[] srcFileNameList, string[] relativeNameList)
{
return PackFiles(format, srcFileNameList, relativeNameList, null);
}
public static byte[] PackFiles(PackerFileFormat format, string[] srcFileNameList, string[] relativeNameList, ProgressDelegate proc)
{
if (srcFileNameList.Length != relativeNameList.Length)
{
throw new ApplicationException("srcFileNameList.Length != relativeNameList.Length");
}
int num = srcFileNameList.Length;
int i;
ZipPacker zip = new ZipPacker();
TarPacker tar = new TarPacker();
for (i = 0; i < num; i++)
{
if (proc != null)
{
bool ret = proc(srcFileNameList[i], relativeNameList[i], i, num);
if (ret == false)
{
continue;
}
}
byte[] srcData = File.ReadAllBytes(srcFileNameList[i]);
DateTime date = File.GetLastWriteTime(srcFileNameList[i]);
switch (format)
{
case PackerFileFormat.Tar:
case PackerFileFormat.TarGZip:
tar.AddFileSimple(relativeNameList[i], srcData, 0, srcData.Length, date);
break;
case PackerFileFormat.ZipRaw:
case PackerFileFormat.ZipCompressed:
zip.AddFileSimple(relativeNameList[i], date, FileAttributes.Normal, srcData, (format == PackerFileFormat.ZipCompressed));
break;
}
}
switch (format)
{
case PackerFileFormat.Tar:
tar.Finish();
return tar.GeneratedData.Read();
case PackerFileFormat.TarGZip:
tar.Finish();
return tar.CompressToGZip();
case PackerFileFormat.ZipCompressed:
case PackerFileFormat.ZipRaw:
zip.Finish();
return zip.GeneratedData.Read();
default:
throw new ApplicationException("format");
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,225 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
namespace CoreUtil
{
public class RC4 : ICloneable
{
uint x, y;
uint[] state;
public RC4(byte[] key)
{
state = new uint[256];
uint i, t, u, ki, si;
x = 0;
y = 0;
for (i = 0; i < 256; i++)
{
state[i] = i;
}
ki = si = 0;
for (i = 0; i < 256; i++)
{
t = state[i];
si = (si + key[ki] + t) & 0xff;
u = state[si];
state[si] = t;
state[i] = u;
if (++ki >= key.Length)
{
ki = 0;
}
}
}
private RC4()
{
}
public object Clone()
{
RC4 rc4 = new RC4();
rc4.x = this.x;
rc4.y = this.y;
rc4.state = (uint[])this.state.Clone();
return rc4;
}
public byte[] Encrypt(byte[] src)
{
return Encrypt(src, src.Length);
}
public byte[] Encrypt(byte[] src, int len)
{
return Encrypt(src, 0, len);
}
public byte[] Encrypt(byte[] src, int offset, int len)
{
byte[] dst = new byte[len];
uint x, y, sx, sy;
x = this.x;
y = this.y;
int src_i = 0, dst_i = 0, end_src_i;
for (end_src_i = src_i + len; src_i != end_src_i; src_i++, dst_i++)
{
x = (x + 1) & 0xff;
sx = state[x];
y = (sx + y) & 0xff;
state[x] = sy = state[y];
state[y] = sx;
dst[dst_i] = (byte)(src[src_i + offset] ^ state[(sx + sy) & 0xff]);
}
this.x = x;
this.y = y;
return dst;
}
public void SkipDecrypt(int len)
{
SkipEncrypt(len);
}
public void SkipEncrypt(int len)
{
uint x, y, sx, sy;
x = this.x;
y = this.y;
int src_i = 0, dst_i = 0, end_src_i;
for (end_src_i = src_i + len; src_i != end_src_i; src_i++, dst_i++)
{
x = (x + 1) & 0xff;
sx = state[x];
y = (sx + y) & 0xff;
state[x] = sy = state[y];
state[y] = sx;
}
this.x = x;
this.y = y;
}
public byte[] Decrypt(byte[] src)
{
return Decrypt(src, src.Length);
}
public byte[] Decrypt(byte[] src, int len)
{
return Decrypt(src, 0, len);
}
public byte[] Decrypt(byte[] src, int offset, int len)
{
return Encrypt(src, offset, len);
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,306 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Web.Mail;
namespace CoreUtil
{
class IniCache
{
static Dictionary<string, IniCacheEntry> caches = new Dictionary<string, IniCacheEntry>();
class IniCacheEntry
{
DateTime lastUpdate;
public DateTime LastUpdate
{
get { return lastUpdate; }
}
Dictionary<string, string> datas;
public Dictionary<string, string> Datas
{
get { return datas; }
}
public IniCacheEntry(DateTime lastUpdate, Dictionary<string, string> datas)
{
this.lastUpdate = lastUpdate;
this.datas = datas;
}
}
public static Dictionary<string, string> GetCache(string filename, DateTime lastUpdate)
{
lock (caches)
{
try
{
IniCacheEntry e = caches[filename];
if (e.LastUpdate == lastUpdate || lastUpdate.Ticks == 0)
{
return e.Datas;
}
else
{
return null;
}
}
catch
{
return null;
}
}
}
public static void AddCache(string filename, DateTime lastUpdate, Dictionary<string, string> datas)
{
lock (caches)
{
if (caches.ContainsKey(filename))
{
caches.Remove(filename);
}
caches.Add(filename, new IniCacheEntry(lastUpdate, datas));
}
}
}
public class ReadIni
{
Dictionary<string, string> datas;
bool updated;
public bool Updated
{
get
{
return updated;
}
}
public StrData this[string key]
{
get
{
string s;
try
{
s = datas[key.ToUpper()];
}
catch
{
s = null;
}
return new StrData(s);
}
}
public string[] GetKeys()
{
List<string> ret = new List<string>();
foreach (string s in datas.Keys)
{
ret.Add(s);
}
return ret.ToArray();
}
public ReadIni(string filename)
{
init(null, filename);
}
void init(byte[] data)
{
init(data, null);
}
void init(byte[] data, string filename)
{
updated = false;
lock (typeof(ReadIni))
{
string[] lines;
string srcstr;
DateTime lastUpdate = new DateTime(0);
if (filename != null)
{
lastUpdate = IO.GetLastWriteTimeUtc(filename);
datas = IniCache.GetCache(filename, lastUpdate);
}
if (datas == null)
{
if (data == null)
{
try
{
data = Buf.ReadFromFile(filename).ByteData;
}
catch
{
data = new byte[0];
datas = IniCache.GetCache(filename, new DateTime());
}
}
if (datas == null)
{
datas = new Dictionary<string, string>();
Encoding currentEncoding = Str.Utf8Encoding;
srcstr = currentEncoding.GetString(data);
lines = Str.GetLines(srcstr);
foreach (string s in lines)
{
string line = s.Trim();
if (Str.IsEmptyStr(line) == false)
{
if (line.StartsWith("#") == false &&
line.StartsWith("//") == false &&
line.StartsWith(";") == false)
{
string key, value;
if (Str.GetKeyAndValue(line, out key, out value))
{
key = key.ToUpper();
if (datas.ContainsKey(key) == false)
{
datas.Add(key, value);
}
else
{
int i;
for (i = 1; ; i++)
{
string key2 = string.Format("{0}({1})", key, i).ToUpper();
if (datas.ContainsKey(key2) == false)
{
datas.Add(key2, value);
break;
}
}
}
}
}
}
}
if (filename != null)
{
IniCache.AddCache(filename, lastUpdate, datas);
}
updated = true;
}
}
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,537 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using Microsoft.Win32;
namespace CoreUtil
{
public class AppReg
{
string appSubKey;
public string AppSubKey
{
get { return appSubKey; }
}
RegRoot rootKey;
public RegRoot RootKey
{
get { return rootKey; }
}
public AppReg(RegRoot root, string subkey)
{
subkey = subkey.TrimEnd('\\');
this.rootKey = root;
this.appSubKey = subkey;
}
public AppReg GetSubReg(string subKeyName)
{
return new AppReg(rootKey, appSubKey + "\\" + subKeyName);
}
public bool WriteStr(string name, string value)
{
return Reg.WriteStr(rootKey, appSubKey, name, value);
}
public bool WriteInt(string name, int value)
{
return Reg.WriteInt(rootKey, appSubKey, name, value);
}
public bool WriteStrList(string name, string[] values)
{
return Reg.WriteStrList(rootKey, appSubKey, name, values);
}
public bool WriteByte(string name, byte[] data)
{
return Reg.WriteByte(rootKey, appSubKey, name, data);
}
public bool DeleteValue(string name)
{
return Reg.DeleteValue(rootKey, appSubKey, name);
}
public string ReadStr(string name)
{
return Reg.ReadStr(rootKey, appSubKey, name);
}
public int ReadInt(string name)
{
return Reg.ReadInt(rootKey, appSubKey, name);
}
public string[] ReadStrList(string name)
{
return Reg.ReadStrList(rootKey, appSubKey, name);
}
public byte[] ReadByte(string name)
{
return Reg.ReadByte(rootKey, appSubKey, name);
}
}
public enum RegRoot
{
LocalMachine = 0,
CurrentUser = 1,
Users = 2,
}
public static class Reg
{
static RegistryKey rootKey(RegRoot r)
{
switch (r)
{
case RegRoot.LocalMachine:
return Registry.LocalMachine;
case RegRoot.CurrentUser:
return Registry.CurrentUser;
case RegRoot.Users:
return Registry.Users;
}
throw new ArgumentException();
}
public static string[] EnumValue(RegRoot root, string keyname)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(keyname);
if (key == null)
{
return new string[0];
}
try
{
return key.GetValueNames();
}
finally
{
key.Close();
}
}
catch
{
return new string[0];
}
}
public static string[] EnumKey(RegRoot root, string keyname)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(keyname);
if (key == null)
{
return new string[0];
}
try
{
return key.GetSubKeyNames();
}
finally
{
key.Close();
}
}
catch
{
return new string[0];
}
}
public static bool WriteByte(RegRoot root, string keyname, string valuename, byte[] data)
{
return WriteValue(root, keyname, valuename, data);
}
public static byte[] ReadByte(RegRoot root, string keyname, string valuename)
{
object o = ReadValue(root, keyname, valuename);
if (o == null)
{
return new byte[0];
}
try
{
return (byte[])o;
}
catch
{
return new byte[0];
}
}
public static bool WriteInt(RegRoot root, string keyname, string valuename, int value)
{
return WriteValue(root, keyname, valuename, value);
}
public static int ReadInt(RegRoot root, string keyname, string valuename)
{
object o = ReadValue(root, keyname, valuename);
if (o == null)
{
return 0;
}
try
{
return (int)o;
}
catch
{
return 0;
}
}
public static bool WriteStrList(RegRoot root, string keyname, string valuename, string[] value)
{
return WriteValue(root, keyname, valuename, value);
}
public static string[] ReadStrList(RegRoot root, string keyname, string valuename)
{
object o = ReadValue(root, keyname, valuename);
if (o == null)
{
return new string[0];
}
try
{
return (string[])o;
}
catch
{
return new string[0];
}
}
public static bool WriteStr(RegRoot root, string keyname, string valuename, string value)
{
return WriteValue(root, keyname, valuename, value);
}
public static string ReadStr(RegRoot root, string keyname, string valuename)
{
object o = ReadValue(root, keyname, valuename);
if (o == null)
{
return "";
}
try
{
return (string)o;
}
catch
{
return "";
}
}
public static bool WriteValue(RegRoot root, string keyname, string valuename, object o)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(keyname, true);
if (key == null)
{
key = rootKey(root).CreateSubKey(keyname);
if (key == null)
{
return false;
}
}
try
{
key.SetValue(valuename, o);
return true;
}
catch
{
return false;
}
finally
{
key.Close();
}
}
catch
{
return false;
}
}
public static object ReadValue(RegRoot root, string keyname, string valuename)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(keyname);
if (key == null)
{
return null;
}
try
{
return key.GetValue(valuename);
}
finally
{
key.Close();
}
}
catch
{
return null;
}
}
public static bool IsValue(RegRoot root, string keyname, string valuename)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(keyname);
try
{
object o = key.GetValue(valuename);
if (o == null)
{
return false;
}
}
finally
{
key.Close();
}
return true;
}
catch
{
return false;
}
}
public static bool DeleteValue(RegRoot root, string keyname, string valuename)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(keyname, true);
if (key == null)
{
return false;
}
try
{
key.DeleteValue(valuename);
return true;
}
finally
{
key.Close();
}
}
catch
{
return false;
}
}
public static bool DeleteKey(RegRoot root, string keyname)
{
return DeleteKey(root, keyname, false);
}
public static bool DeleteKey(RegRoot root, string keyname, bool deleteAll)
{
try
{
if (deleteAll == false)
{
rootKey(root).DeleteSubKey(keyname);
}
else
{
rootKey(root).DeleteSubKeyTree(keyname);
}
return true;
}
catch
{
return false;
}
}
public static bool NewKey(RegRoot root, string keyname)
{
if (IsKey(root, keyname))
{
return true;
}
try
{
RegistryKey key = rootKey(root).CreateSubKey(keyname);
if (key == null)
{
return false;
}
key.Close();
return true;
}
catch
{
return false;
}
}
public static bool IsKey(RegRoot root, string name)
{
try
{
RegistryKey key = rootKey(root).OpenSubKey(name);
if (key == null)
{
return false;
}
key.Close();
return true;
}
catch
{
return false;
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,352 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Net.Mail;
using System.Net.Mime;
using System.Reflection;
using CoreUtil;
namespace CoreUtil
{
public class Stb
{
Dictionary<string, StbEntry> entryList;
public string this[string name]
{
get
{
if (entryList.ContainsKey(name.ToUpper()))
{
return entryList[name.ToUpper()].String;
}
else
{
return "";
}
}
}
public Stb(string filename)
{
init(IO.ReadFile(filename));
}
public Stb(byte[] data)
{
init(data);
}
void init(byte[] data)
{
entryList = new Dictionary<string, StbEntry>();
MemoryStream ms = new MemoryStream(data);
StreamReader sr = new StreamReader(ms);
string prefix = "";
while (true)
{
string tmp = sr.ReadLine();
if (tmp == null)
{
break;
}
StbEntry t = StbEntry.ParseTableLine(tmp, ref prefix);
if (t != null)
{
if (entryList.ContainsKey(t.Name.ToUpper()) == false)
{
entryList.Add(t.Name.ToUpper(), t);
}
}
}
}
const string standardStbFileName = "|strtable.stb";
static string defaultStbFileName = standardStbFileName;
static object lockObj = new object();
static Stb defaultStb = null;
public static string DefaultStbFileName
{
set
{
defaultStbFileName = value;
}
get
{
return defaultStbFileName;
}
}
public static Stb DefaultStb
{
get
{
lock (lockObj)
{
if (defaultStb == null)
{
defaultStb = new Stb(Stb.DefaultStbFileName);
}
return defaultStb;
}
}
}
public static string SS(string name)
{
return DefaultStb[name];
}
public static uint II(string name)
{
return Str.StrToUInt(SS(name));
}
}
public class StbEntry
{
string name;
public string Name
{
get { return name; }
}
string str;
public string String
{
get { return str; }
}
public StbEntry(string name, string str)
{
this.name = name;
this.str = str;
}
public static StbEntry ParseTableLine(string line, ref string prefix)
{
int i, len;
int string_start;
int len_name;
string name, name2;
line = line.TrimStart(' ', '\t');
len = line.Length;
if (len == 0)
{
return null;
}
if (line[0] == '#' || (line[0] == '/' && line[1] == '/'))
{
return null;
}
bool b = false;
len_name = 0;
for (i = 0; i < line.Length; i++)
{
if (line[i] == ' ' || line[i] == '\t')
{
b = true;
break;
}
len_name++;
}
if (b == false)
{
return null;
}
name = line.Substring(0, len_name);
string_start = len_name;
for (i = len_name; i < len; i++)
{
if (line[i] != ' ' && line[i] != '\t')
{
break;
}
string_start++;
}
if (i == len)
{
return null;
}
string str = line.Substring(string_start);
str = UnescapeStr(str);
if (Str.StrCmpi(name, "PREFIX"))
{
prefix = str;
prefix = prefix.TrimStart();
if (Str.StrCmpi(prefix, "$") || Str.StrCmpi(prefix, "NULL"))
{
prefix = "";
}
return null;
}
name2 = "";
if (prefix != "")
{
name2 += prefix + "@";
}
name2 += name;
return new StbEntry(name2, str);
}
public static string UnescapeStr(string str)
{
int i, len;
string tmp;
len = str.Length;
tmp = "";
for (i = 0; i < len; i++)
{
if (str[i] == '\\')
{
i++;
switch (str[i])
{
case '\\':
tmp += '\\';
break;
case ' ':
tmp += ' ';
break;
case 'n':
case 'N':
tmp += '\n';
break;
case 'r':
case 'R':
tmp += '\r';
break;
case 't':
case 'T':
tmp += '\t';
break;
}
}
else
{
tmp += str[i];
}
}
return tmp;
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,430 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace CoreUtil
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TarHeader
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 100)]
public byte[] Name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] Mode;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] UID;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] GID;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] Size;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] MTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] CheckSum;
public byte TypeFlag;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 100)]
public byte[] LinkName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public byte[] Magic;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public byte[] Version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] UName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] GName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] DevMajor;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] DevMinor;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 155)]
public byte[] Prefix;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] Padding;
public TarHeader(bool dummy)
{
this.Name = new byte[100];
this.Mode = new byte[8];
this.UID = new byte[8];
this.GID = new byte[8];
this.Size = new byte[12];
this.MTime = new byte[12];
this.CheckSum = new byte[8];
this.LinkName = new byte[100];
this.Magic = new byte[6];
this.Version = new byte[2];
this.UName = new byte[32];
this.GName = new byte[32];
this.DevMajor = new byte[8];
this.DevMinor = new byte[8];
this.Prefix = new byte[155];
this.Padding = new byte[12];
this.TypeFlag = 0;
this.Version[0] = 0x20;
this.Version[1] = 0x00;
byte[] data = Str.ShiftJisEncoding.GetBytes("ustar ");
Util.CopyByte(this.Magic, 0, data, 0, 6);
}
public void SetName(string name, Encoding encoding)
{
byte[] data = encoding.GetBytes(name);
if (data.Length <= 100)
{
Util.CopyByte(this.Name, 0, data, 0, data.Length);
}
else
{
Util.CopyByte(this.Name, 0, data, 0, 100);
Util.CopyByte(this.Prefix, 0, data, 100, data.Length - 100);
}
}
public void SetMode(string str)
{
StrToByteArray(this.Mode, str);
}
public void SetUID(string str)
{
StrToByteArray(this.UID, str);
}
public void SetGID(string str)
{
StrToByteArray(this.GID, str);
}
public void SetSize(long size)
{
if (size >= 0x1FFFFFFFF || size < 0)
{
throw new InvalidDataException("size");
}
StrToByteArray(this.Size, Str.AppendZeroToNumString(Convert.ToString(size, 8), 11));
}
public void SetMTime(DateTime dt)
{
uint t = Util.DateTimeToUnixTime(dt.ToUniversalTime());
StrToByteArray(this.MTime, Str.AppendZeroToNumString(Convert.ToString(t, 8), 11));
}
public void CalcChecksum()
{
TarHeader h2 = this;
Array.Clear(h2.CheckSum, 0, h2.CheckSum.Length);
byte[] data = Util.StructToByte(h2);
SetChecksum(data);
}
public void SetChecksum(byte[] data)
{
ulong sum = 0;
int i;
for (i = 0; i < data.Length; i++)
{
sum += (ulong)data[i];
}
sum += 0x100;
StrToByteArray(this.CheckSum, Str.AppendZeroToNumString(Convert.ToString((long)sum, 8), 6));
this.CheckSum[7] = 0x20;
}
public void SetTypeFlag(int flag)
{
this.TypeFlag = (byte)flag.ToString()[0];
}
public void SetUName(string str)
{
StrToByteArray(this.UName, str);
}
public void SetGName(string str)
{
StrToByteArray(this.GName, str);
}
public static void StrToByteArray(byte[] dst, string str)
{
Encoding e = Str.ShiftJisEncoding;
byte[] d = e.GetBytes(str);
Array.Clear(dst, 0, dst.Length);
Util.CopyByte(dst, 0, d, 0, Math.Min(d.Length, dst.Length - 1));
}
}
public static class TarUtil
{
public static TarHeader CreateTarHeader(string name, Encoding encoding, int type, long size, DateTime dt)
{
return CreateTarHeader(name, encoding, type, size, dt, "0000777");
}
public static TarHeader CreateTarHeader(string name, Encoding encoding, int type, long size, DateTime dt, string mode)
{
TarHeader h = new TarHeader(false);
h.SetName(name, encoding);
h.SetMode(mode);
h.SetMTime(dt);
h.SetName(name, encoding);
h.SetSize(size);
h.SetTypeFlag(type);
h.SetGID("0000000");
h.SetUID("0000000");
h.CalcChecksum();
return h;
}
}
public class TarPacker
{
Fifo fifo;
Dictionary<string, int> dirList;
Encoding encoding;
public TarPacker()
: this(Str.ShiftJisEncoding)
{
}
public TarPacker(Encoding encoding)
{
fifo = new Fifo();
dirList = new Dictionary<string, int>(new StrEqualityComparer(true));
this.encoding = encoding;
}
public void AddDirectory(string name, DateTime dt, string mode)
{
name = name.Replace('\\', '/');
if (name.EndsWith("/") == false)
{
name = name + "/";
}
if (dirList.ContainsKey(name) == false)
{
TarHeader h = TarUtil.CreateTarHeader(name, encoding, 5, 0, dt, mode);
fifo.Write(Util.StructToByte(h));
dirList.Add(name, 0);
}
}
public void AddDirectory(string name, DateTime dt)
{
AddDirectory(name, dt, "0000777");
}
long currentFileSize = 0;
long currentPos = 0;
public void AddFileSimple(string name, byte[] data, int pos, int len, DateTime dt)
{
AddFileSimple(name, data, pos, len, dt, "0000777", "0000777");
}
public void AddFileSimple(string name, byte[] data, int pos, int len, DateTime dt, string directory_mode, string mode)
{
AddFileStart(name, len, dt, directory_mode, mode);
AddFileData(data, pos, len);
}
public void AddFileStart(string name, long size, DateTime dt)
{
AddFileStart(name, size, dt, "0000777", "0000777");
}
public void AddFileStart(string name, long size, DateTime dt, string directory_mode, string mode)
{
if (currentFileSize != 0 || currentPos != 0)
{
throw new ApplicationException("last file not completed.");
}
name = name.Replace('\\', '/');
if (Str.InStr(name, "/", true))
{
AddDirectory(Path.GetDirectoryName(name), dt, directory_mode);
}
TarHeader h = TarUtil.CreateTarHeader(name, encoding, 0, size, dt, mode);
fifo.Write(Util.StructToByte(h));
currentFileSize = size;
currentPos = 0;
}
public void AddFileData(byte[] data, int pos, int len)
{
long totalSize = currentPos + len;
if (totalSize > currentFileSize)
{
throw new ApplicationException("totalSize > currentFileSize");
}
fifo.Write(data, pos, len);
currentPos += len;
if (currentPos >= currentFileSize)
{
long padding = ((currentFileSize + 511) / 512) * 512 - currentFileSize;
byte[] pad = new byte[padding];
Array.Clear(pad, 0, pad.Length);
fifo.Write(pad, 0, pad.Length);
currentFileSize = 0;
currentPos = 0;
}
}
public Fifo GeneratedData
{
get
{
return this.fifo;
}
}
public void Finish()
{
byte[] data = new byte[1024];
Array.Clear(data, 0, data.Length);
fifo.Write(data);
}
public byte[] CompressToGZip()
{
GZipPacker g = new GZipPacker();
byte[] data = this.fifo.Read();
g.Write(data, 0, data.Length, true);
return g.GeneratedData.Read();
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,542 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Net.Mail;
using System.Net.Mime;
using CoreUtil;
#pragma warning disable 0618
namespace CoreUtil
{
class WorkerQueuePrivate
{
object lockObj = new object();
List<ThreadObj> thread_list;
ThreadProc thread_proc;
int num_worker_threads;
Queue<object> taskQueue = new Queue<object>();
Exception raised_exception = null;
void worker_thread(object param)
{
while (true)
{
object task = null;
lock (lockObj)
{
if (taskQueue.Count == 0)
{
return;
}
task = taskQueue.Dequeue();
}
try
{
this.thread_proc(task);
}
catch (Exception ex)
{
if (raised_exception == null)
{
raised_exception = ex;
}
Console.WriteLine(ex.Message);
}
}
}
public WorkerQueuePrivate(ThreadProc thread_proc, int num_worker_threads, object[] tasks)
{
thread_list = new List<ThreadObj>();
int i;
this.thread_proc = thread_proc;
this.num_worker_threads = num_worker_threads;
foreach (object task in tasks)
{
taskQueue.Enqueue(task);
}
raised_exception = null;
for (i = 0; i < num_worker_threads; i++)
{
ThreadObj t = new ThreadObj(worker_thread);
thread_list.Add(t);
}
foreach (ThreadObj t in thread_list)
{
t.WaitForEnd();
}
if (raised_exception != null)
{
throw raised_exception;
}
}
}
public static class Tick64
{
static object lock_obj = new object();
static uint last_value = 0;
static bool is_first = true;
static uint num_round = 0;
public static long Value
{
get
{
unchecked
{
lock (lock_obj)
{
uint current_value = (uint)(System.Environment.TickCount + 3864700935);
if (is_first)
{
last_value = current_value;
is_first = false;
}
if (last_value > current_value)
{
num_round++;
}
last_value = current_value;
ulong ret = 4294967296UL * (ulong)num_round + current_value;
return (long)ret;
}
}
}
}
public static uint ValueUInt32
{
get
{
unchecked
{
return (uint)((ulong)Value);
}
}
}
}
public class Event
{
EventWaitHandle h;
public const int Infinite = Timeout.Infinite;
public Event()
{
init(false);
}
public Event(bool manualReset)
{
init(manualReset);
}
void init(bool manualReset)
{
h = new EventWaitHandle(false, (manualReset ? EventResetMode.ManualReset : EventResetMode.AutoReset));
}
public void Set()
{
h.Set();
}
public bool Wait()
{
return Wait(Infinite);
}
public bool Wait(int millisecs)
{
return h.WaitOne(millisecs, false);
}
static EventWaitHandle[] toArray(Event[] events)
{
List<EventWaitHandle> list = new List<EventWaitHandle>();
foreach (Event e in events)
{
list.Add(e.h);
}
return list.ToArray();
}
public static bool WaitAll(Event[] events)
{
return WaitAll(events, Infinite);
}
public static bool WaitAll(Event[] events, int millisecs)
{
if (events.Length <= 64)
{
return waitAllInner(events, millisecs);
}
else
{
return waitAllMulti(events, millisecs);
}
}
static bool waitAllMulti(Event[] events, int millisecs)
{
int numBlocks = (events.Length + 63) / 64;
List<Event>[] list = new List<Event>[numBlocks];
int i;
for (i = 0; i < numBlocks; i++)
{
list[i] = new List<Event>();
}
for (i = 0; i < events.Length; i++)
{
list[i / 64].Add(events[i]);
}
double start = Time.NowDouble;
double giveup = start + (double)millisecs / 1000.0;
foreach (List<Event> o in list)
{
double now = Time.NowDouble;
if (now <= giveup || millisecs < 0)
{
int waitmsecs;
if (millisecs >= 0)
{
waitmsecs = (int)((giveup - now) * 1000.0);
}
else
{
waitmsecs = Timeout.Infinite;
}
bool ret = waitAllInner(o.ToArray(), waitmsecs);
if (ret == false)
{
return false;
}
}
else
{
return false;
}
}
return true;
}
static bool waitAllInner(Event[] events, int millisecs)
{
if (events.Length == 1)
{
return events[0].Wait(millisecs);
}
return EventWaitHandle.WaitAll(toArray(events), millisecs, false);
}
public static bool WaitAny(Event[] events)
{
return WaitAny(events, Infinite);
}
public static bool WaitAny(Event[] events, int millisecs)
{
if (events.Length == 1)
{
return events[0].Wait(millisecs);
}
return ((WaitHandle.WaitTimeout == EventWaitHandle.WaitAny(toArray(events), millisecs, false)) ? false : true);
}
public IntPtr Handle
{
get
{
return h.Handle;
}
}
}
public class ThreadData
{
static LocalDataStoreSlot slot = Thread.AllocateDataSlot();
public readonly SortedDictionary<string, object> DataList = new SortedDictionary<string, object>();
public static ThreadData CurrentThreadData
{
get
{
return GetCurrentThreadData();
}
}
public static ThreadData GetCurrentThreadData()
{
ThreadData t;
try
{
t = (ThreadData)Thread.GetData(slot);
}
catch
{
t = null;
}
if (t == null)
{
t = new ThreadData();
Thread.SetData(slot, t);
}
return t;
}
}
public delegate void ThreadProc(object userObject);
public class ThreadObj
{
static int defaultStackSize = 100000;
static LocalDataStoreSlot currentObjSlot = Thread.AllocateDataSlot();
public const int Infinite = Timeout.Infinite;
ThreadProc proc;
Thread thread;
EventWaitHandle waitInit;
EventWaitHandle waitEnd;
EventWaitHandle waitInitForUser;
public Thread Thread
{
get { return thread; }
}
object userObject;
public ThreadObj(ThreadProc threadProc)
{
init(threadProc, null, 0);
}
public ThreadObj(ThreadProc threadProc, int stacksize)
{
init(threadProc, null, stacksize);
}
public ThreadObj(ThreadProc threadProc, object userObject)
{
init(threadProc, userObject, 0);
}
public ThreadObj(ThreadProc threadProc, object userObject, int stacksize)
{
init(threadProc, userObject, stacksize);
}
void init(ThreadProc threadProc, object userObject, int stacksize)
{
if (stacksize == 0)
{
stacksize = defaultStackSize;
}
this.proc = threadProc;
this.userObject = userObject;
waitInit = new EventWaitHandle(false, EventResetMode.AutoReset);
waitEnd = new EventWaitHandle(false, EventResetMode.ManualReset);
waitInitForUser = new EventWaitHandle(false, EventResetMode.ManualReset);
this.thread = new Thread(new ParameterizedThreadStart(commonThreadProc), stacksize);
this.thread.Start(this);
waitInit.WaitOne();
}
public static int DefaultStackSize
{
get
{
return defaultStackSize;
}
set
{
defaultStackSize = value;
}
}
void commonThreadProc(object obj)
{
Thread.SetData(currentObjSlot, this);
waitInit.Set();
try
{
this.proc(this.userObject);
}
finally
{
waitEnd.Set();
}
}
public static ThreadObj GetCurrentThreadObj()
{
return (ThreadObj)Thread.GetData(currentObjSlot);
}
public static void NoticeInited()
{
GetCurrentThreadObj().waitInitForUser.Set();
}
public void WaitForInit()
{
waitInitForUser.WaitOne();
}
public void WaitForEnd(int timeout)
{
waitEnd.WaitOne(timeout, false);
}
public void WaitForEnd()
{
waitEnd.WaitOne();
}
public static void Sleep(int millisec)
{
if (millisec == 0x7fffffff)
{
millisec = ThreadObj.Infinite;
}
Thread.Sleep(millisec);
}
public static void Yield()
{
Thread.Sleep(0);
}
public static void ProcessWorkQueue(ThreadProc thread_proc, int num_worker_threads, object[] tasks)
{
WorkerQueuePrivate q = new WorkerQueuePrivate(thread_proc, num_worker_threads, tasks);
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

View File

@ -0,0 +1,174 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Web.Mail;
namespace CoreUtil
{
class TimeHelper
{
internal Stopwatch Sw;
internal long Freq;
internal DateTime FirstDateTime;
public TimeHelper()
{
FirstDateTime = DateTime.Now;
Sw = new Stopwatch();
Sw.Start();
Freq = Stopwatch.Frequency;
}
public DateTime GetDateTime()
{
return FirstDateTime + this.Sw.Elapsed;
}
}
public static class Time
{
static TimeHelper h = new TimeHelper();
static TimeSpan baseTimeSpan = new TimeSpan(0, 0, 1);
static public TimeSpan NowTimeSpan
{
get
{
return h.Sw.Elapsed.Add(baseTimeSpan);
}
}
static public long NowLong100Usecs
{
get
{
return NowTimeSpan.Ticks;
}
}
static public long NowLongMillisecs
{
get
{
return NowLong100Usecs / 10000;
}
}
static public long Tick64
{
get
{
return NowLongMillisecs;
}
}
static public double NowDouble
{
get
{
return (double)NowLong100Usecs / (double)10000000.0;
}
}
static public DateTime NowDateTime
{
get
{
return h.GetDateTime();
}
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,303 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Web.Mail;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Xml.Serialization;
using System.DirectoryServices;
using CoreUtil;
using CoreUtil.Internal;
namespace CoreUtil
{
public static class Win32
{
static Win32()
{
}
public static void CreateUser(string machineName, string userName, string password, string description)
{
Str.NormalizeString(ref userName);
Str.NormalizeString(ref password);
Str.NormalizeString(ref description);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry newUser = sam.Children.Add(userName, "user"))
{
newUser.Invoke("SetPassword", new object[] { password });
newUser.Invoke("Put", new object[] { "Description", description });
newUser.CommitChanges();
Console.WriteLine(newUser.Path);
}
}
try
{
AddUserToGroup(machineName, userName, "Users");
}
catch
{
}
}
public static void ChangeUserPassword(string machineName, string userName, string oldPassword, string newPassword)
{
Str.NormalizeString(ref userName);
Str.NormalizeString(ref oldPassword);
Str.NormalizeString(ref newPassword);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry user = sam.Children.Find(userName, "user"))
{
user.Invoke("ChangePassword", oldPassword, newPassword);
}
}
}
public static void SetUserPassword(string machineName, string userName, string password)
{
Str.NormalizeString(ref userName);
Str.NormalizeString(ref password);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry user = sam.Children.Find(userName, "user"))
{
user.Invoke("SetPassword", password);
}
}
}
public static string[] GetMembersOfGroup(string machineName, string groupName)
{
List<string> ret = new List<string>();
Str.NormalizeString(ref groupName);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry g = sam.Children.Find(groupName, "group"))
{
object members = g.Invoke("Members", null);
foreach (object member in (IEnumerable)members)
{
using (DirectoryEntry e = new DirectoryEntry(member))
{
ret.Add(e.Name);
}
}
return ret.ToArray();
}
}
}
public static bool IsUserMemberOfGroup(string machineName, string userName, string groupName)
{
Str.NormalizeString(ref userName);
Str.NormalizeString(ref groupName);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry g = sam.Children.Find(groupName, "group"))
{
using (DirectoryEntry u = sam.Children.Find(userName, "user"))
{
return (bool)g.Invoke("IsMember", u.Path);
}
}
}
}
public static void DeleteUserFromGroup(string machineName, string userName, string groupName)
{
Str.NormalizeString(ref userName);
Str.NormalizeString(ref groupName);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry g = sam.Children.Find(groupName, "group"))
{
using (DirectoryEntry u = sam.Children.Find(userName, "user"))
{
g.Invoke("Remove", u.Path);
}
}
}
}
public static void AddUserToGroup(string machineName, string userName, string groupName)
{
Str.NormalizeString(ref userName);
Str.NormalizeString(ref groupName);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry g = sam.Children.Find(groupName, "group"))
{
using (DirectoryEntry u = sam.Children.Find(userName, "user"))
{
g.Invoke("Add", u.Path);
}
}
}
}
public static void DeleteUser(string machineName, string userName)
{
Str.NormalizeString(ref userName);
using (DirectoryEntry sam = OpenSam(machineName))
{
using (DirectoryEntry u = sam.Children.Find(userName, "user"))
{
sam.Children.Remove(u);
}
}
}
public static bool IsUserExists(string machineName, string userName)
{
Str.NormalizeString(ref userName);
using (DirectoryEntry sam = OpenSam(machineName))
{
try
{
using (DirectoryEntry user = sam.Children.Find(userName, "user"))
{
if (user == null)
{
return false;
}
return true;
}
}
catch (COMException ce)
{
if ((uint)ce.ErrorCode == 0x800708AD)
{
return false;
}
else
{
throw;
}
}
}
}
public static DirectoryEntry OpenSam()
{
return OpenSam(null);
}
public static DirectoryEntry OpenSam(string machineName)
{
if (Str.IsEmptyStr(machineName))
{
machineName = Env.MachineName;
}
return new DirectoryEntry(string.Format("WinNT://{0},computer",
machineName));
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,482 @@
// CoreUtil
//
// Copyright (C) 2012-2014 Daiyuu Nobori. All Rights Reserved.
// Copyright (C) 2012-2014 SoftEther VPN Project at University of Tsukuba. All Rights Reserved.
// Comments: Tetsuo Sugiyama, Ph.D.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
// SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
// PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
// COUNTRIES MIGHT BE RESTRICTED.
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
using System;
using System.Threading;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace CoreUtil
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ZipDataHeader
{
public uint Signature;
public ushort NeedVer;
public ushort Option;
public ushort CompType;
public ushort FileTime;
public ushort FileDate;
public uint Crc32;
public uint CompSize;
public uint UncompSize;
public ushort FileNameLen;
public ushort ExtraLen;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ZipDataFooter
{
public uint Signature;
public uint Crc32;
public uint CompSize;
public uint UncompSize;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ZipDirHeader
{
public uint Signature;
public ushort MadeVer;
public ushort NeedVer;
public ushort Option;
public ushort CompType;
public ushort FileTime;
public ushort FileDate;
public uint Crc32;
public uint CompSize;
public uint UncompSize;
public ushort FileNameLen;
public ushort ExtraLen;
public ushort CommentLen;
public ushort DiskNum;
public ushort InAttr;
public uint OutAttr;
public uint HeaderPos;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ZipEndHeader
{
public uint Signature;
public ushort DiskNum;
public ushort StartDiskNum;
public ushort DiskDirEntry;
public ushort DirEntry;
public uint DirSize;
public uint StartPos;
public ushort CommentLen;
}
public static class ZipUtil
{
static ZipUtil()
{
initCrc32();
}
static uint[] table;
const int crcTableSize = 256;
static void initCrc32()
{
table = new uint[crcTableSize];
uint poly = 0xEDB88320;
uint u, i, j;
for (i = 0; i < 256; i++)
{
u = i;
for (j = 0; j < 8; j++)
{
if ((u & 0x1) != 0)
{
u = (u >> 1) ^ poly;
}
else
{
u >>= 1;
}
}
table[i] = u;
}
}
public static uint Crc32(byte[] buf)
{
return Crc32(buf, 0, buf.Length);
}
public static uint Crc32(byte[] buf, int pos, int len)
{
return Crc32Finish(Crc32First(buf, pos, len));
}
public static uint Crc32First(byte[] buf, int pos, int len)
{
return Crc32Next(buf, pos, len, 0xffffffff);
}
public static uint Crc32Next(byte[] buf, int pos, int len, uint lastCrc32)
{
uint ret = lastCrc32;
for (uint i = 0; i < len; i++)
{
ret = (ret >> 8) ^ table[buf[pos + i] ^ (ret & 0xff)];
}
return ret;
}
public static uint Crc32Finish(uint lastCrc32)
{
return ~lastCrc32;
}
}
public class ZipPacker
{
public const uint Signature = 0x04034B50;
public const uint SignatureEnd = 0x06054B50;
public const ushort Version = 10;
public const ushort VersionWithCompress = 20;
public Encoding Encoding = Str.ShiftJisEncoding;
class File
{
public string Name;
public long Size;
public DateTime DateTime;
public FileAttributes Attributes;
public long CurrentSize;
public long CompressSize;
public uint Crc32;
public uint HeaderPos;
public Encoding Encoding;
public bool Compress;
public CoreUtil.Internal.ZStream ZStream;
public void WriteZipDataHeader(ref ZipDataHeader h, bool writeSizes)
{
h.Signature = Signature;
h.NeedVer = Version;
h.CompType = 0;
h.FileTime = Util.DateTimeToDosTime(this.DateTime);
h.FileDate = Util.DateTimeToDosDate(this.DateTime);
h.Option = 8;
if (writeSizes == false)
{
h.CompSize = h.UncompSize = 0;
h.Crc32 = 0;
if (this.Compress)
{
h.NeedVer = VersionWithCompress;
h.CompType = 8;
}
}
else
{
h.CompSize = h.UncompSize = (uint)this.Size;
if (this.Compress)
{
h.CompSize = (uint)this.CompressSize;
h.CompType = 8;
}
h.Crc32 = this.Crc32;
}
h.FileNameLen = (ushort)this.Encoding.GetByteCount(this.Name);
h.ExtraLen = 0;
}
public void WriteZipDataFooter(ref ZipDataFooter h)
{
h.Signature = 0x08074B50;
if (this.Compress == false)
{
h.CompSize = h.UncompSize = (uint)this.Size;
}
else
{
h.CompSize = (uint)this.CompressSize;
h.UncompSize = (uint)this.Size;
}
h.Crc32 = this.Crc32;
}
}
Fifo fifo;
List<File> fileList;
public Fifo GeneratedData
{
get
{
return this.fifo;
}
}
public ZipPacker()
{
fifo = new Fifo();
fileList = new List<File>();
}
File currentFile = null;
public void AddFileSimple(string name, DateTime dt, FileAttributes attribute, byte[] data)
{
AddFileSimple(name, dt, attribute, data, false);
}
public void AddFileSimple(string name, DateTime dt, FileAttributes attribute, byte[] data, bool compress)
{
AddFileStart(name, data.Length, dt, attribute, compress);
AddFileData(data, 0, data.Length);
}
public void AddFileStart(string name, long size, DateTime dt, FileAttributes attribute)
{
AddFileStart(name, size, dt, attribute, false);
}
public void AddFileStart(string name, long size, DateTime dt, FileAttributes attribute, bool compress)
{
if (currentFile != null)
{
throw new ApplicationException("currentFile != null");
}
name = name.Replace("/", "\\");
File f = new File();
f.Encoding = this.Encoding;
f.Name = name;
f.Size = size;
f.DateTime = dt;
f.Attributes = attribute;
f.Compress = compress;
this.fileList.Add(f);
ZipDataHeader h = new ZipDataHeader();
f.HeaderPos = (uint)fifo.TotalWriteSize;
f.WriteZipDataHeader(ref h, false);
fifo.Write(Util.StructToByte(h));
fifo.Write(this.Encoding.GetBytes(f.Name));
f.Crc32 = 0xffffffff;
if (compress)
{
f.ZStream = new CoreUtil.Internal.ZStream();
f.ZStream.deflateInit(-1, -15);
}
currentFile = f;
}
public long AddFileData(byte[] data, int pos, int len)
{
long totalSize = currentFile.CurrentSize + len;
if (totalSize > currentFile.Size)
{
throw new ApplicationException("totalSize > currentFile.Size");
}
if (currentFile.Compress == false)
{
fifo.Write(data, pos, len);
}
else
{
CoreUtil.Internal.ZStream zs = currentFile.ZStream;
byte[] srcData = Util.ExtractByteArray(data, pos, len);
byte[] dstData = new byte[srcData.Length * 2 + 100];
zs.next_in = srcData;
zs.avail_in = srcData.Length;
zs.next_in_index = 0;
zs.next_out = dstData;
zs.avail_out = dstData.Length;
zs.next_out_index = 0;
if (currentFile.Size == (currentFile.CurrentSize + len))
{
zs.deflate(CoreUtil.Internal.zlibConst.Z_FINISH);
}
else
{
zs.deflate(CoreUtil.Internal.zlibConst.Z_SYNC_FLUSH);
}
fifo.Write(dstData, 0, dstData.Length - zs.avail_out);
currentFile.CompressSize += dstData.Length - zs.avail_out;
Util.NoOP();
}
currentFile.CurrentSize += len;
currentFile.Crc32 = ZipUtil.Crc32Next(data, pos, len, currentFile.Crc32);
long ret = currentFile.Size - currentFile.CurrentSize;
if (ret == 0)
{
currentFile.Crc32 = ~currentFile.Crc32;
addFileFooter();
currentFile = null;
}
return ret;
}
void addFileFooter()
{
ZipDataFooter f = new ZipDataFooter();
currentFile.WriteZipDataFooter(ref f);
fifo.Write(Util.StructToByte(f));
}
public void Finish()
{
long posStart = fifo.TotalWriteSize;
foreach (File f in this.fileList)
{
ZipDirHeader d = new ZipDirHeader();
d.Signature = 0x02014B50;// ZipPacker.Signature;
d.MadeVer = Version;
ZipDataHeader dh = new ZipDataHeader();
f.WriteZipDataHeader(ref dh, true);
if (f.Compress)
{
dh.CompType = 8;
dh.CompSize = (uint)f.CompressSize;
dh.NeedVer = ZipPacker.VersionWithCompress;
}
d.NeedVer = dh.NeedVer;
d.Option = dh.Option;
d.CompType = dh.CompType;
d.FileTime = dh.FileTime;
d.FileDate = dh.FileDate;
d.Crc32 = dh.Crc32;
d.CompSize = dh.CompSize;
d.UncompSize = dh.UncompSize;
d.FileNameLen = dh.FileNameLen;
d.ExtraLen = dh.ExtraLen;
d.CommentLen = 0;
d.DiskNum = 0;
d.InAttr = 0;
d.OutAttr = (ushort)f.Attributes;
d.HeaderPos = f.HeaderPos;
fifo.Write(Util.StructToByte(d));
fifo.Write(this.Encoding.GetBytes(f.Name));
}
long posEnd = fifo.TotalWriteSize;
ZipEndHeader e = new ZipEndHeader();
e.Signature = ZipPacker.SignatureEnd;
e.DiskNum = e.StartDiskNum = 0;
e.DiskDirEntry = e.DirEntry = (ushort)this.fileList.Count;
e.DirSize = (uint)(posEnd - posStart);
e.StartPos = (uint)posStart;
e.CommentLen = 0;
fifo.Write(Util.StructToByte(e));
}
}
}
// Developed by SoftEther VPN Project at University of Tsukuba in Japan.
// Department of Computer Science has dozens of overly-enthusiastic geeks.
// Join us: http://www.tsukuba.ac.jp/english/admission/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,431 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CDF_BUTTON_ADD" xml:space="preserve">
<value>[j]追加[e]Add[/]</value>
</data>
<data name="CDF_BUTTON_CANCEL" xml:space="preserve">
<value> [j]キャンセル[e]Cancel[/] </value>
</data>
<data name="CDF_BUTTON_COMPLETE" xml:space="preserve">
<value> [j]完 了[e]Complete[/] </value>
</data>
<data name="CDF_BUTTON_DELETE" xml:space="preserve">
<value>[j]削除[e]Delete[/]</value>
</data>
<data name="CDF_BUTTON_EDIT" xml:space="preserve">
<value>[j]編集[e]Edit[/]</value>
</data>
<data name="CDF_BUTTON_MODIFY" xml:space="preserve">
<value> [j]修正する[e]Modify[/] </value>
</data>
<data name="CDF_BUTTON_OK" xml:space="preserve">
<value> O K </value>
</data>
<data name="CDF_BUTTON_SENDING" xml:space="preserve">
<value> [j]処理中[e]Wait[/]...</value>
</data>
<data name="CDF_CANDIDATES" xml:space="preserve">
<value> [j]最近の候補[e]Recent Candidates[/]: </value>
</data>
<data name="CDF_DATE_EMPTY" xml:space="preserve">
<value>[j]日付が入力されていません。[e]Date field is empty.[/]</value>
</data>
<data name="CDF_DATE_MAX" xml:space="preserve">
<value>[j]{0} 以前の日付を指定してください。[e]Please specify a date before {0}.[/]</value>
</data>
<data name="CDF_DATE_MIN" xml:space="preserve">
<value>[j]{0} 以降の日付を指定してください。[e]Please specift a date since {0}.[/]</value>
</data>
<data name="CDF_DATE_NOTDATE" xml:space="preserve">
<value>[j]日付として認識できない文字列が入力されています。[e]Can't recognize as a valid date.[/]</value>
</data>
<data name="CDF_DL_ALL" xml:space="preserve">
<value>[j]全件表示 ({0} 件)[e]Total ({0} entities)[/]</value>
</data>
<data name="CDF_DOWNLOAD" xml:space="preserve">
<value>[j]ダウンロード[e]Download[/]</value>
</data>
<data name="CDF_DT_EMPTY" xml:space="preserve">
<value>[j]日時が入力されていません。[e]Date and Time are empty.[/]</value>
</data>
<data name="CDF_DT_MAX" xml:space="preserve">
<value>[j]{0} 以前の日時を指定してください。[e]Please specify a date and a time before {0}.[/]</value>
</data>
<data name="CDF_DT_MIN" xml:space="preserve">
<value>[j]{0} 以降の日時を指定してください。[e]Please specify a date and a time since {0}.[/]</value>
</data>
<data name="CDF_DT_NOTDT" xml:space="preserve">
<value>[j]日時として認識できない文字列が入力されています。[e]Can't recognize as a valid date and a time.[/]</value>
</data>
<data name="CDF_EXAMPLE" xml:space="preserve">
<value>[j]記入例[e]Example[/]</value>
</data>
<data name="CDF_GOTHIC" xml:space="preserve">
<value>[j] ゴシック[e]MS Gothic[/]</value>
</data>
<data name="CDF_GRID_ERROR_1" xml:space="preserve">
<value>[j]データ構造のフィールド数が 1 でありません。[e]The number of fields of data structures is not one.[/]</value>
</data>
<data name="CDF_GRID_ERROR_2" xml:space="preserve">
<value>[j]データ構造がリストでありません。[e]The data structure is not a list.[/]</value>
</data>
<data name="CDF_INT_MAX" xml:space="preserve">
<value>[j]数値は {0} 以下を指定してください。[e]The value must be {0} or less.[/]</value>
</data>
<data name="CDF_INT_MIN" xml:space="preserve">
<value>[j]数値は {0} 以上を指定してください。[e]The value must be {0} or more.[/]</value>
</data>
<data name="CDF_INT_NOTINTEGER" xml:space="preserve">
<value>[j]数値が正しく入力されていません。[e]The value can't be recognized as a formal figure.[/]</value>
</data>
<data name="CDF_INT_NOT_NUMBER_CHAR" xml:space="preserve">
<value>[j]整数以外の文字が入力されています。[e]The value can't be recognized as an integer.[/]</value>
</data>
<data name="CDF_INVALID" xml:space="preserve">
<value>[j]データ "{0}" はこのリストでは不正です。[e]The data "{0}" is invalid at this list.[/]</value>
</data>
<data name="CDF_INVALID_EMAIL" xml:space="preserve">
<value>[j]メールアドレスが不正です。[e]The mail address is invalid.[/]</value>
</data>
<data name="CDF_LIST_FORMAT" xml:space="preserve">
<value>[j]【 {0} 個目の項目 (合計 {1} 個中) - {2} 】[e]Item of piece {0} (Total: {1} entities) - {2}[/]</value>
</data>
<data name="CDF_NOITEM" xml:space="preserve">
<value>[j]項目なし[e]No Entities[/]</value>
</data>
<data name="CDF_NOT_SELECTED" xml:space="preserve">
<value>[j]項目が選択されていません。[e]You have to select an entity.[/]</value>
</data>
<data name="CDF_NOT_SELECTED_2" xml:space="preserve">
<value>[j]正しく選択されていません。[e]You have to select correctly.[/]</value>
</data>
<data name="CDF_NO_CDFCLASS" xml:space="preserve">
<value>CdfClass 属性が正しく指定されていないクラス %s が指定されました。</value>
</data>
<data name="CDF_NO_SINGLE_ATT" xml:space="preserve">
<value>%s 項目に %s 属性が 1 つ指定されていません。</value>
</data>
<data name="CDF_NO_SINGLE_GENERIC_TYPE" xml:space="preserve">
<value>%s 項目のジェネリック型が 1 つ指定されていません。</value>
</data>
<data name="CDF_PAGING_FORMAT_1" xml:space="preserve">
<value>[j]ページ {0}[e]Page {0}[/]</value>
</data>
<data name="CDF_PAGING_FORMAT_2" xml:space="preserve">
<value>[j]最新 {0} 件[e]Latest: {0} entities[/]</value>
</data>
<data name="CDF_PAGING_HELPSTR_FORMAT" xml:space="preserve">
<value>[j] ({2}: {0} {1})[e] ({2}: {0} - {1})[/]</value>
</data>
<data name="CDF_PLEASE_SELECT" xml:space="preserve">
<value>[j]▼選択してください▼[e]- Please Select Here -[/]</value>
</data>
<data name="CDF_REMOVE" xml:space="preserve">
<value>[j]削除[e]Delete[/]</value>
</data>
<data name="CDF_REMOVEMSG" xml:space="preserve">
<value>[j]この項目を削除します。よろしいですか?[e]Do you want to delete this entity?[/]</value>
</data>
<data name="CDF_ROW_EMPTY" xml:space="preserve">
<value>[j]項目が 1 件も見つかりませんでした。[e]No entity is found.[/]</value>
</data>
<data name="CDF_SELECTABLE" xml:space="preserve">
<value>[j]▽選択可能[e]- Selectable -[/]</value>
</data>
<data name="CDF_SORT_1" xml:space="preserve">
<value>[j]▲「{0}」でソート[e]Sort by "{0}" Ascending[/]</value>
</data>
<data name="CDF_SORT_2" xml:space="preserve">
<value>[j]▼「{0}」で逆ソート[e]Sort by "{0}" Descending[/]</value>
</data>
<data name="CDF_SORT_DEF1" xml:space="preserve">
<value>[j]▲標準のソート[e]Standard Ascending Sort[/]</value>
</data>
<data name="CDF_SORT_DEF2" xml:space="preserve">
<value>[j]▼標準の逆ソート[e]Standard Descending Sort[/]</value>
</data>
<data name="CDF_STRING_INVALIDCHAR" xml:space="preserve">
<value>[j]使用できない文字が含まれています。[e]There are some invalid characters which can't be used.[/]</value>
</data>
<data name="CDF_STRING_MAX" xml:space="preserve">
<value>[j]文字数は {0} 以下にする必要があります。[e]The number of characters must be {0} or less.[/]</value>
</data>
<data name="CDF_STRING_MIN" xml:space="preserve">
<value>[j]文字を {0} 文字以上入力する必要があります。[e]The number of characters must be {0} or more.[/]</value>
</data>
<data name="CDF_STRING_NOLINE" xml:space="preserve">
<value>[j]改行文字を含めることはできません。[e]There must not be any New-Line characters in the string.[/]</value>
</data>
<data name="CDF_STRING_NONPRINTABLE" xml:space="preserve">
<value>[j]表示不可能な文字コードが含まれています。[e]There must not be any Non-Printable characters in the string.[/]</value>
</data>
<data name="CDF_TEXT_CONFIRM" xml:space="preserve">
<value>[j]入力いただいた内容を確認のため表示しています。内容をよくご確認ください。&lt;BR&gt;この内容で確定する場合は [OK] ボタンを、修正する場合は [修正する] ボタンをクリックしてください。[e]Please confirm the printed data which you input. Please read it carefully.&lt;BR&gt;If you want to commit with this data, click the "OK" button. Otherwise, click the "Modify" button.[/]</value>
</data>
<data name="CDF_TEXT_CONFIRM_ERROR" xml:space="preserve">
<value>[j]エラーが発生しました。内容を見直してください。修正する場合は [修正する] ボタンをクリックしてください。[e]An error has been occurred. Please confirm the fields. To modify it, click the "Modify" button.[/]</value>
</data>
<data name="CDF_TEXT_OK" xml:space="preserve">
<value>[j]入力が完了したら [OK] ボタンを、入力をキャンセルするには [キャンセル] ボタンをクリックしてください。[e]Please click the "OK" button after you complete filling all nessesary fields. To cancel inputting, click the "Cancel" button.[/]</value>
</data>
<data name="CDF_TIME_EMPTY" xml:space="preserve">
<value>[j]時刻が入力されていません。[e]Time is empty.[/]</value>
</data>
<data name="CDF_TIME_MAX" xml:space="preserve">
<value>[j]{0} 以前の時刻を指定してください。[e]Please specify a time before {0}.[/]</value>
</data>
<data name="CDF_TIME_MIN" xml:space="preserve">
<value>[j]{0} 以降の時刻を指定してください。[e]Please specify a time after {0}.[/]</value>
</data>
<data name="CDF_TIME_NOTTIME" xml:space="preserve">
<value>[j]時刻として認識できない文字列が入力されています。[e]Can't recognize as a valid time.[/]</value>
</data>
<data name="CDF_UNSUPPORTED" xml:space="preserve">
<value>[j]フィールド %s の型 %s がサポートされていません。[e]In the field "%s", the type "%s" is not supported.[/]</value>
</data>
<data name="CMD_CT_STD_COLUMN_1" xml:space="preserve">
<value>Item</value>
</data>
<data name="CMD_CT_STD_COLUMN_2" xml:space="preserve">
<value>Value</value>
</data>
<data name="CMD_EVAL_DATE_TIME_FAILED" xml:space="preserve">
<value>The date and time specification is invalid. \nThe date and time must be in the same format as "2005/10/08 19:30:00" where 6 integers are specified, representing year/month/day hour:minute:second separated by forward slashes, a space and then colons. Specify 4 digits for the year.</value>
</data>
<data name="CMD_EVAL_INT" xml:space="preserve">
<value>You must specify an integer that is not less than 1.</value>
</data>
<data name="CMD_EVAL_MIN_MAX" xml:space="preserve">
<value>You must specify an integer in the range from %u to %u for the value.</value>
</data>
<data name="CMD_EVAL_NOT_EMPTY" xml:space="preserve">
<value>You cannot make a blank specification.</value>
</data>
<data name="CMD_EVAL_PORT" xml:space="preserve">
<value>Port number is invalid. Specify a port number that is within the range of 1 to 65535.</value>
</data>
<data name="CMD_EVAL_SAFE" xml:space="preserve">
<value>The string contains unusable characters.</value>
</data>
<data name="CMD_EXEC_MSG_NAME" xml:space="preserve">
<value>%S command - %s</value>
</data>
<data name="CMD_FILE_NAME_EMPTY" xml:space="preserve">
<value>The file name is not specified.</value>
</data>
<data name="CMD_FILE_NOT_FOUND" xml:space="preserve">
<value>Cannot find specified file "%s".</value>
</data>
<data name="CMD_HELP_1" xml:space="preserve">
<value>You can use the following %u commands:</value>
</data>
<data name="CMD_HELP_2" xml:space="preserve">
<value>To reference the usage for each command, input "command name /?" to view a help.</value>
</data>
<data name="CMD_HELP_ARGS" xml:space="preserve">
<value>Parameters:</value>
</data>
<data name="CMD_HELP_DESCRIPTION" xml:space="preserve">
<value>Purpose:</value>
</data>
<data name="CMD_HELP_HELP" xml:space="preserve">
<value>Description:</value>
</data>
<data name="CMD_HELP_TITLE" xml:space="preserve">
<value>Help for command "%S"</value>
</data>
<data name="CMD_HELP_USAGE" xml:space="preserve">
<value>Usage:</value>
</data>
<data name="CMD_PARSE_IP_SUBNET_ERROR_1" xml:space="preserve">
<value>"IP アドレス/サブネットマスク" の形式で指定してください。
IP アドレスは 192.168.0.1 のように 10 進数をドットで区切って指定します。サブネットマスクは 255.255.255.0 のように 10 進数をドットで区切って指定するか、24 のように先頭からのビット長を 10 進数で指定できます。
単一のホストを指定するには、サブネットマスクを 255.255.255.255 または 32 として指定します。
(例)
192.168.0.1/24
192.168.0.1/255.255.255.0
192.168.0.5/255.255.255.255
</value>
</data>
<data name="CMD_PARSE_IP_SUBNET_ERROR_2" xml:space="preserve">
<value>指定された IP アドレスはネットワークアドレスではありません。</value>
</data>
<data name="CMD_PROMPT" xml:space="preserve">
<value>Enter a value: </value>
</data>
<data name="CMD_PROPMT_PORT" xml:space="preserve">
<value>Input the port number: </value>
</data>
<data name="CMD_UNKNOWM" xml:space="preserve">
<value>There is no description for this command.</value>
</data>
<data name="CMD_UNKNOWN_ARGS" xml:space="preserve">
<value>There is no command execution example.</value>
</data>
<data name="CMD_UNKNOWN_HELP" xml:space="preserve">
<value>There is no detailed description for this command. If you would like to know more detail about this command, please refer to the manual or online documentation.</value>
</data>
<data name="CMD_UNKNOWN_PARAM" xml:space="preserve">
<value>There is no description for this parameter.</value>
</data>
<data name="CON_AMBIGIOUS_CMD" xml:space="preserve">
<value>"%S": The command-name is ambiguous.</value>
</data>
<data name="CON_AMBIGIOUS_CMD_1" xml:space="preserve">
<value>The specified command name matches the following multiple commands.</value>
</data>
<data name="CON_AMBIGIOUS_CMD_2" xml:space="preserve">
<value>Please re-specify the command name more strictly.</value>
</data>
<data name="CON_AMBIGIOUS_PARAM" xml:space="preserve">
<value>"%S": The parameter name is ambiguous.</value>
</data>
<data name="CON_AMBIGIOUS_PARAM_1" xml:space="preserve">
<value>The specified parameter name matches with the following parameters that can be specified as a parameter of command "%S".</value>
</data>
<data name="CON_AMBIGIOUS_PARAM_2" xml:space="preserve">
<value>Please re-specify the parameter name more strictly.</value>
</data>
<data name="CON_INFILE_ERROR" xml:space="preserve">
<value>Error: Unable to open the specified input file "%s".</value>
</data>
<data name="CON_INFILE_START" xml:space="preserve">
<value>The commands written in the file "%s" will be used instead of input from keyboard.</value>
</data>
<data name="CON_INVALID_PARAM" xml:space="preserve">
<value>The parameter "/%S" has been specified. It is not possible to specify this parameter when using the command "%S". Input "%S /HELP" to see the list of what parameters can be used.</value>
</data>
<data name="CON_OUTFILE_ERROR" xml:space="preserve">
<value>Error: Unable to create the specified output file "%s".</value>
</data>
<data name="CON_OUTFILE_START" xml:space="preserve">
<value>The message output to the console will be saved in the file "%s".</value>
</data>
<data name="CON_UNKNOWN_CMD" xml:space="preserve">
<value>"%S": Command not found. You can use the HELP command to view a list of the available commands.</value>
</data>
<data name="CON_USER_CANCEL" xml:space="preserve">
<value>[EOF]</value>
</data>
<data name="CON_USER_CANCELED" xml:space="preserve">
<value>The command was canceled.</value>
</data>
</root>

View File

@ -484,6 +484,7 @@ namespace BuildUtil
".sys",
".inf",
".wav",
".cat",
};
foreach (string ext in filesOnlyWin32)