This commit is contained in:
snltty
2023-09-19 10:01:42 +08:00
parent abf7d6436f
commit a3a567b3d8
10 changed files with 136 additions and 11 deletions

25
.dockerignore Normal file
View File

@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

41
.github/workflows/docker.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Docker
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: setup dotnet7
uses: actions/setup-dotnet@v2
env:
GITHUB_TOKEN: '${{ secrets.ACTIONS_TOKEN }}'
with:
dotnet-version: 7.0.x
- name: restore projects
run:
dotnet restore ./cmonitor
- name: docker login
uses: docker/login-action@v2.1.0
with:
username: '${{secrets.DOCKER_USERNAME}}'
password: '${{secrets.DOCKER_PASSWORD}}'
- name: docker buildx
uses: docker/setup-buildx-action@v2.5.0
- name: chmod shell
run: chmod +x publish-docker.sh
- name: publish projects
run: ./publish-docker.sh

View File

@@ -41,9 +41,9 @@
##### 2、客户端
- [x] **【--server】** 服务器ip **192.168.1.18**
- [x] **【--service** 服务端口 **1802**
- [x] **【--service** 服务端口 **1802**
- [x] **【--share-key】** 自定数据共享 **cmonitor/share**每项数据长度255
- [x] **【--share-len】** 长度 **2550**默认预留10项位置0键盘KeyBoard、1用户名UserName、2解锁Lock、3壁纸Wallpaper、4锁屏LLock
- [x] **【--share-len】** 长度 **2550**默认预留10项位置0键盘KeyBoard、1壁纸Wallpaper、2锁屏LLock
##### 3、服务端
- [x] **【--web】** 管理UI端口 **1800**
@@ -60,7 +60,7 @@ params += " --share-key cmonitor/share --share-len 2550";
//server
params = " --mode server --web 1800 --api 1801 --service 1802";
schtasks.exe /create /tn "cmonitor" /rl highest /sc ONLOGON /delay 0000:30 /tr "\\"{exePath}\\"{params}" /f
schtasks.exe /create /tn "cmonitor" /rl highest /sc ONLOGON /delay 0000:30 /tr "\"{exePath}\"{params}" /f
```
##### linux服务端
```

View File

@@ -0,0 +1,19 @@
FROM alpine:latest
ENV TZ=Asia/Shanghai DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/latest-stable/main/" > /etc/apk/repositories \
&& apk add --no-cache libstdc++ libintl tzdata zeromq bash \
&& ln -snf /usr/share/zoneinfo/$clTZ /etc/localtime \
&& echo $TZ > /etc/timezone
EXPOSE 1800/tcp
EXPOSE 1801/tcp
EXPOSE 1802/tcp
EXPOSE 1802/udp
WORKDIR /app
COPY . .
ENTRYPOINT ["./cmonitor.run"]

View File

@@ -257,10 +257,8 @@ namespace cmonitor
public const int ShareMemoryItemLength = 255;
public const int ShareMemoryKeyBoardIndex = 0;
public const int ShareMemoryUserNameIndex = 1;
public const int ShareMemoryLockIndex = 2;
public const int ShareMemoryWallpaperIndex = 3;
public const int ShareMemoryLLockIndex = 4;
public const int ShareMemoryWallpaperIndex = 1;
public const int ShareMemoryLLockIndex = 2;
public const int ReportTime = 30;
public const int ScreenTime = 200;

View File

@@ -0,0 +1,10 @@
{
"profiles": {
"cmonitor": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}

View File

@@ -10,6 +10,7 @@
<ApplicationIcon>favicon.ico</ApplicationIcon>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<Configurations>Debug;Release;ReleaseLinux</Configurations>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -63,6 +64,7 @@
<ItemGroup>
<PackageReference Include="MemoryPack" Version="1.9.16" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="NAudio.Wasapi" Version="2.2.1" />
<PackageReference Include="System.Management" Version="7.0.2" />
</ItemGroup>

View File

@@ -2,5 +2,6 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\desktop\cmonitor\cmonitor\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>

View File

@@ -23,11 +23,11 @@ namespace cmonitor.server.client.reports.share
GetShare();
return dic;
}
public bool GetShare(string key,out ShareItemInfo item)
public bool GetShare(string key, out ShareItemInfo item)
{
return dic.TryGetValue(key, out item);
}
MemoryMappedFile mmf3;
MemoryMappedViewAccessor accessor3;
@@ -56,12 +56,12 @@ namespace cmonitor.server.client.reports.share
while (span.Length > 0)
{
byte keyLen = span[0];
if (keyLen > 0)
if (keyLen > 0 && keyLen <= Config.ShareMemoryItemLength - 2)
{
string key = Encoding.UTF8.GetString(span.Slice(1, keyLen));
string val = string.Empty;
byte valLen = span[1 + keyLen];
if (valLen > 0)
if (valLen > 0 && valLen <= Config.ShareMemoryItemLength - 2 - keyLen)
{
val = Encoding.UTF8.GetString(span.Slice(2 + keyLen, valLen));
}

29
publish-docker.sh Normal file
View File

@@ -0,0 +1,29 @@
target=$(cd $(dirname $0); pwd)
image="snltty/cmonitor"
fs=('cmonitor')
ps=('alpine')
rs=('x64' 'arm64')
for f in ${fs[@]}
do
for p in ${ps[@]}
do
for r in ${rs[@]}
do
dotnet publish ./${f} -c release -f net7.0 -o ./public/publish/docker/linux-${p}-${r}/${f} -r ${p}-${r} --self-contained true -p:TieredPGO=true -p:DebugType=none -p:DebugSymbols=false -p:PublishSingleFile=true -p:PublishTrimmed=true -p:EnableCompressionInSingleFile=true -p:DebuggerSupport=false -p:EnableUnsafeBinaryFormatterSerialization=false -p:EnableUnsafeUTF7Encoding=false -p:HttpActivityPropagationSupport=false -p:InvariantGlobalization=true -p:MetadataUpdaterSupport=false -p:UseSystemResourceKeys=true -p:TrimMode=partial
cp -rf public/publish/docker/linux-${p}-${r}/${f}/${f} public/publish/docker/linux-${p}-${r}/${f}/${f}.run
rm -rf public/publish/docker/linux-${p}-${r}/${f}/${f}
cp -rf smash.proxy/Dockerfile-${p} public/publish/docker/linux-${p}-${r}/${f}/Dockerfile-${p}
done
cd public/publish/docker/linux-${p}-x64/${f}
docker buildx build -f ${target}/public/publish/docker/linux-${p}-x64/${f}/Dockerfile-${p} --platform="linux/x86_64" --force-rm -t "${image}-${p}-x64" . --push
cd ../../../../../
cd public/publish/docker/linux-${p}-arm64/${f}
docker buildx build -f ${target}/public/publish/docker/linux-${p}-arm64/${f}/Dockerfile-${p} --platform="linux/arm64" --force-rm -t "${image}-${p}-arm64" . --push
cd ../../../../../
done
done