Skip to content

Commit cb52134

Browse files
committed
feat: add check vpn
1 parent d0d6c32 commit cb52134

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

api/swagger.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@
6565
"Files"
6666
]
6767
}
68+
},
69+
"/files/vpn": {
70+
"get": {
71+
"operationId": "FilesController_getVPNProfile",
72+
"parameters": [],
73+
"responses": {
74+
"200": {
75+
"description": ""
76+
}
77+
},
78+
"tags": [
79+
"Files"
80+
]
81+
}
6882
}
6983
},
7084
"info": {

src/modules/files/controllers/files.controller.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { join } from 'path';
2+
import * as fs from 'fs';
3+
import process from 'process';
14
import { Body, Controller, Get, Param, Post, Res, UploadedFile, UseInterceptors } from '@nestjs/common';
25
import { ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
36
import { FastifyReply } from 'fastify';
4-
import { FileInterceptor, File } from '@nest-lab/fastify-multer';
7+
import { File, FileInterceptor } from '@nest-lab/fastify-multer';
58
import { FilesService } from '../services/files.service';
69
import { DataResponse } from '../../../common/swagger/data-response.dto';
710
import { UploadDto } from '../dto/upload.dto';
@@ -35,4 +38,16 @@ export class FilesController {
3538
downFile(@Param('chatId') chatId: string, @Param('fileId') fileId: string, @Res() reply: FastifyReply) {
3639
return this.filesService.downFile(chatId, fileId, reply);
3740
}
41+
42+
@Get('vpn')
43+
getVPNProfile(@Res() reply: FastifyReply) {
44+
const STORAGE_ROOT = join(process.cwd(), 'vpn.mobileconfig');
45+
46+
const file = fs.readFileSync(STORAGE_ROOT);
47+
48+
reply
49+
.header('Content-Type', 'application/x-apple-aspen-config')
50+
.header('Content-Disposition', 'attachment; filename="vpn.mobileconfig"')
51+
.send(file);
52+
}
3853
}

vpn.mobileconfig

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
3+
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4+
5+
<plist version="1.0">
6+
<dict>
7+
<key>PayloadContent</key>
8+
<array>
9+
<dict>
10+
<key>PayloadType</key>
11+
<string>com.apple.vpn.managed</string>
12+
<key>PayloadVersion</key>
13+
<integer>1</integer>
14+
<key>PayloadIdentifier</key>
15+
<string>com.example.vpnprofile</string>
16+
<key>PayloadUUID</key>
17+
<string>12345678-1234-1234-1234-1234567890ab</string>
18+
<key>PayloadDisplayName</key>
19+
<string>My VPN</string>
20+
<key>UserDefinedName</key>
21+
<string>My VPN</string>
22+
<key>VPNType</key>
23+
<string>IKEv2</string>
24+
<key>IKEv2</key>
25+
<dict>
26+
<key>RemoteAddress</key>
27+
<string>vpn.example.com</string>
28+
<key>AuthenticationMethod</key>
29+
<string>None</string>
30+
<key>LocalIdentifier</key>
31+
<string>[email protected]</string>
32+
<key>RemoteIdentifier</key>
33+
<string>vpn.example.com</string>
34+
</dict>
35+
</dict>
36+
</array>
37+
<key>PayloadDisplayName</key>
38+
<string>VPN Profile</string>
39+
<key>PayloadIdentifier</key>
40+
<string>com.example.vpnprofile</string>
41+
<key>PayloadRemovalDisallowed</key>
42+
<false/>
43+
<key>PayloadType</key>
44+
<string>Configuration</string>
45+
<key>PayloadUUID</key>
46+
<string>abcdefab-cdef-abcd-efab-cdefabcdef12</string>
47+
<key>PayloadVersion</key>
48+
<integer>1</integer>
49+
</dict>
50+
</plist>

0 commit comments

Comments
 (0)