mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-06 15:54:57 +03:00
Compare commits
370 Commits
Author | SHA1 | Date | |
---|---|---|---|
56bb573b17 | |||
e3f0837bd1 | |||
c1370987bf | |||
79d1ade09d | |||
a3f984e521 | |||
43a80702a9 | |||
682052e0dc | |||
ad139a7cbb | |||
64f1e349f8 | |||
214992c232 | |||
82b4b083b3 | |||
f18837b491 | |||
28c90b190c | |||
5f76dbcfa2 | |||
b4817fd27a | |||
89ca29f259 | |||
7a208d6114 | |||
5b910322a7 | |||
2262b8a160 | |||
2923b5500a | |||
7acd52d724 | |||
8c12e79448 | |||
dc8d705854 | |||
81c71d309a | |||
e0182ca3d9 | |||
97d9761a9b | |||
544c9a73da | |||
f9a1d72ce7 | |||
e2d61133fe | |||
2f801f30de | |||
60568da9b7 | |||
515d823ef8 | |||
146455e97d | |||
c20bcb2e60 | |||
ce54531b53 | |||
cf318d7219 | |||
285e322171 | |||
cca769e2e6 | |||
4e248e833c | |||
92f41341d9 | |||
19af52e288 | |||
3a595b4a46 | |||
76395d8f8d | |||
2aaf9012a0 | |||
aeff295c01 | |||
4b05de1a93 | |||
92966e0f5c | |||
485e680cff | |||
f8c4713fad | |||
789ed26113 | |||
6f050f2b01 | |||
6a25ccfa28 | |||
138e0b76d6 | |||
ee84891559 | |||
0472f9c286 | |||
f7e988ffc7 | |||
a541c0286e | |||
30f707d6c0 | |||
bad9310aa4 | |||
d4d15b66d3 | |||
c4b5455663 | |||
192083e7c4 | |||
1708998a11 | |||
01663f836d | |||
4ec2995604 | |||
2bb6fb2845 | |||
a6ba9b8788 | |||
46b54f00be | |||
5cab279a8c | |||
3e17c818a6 | |||
84588095d5 | |||
a79f91161f | |||
ed6013affc | |||
ac04e15b72 | |||
4db6247b80 | |||
3761876254 | |||
934e49fea0 | |||
b7e7d3b028 | |||
808f081e3a | |||
8fb9bfd39c | |||
9d29d8813b | |||
68367fa2fb | |||
d5fa90cc71 | |||
68574e9af9 | |||
de03b3ec59 | |||
9e7f26395a | |||
b00aa39b29 | |||
2d82d84fd5 | |||
42dbfb7c7e | |||
ef5c32dca1 | |||
65483499bf | |||
3ffdda6c13 | |||
3d69a71d9b | |||
4506b60e80 | |||
b6b692046c | |||
56a19d7651 | |||
2078a069de | |||
562ffe8945 | |||
914bfe7d44 | |||
7f30cbccf4 | |||
2dab282eb2 | |||
ef24ff74c8 | |||
a8580458c4 | |||
6115f1c713 | |||
dd1eebdbed | |||
8495388933 | |||
afe576dcdc | |||
decfcecc97 | |||
d8aa470192 | |||
b339104f4f | |||
8a37f5ce11 | |||
e7bf97583d | |||
a39905c288 | |||
dbd4dd5ae7 | |||
ec201f340a | |||
0a924aea4d | |||
d161b75a7d | |||
621fb087f8 | |||
809f891f0c | |||
82f2c73ce9 | |||
5cddafbb3b | |||
dd6e79d526 | |||
5792aa7c41 | |||
0325c13c40 | |||
25e2854725 | |||
cf2585c079 | |||
1301dc93c6 | |||
5ed11a0270 | |||
5c346ef96e | |||
2715d80e18 | |||
a08857150b | |||
e5cfa347da | |||
a6239a4ae3 | |||
8e2616ef7d | |||
ea2c8f9861 | |||
e5e86abc0e | |||
992410c3d4 | |||
cd889f78dc | |||
cabcba1ef9 | |||
2969237e04 | |||
78f06569b3 | |||
1fa6c14e4e | |||
586c27d43b | |||
63b841efc0 | |||
2981a44de3 | |||
2db9f15ea7 | |||
ebd1d281dd | |||
9620dcbcd0 | |||
943ddadd3d | |||
272ec5a8ef | |||
d53f80bfa6 | |||
ac48ac348b | |||
44447e9762 | |||
394354ff8a | |||
6ff00f637b | |||
5611156ca8 | |||
f03e83369e | |||
501fe217ff | |||
bf1201aa26 | |||
a207260e38 | |||
eddf593e22 | |||
3fa24c6731 | |||
5f12684b42 | |||
5f6306d5e5 | |||
023250df9a | |||
16ca0694fb | |||
99e99a46b1 | |||
fffed52f3b | |||
69b4001355 | |||
c029b34b80 | |||
7fdacec2a6 | |||
190672bd84 | |||
5ca62bdd8a | |||
d0b3cde485 | |||
bb2e2ff997 | |||
a2d15615f3 | |||
945715e4bb | |||
1ac7602b3a | |||
3c140dde8d | |||
d29d1f516a | |||
b890c7d813 | |||
8bb787f233 | |||
819f2f92f6 | |||
e6a80fb4f2 | |||
249575a5a5 | |||
2c9ac51c84 | |||
9e7d87bea6 | |||
3cf23e58a3 | |||
f52ccc6493 | |||
2e0c24f6c8 | |||
d1ad4196bb | |||
1e164ecc4e | |||
51ffe4be2c | |||
20b84f3928 | |||
dec532a8eb | |||
ff3910eb86 | |||
684d17e86a | |||
efd24133be | |||
1c4b257a1b | |||
77aee2d21c | |||
f22b013dda | |||
488eb06d64 | |||
763e1b67a5 | |||
fc39173b73 | |||
1a4ed27e89 | |||
cd0db9c7d6 | |||
c5a3fd74c0 | |||
a800e6f6cc | |||
5b07163975 | |||
feba98199b | |||
7b73e3c0c8 | |||
490fc7b65c | |||
a8fdc1184a | |||
7edda54b9a | |||
cc5d68a7c3 | |||
6a7883b5fe | |||
61ccaed4f6 | |||
09f24e46b3 | |||
69cd39616b | |||
e18bb465c9 | |||
337a04b758 | |||
1c56562cc7 | |||
b4cd4ce360 | |||
818103950c | |||
5d782a67b4 | |||
cda0062367 | |||
a8c6a0c1b3 | |||
712c51a971 | |||
ac1b045634 | |||
3b2db45509 | |||
10e292b196 | |||
e8793a0098 | |||
5cdd2a4e4a | |||
e1d9eaf590 | |||
6b3ac84ba2 | |||
18ad35ebfe | |||
b853140626 | |||
5209b310e3 | |||
3a275d7257 | |||
aa65327e73 | |||
b352aa4cc3 | |||
6d85fffdb5 | |||
8685fe0da1 | |||
cd850c07ae | |||
14a410a179 | |||
c865103795 | |||
60410accce | |||
352ed759b2 | |||
b57a4b051b | |||
6c665f889f | |||
5bf08e63bb | |||
4b9c33cd30 | |||
78dad1d568 | |||
6a472d827a | |||
a3eb115b0a | |||
24d64222ea | |||
cc61c90372 | |||
35200a29ea | |||
c084ce30f9 | |||
755e09e5c1 | |||
2cdffffa54 | |||
8e53b948c5 | |||
ff247687ed | |||
588d7539f4 | |||
112b4c2c67 | |||
28d4a113dc | |||
3732447571 | |||
0133682eb3 | |||
3747d2bf3f | |||
3c99f64621 | |||
74a1e9bd1b | |||
59be67df25 | |||
5e0c036e39 | |||
6801e4b384 | |||
c948f65850 | |||
a9b30b829f | |||
d074899fd8 | |||
3c2f5a41ba | |||
369a8850c4 | |||
7b042e53d2 | |||
844dcdb0af | |||
144392c587 | |||
3baf4674e7 | |||
869496be3e | |||
d917b2ac73 | |||
96a2d5a124 | |||
3090688506 | |||
19dbdf46be | |||
eb5150a002 | |||
e0c6813d44 | |||
6869955acc | |||
f84513c95b | |||
45399d9797 | |||
b60844e276 | |||
40ed982079 | |||
eeaac4e78c | |||
6fe678fe84 | |||
853b4a57bc | |||
275e8a81ef | |||
235bd07e67 | |||
47d08b055e | |||
485a5922eb | |||
4514ba5e2f | |||
5ebdb394fc | |||
2fafd7c70e | |||
d726719602 | |||
09be880263 | |||
f7f6eeec44 | |||
c4838006b1 | |||
c52e49de2d | |||
9e6476c7b2 | |||
37f28b4119 | |||
f1cb86d979 | |||
c4ec63fe32 | |||
60cc784aee | |||
b77dd167ff | |||
1a8e1385cf | |||
e3e35f5a4c | |||
c15a4ba04f | |||
5e1c728f92 | |||
eb9d6e77a4 | |||
6e707f7550 | |||
71b814060d | |||
8e1a377b82 | |||
adf0f18b7a | |||
20bbe325fe | |||
1d5ded9388 | |||
cbbac659a3 | |||
2cfe031398 | |||
a2a6502ab9 | |||
f2fee4d32c | |||
f627b64264 | |||
1d6a4d3ec8 | |||
3b7dd25b65 | |||
3f16a7e704 | |||
4e583e43f1 | |||
8fdf7302a5 | |||
981b57ee28 | |||
27f7d43ff7 | |||
a3aea00820 | |||
0570f7d31c | |||
667108319d | |||
7e8b3c0b39 | |||
34dfc14549 | |||
1fe863e866 | |||
b41c17f45a | |||
ca1c6a5f3f | |||
8fb456f6a6 | |||
132926ee09 | |||
8a856e4672 | |||
e6803a1fab | |||
9180e065a0 | |||
39becfe4ab | |||
723f38e72f | |||
a2b7cb0148 | |||
24bd2b3198 | |||
9f2a5cecf3 | |||
a65c436e8f | |||
aa0ec4343c | |||
1bdd9a92bc | |||
942051d3a8 | |||
039cd8edf0 | |||
e025762a52 | |||
a902d3eed9 | |||
44f731f781 | |||
14e9c7299d | |||
f20e99f8e4 | |||
b9109211d3 | |||
9073452b09 | |||
b6ef9f88c9 |
@ -1,10 +1,6 @@
|
||||
version: '{build}'
|
||||
|
||||
image:
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
- Ubuntu1604
|
||||
- Ubuntu1804
|
||||
image: Ubuntu1804
|
||||
|
||||
configuration: Release
|
||||
|
||||
@ -21,77 +17,20 @@ skip_commits:
|
||||
init:
|
||||
- ps: Update-AppveyorBuild -Version "build-$env:APPVEYOR_BUILD_NUMBER-$($env:APPVEYOR_REPO_COMMIT.substring(0,7))"
|
||||
|
||||
install: git submodule update --init --recursive
|
||||
|
||||
for:
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Visual Studio 2015
|
||||
build_script:
|
||||
- src\BuildAll.cmd
|
||||
- exit %errorlevel%
|
||||
after_build:
|
||||
- 7z a "%APPVEYOR_BUILD_FOLDER%\%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x86_%CONFIGURATION%_PDBs-vs2015.zip" "%APPVEYOR_BUILD_FOLDER%\src\DebugFiles\pdb\Win32_Release\*.pdb"
|
||||
- 7z a "%APPVEYOR_BUILD_FOLDER%\%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%_PDBs-vs2015.zip" "%APPVEYOR_BUILD_FOLDER%\src\DebugFiles\pdb\x64_Release\*.pdb"
|
||||
artifacts:
|
||||
- path: output\pkg\*\*
|
||||
name: Release
|
||||
- path: "%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x86_%CONFIGURATION%_PDBs-vs2015.zip"
|
||||
name: PDBs (x86)
|
||||
- path: "%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%_PDBs-vs2015.zip"
|
||||
name: PDBs (x64)
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Visual Studio 2017
|
||||
init:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
before_build:
|
||||
- configure
|
||||
build_script:
|
||||
- nmake
|
||||
test_script:
|
||||
- ps: cd $env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: .\.ci\appveyor-vpntest.ps1
|
||||
after_build:
|
||||
- 7z a "%APPVEYOR_BUILD_FOLDER%\%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%-vs2017.zip" "%APPVEYOR_BUILD_FOLDER%\build\*.exe"
|
||||
- 7z a "%APPVEYOR_BUILD_FOLDER%\%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%-vs2017.zip" "%APPVEYOR_BUILD_FOLDER%\build\hamcore.se2"
|
||||
- 7z a "%APPVEYOR_BUILD_FOLDER%\%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%_PDBs-vs2017.zip" "%APPVEYOR_BUILD_FOLDER%\build\*.pdb"
|
||||
artifacts:
|
||||
- path: "%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%-vs2017.zip"
|
||||
name: Release
|
||||
- path: "%APPVEYOR_PROJECT_NAME%_%APPVEYOR_BUILD_VERSION%_Windows_x64_%CONFIGURATION%_PDBs-vs2017.zip"
|
||||
name: PDBs
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Ubuntu1604
|
||||
before_build:
|
||||
- ./configure
|
||||
build_script:
|
||||
- make package -C tmp -j $(nproc || sysctl -n hw.ncpu || echo 4)
|
||||
test_script:
|
||||
- .ci/appveyor-deb-install-test.sh
|
||||
- sudo apt-get update && sudo apt-get -y install autoconf libtool liblzo2-dev libpam-dev fping unzip # openvpn build deps
|
||||
- sudo .ci/start-se-openvpn.sh
|
||||
- sudo .ci/run-openvpn-tests.sh
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Ubuntu1804
|
||||
before_build:
|
||||
- sh: "if [ ${APPVEYOR_REPO_TAG} == \"true\" ]; then .ci/appveyor-create-release-tarball.sh\nfi"
|
||||
- ./configure
|
||||
build_script:
|
||||
- make package -C tmp -j $(nproc || sysctl -n hw.ncpu || echo 4)
|
||||
- .ci/memory-leak-test.sh
|
||||
test_script:
|
||||
- .ci/appveyor-deb-install-test.sh
|
||||
- sudo apt-get update && sudo apt-get -y install autoconf libtool liblzo2-dev libpam-dev fping unzip # openvpn build deps
|
||||
- sudo .ci/start-se-openvpn.sh
|
||||
- sudo .ci/run-openvpn-tests.sh
|
||||
install:
|
||||
- sudo apt-get -y install libsodium-dev
|
||||
before_build:
|
||||
- sh: "if [ ${APPVEYOR_REPO_TAG} == \"true\" ]; then .ci/appveyor-create-release-tarball.sh\nfi"
|
||||
- git submodule update --init --recursive
|
||||
- ./configure
|
||||
build_script:
|
||||
- make package -C build -j $(nproc || sysctl -n hw.ncpu || echo 4)
|
||||
- .ci/memory-leak-test.sh
|
||||
test_script:
|
||||
- .ci/appveyor-deb-install-test.sh
|
||||
- sudo apt-get update && sudo apt-get -y install autoconf libtool liblzo2-dev libpam-dev fping unzip liblz4-dev # openvpn build deps
|
||||
- sudo .ci/start-se-openvpn.sh
|
||||
- sudo .ci/run-openvpn-tests.sh
|
||||
|
||||
deploy:
|
||||
description: 'automatic release'
|
||||
|
@ -1,6 +1,4 @@
|
||||
jobs:
|
||||
- template: .ci/azure-pipelines-linux.yml
|
||||
|
||||
# - template: .ci/azure-pipelines-osx.yml
|
||||
|
||||
- template: .ci/azure-pipelines-win.yml
|
||||
- template: .ci/azure-pipelines/linux.yml
|
||||
- template: .ci/azure-pipelines/windows.yml
|
||||
- template: .ci/azure-pipelines/macos.yml
|
||||
|
@ -2,11 +2,13 @@
|
||||
|
||||
set -eux
|
||||
|
||||
sudo dpkg -i build/softether-common*.deb
|
||||
sudo dpkg -i build/softether-vpnbridge*.deb
|
||||
sudo dpkg -i build/softether-vpnclient*.deb
|
||||
sudo dpkg -i build/softether-vpncmd*.deb
|
||||
sudo dpkg -i build/softether-vpnserver*.deb
|
||||
BUILD_BINARIESDIRECTORY="${BUILD_BINARIESDIRECTORY:-build}"
|
||||
|
||||
sudo dpkg -i $BUILD_BINARIESDIRECTORY/softether-common*.deb
|
||||
sudo dpkg -i $BUILD_BINARIESDIRECTORY/softether-vpnbridge*.deb
|
||||
sudo dpkg -i $BUILD_BINARIESDIRECTORY/softether-vpnclient*.deb
|
||||
sudo dpkg -i $BUILD_BINARIESDIRECTORY/softether-vpncmd*.deb
|
||||
sudo dpkg -i $BUILD_BINARIESDIRECTORY/softether-vpnserver*.deb
|
||||
|
||||
sudo systemctl restart softether-vpnserver || (sudo journalctl -xe --no-pager >> systemctl.log && appveyor PushArtifact systemctl.log && exit 1)
|
||||
|
||||
|
@ -1,20 +1,25 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (Test-Path "env:BUILD_BINARIESDIRECTORY") {
|
||||
$BUILD_BINARIESDIRECTORY = $env:BUILD_BINARIESDIRECTORY
|
||||
} else {
|
||||
$BUILD_BINARIESDIRECTORY = "build"
|
||||
}
|
||||
|
||||
# ('s', 'c', 'b', 'sm', 'cm') ??
|
||||
('s', 'c', 'b') | % {
|
||||
|
||||
[String] $mode = $_
|
||||
Write-Host "testing: $mode"
|
||||
|
||||
$full = (Write-Output "q\n" | & .\build\vpntest.exe $mode)
|
||||
$full = (Write-Output "q\n" | & "$BUILD_BINARIESDIRECTORY\vpntest.exe" $mode)
|
||||
$t = ($full | Select-String -Pattern 'NO MEMORY LEAKS' -CaseSensitive)
|
||||
|
||||
if( ($t).Count -ne 1){
|
||||
if (($t).Count -ne 1) {
|
||||
$full
|
||||
Write-Error 'failed'
|
||||
return $false
|
||||
}else{
|
||||
} else {
|
||||
Write-Host 'ok'
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
jobs:
|
||||
- job: linux_64
|
||||
displayName: 'Ubuntu 16.04'
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
variables:
|
||||
CPACK_GENERATOR: DEB
|
||||
steps:
|
||||
- checkout: self
|
||||
submodules: recursive
|
||||
- script: |
|
||||
sudo apt -y install cmake gcc g++ libncurses5-dev libreadline-dev libssl-dev make zlib1g-dev
|
||||
./configure
|
||||
make package -C tmp -j $(nproc || sysctl -n hw.ncpu || echo 4)
|
||||
.ci/appveyor-deb-install-test.sh
|
||||
sudo apt-get -y install autoconf libtool liblzo2-dev libpam-dev fping unzip # openvpn build deps
|
||||
sudo .ci/start-se-openvpn.sh
|
||||
sudo .ci/run-openvpn-tests.sh
|
||||
displayName: 'Ubuntu 16.04'
|
@ -1,28 +0,0 @@
|
||||
jobs:
|
||||
- job: win_64
|
||||
displayName: 'Visual Studio 2017'
|
||||
pool:
|
||||
vmImage: vs2017-win2016
|
||||
steps:
|
||||
- checkout: self
|
||||
submodules: recursive
|
||||
- script: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
configure
|
||||
- script: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cd tmp
|
||||
nmake
|
||||
- powershell: |
|
||||
. .ci\appveyor-vpntest.ps1
|
||||
- powershell: |
|
||||
New-Item -Path '$(build.artifactstagingdirectory)/publish' -ItemType Directory
|
||||
- task: CopyFiles@2
|
||||
inputs:
|
||||
sourceFolder: '$(Build.SourcesDirectory)'
|
||||
contents: 'build/?(*.exe|*.se2|*.pdb)'
|
||||
TargetFolder: '$(build.artifactstagingdirectory)/publish'
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: '$(build.artifactstagingdirectory)/publish'
|
||||
artifactName: vs2017
|
17
.ci/azure-pipelines/linux.yml
Normal file
17
.ci/azure-pipelines/linux.yml
Normal file
@ -0,0 +1,17 @@
|
||||
jobs:
|
||||
- job: Ubuntu_x64
|
||||
pool:
|
||||
vmImage: ubuntu-18.04
|
||||
steps:
|
||||
- script: sudo apt update && sudo apt-get -y install cmake gcc g++ ninja-build libncurses5-dev libreadline-dev libsodium-dev libssl-dev make zlib1g-dev liblz4-dev
|
||||
displayName: 'Prepare environment'
|
||||
- script: "$(Build.SourcesDirectory)/.ci/azure-pipelines/linux_build.sh"
|
||||
env:
|
||||
SE_BUILD_NUMBER_TOKEN: $(BUILD_NUMBER_TOKEN)
|
||||
displayName: 'Build'
|
||||
- script: |
|
||||
.ci/appveyor-deb-install-test.sh
|
||||
sudo apt-get -y install autoconf libtool liblzo2-dev libpam-dev fping unzip # To build OpenVPN
|
||||
sudo BUILD_BINARIESDIRECTORY=$BUILD_BINARIESDIRECTORY .ci/start-se-openvpn.sh
|
||||
sudo BUILD_BINARIESDIRECTORY=$BUILD_BINARIESDIRECTORY .ci/run-openvpn-tests.sh
|
||||
displayName: 'Test'
|
15
.ci/azure-pipelines/linux_build.sh
Executable file
15
.ci/azure-pipelines/linux_build.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "${#SE_BUILD_NUMBER_TOKEN}" -eq 64 ]]; then
|
||||
VERSION=$(python3 "version.py")
|
||||
BUILD_NUMBER=$(curl "https://softether.network/get-build-number?commit=${BUILD_SOURCEVERSION}&version=${VERSION}&token=${SE_BUILD_NUMBER_TOKEN}")
|
||||
else
|
||||
BUILD_NUMBER=0
|
||||
fi
|
||||
|
||||
cd ${BUILD_BINARIESDIRECTORY}
|
||||
|
||||
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_NUMBER=${BUILD_NUMBER} ${BUILD_SOURCESDIRECTORY}
|
||||
cmake --build .
|
||||
|
||||
cpack -C Release -G DEB
|
11
.ci/azure-pipelines/macos.yml
Normal file
11
.ci/azure-pipelines/macos.yml
Normal file
@ -0,0 +1,11 @@
|
||||
jobs:
|
||||
- job: macOS
|
||||
pool:
|
||||
vmImage: macOS-latest
|
||||
steps:
|
||||
- script: brew install pkg-config cmake ninja ncurses readline libsodium openssl zlib
|
||||
displayName: 'Prepare environment'
|
||||
- script: '$(Build.SourcesDirectory)/.ci/azure-pipelines/macos_build.sh'
|
||||
env:
|
||||
SE_BUILD_NUMBER_TOKEN: $(BUILD_NUMBER_TOKEN)
|
||||
displayName: 'Build'
|
13
.ci/azure-pipelines/macos_build.sh
Executable file
13
.ci/azure-pipelines/macos_build.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "${#SE_BUILD_NUMBER_TOKEN}" -eq 64 ]]; then
|
||||
VERSION=$(python3 "version.py")
|
||||
BUILD_NUMBER=$(curl "https://softether.network/get-build-number?commit=${BUILD_SOURCEVERSION}&version=${VERSION}&token=${SE_BUILD_NUMBER_TOKEN}")
|
||||
else
|
||||
BUILD_NUMBER=0
|
||||
fi
|
||||
|
||||
cd ${BUILD_BINARIESDIRECTORY}
|
||||
|
||||
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_NUMBER=${BUILD_NUMBER} -DOPENSSL_ROOT_DIR="/usr/local/opt/openssl" ${BUILD_SOURCESDIRECTORY}
|
||||
cmake --build .
|
45
.ci/azure-pipelines/windows-steps.yml
Normal file
45
.ci/azure-pipelines/windows-steps.yml
Normal file
@ -0,0 +1,45 @@
|
||||
parameters:
|
||||
- name: architecture
|
||||
type: string
|
||||
- name: compilerPath
|
||||
type: string
|
||||
- name: vcpkgTriplet
|
||||
type: string
|
||||
- name: vcvarsPath
|
||||
type: string
|
||||
|
||||
steps:
|
||||
- task: Cache@2
|
||||
inputs:
|
||||
key: '"vcpkg-installed-windows-${{parameters.architecture}}"'
|
||||
path: 'C:/vcpkg/installed'
|
||||
displayName: 'Environment storage'
|
||||
- script: |
|
||||
vcpkg install libsodium openssl zlib --triplet ${{parameters.vcpkgTriplet}}
|
||||
workingDirectory: C:/vcpkg
|
||||
displayName: 'Prepare environment'
|
||||
- script: '$(Build.SourcesDirectory)/.ci/azure-pipelines/windows_build.bat'
|
||||
env:
|
||||
ARCHITECTURE: ${{parameters.architecture}}
|
||||
COMPILER_PATH: ${{parameters.compilerPath}}
|
||||
VCPKG_TRIPLET: ${{parameters.vcpkgTriplet}}
|
||||
VCVARS_PATH: ${{parameters.vcvarsPath}}
|
||||
SE_BUILD_NUMBER_TOKEN: $(BUILD_NUMBER_TOKEN)
|
||||
displayName: 'Build'
|
||||
- powershell: |
|
||||
. .ci/appveyor-vpntest.ps1
|
||||
displayName: 'Test'
|
||||
- task: CopyFiles@2
|
||||
inputs:
|
||||
sourceFolder: '$(Build.BinariesDirectory)'
|
||||
contents: '?(*.exe|*.se2|*.pdb)'
|
||||
TargetFolder: '$(Build.StagingDirectory)/binaries'
|
||||
flattenFolders: true
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: '$(Build.StagingDirectory)/binaries'
|
||||
artifactName: 'Binaries'
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: '$(Build.StagingDirectory)/installers'
|
||||
artifactName: 'Installers'
|
21
.ci/azure-pipelines/windows.yml
Normal file
21
.ci/azure-pipelines/windows.yml
Normal file
@ -0,0 +1,21 @@
|
||||
jobs:
|
||||
- job: Windows_x64
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
steps:
|
||||
- template: "windows-steps.yml"
|
||||
parameters:
|
||||
architecture: "x64"
|
||||
compilerPath: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe"
|
||||
vcpkgTriplet: "x64-windows-static-md"
|
||||
vcvarsPath: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
|
||||
- job: Windows_x86
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
steps:
|
||||
- template: "windows-steps.yml"
|
||||
parameters:
|
||||
architecture: "x86"
|
||||
compilerPath: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/bin/clang-cl.exe"
|
||||
vcpkgTriplet: "x86-windows-static-md"
|
||||
vcvarsPath: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvarsamd64_x86.bat"
|
26
.ci/azure-pipelines/windows_build.bat
Normal file
26
.ci/azure-pipelines/windows_build.bat
Normal file
@ -0,0 +1,26 @@
|
||||
@echo on
|
||||
|
||||
:: The method we use to store a command's output into a variable:
|
||||
:: https://stackoverflow.com/a/6362922
|
||||
for /f "tokens=* USEBACKQ" %%g in (`python "version.py"`) do (set "VERSION=%%g")
|
||||
|
||||
:: https://stackoverflow.com/a/8566001
|
||||
echo %SE_BUILD_NUMBER_TOKEN%> "%tmp%\length.txt"
|
||||
for %%? in ("%tmp%\length.txt") do ( set /A SE_BUILD_NUMBER_TOKEN_LENGTH=%%~z? - 2 )
|
||||
|
||||
if %SE_BUILD_NUMBER_TOKEN_LENGTH% equ 64 (
|
||||
for /f "tokens=* USEBACKQ" %%g in (`curl "https://softether.network/get-build-number?commit=%BUILD_SOURCEVERSION%&version=%VERSION%&token=%SE_BUILD_NUMBER_TOKEN%"`) do (set "BUILD_NUMBER=%%g")
|
||||
) else (
|
||||
set BUILD_NUMBER=0
|
||||
)
|
||||
|
||||
cd %BUILD_BINARIESDIRECTORY%
|
||||
|
||||
call "%VCVARS_PATH%"
|
||||
|
||||
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER="%COMPILER_PATH%" -DCMAKE_CXX_COMPILER="%COMPILER_PATH%" -DBUILD_NUMBER=%BUILD_NUMBER% "%BUILD_SOURCESDIRECTORY%"
|
||||
cmake --build .
|
||||
|
||||
mkdir "%BUILD_STAGINGDIRECTORY%\installers"
|
||||
vpnsetup /SFXMODE:vpnclient /SFXOUT:"%BUILD_STAGINGDIRECTORY%\installers\softether-vpnclient-%VERSION%.%BUILD_NUMBER%.%ARCHITECTURE%.exe"
|
||||
vpnsetup /SFXMODE:vpnserver_vpnbridge /SFXOUT:"%BUILD_STAGINGDIRECTORY%\installers\softether-vpnserver_vpnbridge-%VERSION%.%BUILD_NUMBER%.%ARCHITECTURE%.exe"
|
@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
RUN_COVERITY="${RUN_COVERITY:-0}"
|
||||
|
||||
export COVERITY_SCAN_PROJECT_NAME="SoftEtherVPN/SoftEtherVPN"
|
||||
export COVERITY_SCAN_BRANCH_PATTERN="master"
|
||||
export COVERITY_SCAN_NOTIFICATION_EMAIL="chipitsine@gmail.com"
|
||||
export COVERITY_SCAN_BUILD_COMMAND_PREPEND="./configure"
|
||||
export COVERITY_SCAN_BUILD_COMMAND="make -C tmp"
|
||||
|
||||
if [ "${RUN_COVERITY}" = "1" ]; then
|
||||
# Ignore exit code, script exits with 1 if we're not on the right branch
|
||||
curl -s "https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh" | bash || true
|
||||
else
|
||||
echo "Skipping coverity scan because \$RUN_COVERITY != \"1\""
|
||||
fi
|
@ -2,7 +2,10 @@
|
||||
|
||||
set -eux
|
||||
|
||||
cd
|
||||
BUILD_BINARIESDIRECTORY="${BUILD_BINARIESDIRECTORY:-build}"
|
||||
|
||||
cd $BUILD_BINARIESDIRECTORY
|
||||
|
||||
git clone https://github.com/openvpn/openvpn
|
||||
cd openvpn
|
||||
autoreconf -iv
|
||||
|
@ -5,7 +5,7 @@ RUN_SONARCLOUD="${RUN_SONARCLOUD:-0}"
|
||||
|
||||
if [ "${RUN_SONARCLOUD}" = "1" ] && [ ! -z ${SONAR_TOKEN+x} ]; then
|
||||
./configure
|
||||
build-wrapper-linux-x86-64 --out-dir bw-output make -C tmp
|
||||
build-wrapper-linux-x86-64 --out-dir bw-output make -C build
|
||||
sonar-scanner -Dsonar.projectKey=SoftEtherVPN_SoftEtherVPN -Dsonar.organization=softethervpn -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN}
|
||||
else
|
||||
echo "Skipping sonar-scan because \$RUN_SONARCLOUD != \"1\" or \$SONAR_TOKEN is not set"
|
||||
|
@ -1,13 +1,42 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
set -eux
|
||||
|
||||
build/vpnserver start
|
||||
BUILD_BINARIESDIRECTORY="${BUILD_BINARIESDIRECTORY:-build}"
|
||||
|
||||
build/vpncmd 127.0.0.1:443 /SERVER /HUB:DEFAULT /CMD:SecureNatEnable
|
||||
build/vpncmd 127.0.0.1:443 /SERVER /CMD:"OpenVpnEnable yes /PORTS:1194"
|
||||
build/vpncmd 127.0.0.1:443 /SERVER /HUB:DEFAULT /CMD:"UserCreate test /GROUP:none /REALNAME:none /NOTE:none"
|
||||
build/vpncmd 127.0.0.1:443 /SERVER /HUB:DEFAULT /CMD:"UserPasswordSet test /PASSWORD:test"
|
||||
build/vpncmd 127.0.0.1:443 /SERVER /CMD:"OpenVpnMakeConfig ~/my_openvpn_config.zip"
|
||||
cd $BUILD_BINARIESDIRECTORY
|
||||
|
||||
unzip -d /tmp ~/my_openvpn_config.zip
|
||||
./vpnserver start
|
||||
|
||||
#
|
||||
# wait until server listen 443
|
||||
#
|
||||
set +e
|
||||
started="false"
|
||||
for i in 1 2 3 4 5 6
|
||||
do
|
||||
s=$(echo exit | telnet 127.0.0.1 443 | grep "Connected")
|
||||
if [ "$s" != "" ]
|
||||
then
|
||||
started="true"
|
||||
break
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$started" == "false" ]
|
||||
then
|
||||
echo "vpnserver is not listening 127.0.0.1:443"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./vpncmd 127.0.0.1:443 /SERVER /HUB:DEFAULT /CMD:SecureNatEnable
|
||||
./vpncmd 127.0.0.1:443 /SERVER /CMD:"ProtoOptionsSet OpenVPN /NAME:Enabled /VALUE:True"
|
||||
./vpncmd 127.0.0.1:443 /SERVER /CMD:"PortsUDPSet 1194"
|
||||
./vpncmd 127.0.0.1:443 /SERVER /HUB:DEFAULT /CMD:"UserCreate test /GROUP:none /REALNAME:none /NOTE:none"
|
||||
./vpncmd 127.0.0.1:443 /SERVER /HUB:DEFAULT /CMD:"UserPasswordSet test /PASSWORD:test"
|
||||
./vpncmd 127.0.0.1:443 /SERVER /CMD:"OpenVpnMakeConfig my_openvpn_config.zip"
|
||||
|
||||
unzip -d /tmp my_openvpn_config.zip
|
||||
|
@ -13,12 +13,12 @@ FreeBSD_task:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-1
|
||||
prepare_script:
|
||||
- pkg install -y cmake git $SSL
|
||||
- pkg install -y pkgconf cmake git libsodium $SSL
|
||||
- git submodule update --init --recursive
|
||||
configure_script:
|
||||
- ./configure
|
||||
build_script:
|
||||
- make -j $(sysctl -n hw.ncpu || echo 4) -C tmp
|
||||
- make -j $(sysctl -n hw.ncpu || echo 4) -C build
|
||||
test_script:
|
||||
- ldd build/vpnserver
|
||||
- .ci/memory-leak-test.sh
|
||||
|
39
.github/workflows/build_source_release.yml
vendored
Normal file
39
.github/workflows/build_source_release.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Build Source Release
|
||||
|
||||
# Trigger whenever a release is created
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: archive
|
||||
id: archive
|
||||
run: |
|
||||
VERSION=${{ github.event.release.tag_name }}
|
||||
PKGNAME="SoftEtherVPN-$VERSION"
|
||||
mkdir -p /tmp/$PKGNAME
|
||||
mv * /tmp/$PKGNAME
|
||||
mv /tmp/$PKGNAME .
|
||||
TARBALL=$PKGNAME.tar.xz
|
||||
tar cJf $TARBALL $PKGNAME
|
||||
echo "::set-output name=tarball::$TARBALL"
|
||||
|
||||
- name: upload tarball
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: ./${{ steps.archive.outputs.tarball }}
|
||||
asset_name: ${{ steps.archive.outputs.tarball }}
|
||||
asset_content_type: application/gzip
|
30
.github/workflows/coverity.yml
vendored
Normal file
30
.github/workflows/coverity.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
name: Coverity
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository_owner == 'SoftEtherVPN' }}
|
||||
env:
|
||||
COVERITY_SCAN_PROJECT_NAME: 'SoftEtherVPN/SoftEtherVPN'
|
||||
COVERITY_SCAN_BRANCH_PATTERN: '*'
|
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: 'chipitsine@gmail.com'
|
||||
COVERITY_SCAN_BUILD_COMMAND_PREPEND: "./configure"
|
||||
COVERITY_SCAN_BUILD_COMMAND: "make -C build"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install apt dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y cmake gcc g++ libncurses5-dev libreadline-dev libssl-dev make zlib1g-dev libsodium-dev
|
||||
- name: Run Coverity Scan
|
||||
env:
|
||||
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
run: |
|
||||
curl -fsSL "https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh" | bash || true
|
@ -9,13 +9,13 @@
|
||||
- .cirrus.yml
|
||||
before_script:
|
||||
- REPOSITORY="$PWD" && cd ..
|
||||
- apt-get update && apt-get install -y dpkg-dev wget g++ gcc libncurses5-dev libreadline-dev libssl-dev make zlib1g-dev git file
|
||||
- apt-get update && apt-get install -y dpkg-dev wget g++ gcc libncurses5-dev libreadline-dev libsodium-dev libssl-dev make zlib1g-dev git file
|
||||
- wget https://cmake.org/files/v${CMAKE_VERSION%.*}/cmake-${CMAKE_VERSION}.tar.gz && tar -xzf cmake-${CMAKE_VERSION}.tar.gz
|
||||
- cd cmake-${CMAKE_VERSION} && ./bootstrap && make install
|
||||
- cd "$REPOSITORY" && git submodule update --init --recursive
|
||||
script:
|
||||
- ./configure
|
||||
- make package -C tmp
|
||||
- make package -C build
|
||||
- dpkg -i build/softether-vpn*.deb
|
||||
- .ci/memory-leak-test.sh
|
||||
|
||||
@ -36,7 +36,7 @@ build_illumos:
|
||||
script:
|
||||
- git submodule init && git submodule update
|
||||
- CMAKE_FLAGS="-DCMAKE_PREFIX_PATH=/opt/local -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_C_FLAGS=-m64" ./configure
|
||||
- gmake -C tmp
|
||||
- gmake -C build
|
||||
|
||||
#
|
||||
# flawfinder
|
||||
|
12
.gitmodules
vendored
12
.gitmodules
vendored
@ -1,6 +1,12 @@
|
||||
[submodule "src/Mayaqua/3rdparty/cpu_features"]
|
||||
path = src/Mayaqua/3rdparty/cpu_features
|
||||
url = https://github.com/google/cpu_features.git
|
||||
[submodule "src/Mayaqua/3rdparty/zlib"]
|
||||
path = src/Mayaqua/3rdparty/zlib
|
||||
url = https://github.com/madler/zlib.git
|
||||
[submodule "3rdparty/tinydir"]
|
||||
path = 3rdparty/tinydir
|
||||
url = https://github.com/cxong/tinydir.git
|
||||
[submodule "3rdparty/BLAKE2"]
|
||||
path = 3rdparty/BLAKE2
|
||||
url = https://github.com/BLAKE2/BLAKE2.git
|
||||
[submodule "src/libhamcore"]
|
||||
path = src/libhamcore
|
||||
url = https://github.com/SoftEtherVPN/libhamcore.git
|
||||
|
23
.travis.yml
23
.travis.yml
@ -1,5 +1,5 @@
|
||||
sudo: required
|
||||
dist: xenial
|
||||
dist: bionic
|
||||
|
||||
language: c
|
||||
|
||||
@ -20,7 +20,8 @@ matrix:
|
||||
os: linux
|
||||
compiler: gcc
|
||||
- env: OPENSSL_VERSION="1.1.1c" LABEL="linux-ppc64le" CMAKE_VERSION="3.9.6"
|
||||
os: linux-ppc64le
|
||||
arch: ppc64le
|
||||
os: linux
|
||||
compiler: gcc
|
||||
install:
|
||||
- wget https://cmake.org/files/v${CMAKE_VERSION%.*}/cmake-${CMAKE_VERSION}.tar.gz && tar -xzf cmake-${CMAKE_VERSION}.tar.gz
|
||||
@ -28,9 +29,6 @@ matrix:
|
||||
- ./bootstrap > build-deps.log 2>&1 || (cat build-deps.log && exit 1)
|
||||
- sudo make install > build-deps.log 2>&1 || (cat build-deps.log && exit 1)
|
||||
- cd ..
|
||||
- env: OPENSSL_VERSION="1.0.2s" RUN_COVERITY="1"
|
||||
os: linux
|
||||
compiler: clang
|
||||
- env: OPENSSL_VERSION="1.1.1c"
|
||||
os: linux
|
||||
compiler: clang
|
||||
@ -38,6 +36,7 @@ matrix:
|
||||
os: linux
|
||||
compiler: gcc
|
||||
before_install:
|
||||
- sudo apt-get -y install libsodium-dev
|
||||
- bash .ci/build-libressl.sh > build-deps.log 2>&1 || (cat build-deps.log && exit 1)
|
||||
- env: LABEL="check stb files"
|
||||
os: linux
|
||||
@ -52,10 +51,10 @@ matrix:
|
||||
- os: osx
|
||||
compiler: clang
|
||||
before_install:
|
||||
- true
|
||||
- brew install libsodium
|
||||
script:
|
||||
- ./configure
|
||||
- make -C tmp
|
||||
- make -C build
|
||||
- otool -L build/vpnserver
|
||||
- .ci/memory-leak-test.sh
|
||||
|
||||
@ -65,18 +64,16 @@ cache:
|
||||
- ${HOME}/opt
|
||||
|
||||
before_install:
|
||||
- sudo apt-get -y install libsodium-dev
|
||||
- bash .ci/build-openssl.sh > build-deps.log 2>&1 || (cat build-deps.log && exit 1)
|
||||
|
||||
script:
|
||||
- export OPENSSL_ROOT_DIR=${OPENSSL_INSTALL_DIR}
|
||||
- export LD_LIBRARY_PATH="${HOME}/opt/lib:${LD_LIBRARY_PATH:-}"
|
||||
- export CFLAGS="-I${HOME}/opt/include"
|
||||
- export LDFLAGS="-L${HOME}/opt/lib"
|
||||
- echo "check_certificate = off" > ~/.wgetrc
|
||||
- .ci/coverity.sh
|
||||
- export LDFLAGS="-L${HOME}/opt/lib -Wl,-rpath,${HOME}/opt/lib"
|
||||
- .ci/sonarcloud.sh
|
||||
- ./configure
|
||||
- make -j $(nproc || sysctl -n hw.ncpu || echo 4) -C tmp
|
||||
- make -j $(nproc || sysctl -n hw.ncpu || echo 4) -C build
|
||||
- ldd build/vpnserver
|
||||
- if [ "${BUILD_DEB}" = "1" ]; then make package -C tmp; fi
|
||||
- if [ "${BUILD_DEB}" = "1" ]; then make package -C build; fi
|
||||
- .ci/memory-leak-test.sh
|
||||
|
1
3rdparty/BLAKE2
vendored
Submodule
1
3rdparty/BLAKE2
vendored
Submodule
Submodule 3rdparty/BLAKE2 added at b52178a376
1
3rdparty/tinydir
vendored
Submodule
1
3rdparty/tinydir
vendored
Submodule
Submodule 3rdparty/tinydir added at ec6bff2043
@ -112,6 +112,7 @@ CONTRIBUTORS:
|
||||
- NV <nvsofts@gmail.com>
|
||||
- Olimjon <olim98@bk.ru>
|
||||
- parly <https://github.com/parly>
|
||||
- PeTeeR <tom2pet@gmail.com>
|
||||
- Quantum <quantum2048@gmail.com>
|
||||
- Quintin <quintin@last.za.net>
|
||||
- Raymond Tau <raymondtau@gmail.com>
|
||||
|
@ -1,12 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(BUILD_NUMBER CACHE STRING "The number of the current build.")
|
||||
|
||||
if ("${BUILD_NUMBER}" STREQUAL "")
|
||||
set(BUILD_NUMBER "5180")
|
||||
endif()
|
||||
|
||||
if (BUILD_NUMBER LESS 5180)
|
||||
message(WARNING
|
||||
"Setting BUILD_NUMBER to a value less than 5180 will break compatibility with client binaries distributed by SoftEther Corporation. "
|
||||
"Set to a value greater than or equal to 5180 if you want such clients to work properly.\n"
|
||||
"For detailed info: https://github.com/SoftEtherVPN/SoftEtherVPN/issues/1392#issuecomment-867348281")
|
||||
endif()
|
||||
|
||||
project("SoftEther VPN"
|
||||
VERSION 5.01.9673
|
||||
VERSION "5.02.${BUILD_NUMBER}"
|
||||
LANGUAGES C
|
||||
)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
set(TOP_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
set(BUILD_DIRECTORY ${TOP_DIRECTORY}/build)
|
||||
set(BUILD_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
# We define a dedicated variable because CMAKE_BUILD_TYPE can have different
|
||||
# configurations than "Debug" and "Release", such as "RelWithDebInfo".
|
||||
@ -17,27 +32,12 @@ else()
|
||||
endif()
|
||||
|
||||
# Check that submodules are present only if source was downloaded with git
|
||||
if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/Mayaqua/3rdparty/cpu_features/CMakeLists.txt")
|
||||
if(EXISTS "${TOP_DIRECTORY}/.git" AND NOT EXISTS "${TOP_DIRECTORY}/src/libhamcore/CMakeLists.txt")
|
||||
message (FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
|
||||
endif()
|
||||
|
||||
# Compare ${PROJECT_VERSION} and src/CurrentBuild.txt
|
||||
file(READ ${TOP_DIRECTORY}/src/CurrentBuild.txt CurrentBuild)
|
||||
|
||||
string(REGEX MATCH "VERSION_MAJOR ([0-9]+)" temp ${CurrentBuild})
|
||||
string(REGEX REPLACE "VERSION_MAJOR ([0-9]+)" "\\1" CurrentBuild_MAJOR ${temp})
|
||||
string(REGEX MATCH "VERSION_MINOR ([0-9]+)" temp ${CurrentBuild})
|
||||
string(REGEX REPLACE "VERSION_MINOR ([0-9]+)" "\\1" CurrentBuild_MINOR ${temp})
|
||||
string(REGEX MATCH "VERSION_BUILD ([0-9]+)" temp ${CurrentBuild})
|
||||
string(REGEX REPLACE "VERSION_BUILD ([0-9]+)" "\\1" CurrentBuild_BUILD ${temp})
|
||||
|
||||
if(NOT ${PROJECT_VERSION} VERSION_EQUAL "${CurrentBuild_MAJOR}.${CurrentBuild_MINOR}.${CurrentBuild_BUILD}")
|
||||
message (FATAL_ERROR "PROJECT_VERSION does not match to src/CurrentBuild.txt")
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
include(GNUInstallDirs)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
include(CheckIncludeFile)
|
||||
Check_Include_File(sys/auxv.h HAVE_SYS_AUXV)
|
||||
@ -59,8 +59,6 @@ string(TIMESTAMP TIME_SECOND "%S" UTC)
|
||||
message(STATUS "Build date: ${DATE_DAY}/${DATE_MONTH}/${DATE_YEAR}")
|
||||
message(STATUS "Build time: ${TIME_HOUR}:${TIME_MINUTE}:${TIME_SECOND}")
|
||||
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(UNIX)
|
||||
@ -90,5 +88,14 @@ if(UNIX)
|
||||
set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
|
||||
|
||||
# Exclude system directories
|
||||
if(CPACK_GENERATOR STREQUAL "RPM")
|
||||
execute_process(
|
||||
COMMAND rpm -ql filesystem
|
||||
COMMAND tr \n \;
|
||||
OUTPUT_VARIABLE CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
|
||||
ERROR_QUIET)
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
endif()
|
||||
|
5
CODE_OF_CONDUCT.md
Normal file
5
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
This project adheres to No Code of Conduct. We are all adults. We accept anyone's contributions. Nothing else matters.
|
||||
|
||||
For more information please visit the [No Code of Conduct](https://nocodeofconduct.com) homepage.
|
@ -1 +1,2 @@
|
||||
liberapay: softether
|
||||
custom: https://salt.bountysource.com/teams/softether-vpn
|
||||
|
23
README.md
23
README.md
@ -1,6 +1,12 @@
|
||||
# SoftEther VPN
|
||||
|
||||
[](https://ci.appveyor.com/project/softethervpn/softethervpn) [](https://travis-ci.org/SoftEtherVPN/SoftEtherVPN) [](https://gitlab.com/SoftEther/SoftEtherVPN/pipelines) [](https://scan.coverity.com/projects/softethervpn-softethervpn)
|
||||
||Badges|
|
||||
|---|---|
|
||||
|AppVeyor|[](https://ci.appveyor.com/project/softethervpn/softethervpn) |
|
||||
|GitLab CI|[](https://gitlab.com/SoftEther/SoftEtherVPN/pipelines)|
|
||||
|Coverity Scan|[](https://scan.coverity.com/projects/softethervpn-softethervpn)|
|
||||
|Azure Pipelines|[](https://dev.azure.com/SoftEther-VPN/SoftEther%20VPN/_build?definitionId=6)|
|
||||
|Cirrus CI|[](https://cirrus-ci.com/github/SoftEtherVPN/SoftEtherVPN)|
|
||||
|
||||
- [SoftEther VPN](#softether-vpn)
|
||||
- [BOARD MEMBERS OF THIS REPOSITORY](#board-members-of-this-repository)
|
||||
@ -226,22 +232,23 @@ some censorship governments want to block your access to the source code
|
||||
of SoftEther VPN, by abusing their censorship firewalls.
|
||||
|
||||
To circumvent your censor's unjust restriction,
|
||||
SoftEther VPN Project distributes the up-to-date source-code
|
||||
SoftEther VPN Project distributes the up-to-date source code
|
||||
on all the following open-source repositories:
|
||||
|
||||
- GitHub
|
||||
https://github.com/SoftEtherVPN/SoftEtherVPN/
|
||||
|
||||
```
|
||||
$ git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
|
||||
```
|
||||
$ git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
|
||||
|
||||
- GitLab (mirrored from GitHub)
|
||||
https://gitlab.com/SoftEther/SoftEtherVPN/
|
||||
|
||||
```
|
||||
$ git clone https://gitlab.com/SoftEther/SoftEtherVPN.git
|
||||
```
|
||||
$ git clone https://gitlab.com/SoftEther/SoftEtherVPN.git
|
||||
|
||||
- Codeberg (mirrored from GitHub)
|
||||
https://codeberg.org/softether/vpn
|
||||
|
||||
$ git clone https://codeberg.org/softether/vpn.git
|
||||
|
||||
We hope that you can reach one of the above URLs at least!
|
||||
|
||||
|
8
configure
vendored
8
configure
vendored
@ -17,8 +17,8 @@ echo
|
||||
echo 'Welcome to the corner-cutting configure script !'
|
||||
echo
|
||||
|
||||
if [ ! -d "tmp" ]; then
|
||||
mkdir tmp
|
||||
if [ ! -d "build" ]; then
|
||||
mkdir build
|
||||
fi
|
||||
|
||||
if [ ! -z ${CMAKE_FLAGS+x} ]; then
|
||||
@ -50,9 +50,9 @@ fi
|
||||
|
||||
echo ""
|
||||
|
||||
(cd tmp && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ${CMAKE_FLAGS} .. || exit 1)
|
||||
(cd build && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ${CMAKE_FLAGS} .. || exit 1)
|
||||
|
||||
|
||||
echo ""
|
||||
|
||||
echo "The Makefile is generated. Run 'make -C tmp' to build SoftEther VPN."
|
||||
echo "The Makefile is generated. Run 'make -C build' to build SoftEther VPN."
|
||||
|
@ -13,11 +13,11 @@ echo.
|
||||
echo Welcome to the corner-cutting configure script !
|
||||
echo.
|
||||
|
||||
if not exist "tmp" (
|
||||
mkdir tmp
|
||||
if not exist "build" (
|
||||
mkdir build
|
||||
)
|
||||
|
||||
cd tmp
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "NMake Makefiles" ..
|
||||
|
||||
|
@ -580,32 +580,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -615,7 +615,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>CurrentTime_dt</code></td>
|
||||
@ -2695,32 +2695,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -2730,7 +2730,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>SecureNATEnabled_bool</code></td>
|
||||
@ -6212,32 +6212,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -6247,7 +6247,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>UsePolicy_bool</code></td>
|
||||
@ -6683,32 +6683,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -6718,7 +6718,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>UsePolicy_bool</code></td>
|
||||
@ -7103,32 +7103,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -7138,7 +7138,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>UsePolicy_bool</code></td>
|
||||
@ -7747,32 +7747,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -7782,7 +7782,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>UsePolicy_bool</code></td>
|
||||
@ -8137,32 +8137,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -8172,7 +8172,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>UsePolicy_bool</code></td>
|
||||
@ -8485,32 +8485,32 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Recv)</td>
|
||||
<td>Number of broadcast packets (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Recv.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Recv)</td>
|
||||
<td>Unicast count (Recv)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastBytes_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.BroadcastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Broadcast bytes (Send)</td>
|
||||
<td>Number of broadcast packets (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>Send.UnicastBytes_u64</code></td>
|
||||
@ -8520,7 +8520,7 @@ All APIs are based on the <a href="https://www.jsonrpc.org/specification">JSON-R
|
||||
<tr>
|
||||
<td><code>Send.UnicastCount_u64</code></td>
|
||||
<td><code>number</code> (uint64)</td>
|
||||
<td>Unicast bytes (Send)</td>
|
||||
<td>Unicast count (Send)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>UsePolicy_bool</code></td>
|
||||
|
@ -404,14 +404,14 @@ Name | Type | Description
|
||||
`AssignedClientLicenses_u32` | `number` (uint32) | Number of assigned client licenses (Useful to make a commercial version)
|
||||
`AssignedBridgeLicensesTotal_u32` | `number` (uint32) | Number of Assigned bridge license (cluster-wide), useful to make a commercial version
|
||||
`AssignedClientLicensesTotal_u32` | `number` (uint32) | Number of assigned client licenses (cluster-wide), useful to make a commercial version
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`CurrentTime_dt` | `Date` | Current time
|
||||
`CurrentTick_u64` | `number` (uint64) | 64 bit High-Precision Logical System Clock
|
||||
`StartTime_dt` | `Date` | VPN Server Start-up time
|
||||
@ -1759,14 +1759,14 @@ Name | Type | Description
|
||||
`NumGroups_u32` | `number` (uint32) | Number of groups
|
||||
`NumMacTables_u32` | `number` (uint32) | Number of MAC table entries
|
||||
`NumIpTables_u32` | `number` (uint32) | Number of IP table entries
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`SecureNATEnabled_bool` | `boolean` | Whether SecureNAT is enabled
|
||||
`LastCommTime_dt` | `Date` | Last communication date and time
|
||||
`LastLoginTime_dt` | `Date` | Last login date and time
|
||||
@ -3712,14 +3712,14 @@ Name | Type | Description
|
||||
`RadiusUsername_utf` | `string` (UTF8) | Username in RADIUS server, optional, valid only if AuthType_u32 == Radius(4).
|
||||
`NtUsername_utf` | `string` (UTF8) | Username in NT Domain server, optional, valid only if AuthType_u32 == NT(5).
|
||||
`NumLogin_u32` | `number` (uint32) | Number of total logins of the user
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`UsePolicy_bool` | `boolean` | The flag whether to use security policy
|
||||
`policy:Access_bool` | `boolean` | Security policy: Allow Access. The users, which this policy value is true, have permission to make VPN connection to VPN Server.
|
||||
`policy:DHCPFilter_bool` | `boolean` | Security policy: Filter DHCP Packets (IPv4). All IPv4 DHCP packets in sessions defined this policy will be filtered.
|
||||
@ -3925,14 +3925,14 @@ Name | Type | Description
|
||||
`RadiusUsername_utf` | `string` (UTF8) | Username in RADIUS server, optional, valid only if AuthType_u32 == Radius(4).
|
||||
`NtUsername_utf` | `string` (UTF8) | Username in NT Domain server, optional, valid only if AuthType_u32 == NT(5).
|
||||
`NumLogin_u32` | `number` (uint32) | Number of total logins of the user
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`UsePolicy_bool` | `boolean` | The flag whether to use security policy
|
||||
`policy:Access_bool` | `boolean` | Security policy: Allow Access. The users, which this policy value is true, have permission to make VPN connection to VPN Server.
|
||||
`policy:DHCPFilter_bool` | `boolean` | Security policy: Filter DHCP Packets (IPv4). All IPv4 DHCP packets in sessions defined this policy will be filtered.
|
||||
@ -4087,14 +4087,14 @@ Name | Type | Description
|
||||
`RadiusUsername_utf` | `string` (UTF8) | Username in RADIUS server, optional, valid only if AuthType_u32 == Radius(4).
|
||||
`NtUsername_utf` | `string` (UTF8) | Username in NT Domain server, optional, valid only if AuthType_u32 == NT(5).
|
||||
`NumLogin_u32` | `number` (uint32) | Number of total logins of the user
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`UsePolicy_bool` | `boolean` | The flag whether to use security policy
|
||||
`policy:Access_bool` | `boolean` | Security policy: Allow Access. The users, which this policy value is true, have permission to make VPN connection to VPN Server.
|
||||
`policy:DHCPFilter_bool` | `boolean` | Security policy: Filter DHCP Packets (IPv4). All IPv4 DHCP packets in sessions defined this policy will be filtered.
|
||||
@ -4425,14 +4425,14 @@ Name | Type | Description
|
||||
`Name_str` | `string` (ASCII) | The group name
|
||||
`Realname_utf` | `string` (UTF8) | Optional real name (full name) of the group, allow using any Unicode characters
|
||||
`Note_utf` | `string` (UTF8) | Optional, specify a description of the group
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`UsePolicy_bool` | `boolean` | The flag whether to use security policy
|
||||
`policy:Access_bool` | `boolean` | Security policy: Allow Access. The users, which this policy value is true, have permission to make VPN connection to VPN Server.
|
||||
`policy:DHCPFilter_bool` | `boolean` | Security policy: Filter DHCP Packets (IPv4). All IPv4 DHCP packets in sessions defined this policy will be filtered.
|
||||
@ -4605,14 +4605,14 @@ Name | Type | Description
|
||||
`Name_str` | `string` (ASCII) | The group name
|
||||
`Realname_utf` | `string` (UTF8) | Optional real name (full name) of the group, allow using any Unicode characters
|
||||
`Note_utf` | `string` (UTF8) | Optional, specify a description of the group
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`UsePolicy_bool` | `boolean` | The flag whether to use security policy
|
||||
`policy:Access_bool` | `boolean` | Security policy: Allow Access. The users, which this policy value is true, have permission to make VPN connection to VPN Server.
|
||||
`policy:DHCPFilter_bool` | `boolean` | Security policy: Filter DHCP Packets (IPv4). All IPv4 DHCP packets in sessions defined this policy will be filtered.
|
||||
@ -4743,14 +4743,14 @@ Name | Type | Description
|
||||
`Name_str` | `string` (ASCII) | The group name
|
||||
`Realname_utf` | `string` (UTF8) | Optional real name (full name) of the group, allow using any Unicode characters
|
||||
`Note_utf` | `string` (UTF8) | Optional, specify a description of the group
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Recv.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Recv)
|
||||
`Recv.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Recv)
|
||||
`Recv.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Recv)
|
||||
`Recv.UnicastCount_u64` | `number` (uint64) | Unicast count (Recv)
|
||||
`Send.BroadcastBytes_u64` | `number` (uint64) | Broadcast bytes (Send)
|
||||
`Send.BroadcastCount_u64` | `number` (uint64) | Number of broadcast packets (Send)
|
||||
`Send.UnicastBytes_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast bytes (Send)
|
||||
`Send.UnicastCount_u64` | `number` (uint64) | Unicast count (Send)
|
||||
`UsePolicy_bool` | `boolean` | The flag whether to use security policy
|
||||
`policy:Access_bool` | `boolean` | Security policy: Allow Access. The users, which this policy value is true, have permission to make VPN connection to VPN Server.
|
||||
`policy:DHCPFilter_bool` | `boolean` | Security policy: Filter DHCP Packets (IPv4). All IPv4 DHCP packets in sessions defined this policy will be filtered.
|
||||
|
@ -33,18 +33,18 @@ You need to install the following software to build SoftEther VPN for UNIX.
|
||||
|
||||
```bash
|
||||
sudo yum -y groupinstall "Development Tools"
|
||||
sudo yum -y install cmake ncurses-devel openssl-devel readline-devel zlib-devel
|
||||
sudo yum -y install cmake ncurses-devel openssl-devel libsodium-devel readline-devel zlib-devel
|
||||
```
|
||||
|
||||
## Install requirements on Debian/Ubuntu
|
||||
```bash
|
||||
sudo apt -y install cmake gcc g++ libncurses5-dev libreadline-dev libssl-dev make zlib1g-dev
|
||||
sudo apt -y install cmake gcc g++ make libncurses5-dev libssl-dev libsodium-dev libreadline-dev zlib1g-dev
|
||||
```
|
||||
|
||||
## Install requirements on macOS
|
||||
```bash
|
||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
brew install cmake openssl readline
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||
brew install cmake openssl libsodium readline
|
||||
```
|
||||
|
||||
# Build from source code and install
|
||||
@ -56,8 +56,8 @@ git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
|
||||
cd SoftEtherVPN
|
||||
git submodule init && git submodule update
|
||||
./configure
|
||||
make -C tmp
|
||||
make -C tmp install
|
||||
make -C build
|
||||
make -C build install
|
||||
```
|
||||
|
||||
This will compile and install SoftEther VPN Server, Bridge and Client binaries under your executable path.
|
||||
@ -74,8 +74,8 @@ git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
|
||||
cd SoftEtherVPN
|
||||
git submodule init && git submodule update
|
||||
./configure
|
||||
make -C tmp
|
||||
make -C tmp install
|
||||
make -C build
|
||||
make -C build install
|
||||
```
|
||||
|
||||
Building without USE_MUSL environment variable set compiles, but produced executables exhibit bad run-time behaviour.
|
||||
|
@ -1,59 +1,18 @@
|
||||
How to build SoftEther VPN for Windows
|
||||
======================================
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
You need to install the following software to run a full release build of SoftEther VPN for Windows.
|
||||
|
||||
- Microsoft Windows XP, Vista, 7, 8 or later.
|
||||
- Microsoft Visual Studio 2008 with the latest SP (SP1 9.0.30729.4462 QFE).
|
||||
Make sure that you installed the x64 compiler and build tools.
|
||||
- Microsoft Windows Driver Kit 7.1.0.
|
||||
|
||||
|
||||
Full Build Instructions
|
||||
-----------------------
|
||||
|
||||
The following steps will build all SoftEther VPN program files, and also build
|
||||
the installer packages of SoftEther VPN. It is very easy.
|
||||
|
||||
1. Run the "BuildAll.cmd" batch file in the "src" directory.
|
||||
2. Wait until the building process will complete.
|
||||
3. The built files are stored on the "output" directory.
|
||||
|
||||
|
||||
Partly Build, Debug, or Development Instructions on Visual Studio 2008
|
||||
---------------------------------------------------------------------
|
||||
|
||||
If you are a programmer, you can open the SoftEther VPN solution file
|
||||
with Visual Studio 2008 to customize. Open "src\SEVPN.sln" and enjoy it.
|
||||
|
||||
Visual Studio 2008 is required as to maintain compatibility with Windows 9x, due to Visual C++ 2008 being the last version compatibile with Windows 9x and Windows NT 4.x binary linking.
|
||||
|
||||
- Visual Studio 2008's installer ISO can be found on Microsoft's site here: https://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso
|
||||
|
||||
- The Microsoft Windows Driver Kit 7.1.0 can be found here: https://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO
|
||||
|
||||
If using anything else other than Visual Studio 2008 for development, your code **MUST** support Microsoft Visual C++ 2008 due to aforementioned reasons.
|
||||
|
||||
It is OK to add newer Visual Studio (2015, 2017) solution files to the project, but there then must be dual solution files for both Visual C++ 2008 and the latest Visual Studio.
|
||||
|
||||
Build and Development Instructions with Visual Studio 2017 & CMake
|
||||
---------------------------------------------------------------------
|
||||
|
||||
An alternative method for development of the SoftEtherVPN project on Windows is through CMake.
|
||||
|
||||
There are several methods for using CMake but the easiest by far is through Visual Studio 2017 by importing the CMake project directly
|
||||
There are several methods for using CMake but the easiest by far is through Visual Studio 2019 by importing the CMake project directly
|
||||
into it. So that is what will be described below.
|
||||
|
||||
Requirements:
|
||||
|
||||
1. Download Visual Studio 2017 (Community Edition is fine).
|
||||
1. Download Visual Studio 2019 (Community Edition is fine).
|
||||
2. During install, make sure to check "Desktop development with C++" under "Workloads".
|
||||
3. Click on individual components and scroll until you see "Visual C++ tools for CMake" under the compilers section. Make sure this is checked.
|
||||
4. Proceed with and finish Visual Studio 2017 install.
|
||||
4. Proceed with and finish Visual Studio 2019 installation.
|
||||
5. Install the needed submodules to build the project, avoiding CMake telling you to do so with: `git submodule update --init --recursive`
|
||||
|
||||
Building:
|
||||
@ -69,9 +28,4 @@ of all the SoftEtherVPN components.
|
||||
Congrats, you now have a complete CMake development environment for SoftEtherVPN on Windows, enjoy and happy contributing!
|
||||
|
||||
Download Links:
|
||||
- Visual Studio 2017 from Microsoft: https://visualstudio.microsoft.com/downloads
|
||||
|
||||
************************************
|
||||
Thank You Using SoftEther VPN !
|
||||
By SoftEther VPN Open-Source Project
|
||||
https://www.softether.org/
|
||||
- Visual Studio 2019 from Microsoft: https://visualstudio.microsoft.com/downloads
|
||||
|
@ -1,38 +0,0 @@
|
||||
SETLOCAL
|
||||
SET BATCH_FILE_NAME=%0
|
||||
SET BATCH_DIR_PATH=%~dp0
|
||||
SET NOW_TMP=%time:~0,2%
|
||||
SET NOW=%date:~0,4%%date:~5,2%%date:~8,2%_%NOW_TMP: =0%%time:~3,2%%time:~6,2%
|
||||
|
||||
if exist "C:\Program Files\Microsoft Visual Studio 9.0" (
|
||||
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
|
||||
) else if exist "C:\Program Files (x86)\Microsoft Visual Studio 9.0" (
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
|
||||
) else (
|
||||
echo "Visual Studio 2008 not found!"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "C:\windows\Microsoft.NET\Framework\v3.5" (
|
||||
echo ".NET Framework 3.5 not found!"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo on
|
||||
|
||||
copy "%BATCH_DIR_PATH%..\AUTHORS.TXT" "%BATCH_DIR_PATH%bin\hamcore\authors.txt"
|
||||
|
||||
echo f | xcopy "%BATCH_DIR_PATH%BuildFiles\Library\vs2008\Win32_Release\ossl_static.pdb" "%BATCH_DIR_PATH%DebugFiles\pdb\Win32_Release\ossl_static.pdb"
|
||||
echo f | xcopy "%BATCH_DIR_PATH%BuildFiles\Library\vs2008\x64_Release\ossl_static.pdb" "%BATCH_DIR_PATH%DebugFiles\pdb\x64_Release\ossl_static.pdb"
|
||||
|
||||
if exist "%BATCH_DIR_PATH%bin\BuildUtil.exe" (
|
||||
del "%BATCH_DIR_PATH%bin\BuildUtil.exe"
|
||||
)
|
||||
|
||||
C:\windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /toolsversion:3.5 /target:Clean;Rebuild /property:Configuration=Debug "%BATCH_DIR_PATH%BuildUtil\BuildUtil.csproj"
|
||||
|
||||
cd "%BATCH_DIR_PATH%bin"
|
||||
|
||||
BuildUtil.exe /CMD:All
|
||||
|
||||
if errorlevel 1 exit /b %errorlevel%
|
@ -1 +0,0 @@
|
||||
crosslib_win32_191019_02
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
crosslib_win32_191019_02
|
@ -1 +0,0 @@
|
||||
crosslib_win32_191019_02
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
crosslib_win32_191019_02
|
29
src/BuildFiles/Manifests/common.manifest
Normal file
29
src/BuildFiles/Manifests/common.manifest
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
|
||||
</application>
|
||||
</compatibility>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
|
||||
</application>
|
||||
</compatibility>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
|
||||
</application>
|
||||
</compatibility>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
|
||||
</application>
|
||||
</compatibility>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedOS>
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedOS>
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedOS>
|
||||
</application>
|
||||
</compatibility>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
@ -1,214 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{384815C3-333C-4CEC-9DCD-B6AB2602EBB9}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BuildUtil</RootNamespace>
|
||||
<AssemblyName>BuildUtilTmp</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ApplicationIcon>BuildUtilIcon.ico</ApplicationIcon>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<StartupObject>BuildUtil.BuildUtilMain</StartupObject>
|
||||
<NoWin32Manifest>true</NoWin32Manifest>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;BU_SOFTETHER;BU_OSS</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Test.cs" />
|
||||
<Compile Include="UnixBuildSoftwares.cs" />
|
||||
<Compile Include="VpnBuilder.cs" />
|
||||
<Compile Include="VpnBuilderConfig.cs" />
|
||||
<Compile Include="VpnBuilderConfigTypes.cs" />
|
||||
<Compile Include="Web References\HvSignService\Reference.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Reference.map</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Web References\SignService\Reference.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Reference.map</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Win32BuildSoftware.cs" />
|
||||
<Compile Include="Win32BuildUtil.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WebReferences Include="Web References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WebReferenceUrl Include="http://dv/Sign/Sign.asmx">
|
||||
<UrlBehavior>Dynamic</UrlBehavior>
|
||||
<RelPath>Web References\SignService\</RelPath>
|
||||
<UpdateFromURL>http://dv/Sign/Sign.asmx</UpdateFromURL>
|
||||
<ServiceLocationURL>
|
||||
</ServiceLocationURL>
|
||||
<CachedDynamicPropName>
|
||||
</CachedDynamicPropName>
|
||||
<CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName>
|
||||
<CachedSettingsPropName>BuildUtil_SignService_Sign</CachedSettingsPropName>
|
||||
</WebReferenceUrl>
|
||||
<WebReferenceUrl Include="http://hvsigncode/Sign.asmx">
|
||||
<UrlBehavior>Dynamic</UrlBehavior>
|
||||
<RelPath>Web References\HvSignService\</RelPath>
|
||||
<UpdateFromURL>http://hvsigncode/Sign.asmx</UpdateFromURL>
|
||||
<ServiceLocationURL>
|
||||
</ServiceLocationURL>
|
||||
<CachedDynamicPropName>
|
||||
</CachedDynamicPropName>
|
||||
<CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName>
|
||||
<CachedSettingsPropName>BuildUtilTmp_HvSignService_Sign</CachedSettingsPropName>
|
||||
</WebReferenceUrl>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Web References\HvSignService\Sign.wsdl" />
|
||||
<None Include="Web References\SignService\Reference.map">
|
||||
<Generator>MSDiscoCodeGenerator</Generator>
|
||||
<LastGenOutput>Reference.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Web References\SignService\Sign.disco" />
|
||||
<None Include="Web References\SignService\Sign.wsdl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="BuildUtilIcon.ico" />
|
||||
<None Include="Web References\HvSignService\Reference.map">
|
||||
<Generator>MSDiscoCodeGenerator</Generator>
|
||||
<LastGenOutput>Reference.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Web References\HvSignService\Sign.disco" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>$(ProjectDir)CopyBuildUtil.cmd</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 30 KiB |
@ -1,113 +0,0 @@
|
||||
// SoftEther VPN Source Code - Developer Edition Master Branch
|
||||
// Build Utility
|
||||
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
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.Net;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using CoreUtil;
|
||||
|
||||
namespace BuildUtil
|
||||
{
|
||||
public class BuildUtilMain
|
||||
{
|
||||
public static bool pause = false;
|
||||
|
||||
// Main function
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
string errMsg = "";
|
||||
|
||||
int ret = 0;
|
||||
|
||||
ret = ConsoleService.EntryPoint("BuildUtil " + Env.CommandLine, "BuildUtil", typeof(BuildUtilMain), out errMsg);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
Con.WriteLine("{0}: fatal error C0001: {1}", Path.GetFileNameWithoutExtension(Env.ExeFileName), errMsg);
|
||||
|
||||
if (pause)
|
||||
{
|
||||
Console.Write("Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Command execution
|
||||
[ConsoleCommandMethod(
|
||||
"VPN Build Utility",
|
||||
"[/IN:infile] [/OUT:outfile] [/CSV] [/PAUSEIFERROR:yes|no] [/CMD command_line...]",
|
||||
"VPN Build Utility",
|
||||
"IN:This will specify the text file 'infile' that contains the list of commands that are automatically executed after the connection is completed. If the /IN parameter is specified, the vpncmd program will terminate automatically after the execution of all commands in the file are finished. If the file contains multiple-byte characters, the encoding must be Unicode (UTF-8). This cannot be specified together with /CMD (if /CMD is specified, /IN will be ignored).",
|
||||
"OUT:You can specify the text file 'outfile' to write all strings such as onscreen prompts, message, error and execution results. Note that if the specified file already exists, the contents of the existing file will be overwritten. Output strings will be recorded using Unicode (UTF-8) encoding.",
|
||||
"CMD:If the optional command 'command_line...' is included after /CMD, that command will be executed after the connection is complete and the vpncmd program will terminate after that. This cannot be specified together with /IN (if specified together with /IN, /IN will be ignored). Specify the /CMD parameter after all other vpncmd parameters.",
|
||||
"CSV:Enable CSV Mode.",
|
||||
"PAUSEIFERROR:Specify yes if you'd like to pause before exiting the process if there are any errors."
|
||||
)]
|
||||
public static int BuildUtil(ConsoleService c, string cmdName, string str)
|
||||
{
|
||||
Con.WriteLine("");
|
||||
Con.WriteLine("Copyright (c) SoftEther VPN Project. All Rights Reserved.");
|
||||
Con.WriteLine("");
|
||||
|
||||
ConsoleParam[] args =
|
||||
{
|
||||
new ConsoleParam("IN", null, null, null, null),
|
||||
new ConsoleParam("OUT", null, null, null, null),
|
||||
new ConsoleParam("CMD", null, null, null, null),
|
||||
new ConsoleParam("CSV", null, null, null, null),
|
||||
new ConsoleParam("PAUSEIFERROR", null, null, null, null),
|
||||
new ConsoleParam("DT", null, null, null, null),
|
||||
};
|
||||
|
||||
ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);
|
||||
|
||||
pause = vl["PAUSEIFERROR"].BoolValue;
|
||||
|
||||
string cmdline = vl["CMD"].StrValue;
|
||||
|
||||
if (vl["DT"].IsEmpty == false)
|
||||
{
|
||||
BuildSoftwareList.ListCreatedDateTime = Str.StrToDateTime(vl["DT"].StrValue);
|
||||
}
|
||||
|
||||
ConsoleService cs = c;
|
||||
|
||||
while (cs.DispatchCommand(cmdline, "BuildUtil>", typeof(BuildUtilCommands), null))
|
||||
{
|
||||
if (Str.IsEmptyStr(cmdline) == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return cs.RetCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,195 +0,0 @@
|
||||
// SoftEther VPN Source Code - Developer Edition Master Branch
|
||||
// Build Utility
|
||||
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
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.Net;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using CoreUtil;
|
||||
using BuildUtil.HvSignService;
|
||||
|
||||
namespace BuildUtil
|
||||
{
|
||||
public static class CodeSign
|
||||
{
|
||||
public const int NumRetries = 1;
|
||||
public const int RetryIntervals = 200;
|
||||
|
||||
public const int NumRetriesForCopy = 50;
|
||||
public const int RetryIntervalsForCopy = 10;
|
||||
|
||||
const string in_dir = @"\\hvsigncode\SIGN\IN";
|
||||
const string out_dir = @"\\hvsigncode\SIGN\OUT";
|
||||
|
||||
#if !BU_SOFTETHER
|
||||
public static int UsingCertId = 1;
|
||||
#else
|
||||
public static int UsingCertId = 2;
|
||||
#endif
|
||||
|
||||
static object lockObj = new object();
|
||||
|
||||
// Digital-sign the data on the memory
|
||||
public static byte[] SignMemory(byte[] srcData, string comment, bool kernelModeDriver, int cert_id, int sha_mode)
|
||||
{
|
||||
#if !BU_OSS
|
||||
int i;
|
||||
string out_filename = null;
|
||||
byte[] ret = null;
|
||||
|
||||
string in_tmp_filename = Path.Combine(in_dir,
|
||||
Str.DateTimeToStrShortWithMilliSecs(DateTime.Now) + "_" +
|
||||
Env.MachineName + "_" +
|
||||
Secure.Rand63i().ToString() + ".dat");
|
||||
|
||||
IO.SaveFile(in_tmp_filename, srcData);
|
||||
|
||||
for (i = 0; i < NumRetries; i++)
|
||||
{
|
||||
Sign sign = new Sign();
|
||||
sign.Proxy = new WebProxy();
|
||||
|
||||
try
|
||||
{
|
||||
out_filename = sign.ExecSignEx(Path.GetFileName(in_tmp_filename),
|
||||
kernelModeDriver,
|
||||
comment,
|
||||
cert_id,
|
||||
sha_mode);
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (i != (NumRetries - 1))
|
||||
{
|
||||
Kernel.SleepThread(RetryIntervals);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NumRetriesForCopy; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
ret = IO.ReadFile(Path.Combine(out_dir, out_filename));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (i != (NumRetriesForCopy - 1))
|
||||
{
|
||||
Kernel.SleepThread(RetryIntervalsForCopy);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string tmpFileName = IO.CreateTempFileNameByExt(".exe");
|
||||
try
|
||||
{
|
||||
File.Delete(tmpFileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
File.WriteAllBytes(tmpFileName, ret);
|
||||
|
||||
lock (lockObj)
|
||||
{
|
||||
if (ExeSignChecker.CheckFileDigitalSignature(tmpFileName) == false)
|
||||
{
|
||||
throw new ApplicationException("CheckFileDigitalSignature failed.");
|
||||
}
|
||||
|
||||
if (kernelModeDriver)
|
||||
{
|
||||
if (ExeSignChecker.IsKernelModeSignedFile(tmpFileName) == false)
|
||||
{
|
||||
throw new ApplicationException("IsKernelModeSignedFile failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
}
|
||||
catch
|
||||
{
|
||||
File.Delete(tmpFileName);
|
||||
}
|
||||
|
||||
return ret;
|
||||
#else // BU_OSS
|
||||
return srcData;
|
||||
#endif // BU_OSS
|
||||
}
|
||||
|
||||
// Digital-sign the data on the file
|
||||
public static void SignFile(string destFileName, string srcFileName, string comment, bool kernelModeDriver)
|
||||
{
|
||||
int cert_id = UsingCertId;
|
||||
|
||||
SignFile(destFileName, srcFileName, comment, kernelModeDriver, cert_id, 0);
|
||||
}
|
||||
public static void SignFile(string destFileName, string srcFileName, string comment, bool kernelModeDriver, int cert_id, int sha_mode)
|
||||
{
|
||||
#if !BU_OSS
|
||||
if (cert_id == 0)
|
||||
{
|
||||
cert_id = UsingCertId;
|
||||
}
|
||||
|
||||
Con.WriteLine("Signing for '{0}'...", Path.GetFileName(destFileName));
|
||||
byte[] srcData = File.ReadAllBytes(srcFileName);
|
||||
|
||||
if (srcFileName.EndsWith(".msi", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
sha_mode = 1;
|
||||
// todo: Set 2 in future !!!
|
||||
}
|
||||
|
||||
byte[] destData = SignMemory(srcData, comment, kernelModeDriver, cert_id, sha_mode);
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(destFileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
File.WriteAllBytes(destFileName, destData);
|
||||
|
||||
Con.WriteLine("Done.");
|
||||
#else // BU_OSS
|
||||
Con.WriteLine("Skipping the code signing for '{0}' in the build process. You can insert your own authenticode sign process here.", srcFileName);
|
||||
#endif // BU_OSS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
copy "%0\..\..\bin\BuildUtilTmp.exe" "%0\..\..\bin\BuildUtil.exe"
|
||||
exit /b 0
|
@ -1,117 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,602 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,249 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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_interval = expireSpan.Milliseconds / 10;
|
||||
|
||||
lock (lockObj)
|
||||
{
|
||||
if (last_deleted == 0 || now > (last_deleted + delete_interval))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,111 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,426 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,501 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,162 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,868 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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 IsUrlModified;
|
||||
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.IsUrlModified = 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.IsUrlModified == 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,131 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,466 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,958 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CoreUtil
|
||||
{
|
||||
public class CommonSign
|
||||
{
|
||||
byte[] keyData;
|
||||
static uint init_dummy = CryptoConfigHelper.Init();
|
||||
|
||||
public CommonSign(byte[] key)
|
||||
{
|
||||
init(key);
|
||||
}
|
||||
public CommonSign(Buf buf)
|
||||
{
|
||||
init(buf.ByteData);
|
||||
}
|
||||
public CommonSign(string filename)
|
||||
{
|
||||
init(Buf.ReadFromFile(filename).ByteData);
|
||||
}
|
||||
void init(byte[] key)
|
||||
{
|
||||
keyData = (byte[])key.Clone();
|
||||
}
|
||||
|
||||
public byte[] Sign(byte[] data)
|
||||
{
|
||||
Buf b = new Buf(data);
|
||||
b.SeekToEnd();
|
||||
b.Write(keyData);
|
||||
|
||||
return Secure.HashSHA1(b.ByteData);
|
||||
}
|
||||
public bool Verify(byte[] data, byte[] sign)
|
||||
{
|
||||
byte[] sign2 = Sign(data);
|
||||
|
||||
return Util.CompareByte(sign, sign2);
|
||||
}
|
||||
}
|
||||
|
||||
public class Rsa
|
||||
{
|
||||
byte[] data;
|
||||
Cert cert;
|
||||
static uint init_dummy = CryptoConfigHelper.Init();
|
||||
static object lockObj = new object();
|
||||
|
||||
public Rsa(byte[] data)
|
||||
{
|
||||
init(data);
|
||||
}
|
||||
public Rsa(string filename)
|
||||
{
|
||||
Buf b = Buf.ReadFromFile(filename);
|
||||
init(b.ByteData);
|
||||
}
|
||||
public Rsa(Buf b)
|
||||
{
|
||||
init(b.ByteData);
|
||||
}
|
||||
void init(byte[] data)
|
||||
{
|
||||
this.data = (byte[])data.Clone();
|
||||
this.cert = null;
|
||||
|
||||
Cert.deleteOldTempFiles();
|
||||
}
|
||||
|
||||
public Rsa(Cert cert)
|
||||
{
|
||||
init(cert);
|
||||
}
|
||||
void init(Cert cert)
|
||||
{
|
||||
this.cert = (Cert)cert.Clone();
|
||||
this.data = null;
|
||||
|
||||
Cert.deleteOldTempFiles();
|
||||
}
|
||||
|
||||
public byte[] SignData(byte[] data)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
byte[] ret;
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
ret = rsa.SignData(data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] SignHash(byte[] hash)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
byte[] ret;
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
ret = rsa.SignHash(hash);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public bool VerifyData(byte[] data, byte[] sign)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
bool ret;
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
ret = rsa.VerifyData(data, sign);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public bool VerifyHash(byte[] hash, byte[] sign)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
bool ret;
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
ret = rsa.VerifyHash(hash, sign);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Encrypt(byte[] data)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
return rsa.Encrypt(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Decrypt(byte[] data)
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
return rsa.Decrypt(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int KeySizeBit
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
using (RsaInner rsa = new RsaInner(this.data, this.cert))
|
||||
{
|
||||
return rsa.KeySizeBit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RsaInner : IDisposable
|
||||
{
|
||||
static string sha1rsa = CryptoConfig.MapNameToOID("SHA1");
|
||||
RSACryptoServiceProvider rsa;
|
||||
static object lockObj = new Object();
|
||||
static LocalDataStoreSlot slot = Thread.AllocateDataSlot();
|
||||
static LocalDataStoreSlot slot2 = Thread.AllocateDataSlot();
|
||||
static uint init_dummy = CryptoConfigHelper.Init();
|
||||
|
||||
public static void Lock()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Unlock()
|
||||
{
|
||||
}
|
||||
|
||||
public RsaInner(byte[] data, Cert cert)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
init(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
init(cert);
|
||||
}
|
||||
}
|
||||
public RsaInner(byte[] data)
|
||||
{
|
||||
init(data);
|
||||
}
|
||||
public RsaInner(string filename)
|
||||
{
|
||||
Buf b = Buf.ReadFromFile(filename);
|
||||
init(b.ByteData);
|
||||
}
|
||||
public RsaInner(Buf b)
|
||||
{
|
||||
init(b.ByteData);
|
||||
}
|
||||
void init(byte[] data)
|
||||
{
|
||||
Lock();
|
||||
rsa = readRsaPrivate(data);
|
||||
}
|
||||
|
||||
public RsaInner(Cert cert)
|
||||
{
|
||||
init(cert);
|
||||
}
|
||||
void init(Cert cert)
|
||||
{
|
||||
Lock();
|
||||
string text1 = cert.X509Cert.GetKeyAlgorithm();
|
||||
byte[] buffer1 = cert.X509Cert.GetKeyAlgorithmParameters();
|
||||
byte[] buffer2 = cert.X509Cert.GetPublicKey();
|
||||
Oid oid1 = new Oid("1.2.840.113549.1.1.1", "RSA");
|
||||
|
||||
rsa = (RSACryptoServiceProvider)(new PublicKey(oid1, new AsnEncodedData(oid1, buffer1), new AsnEncodedData(oid1, buffer2))).Key;
|
||||
}
|
||||
|
||||
public byte[] SignData(byte[] data)
|
||||
{
|
||||
byte[] hash = Secure.HashSHA1(data);
|
||||
return SignHash(hash);
|
||||
}
|
||||
|
||||
public byte[] SignHash(byte[] hash)
|
||||
{
|
||||
byte[] ret = null;
|
||||
ret = rsa.SignHash(hash, sha1rsa);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool VerifyData(byte[] data, byte[] sign)
|
||||
{
|
||||
byte[] hash = Secure.HashSHA1(data);
|
||||
return VerifyHash(hash, sign);
|
||||
}
|
||||
|
||||
public bool VerifyHash(byte[] hash, byte[] sign)
|
||||
{
|
||||
return rsa.VerifyHash(hash, sha1rsa, sign);
|
||||
}
|
||||
|
||||
public byte[] Encrypt(byte[] data)
|
||||
{
|
||||
return rsa.Encrypt(data, false);
|
||||
}
|
||||
|
||||
public byte[] Decrypt(byte[] data)
|
||||
{
|
||||
return rsa.Decrypt(data, false);
|
||||
}
|
||||
|
||||
static RSACryptoServiceProvider readRsaPrivate(byte[] data)
|
||||
{
|
||||
// From http://forums.l-space-design.com/blogs/day_of_the_developer/archive/2006/06/08/216.aspx
|
||||
string t = Str.AsciiEncoding.GetString(data);
|
||||
if (!t.StartsWith("-----BEGIN RSA PRIVATE KEY-----"))
|
||||
{
|
||||
throw new ArgumentException("Not an RSA Private Key");
|
||||
}
|
||||
t = t.Substring("-----BEGIN RSA PRIVATE KEY-----".Length);
|
||||
t = t.Substring(0, t.IndexOf("----"));
|
||||
t = t.Replace("\r", "").Replace("\n", "");
|
||||
byte[] byteArray = System.Convert.FromBase64String(t);
|
||||
System.IO.MemoryStream s = new MemoryStream(byteArray);
|
||||
BinaryReader binr = new BinaryReader(s, Str.AsciiEncoding);
|
||||
byte[] MODULUS, E, D, P, Q, DP, DQ, IQ;
|
||||
// --------- Set up stream to decode the asn.1 encoded RSA private key ------
|
||||
byte bt = 0;
|
||||
ushort twobytes = 0;
|
||||
int elems = 0;
|
||||
RSAParameters result = new RSAParameters();
|
||||
try
|
||||
{
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81)
|
||||
binr.ReadByte(); //advance 1 byte
|
||||
else if (twobytes == 0x8230)
|
||||
binr.ReadInt16(); //advance 2 bytes
|
||||
else
|
||||
return null;
|
||||
twobytes = binr.ReadUInt16();
|
||||
if (twobytes != 0x0102) //version number
|
||||
return null;
|
||||
bt = binr.ReadByte();
|
||||
if (bt != 0x00)
|
||||
return null;
|
||||
//------ all private key components are Integer sequences ----
|
||||
elems = getIntegerSize(binr);
|
||||
MODULUS = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
E = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
D = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
P = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
Q = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
DP = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
DQ = binr.ReadBytes(elems);
|
||||
elems = getIntegerSize(binr);
|
||||
IQ = binr.ReadBytes(elems);
|
||||
result.Modulus = MODULUS;
|
||||
result.Exponent = E;
|
||||
result.D = D;
|
||||
result.P = P;
|
||||
result.Q = Q;
|
||||
result.DP = DP;
|
||||
result.DQ = DQ;
|
||||
result.InverseQ = IQ;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
binr.Close();
|
||||
}
|
||||
CspParameters cp = new CspParameters();
|
||||
cp.Flags = CspProviderFlags.UseMachineKeyStore;
|
||||
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(cp);
|
||||
RSA.PersistKeyInCsp = false;
|
||||
RSA.ImportParameters(result);
|
||||
return RSA;
|
||||
}
|
||||
|
||||
static int getIntegerSize(BinaryReader binr)
|
||||
{
|
||||
byte bt = 0;
|
||||
byte lowbyte = 0x00;
|
||||
byte highbyte = 0x00;
|
||||
int count = 0;
|
||||
bt = binr.ReadByte();
|
||||
if (bt != 0x02) //expect integer
|
||||
return 0;
|
||||
bt = binr.ReadByte();
|
||||
if (bt == 0x81)
|
||||
count = binr.ReadByte(); // data size in next byte
|
||||
else
|
||||
if (bt == 0x82)
|
||||
{
|
||||
highbyte = binr.ReadByte(); // data size in next 2 bytes
|
||||
lowbyte = binr.ReadByte();
|
||||
byte[] modint = { lowbyte, highbyte, 0x00, 0x00 };
|
||||
count = BitConverter.ToInt32(modint, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = bt; // we already have the data size
|
||||
}
|
||||
while (binr.PeekChar() == 0x00)
|
||||
{ //remove high order zeros in data
|
||||
binr.ReadByte();
|
||||
count -= 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
rsa.Clear();
|
||||
rsa = null;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
public int KeySizeBit
|
||||
{
|
||||
get
|
||||
{
|
||||
return rsa.KeySize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Cert
|
||||
{
|
||||
X509Certificate2 x509;
|
||||
static TimeSpan deleteOldCertSpan = new TimeSpan(0, 0, 30);
|
||||
static object lockObj = new Object();
|
||||
static RSACryptoServiceProvider rsaDummy = null;
|
||||
static uint init_dummy = CryptoConfigHelper.Init();
|
||||
|
||||
public int KeySizeBit
|
||||
{
|
||||
get
|
||||
{
|
||||
Rsa r = new Rsa(this);
|
||||
|
||||
return r.KeySizeBit;
|
||||
}
|
||||
}
|
||||
|
||||
public X509Certificate2 X509Cert
|
||||
{
|
||||
get { return x509; }
|
||||
}
|
||||
|
||||
public Rsa RsaPublicKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Rsa(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Cert(byte[] data)
|
||||
{
|
||||
init(data);
|
||||
}
|
||||
public Cert(string filename)
|
||||
{
|
||||
init(IO.ReadFile(filename));
|
||||
}
|
||||
public Cert(Buf buf)
|
||||
{
|
||||
init(buf.ByteData);
|
||||
}
|
||||
void init(byte[] data)
|
||||
{
|
||||
deleteOldTempFiles();
|
||||
x509 = new X509Certificate2(data);
|
||||
|
||||
if (rsaDummy == null)
|
||||
{
|
||||
rsaDummy = (RSACryptoServiceProvider)(new X509Certificate2(data).PublicKey.Key);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
return x509.GetCertHash();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] PublicKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return x509.GetPublicKey();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ByteData
|
||||
{
|
||||
get
|
||||
{
|
||||
return x509.Export(X509ContentType.Cert);
|
||||
}
|
||||
}
|
||||
public Buf ToBuf()
|
||||
{
|
||||
return new Buf(ByteData);
|
||||
}
|
||||
public void ToFile(string filename)
|
||||
{
|
||||
ToBuf().WriteToFile(filename);
|
||||
}
|
||||
|
||||
public Cert Clone()
|
||||
{
|
||||
return new Cert(this.ByteData);
|
||||
}
|
||||
|
||||
static DateTime lastDeletedDateTime = new DateTime();
|
||||
static readonly TimeSpan deleteTimeSpan = new TimeSpan(0, 1, 0);
|
||||
internal static void deleteOldTempFiles()
|
||||
{
|
||||
lock (lockObj)
|
||||
{
|
||||
DateTime now = Time.NowDateTime;
|
||||
|
||||
if (lastDeletedDateTime.Ticks == 0 ||
|
||||
now >= (lastDeletedDateTime + deleteTimeSpan))
|
||||
{
|
||||
lastDeletedDateTime = now;
|
||||
|
||||
string tempDir = Path.GetTempPath();
|
||||
string[] files = Directory.GetFiles(tempDir);
|
||||
|
||||
if (files != null)
|
||||
{
|
||||
foreach (string name in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Str.StrCmpi(Path.GetExtension(name), ".tmp") && Path.GetFileName(name).StartsWith("tmp", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
DateTime dt = File.GetLastWriteTimeUtc(name);
|
||||
if ((DateTime.UtcNow - dt) >= deleteOldCertSpan)
|
||||
{
|
||||
FileInfo info = new FileInfo(name);
|
||||
|
||||
if (info.Length == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(name);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Secure
|
||||
{
|
||||
static RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
|
||||
static MD5 md5 = new MD5CryptoServiceProvider();
|
||||
static uint init_dummy = CryptoConfigHelper.Init();
|
||||
public const uint SHA1Size = 20;
|
||||
public const uint MD5Size = 16;
|
||||
static object rand_lock = new object();
|
||||
|
||||
public static byte[] Rand(uint size)
|
||||
{
|
||||
lock (rand_lock)
|
||||
{
|
||||
byte[] ret = new byte[size];
|
||||
rng.GetBytes(ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
public static uint Rand32()
|
||||
{
|
||||
return BitConverter.ToUInt32(Rand(4), 0);
|
||||
}
|
||||
public static ulong Rand64()
|
||||
{
|
||||
return BitConverter.ToUInt64(Rand(8), 0);
|
||||
}
|
||||
public static ushort Rand16()
|
||||
{
|
||||
return BitConverter.ToUInt16(Rand(2), 0);
|
||||
}
|
||||
public static int Rand32i()
|
||||
{
|
||||
return BitConverter.ToInt32(Rand(4), 0);
|
||||
}
|
||||
public static long Rand64i()
|
||||
{
|
||||
return BitConverter.ToInt64(Rand(8), 0);
|
||||
}
|
||||
public static short Rand16i()
|
||||
{
|
||||
return BitConverter.ToInt16(Rand(2), 0);
|
||||
}
|
||||
public static int Rand31i()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int i = Rand32i();
|
||||
if (i >= 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static long Rand63i()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
long i = Rand64i();
|
||||
if (i >= 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static short Rand15i()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
short i = Rand16i();
|
||||
if (i >= 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static byte Rand8()
|
||||
{
|
||||
return Rand(1)[0];
|
||||
}
|
||||
public static bool Rand1()
|
||||
{
|
||||
return (Rand32() % 2) == 0;
|
||||
}
|
||||
|
||||
// MD5
|
||||
public static byte[] HashMD5(byte[] data)
|
||||
{
|
||||
byte[] ret;
|
||||
|
||||
RsaInner.Lock();
|
||||
try
|
||||
{
|
||||
ret = md5.ComputeHash(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
RsaInner.Unlock();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// SHA1
|
||||
public static byte[] HashSHA1(byte[] data)
|
||||
{
|
||||
SHA1 sha1 = new SHA1Managed();
|
||||
|
||||
return sha1.ComputeHash(data);
|
||||
}
|
||||
|
||||
// SHA256
|
||||
public static byte[] HashSHA256(byte[] data)
|
||||
{
|
||||
SHA256 sha256 = new SHA256Managed();
|
||||
|
||||
return sha256.ComputeHash(data);
|
||||
}
|
||||
|
||||
public static byte[] PkcsPadding(byte[] srcData, int destSize)
|
||||
{
|
||||
int srcSize = srcData.Length;
|
||||
|
||||
if ((srcSize + 11) > destSize)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
|
||||
int randSize = destSize - srcSize - 3;
|
||||
byte[] rand = Secure.Rand((uint)randSize);
|
||||
|
||||
Buf b = new Buf();
|
||||
b.WriteByte(0x00);
|
||||
b.WriteByte(0x02);
|
||||
b.Write(rand);
|
||||
b.WriteByte(0x00);
|
||||
b.Write(srcData);
|
||||
|
||||
return b.ByteData;
|
||||
}
|
||||
}
|
||||
|
||||
public class CryptoConfigHelper
|
||||
{
|
||||
static object objLock = new Object();
|
||||
static bool flag = false;
|
||||
|
||||
public static uint Init()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (objLock)
|
||||
{
|
||||
if (flag == false)
|
||||
{
|
||||
flag = true;
|
||||
Type t = typeof(CryptoConfig);
|
||||
Hashtable ht = (Hashtable)t.InvokeMember("DefaultOidHT", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static,
|
||||
null, null, null);
|
||||
List<string> values = new List<string>();
|
||||
|
||||
foreach (string key in ht.Keys)
|
||||
{
|
||||
string value = (string)ht[key];
|
||||
|
||||
values.Add(value);
|
||||
}
|
||||
|
||||
foreach (string s in values)
|
||||
{
|
||||
ht.Add(s, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExeSignChecker
|
||||
{
|
||||
public static bool IsKernelModeSignedFile(string fileName)
|
||||
{
|
||||
return IsKernelModeSignedFile(File.ReadAllBytes(fileName));
|
||||
}
|
||||
|
||||
public static bool IsKernelModeSignedFile(byte[] data)
|
||||
{
|
||||
string str = Str.AsciiEncoding.GetString(data);
|
||||
|
||||
if (str.IndexOf("Microsoft Code Verification Root") != -1 &&
|
||||
str.IndexOf("http://crl.microsoft.com/pki/crl/products/MicrosoftCodeVerifRoot.crl") != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
enum SignChecker_MemoryAllocator { HGlobal, CoTaskMem };
|
||||
enum SignChecker_UiChoice { All = 1, NoUI, NoBad, NoGood };
|
||||
enum SignChecker_StateAction { Ignore = 0, Verify, Close, AutoCache, AutoCacheFlush };
|
||||
enum SignChecker_UnionChoice { File = 1, Catalog, Blob, Signer, Cert };
|
||||
enum SignChecker_RevocationCheckFlags { None = 0, WholeChain };
|
||||
enum SignChecker_TrustProviderFlags
|
||||
{
|
||||
UseIE4Trust = 1,
|
||||
NoIE4Chain = 2,
|
||||
NoPolicyUsage = 4,
|
||||
RevocationCheckNone = 16,
|
||||
RevocationCheckEndCert = 32,
|
||||
RevocationCheckChain = 64,
|
||||
RevocationCheckChainExcludeRoot = 128,
|
||||
Safer = 256,
|
||||
HashOnly = 512,
|
||||
UseDefaultOSVerCheck = 1024,
|
||||
LifetimeSigning = 2048
|
||||
};
|
||||
enum SignChecker_UIContext { Execute = 0, Install };
|
||||
|
||||
[DllImport("Wintrust.dll", PreserveSig = true, SetLastError = false)]
|
||||
static extern uint WinVerifyTrust(IntPtr hWnd, IntPtr pgActionID, IntPtr pWinTrustData);
|
||||
|
||||
sealed class SignCheckerUnmanagedPointer : IDisposable
|
||||
{
|
||||
private IntPtr m_ptr;
|
||||
private SignChecker_MemoryAllocator m_meth;
|
||||
public SignCheckerUnmanagedPointer(IntPtr ptr, SignChecker_MemoryAllocator method)
|
||||
{
|
||||
m_meth = method;
|
||||
m_ptr = ptr;
|
||||
}
|
||||
|
||||
~SignCheckerUnmanagedPointer()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
void Dispose(bool disposing)
|
||||
{
|
||||
if (m_ptr != IntPtr.Zero)
|
||||
{
|
||||
if (m_meth == SignChecker_MemoryAllocator.HGlobal)
|
||||
{
|
||||
Marshal.FreeHGlobal(m_ptr);
|
||||
}
|
||||
else if (m_meth == SignChecker_MemoryAllocator.CoTaskMem)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(m_ptr);
|
||||
}
|
||||
m_ptr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
public static implicit operator IntPtr(SignCheckerUnmanagedPointer ptr)
|
||||
{
|
||||
return ptr.m_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
struct WINTRUST_FILE_INFO : IDisposable
|
||||
{
|
||||
public WINTRUST_FILE_INFO(string fileName, Guid subject)
|
||||
{
|
||||
cbStruct = (uint)Marshal.SizeOf(typeof(WINTRUST_FILE_INFO));
|
||||
pcwszFilePath = fileName;
|
||||
|
||||
if (subject != Guid.Empty)
|
||||
{
|
||||
tmp = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid)));
|
||||
Marshal.StructureToPtr(subject, tmp, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = IntPtr.Zero;
|
||||
}
|
||||
hFile = IntPtr.Zero;
|
||||
}
|
||||
public uint cbStruct;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pcwszFilePath;
|
||||
public IntPtr hFile;
|
||||
public IntPtr tmp;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (tmp != IntPtr.Zero)
|
||||
{
|
||||
Marshal.DestroyStructure(this.tmp, typeof(Guid));
|
||||
Marshal.FreeHGlobal(this.tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct WINTRUST_DATA : IDisposable
|
||||
{
|
||||
public WINTRUST_DATA(WINTRUST_FILE_INFO fileInfo)
|
||||
{
|
||||
this.cbStruct = (uint)Marshal.SizeOf(typeof(WINTRUST_DATA));
|
||||
pInfoStruct = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WINTRUST_FILE_INFO)));
|
||||
Marshal.StructureToPtr(fileInfo, pInfoStruct, false);
|
||||
dwUnionChoice = SignChecker_UnionChoice.File;
|
||||
pPolicyCallbackData = IntPtr.Zero;
|
||||
pSIPCallbackData = IntPtr.Zero;
|
||||
dwUIChoice = SignChecker_UiChoice.NoUI;
|
||||
fdwRevocationChecks = SignChecker_RevocationCheckFlags.WholeChain;
|
||||
dwStateAction = SignChecker_StateAction.Ignore;
|
||||
hWVTStateData = IntPtr.Zero;
|
||||
pwszURLReference = IntPtr.Zero;
|
||||
dwProvFlags = SignChecker_TrustProviderFlags.RevocationCheckChain;
|
||||
|
||||
dwUIContext = SignChecker_UIContext.Execute;
|
||||
}
|
||||
|
||||
public uint cbStruct;
|
||||
public IntPtr pPolicyCallbackData;
|
||||
public IntPtr pSIPCallbackData;
|
||||
public SignChecker_UiChoice dwUIChoice;
|
||||
public SignChecker_RevocationCheckFlags fdwRevocationChecks;
|
||||
public SignChecker_UnionChoice dwUnionChoice;
|
||||
public IntPtr pInfoStruct;
|
||||
public SignChecker_StateAction dwStateAction;
|
||||
public IntPtr hWVTStateData;
|
||||
private IntPtr pwszURLReference;
|
||||
public SignChecker_TrustProviderFlags dwProvFlags;
|
||||
public SignChecker_UIContext dwUIContext;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (dwUnionChoice == SignChecker_UnionChoice.File)
|
||||
{
|
||||
WINTRUST_FILE_INFO info = new WINTRUST_FILE_INFO();
|
||||
Marshal.PtrToStructure(pInfoStruct, info);
|
||||
info.Dispose();
|
||||
Marshal.DestroyStructure(pInfoStruct, typeof(WINTRUST_FILE_INFO));
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(pInfoStruct);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckFileDigitalSignature(string fileName)
|
||||
{
|
||||
Guid wintrust_action_generic_verify_v2 = new Guid("{00AAC56B-CD44-11d0-8CC2-00C04FC295EE}");
|
||||
WINTRUST_FILE_INFO fileInfo = new WINTRUST_FILE_INFO(fileName, Guid.Empty);
|
||||
WINTRUST_DATA data = new WINTRUST_DATA(fileInfo);
|
||||
|
||||
uint ret = 0;
|
||||
|
||||
using (SignCheckerUnmanagedPointer guidPtr = new SignCheckerUnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))), SignChecker_MemoryAllocator.HGlobal))
|
||||
using (SignCheckerUnmanagedPointer wvtDataPtr = new SignCheckerUnmanagedPointer(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WINTRUST_DATA))), SignChecker_MemoryAllocator.HGlobal))
|
||||
{
|
||||
IntPtr pGuid = guidPtr;
|
||||
IntPtr pData = wvtDataPtr;
|
||||
|
||||
Marshal.StructureToPtr(wintrust_action_generic_verify_v2, pGuid, false);
|
||||
Marshal.StructureToPtr(data, pData, false);
|
||||
|
||||
ret = WinVerifyTrust(IntPtr.Zero, pGuid, pData);
|
||||
}
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,281 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,359 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,471 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,963 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CoreUtil
|
||||
{
|
||||
public enum CoreLanguage
|
||||
{
|
||||
Japanese = 0,
|
||||
English = 1,
|
||||
}
|
||||
|
||||
public class CoreLanguageClass
|
||||
{
|
||||
public readonly CoreLanguage Language;
|
||||
public readonly int Id;
|
||||
readonly string name;
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (name == "ja")
|
||||
{
|
||||
if (CoreLanguageList.RegardsJapanAsJP)
|
||||
{
|
||||
return "jp";
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
public readonly string TitleInEnglish;
|
||||
public readonly string TitleInNative;
|
||||
|
||||
public CoreLanguageClass(CoreLanguage lang, int id, string name,
|
||||
string titleInEnglish, string titleInNative)
|
||||
{
|
||||
this.Language = lang;
|
||||
this.Id = id;
|
||||
this.name = name;
|
||||
this.TitleInEnglish = titleInEnglish;
|
||||
this.TitleInNative = titleInNative;
|
||||
}
|
||||
|
||||
public static void SetCurrentThreadLanguageClass(CoreLanguageClass lang)
|
||||
{
|
||||
ThreadData.CurrentThreadData.DataList["current_thread_language"] = lang;
|
||||
}
|
||||
|
||||
public static CoreLanguageClass CurrentThreadLanguageClass
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCurrentThreadLanguageClass();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetCurrentThreadLanguageClass(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static CoreLanguage CurrentThreadLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return CurrentThreadLanguageClass.Language;
|
||||
}
|
||||
}
|
||||
|
||||
public static CoreLanguageClass GetCurrentThreadLanguageClass()
|
||||
{
|
||||
CoreLanguageClass lang = null;
|
||||
|
||||
try
|
||||
{
|
||||
lang = (CoreLanguageClass)ThreadData.CurrentThreadData.DataList["current_thread_language"];
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (lang == null)
|
||||
{
|
||||
lang = CoreLanguageList.DefaultLanguage;
|
||||
|
||||
SetCurrentThreadLanguageClass(lang);
|
||||
}
|
||||
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CoreLanguageList
|
||||
{
|
||||
public static readonly CoreLanguageClass DefaultLanguage;
|
||||
public static readonly CoreLanguageClass Japanese;
|
||||
public static readonly CoreLanguageClass English;
|
||||
public static bool RegardsJapanAsJP = false;
|
||||
|
||||
public static readonly List<CoreLanguageClass> LanguageList = new List<CoreLanguageClass>();
|
||||
|
||||
static CoreLanguageList()
|
||||
{
|
||||
CoreLanguageList.LanguageList = new List<CoreLanguageClass>();
|
||||
|
||||
CoreLanguageList.Japanese = new CoreLanguageClass(CoreLanguage.Japanese,
|
||||
0, "ja", "Japanese", "日本語");
|
||||
CoreLanguageList.English = new CoreLanguageClass(CoreLanguage.English,
|
||||
1, "en", "English", "English");
|
||||
|
||||
CoreLanguageList.DefaultLanguage = CoreLanguageList.Japanese;
|
||||
|
||||
CoreLanguageList.LanguageList.Add(CoreLanguageList.Japanese);
|
||||
CoreLanguageList.LanguageList.Add(CoreLanguageList.English);
|
||||
}
|
||||
|
||||
public static CoreLanguageClass GetLanguageClassByName(string name)
|
||||
{
|
||||
Str.NormalizeStringStandard(ref name);
|
||||
|
||||
foreach (CoreLanguageClass c in LanguageList)
|
||||
{
|
||||
if (Str.StrCmpi(c.Name, name))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultLanguage;
|
||||
}
|
||||
|
||||
public static CoreLanguageClass GetLanguageClassByEnum(CoreLanguage lang)
|
||||
{
|
||||
foreach (CoreLanguageClass c in LanguageList)
|
||||
{
|
||||
if (c.Language == lang)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Util
|
||||
{
|
||||
public const int SizeOfInt32 = 4;
|
||||
public const int SizeOfInt16 = 2;
|
||||
public const int SizeOfInt64 = 8;
|
||||
public const int SizeOfInt8 = 1;
|
||||
|
||||
public static byte[] ToByte(ushort i)
|
||||
{
|
||||
byte[] ret = BitConverter.GetBytes(i);
|
||||
Endian(ret);
|
||||
return ret;
|
||||
}
|
||||
public static byte[] ToByte(short i)
|
||||
{
|
||||
byte[] ret = BitConverter.GetBytes(i);
|
||||
Endian(ret);
|
||||
return ret;
|
||||
}
|
||||
public static byte[] ToByte(uint i)
|
||||
{
|
||||
byte[] ret = BitConverter.GetBytes(i);
|
||||
Endian(ret);
|
||||
return ret;
|
||||
}
|
||||
public static byte[] ToByte(int i)
|
||||
{
|
||||
byte[] ret = BitConverter.GetBytes(i);
|
||||
Endian(ret);
|
||||
return ret;
|
||||
}
|
||||
public static byte[] ToByte(ulong i)
|
||||
{
|
||||
byte[] ret = BitConverter.GetBytes(i);
|
||||
Endian(ret);
|
||||
return ret;
|
||||
}
|
||||
public static byte[] ToByte(long i)
|
||||
{
|
||||
byte[] ret = BitConverter.GetBytes(i);
|
||||
Endian(ret);
|
||||
return ret;
|
||||
}
|
||||
public static ushort ByteToUShort(byte[] b)
|
||||
{
|
||||
byte[] c = CloneByteArray(b);
|
||||
Endian(c);
|
||||
return BitConverter.ToUInt16(c, 0);
|
||||
}
|
||||
public static short ByteToShort(byte[] b)
|
||||
{
|
||||
byte[] c = CloneByteArray(b);
|
||||
Endian(c);
|
||||
return BitConverter.ToInt16(c, 0);
|
||||
}
|
||||
public static uint ByteToUInt(byte[] b)
|
||||
{
|
||||
byte[] c = CloneByteArray(b);
|
||||
Endian(c);
|
||||
return BitConverter.ToUInt32(c, 0);
|
||||
}
|
||||
public static int ByteToInt(byte[] b)
|
||||
{
|
||||
byte[] c = CloneByteArray(b);
|
||||
Endian(c);
|
||||
return BitConverter.ToInt32(c, 0);
|
||||
}
|
||||
public static ulong ByteToULong(byte[] b)
|
||||
{
|
||||
byte[] c = CloneByteArray(b);
|
||||
Endian(c);
|
||||
return BitConverter.ToUInt64(c, 0);
|
||||
}
|
||||
public static long ByteToLong(byte[] b)
|
||||
{
|
||||
byte[] c = CloneByteArray(b);
|
||||
Endian(c);
|
||||
return BitConverter.ToInt64(c, 0);
|
||||
}
|
||||
|
||||
public static byte[] ReadAllFromStream(Stream st)
|
||||
{
|
||||
byte[] tmp = new byte[32 * 1024];
|
||||
Buf b = new Buf();
|
||||
|
||||
while (true)
|
||||
{
|
||||
int r = st.Read(tmp, 0, tmp.Length);
|
||||
|
||||
if (r == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
b.Write(tmp, 0, r);
|
||||
}
|
||||
|
||||
return b.ByteData;
|
||||
}
|
||||
|
||||
public static List<T> CloneList<T>(List<T> src)
|
||||
{
|
||||
List<T> ret = new List<T>();
|
||||
foreach (T t in src)
|
||||
{
|
||||
ret.Add(t);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static byte[] ExtractByteArray(byte[] data, int pos, int len)
|
||||
{
|
||||
byte[] ret = new byte[len];
|
||||
|
||||
Util.CopyByte(ret, 0, data, pos, len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static T[] CombineArray<T>(params T[][] arrays)
|
||||
{
|
||||
List<T> o = new List<T>();
|
||||
foreach (T[] array in arrays)
|
||||
{
|
||||
foreach (T element in array)
|
||||
{
|
||||
o.Add(element);
|
||||
}
|
||||
}
|
||||
return o.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] CombineByteArray(byte[] b1, byte[] b2)
|
||||
{
|
||||
Buf b = new Buf();
|
||||
|
||||
if (b1 != null)
|
||||
{
|
||||
b.Write(b1);
|
||||
}
|
||||
|
||||
if (b2 != null)
|
||||
{
|
||||
b.Write(b2);
|
||||
}
|
||||
|
||||
return b.ByteData;
|
||||
}
|
||||
|
||||
public static byte[] RemoveStartByteArray(byte[] src, int numBytes)
|
||||
{
|
||||
if (numBytes == 0)
|
||||
{
|
||||
return src;
|
||||
}
|
||||
int num = src.Length - numBytes;
|
||||
byte[] ret = new byte[num];
|
||||
Util.CopyByte(ret, 0, src, numBytes, num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static DateTime[] GetYearNendoList(DateTime startYear, DateTime endYear)
|
||||
{
|
||||
startYear = GetStartOfNendo(startYear);
|
||||
endYear = GetEndOfNendo(endYear);
|
||||
|
||||
if (startYear > endYear)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
List<DateTime> ret = new List<DateTime>();
|
||||
|
||||
DateTime dt;
|
||||
for (dt = startYear; dt <= endYear; dt = GetStartOfNendo(dt.AddYears(1)))
|
||||
{
|
||||
ret.Add(dt);
|
||||
}
|
||||
|
||||
return ret.ToArray();
|
||||
}
|
||||
|
||||
public static DateTime[] GetYearList(DateTime startYear, DateTime endYear)
|
||||
{
|
||||
startYear = GetStartOfYear(startYear);
|
||||
endYear = GetEndOfYear(endYear);
|
||||
|
||||
if (startYear > endYear)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
List<DateTime> ret = new List<DateTime>();
|
||||
|
||||
DateTime dt;
|
||||
for (dt = startYear; dt <= endYear; dt = GetStartOfYear(dt.AddYears(1)))
|
||||
{
|
||||
ret.Add(dt);
|
||||
}
|
||||
|
||||
return ret.ToArray();
|
||||
}
|
||||
|
||||
public static DateTime[] GetMonthList(DateTime startMonth, DateTime endMonth)
|
||||
{
|
||||
startMonth = GetStartOfMonth(startMonth);
|
||||
endMonth = GetEndOfMonth(endMonth);
|
||||
|
||||
if (startMonth > endMonth)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
List<DateTime> ret = new List<DateTime>();
|
||||
|
||||
DateTime dt;
|
||||
for (dt = startMonth; dt <= endMonth; dt = GetStartOfMonth(dt.AddMonths(1)))
|
||||
{
|
||||
ret.Add(dt);
|
||||
}
|
||||
|
||||
return ret.ToArray();
|
||||
}
|
||||
|
||||
public static int GetAge(DateTime birthDay, DateTime now)
|
||||
{
|
||||
birthDay = birthDay.Date;
|
||||
now = now.Date;
|
||||
|
||||
DateTime dayBirthDay = new DateTime(2000, birthDay.Month, birthDay.Day);
|
||||
DateTime dayNow = new DateTime(2000, now.Month, now.Day);
|
||||
|
||||
int ret = now.Year - birthDay.Year;
|
||||
|
||||
if (dayBirthDay > dayNow)
|
||||
{
|
||||
ret -= 1;
|
||||
}
|
||||
|
||||
return Math.Max(ret, 0);
|
||||
}
|
||||
|
||||
public static int GetNumOfDaysInMonth(DateTime dt)
|
||||
{
|
||||
DateTime dt1 = new DateTime(dt.Year, dt.Month, dt.Day);
|
||||
DateTime dt2 = dt1.AddMonths(1);
|
||||
TimeSpan span = dt2 - dt1;
|
||||
|
||||
return span.Days;
|
||||
}
|
||||
|
||||
public static int GetNumMonthSpan(DateTime dt1, DateTime dt2, bool kiriage)
|
||||
{
|
||||
if (dt1 > dt2)
|
||||
{
|
||||
DateTime dtt = dt2;
|
||||
dt2 = dt1;
|
||||
dt1 = dtt;
|
||||
}
|
||||
|
||||
int i;
|
||||
DateTime dt = dt1;
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
if (kiriage)
|
||||
{
|
||||
if (dt >= dt2)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dt >= dt2.AddMonths(1).AddTicks(-1))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
dt = dt.AddMonths(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime GetStartOfMonth(DateTime dt)
|
||||
{
|
||||
return new DateTime(dt.Year, dt.Month, 1);
|
||||
}
|
||||
|
||||
public static DateTime GetEndOfMonth(DateTime dt)
|
||||
{
|
||||
return new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddSeconds(-1).Date;
|
||||
}
|
||||
|
||||
public static DateTime GetStartOfYear(DateTime dt)
|
||||
{
|
||||
return new DateTime(dt.Year, 1, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static DateTime GetEndOfYear(DateTime dt)
|
||||
{
|
||||
return GetStartOfYear(dt).AddYears(1).AddSeconds(-1).Date;
|
||||
}
|
||||
|
||||
public static DateTime GetEndOfMonthForSettle(DateTime dt)
|
||||
{
|
||||
dt = new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddSeconds(-1).Date;
|
||||
if (dt.Month == 4 && (new DateTime(dt.Year, 4, 29).DayOfWeek == DayOfWeek.Sunday))
|
||||
{
|
||||
dt = dt.AddDays(1);
|
||||
}
|
||||
while ((dt.DayOfWeek == DayOfWeek.Sunday || dt.DayOfWeek == DayOfWeek.Saturday) ||
|
||||
(dt.Month == 12 && dt.Day >= 29) ||
|
||||
(dt.Month == 1 && dt.Day <= 3))
|
||||
{
|
||||
dt = dt.AddDays(1);
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static DateTime GetStartOfDay(DateTime dt)
|
||||
{
|
||||
return dt.Date;
|
||||
}
|
||||
|
||||
public static DateTime GetEndOfDate(DateTime dt)
|
||||
{
|
||||
return GetStartOfDay(dt).AddDays(1).AddTicks(-1);
|
||||
}
|
||||
|
||||
public static int GetNendo(DateTime dt)
|
||||
{
|
||||
if (dt.Month >= 4)
|
||||
{
|
||||
return dt.Year;
|
||||
}
|
||||
else
|
||||
{
|
||||
return dt.Year - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime GetStartOfNendo(DateTime dt)
|
||||
{
|
||||
return GetStartOfNendo(GetNendo(dt));
|
||||
}
|
||||
public static DateTime GetStartOfNendo(int nendo)
|
||||
{
|
||||
return new DateTime(nendo, 4, 1, 0, 0, 0).Date;
|
||||
}
|
||||
|
||||
public static DateTime GetEndOfNendo(DateTime dt)
|
||||
{
|
||||
return GetEndOfNendo(GetNendo(dt));
|
||||
}
|
||||
public static DateTime GetEndOfNendo(int nendo)
|
||||
{
|
||||
return new DateTime(nendo + 1, 3, 31, 0, 0, 0).Date;
|
||||
}
|
||||
|
||||
public static void Endian(byte[] b)
|
||||
{
|
||||
if (Env.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(b);
|
||||
}
|
||||
}
|
||||
public static byte[] EndianRetByte(byte[] b)
|
||||
{
|
||||
b = Util.CloneByteArray(b);
|
||||
|
||||
Endian(b);
|
||||
|
||||
return b;
|
||||
}
|
||||
public static UInt16 Endian(UInt16 v)
|
||||
{
|
||||
return Util.ByteToUShort(Util.EndianRetByte(Util.ToByte(v)));
|
||||
}
|
||||
public static UInt32 Endian(UInt32 v)
|
||||
{
|
||||
return Util.ByteToUInt(Util.EndianRetByte(Util.ToByte(v)));
|
||||
}
|
||||
public static UInt64 Endian(UInt64 v)
|
||||
{
|
||||
return Util.ByteToULong(Util.EndianRetByte(Util.ToByte(v)));
|
||||
}
|
||||
|
||||
public static string SafeDomainStr(string str)
|
||||
{
|
||||
string ret = str.Replace("(", "").Replace(")", "").Replace(" ", "").Replace("-", "").Replace("#", "")
|
||||
.Replace("%", "").Replace("%", "").Replace("&", "").Replace(".", "");
|
||||
if (ret == "")
|
||||
{
|
||||
ret = "host";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static byte[] CopyByte(byte[] src)
|
||||
{
|
||||
return (byte[])src.Clone();
|
||||
}
|
||||
public static byte[] CopyByte(byte[] src, int srcOffset)
|
||||
{
|
||||
return CopyByte(src, srcOffset, src.Length - srcOffset);
|
||||
}
|
||||
public static byte[] CopyByte(byte[] src, int srcOffset, int size)
|
||||
{
|
||||
byte[] ret = new byte[size];
|
||||
CopyByte(ret, 0, src, srcOffset, size);
|
||||
return ret;
|
||||
}
|
||||
public static void CopyByte(byte[] dst, byte[] src, int srcOffset, int size)
|
||||
{
|
||||
CopyByte(dst, 0, src, srcOffset, size);
|
||||
}
|
||||
public static void CopyByte(byte[] dst, int dstOffset, byte[] src)
|
||||
{
|
||||
CopyByte(dst, dstOffset, src, 0, src.Length);
|
||||
}
|
||||
public static void CopyByte(byte[] dst, int dstOffset, byte[] src, int srcOffset, int size)
|
||||
{
|
||||
Array.Copy(src, srcOffset, dst, dstOffset, size);
|
||||
}
|
||||
|
||||
public static bool IsZero(byte[] data)
|
||||
{
|
||||
return IsZero(data, 0, data.Length);
|
||||
}
|
||||
public static bool IsZero(byte[] data, int offset, int size)
|
||||
{
|
||||
int i;
|
||||
for (i = offset; i < offset + size; i++)
|
||||
{
|
||||
if (data[i] != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CompareByte(byte[] b1, byte[] b2)
|
||||
{
|
||||
if (b1.Length != b2.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int i, len;
|
||||
len = b1.Length;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (b1[i] != b2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int CompareByteRetInt(byte[] b1, byte[] b2)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
int a1 = -1, a2 = -1;
|
||||
if (b1.Length < i)
|
||||
{
|
||||
a1 = (int)b1[i];
|
||||
}
|
||||
if (b2.Length < i)
|
||||
{
|
||||
a2 = (int)b2[i];
|
||||
}
|
||||
|
||||
if (a1 > a2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (a1 < a2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (a1 == -1 && a2 == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] CloneByteArray(byte[] src)
|
||||
{
|
||||
byte[] ret = new byte[src.Length];
|
||||
|
||||
Util.CopyByte(ret, src, 0, src.Length);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static DateTime UnixTimeToDateTime(uint t)
|
||||
{
|
||||
return new DateTime(1970, 1, 1).AddSeconds(t);
|
||||
}
|
||||
|
||||
public static uint DateTimeToUnixTime(DateTime dt)
|
||||
{
|
||||
TimeSpan ts = dt - new DateTime(1970, 1, 1);
|
||||
if (ts.Ticks < 0)
|
||||
{
|
||||
throw new InvalidDataException("dt");
|
||||
}
|
||||
|
||||
return (uint)ts.TotalSeconds;
|
||||
}
|
||||
|
||||
public static DateTime ConvertDateTime(ulong time64)
|
||||
{
|
||||
if (time64 == 0)
|
||||
{
|
||||
return new DateTime(0);
|
||||
}
|
||||
return new DateTime(((long)time64 + 62135629200000) * 10000);
|
||||
}
|
||||
|
||||
public static ulong ConvertDateTime(DateTime dt)
|
||||
{
|
||||
if (dt.Ticks == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return (ulong)dt.Ticks / 10000 - 62135629200000;
|
||||
}
|
||||
|
||||
public static TimeSpan ConvertTimeSpan(ulong tick)
|
||||
{
|
||||
return new TimeSpan((long)tick * 10000);
|
||||
}
|
||||
|
||||
public static ulong ConvertTimeSpan(TimeSpan span)
|
||||
{
|
||||
return (ulong)span.Ticks / 10000;
|
||||
}
|
||||
|
||||
public static ushort DateTimeToDosDate(DateTime dt)
|
||||
{
|
||||
return (ushort)(
|
||||
((uint)(dt.Year - 1980) << 9) |
|
||||
((uint)dt.Month << 5) |
|
||||
(uint)dt.Day);
|
||||
}
|
||||
|
||||
public static ushort DateTimeToDosTime(DateTime dt)
|
||||
{
|
||||
return (ushort)(
|
||||
((uint)dt.Hour << 11) |
|
||||
((uint)dt.Minute << 5) |
|
||||
((uint)dt.Second >> 1));
|
||||
}
|
||||
|
||||
public static bool IsNullOrEmpty(object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (o is string)
|
||||
{
|
||||
string s = (string)o;
|
||||
|
||||
return Str.IsEmptyStr(s);
|
||||
}
|
||||
|
||||
if (o is Array)
|
||||
{
|
||||
Array a = (Array)o;
|
||||
if (a.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static byte[] GetXmlSchemaFromType(Type type)
|
||||
{
|
||||
XmlSchemas sms = new XmlSchemas();
|
||||
XmlSchemaExporter ex = new XmlSchemaExporter(sms);
|
||||
XmlReflectionImporter im = new XmlReflectionImporter();
|
||||
XmlTypeMapping map = im.ImportTypeMapping(type);
|
||||
ex.ExportTypeMapping(map);
|
||||
sms.Compile(null, false);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
StreamWriter sw = new StreamWriter(ms);
|
||||
foreach (System.Xml.Schema.XmlSchema sm in sms)
|
||||
{
|
||||
sm.Write(sw);
|
||||
}
|
||||
sw.Close();
|
||||
ms.Flush();
|
||||
|
||||
byte[] data = ms.ToArray();
|
||||
return data;
|
||||
}
|
||||
public static string GetXmlSchemaFromTypeString(Type type)
|
||||
{
|
||||
byte[] data = GetXmlSchemaFromType(type);
|
||||
|
||||
return Str.Utf8Encoding.GetString(data);
|
||||
}
|
||||
|
||||
public static string ObjectToXmlString(object o)
|
||||
{
|
||||
byte[] data = ObjectToXml(o);
|
||||
|
||||
return Str.Utf8Encoding.GetString(data);
|
||||
}
|
||||
public static byte[] ObjectToXml(object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Type t = o.GetType();
|
||||
|
||||
return ObjectToXml(o, t);
|
||||
}
|
||||
public static string ObjectToXmlString(object o, Type t)
|
||||
{
|
||||
byte[] data = ObjectToXml(o, t);
|
||||
|
||||
return Str.Utf8Encoding.GetString(data);
|
||||
}
|
||||
public static byte[] ObjectToXml(object o, Type t)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
XmlSerializer x = new XmlSerializer(t);
|
||||
|
||||
x.Serialize(ms, o);
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
public static object XmlToObject(string str, Type t)
|
||||
{
|
||||
if (Str.IsEmptyStr(str))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] data = Str.Utf8Encoding.GetBytes(str);
|
||||
|
||||
return XmlToObject(data, t);
|
||||
}
|
||||
public static object XmlToObject(byte[] data, Type t)
|
||||
{
|
||||
if (data == null || data.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.Write(data, 0, data.Length);
|
||||
ms.Position = 0;
|
||||
|
||||
XmlSerializer x = new XmlSerializer(t);
|
||||
|
||||
return x.Deserialize(ms);
|
||||
}
|
||||
|
||||
public static void NoOP(object o)
|
||||
{
|
||||
}
|
||||
public static void NoOP()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool False
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool True
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static int Zero
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static object ByteToStruct(byte[] src, Type type)
|
||||
{
|
||||
int size = src.Length;
|
||||
if (size != SizeOfStruct(type))
|
||||
{
|
||||
throw new SystemException("size error");
|
||||
}
|
||||
|
||||
IntPtr p = Marshal.AllocHGlobal(size);
|
||||
|
||||
try
|
||||
{
|
||||
Marshal.Copy(src, 0, p, size);
|
||||
|
||||
return Marshal.PtrToStructure(p, type);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(p);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] StructToByte(object obj)
|
||||
{
|
||||
int size = SizeOfStruct(obj);
|
||||
IntPtr p = Marshal.AllocHGlobal(size);
|
||||
try
|
||||
{
|
||||
Marshal.StructureToPtr(obj, p, false);
|
||||
|
||||
byte[] ret = new byte[size];
|
||||
|
||||
Marshal.Copy(p, ret, 0, size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(p);
|
||||
}
|
||||
}
|
||||
|
||||
public static int SizeOfStruct(object obj)
|
||||
{
|
||||
return Marshal.SizeOf(obj);
|
||||
}
|
||||
public static int SizeOfStruct(Type type)
|
||||
{
|
||||
return Marshal.SizeOf(type);
|
||||
}
|
||||
|
||||
public static XmlAndXsd GenerateXmlAndXsd(object obj)
|
||||
{
|
||||
XmlAndXsd ret = new XmlAndXsd();
|
||||
Type type = obj.GetType();
|
||||
|
||||
ret.XsdFileName = Str.MakeSafeFileName(type.Name + ".xsd");
|
||||
ret.XsdData = GetXmlSchemaFromType(type);
|
||||
|
||||
ret.XmlFileName = Str.MakeSafeFileName(type.Name + ".xml");
|
||||
string str = Util.ObjectToXmlString(obj);
|
||||
str = str.Replace(
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"",
|
||||
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\""
|
||||
+ ret.XsdFileName
|
||||
+ "\"");
|
||||
ret.XmlData = Str.Utf8Encoding.GetBytes(str);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public class XmlAndXsd
|
||||
{
|
||||
public byte[] XmlData;
|
||||
public byte[] XsdData;
|
||||
public string XmlFileName;
|
||||
public string XsdFileName;
|
||||
}
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
// CoreUtil
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user