@gogoqiu/tencent-http-server 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/bin/gogoqiu-node-http-service +3 -0
  2. package/dist/build.d.ts +3 -0
  3. package/dist/build.d.ts.map +1 -0
  4. package/dist/build.js +3 -0
  5. package/dist/build.js.map +1 -0
  6. package/dist/routes/index.d.ts +4 -0
  7. package/dist/routes/index.d.ts.map +1 -0
  8. package/dist/routes/index.js +106 -0
  9. package/dist/routes/index.js.map +1 -0
  10. package/dist/server.d.ts +3 -0
  11. package/dist/server.d.ts.map +1 -0
  12. package/dist/server.js +318 -0
  13. package/dist/server.js.map +1 -0
  14. package/dist/serverCmd.d.ts +8 -0
  15. package/dist/serverCmd.d.ts.map +1 -0
  16. package/dist/serverCmd.js +44 -0
  17. package/dist/serverCmd.js.map +1 -0
  18. package/dist/shell/install.d.ts +5 -0
  19. package/dist/shell/install.d.ts.map +1 -0
  20. package/dist/shell/install.js +221 -0
  21. package/dist/shell/install.js.map +1 -0
  22. package/dist/shell/postinst.d.ts +2 -0
  23. package/dist/shell/postinst.d.ts.map +1 -0
  24. package/dist/shell/postinst.js +4 -0
  25. package/dist/shell/postinst.js.map +1 -0
  26. package/dist/shell.d.ts +2 -0
  27. package/dist/shell.d.ts.map +1 -0
  28. package/dist/shell.js +249 -0
  29. package/dist/shell.js.map +1 -0
  30. package/package.json +82 -0
  31. package/public/captures1//346/265/213/350/257/225/347/224/250captures +0 -0
  32. package/public/chat/offer.html +796 -0
  33. package/public/chat/options.html +58 -0
  34. package/public/chat/server-info.html +32 -0
  35. package/public/chat2.html +272 -0
  36. package/public/chat3.html +246 -0
  37. package/public/chat4.html +302 -0
  38. package/public/chat5.html +41 -0
  39. package/public/formdata.html +41 -0
  40. package/public/hls-player.htm +41 -0
  41. package/public/img/back.svg +1 -0
  42. package/public/img/offline.svg +1 -0
  43. package/public/img/online.svg +1 -0
  44. package/public/ip-record.html +28 -0
  45. package/public/js/encrypt.js +36 -0
  46. package/public/js/socket.io.min.js +7 -0
  47. package/public/js/socket.io.min.js.map +1 -0
  48. package/public/myhost/hostReg.html +35 -0
  49. package/public/mylog-chat.htm +260 -0
  50. package/public/mylog3.html +245 -0
  51. package/public/navbar.css +17 -0
  52. package/public/readme.txt +3 -0
  53. package/public/scroll.htm +139 -0
  54. package/public/ssh-client.html +0 -0
  55. package/public/upload-file.html +226 -0
  56. package/public/upload.html +23 -0
  57. package/public/uploads1/files-1757866537383-447469495.jpg +0 -0
  58. package/public/uploads1/files-1757867389485-764531720.jpg +0 -0
  59. package/public/uploads1/files-1757867518311-278635302.jpg +0 -0
  60. package/public/uploads1/files-1757867629687-688924576.jpg +0 -0
  61. package/public/uploads1/files-1757868630683-52261917.jpg +0 -0
  62. package/public/uploads1/files-1757869187061-619427683.jpg +0 -0
  63. package/public/uploads1/small_files-1757869187061-619427683.jpg +0 -0
  64. package/public/uploads1//346/265/213/350/257/225/347/224/250upload +0 -0
  65. package/public/utils.html +57 -0
  66. package/public/utils.js +161 -0
  67. package/public/webrtc/rtc-client.html +238 -0
  68. package/public/webrtc/rtc-file-transfer-client.html +238 -0
  69. package/public/webrtc/rtc-file-transfer-server.html +453 -0
  70. package/public/webrtc/rtc-server.html +453 -0
  71. package/public/webrtc/video-client-input.html +264 -0
  72. package/public/webrtc/video-server-input.html +312 -0
  73. package/public/webrtc/webrtc-chat-with-files.html +581 -0
  74. package/public/webrtc/webrtc-chat.html +367 -0
  75. package/public/webrtc/webrtc-file-offer.html +88 -0
  76. package/public/webrtc/webrtc1.html +186 -0
  77. package/readme.txt +71 -0
  78. package/views/chat.ejs +53 -0
  79. package/views/index.ejs +125 -0
  80. package/views/special-message.ejs +8 -0
  81. package/views/ssh.ejs +142 -0
  82. package/views/utils.ejs +0 -0
  83. package/views/webrtc/client.ejs +203 -0
  84. package/views/webrtc/server.ejs +365 -0
@@ -0,0 +1,238 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+
6
+ <meta charset="utf-8">
7
+ <meta name="description" content="WebRTC code samples">
8
+ <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
9
+ <meta itemprop="description" content="Client-side WebRTC code samples">
10
+ <meta itemprop="image" content="../../../images/webrtc-icon-192x192.png">
11
+ <meta itemprop="name" content="WebRTC code samples">
12
+ <meta name="mobile-web-app-capable" content="yes">
13
+ <meta id="theme-color" name="theme-color" content="#ffffff">
14
+
15
+ <base target="_blank">
16
+
17
+ <title>手动构建WebRTC/Cliet</title>
18
+
19
+ <script src="/js/socket.io.min.js"></script>
20
+ <style>
21
+ video{
22
+ width: 400px;
23
+ height: 300px;
24
+ }
25
+ </style>
26
+ </head>
27
+
28
+ <body>
29
+
30
+ <div id="container">
31
+ <P><a href="/">CLIENT</a></P>
32
+ <div id="log"></div>
33
+ <div>
34
+ <!--reflect-->
35
+ <!--copy出去-->
36
+ <textarea id="candidate" placeholder="candidate from ice"></textarea>
37
+ </div>
38
+ <div>
39
+ <!--get-->
40
+ <!--copy进来-->
41
+ <textarea id="offer" placeholder="copy offer from server"></textarea>
42
+ <button id="set-offer" onclick="fillRemoteAndLocal()">set offer</button>
43
+ <textarea id="server-candidate" placeholder="copy candidate from server"></textarea>
44
+ <button id="" onclick="setServerCandidate()">setServerCandidate</button>
45
+ </div>
46
+ <div>
47
+ <!--gen-->
48
+ <!--copy出去-->
49
+ <textarea id="answer" placeholder="answer by gen"></textarea>
50
+ </div>
51
+ <video id="video" autoplay controls></video>
52
+ </div>
53
+
54
+ <script>
55
+
56
+ 'use strict';
57
+
58
+ //var leftVideo = document.getElementById('leftVideo');
59
+ var video, pc
60
+ var startTime;
61
+
62
+ // 对应<!--copy进来--><textarea id="server-candidate"></textarea>
63
+ // copy进来的元素,都对应一个set函数
64
+ function setServerCandidate(){
65
+ const candidate = document.getElementById('server-candidate').value
66
+ const cds = JSON.parse(candidate)
67
+ cds.forEach(element => {
68
+ /*
69
+ {
70
+ "candidate": "candidate:2316088585 1 udp 2113937151 a2ead078-c10d-4db3-a197-5d853e320c5f.local 60373 typ host generation 0 ufrag VGiA network-cost 999",
71
+ "sdpMid": "0",
72
+ "sdpMLineIndex": 0,
73
+ "usernameFragment": "VGiA"
74
+ }
75
+ Error adding candidate:InvalidStateError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': The remote description was null
76
+ remote description, 先要吸收offer?
77
+ 设置远方描述,再设置远方描述的网络候选者?
78
+ */
79
+ pc.addIceCandidate(element)
80
+ .then(() => {
81
+ console.log('addIceCandidate success', element)
82
+ })
83
+ .catch(function (err) {
84
+ console.error('Error adding candidate:' + err)
85
+ });
86
+ });
87
+ }
88
+
89
+ function setOffer(){
90
+ const desc = document.getElementById('offer').value
91
+ if( !desc ){
92
+ alert('Please enter offer')
93
+ return false;
94
+ }
95
+ // 发起pc.onicecandidate前重置
96
+ cds = []
97
+ // 会立即触发:pc.onicecandidate
98
+ pc.setRemoteDescription(JSON.parse(desc), ()=> {
99
+ // offer description
100
+ console.log('!!!!!!setRemoteDescription ok');
101
+ }, (error) => console.error('Failed to set session description: ' + error.toString()));
102
+ //console.log(desc)
103
+ return true;
104
+ }
105
+
106
+ function createAnswer() {
107
+ // answer能否夹带video/stream
108
+ /*
109
+ stream.getTracks().forEach(
110
+ function (track) {
111
+ pc.addTrack(
112
+ track,
113
+ stream
114
+ );
115
+ }
116
+ );
117
+ */
118
+ pc.createAnswer((desc) => {
119
+ document.getElementById('answer').value = JSON.stringify(desc, null, 2)
120
+ // answer with client description
121
+ pc.setLocalDescription(desc, function () {
122
+ console.log('!!!!!!setLocalDescription ok');
123
+ }, (error) => console.log('Failed to set session description: ' + error.toString())
124
+ );
125
+ // 特定类型的消息
126
+ //socket.emit('webrtc answer', desc);
127
+ },
128
+ (error) => console.log('Failed to create session description: ' + error.toString()));
129
+ }
130
+
131
+ // 先配置远端描述
132
+ function fillRemoteAndLocal() {
133
+ if( setOffer() ) {
134
+ createAnswer()
135
+ }
136
+ }
137
+
138
+ var cds = [];
139
+ function initPC() {
140
+ const configuration = {
141
+ iceServers: [
142
+ //stun协议服务器。反馈外网信息
143
+ { urls: 'stun:stun.l.google.com:19302' },
144
+ /*
145
+ {
146
+ urls: 'turn:yourturnserver.com:3478',
147
+ username: 'yourusername',
148
+ credential: 'yourpassword'
149
+ }*/
150
+ ]
151
+ };
152
+ // 获得外网信息?
153
+ pc = new RTCPeerConnection(configuration);
154
+ pc.onicecandidate = function (e) {
155
+ // 与ice通讯的结果,从ice服务器获得的自身外网情况
156
+ //console.log('onicecandidate', event);
157
+ //document.getElementById("candidate").value = event.candidate;
158
+ //socket.emit('webrtc ice-candidate', { host: hostId, candidate: event.candidate });
159
+ console.log('onicecandidate', e.candidate)
160
+ cds.push( e.candidate )
161
+ document.getElementById('candidate').value = JSON.stringify(cds, null, 2);
162
+ };
163
+ pc.oniceconnectionstatechange = function (e) {
164
+ console.log('ICE state change event: ', e);
165
+ };
166
+ /*
167
+ 增加channel
168
+ */
169
+ pc.ondatachannel = (event) => {
170
+ const dataChannelB = event.channel; // 这就是 A 端创建的通道
171
+
172
+ // 监听 B 端通道事件(接收 A 端消息用)
173
+ dataChannelB.onopen = () => {
174
+ console.log('B 端数据通道已打开');
175
+ };
176
+
177
+ dataChannelB.onmessage = (e) => {
178
+ console.log('B 收到消息:', e.data); // 输出 "Hello from A!"
179
+ };
180
+ };
181
+ //设置接入到哪个播放器
182
+ /*
183
+ 这里设置addtrack, 那一头也可以设置ontrack
184
+ */
185
+ pc.ontrack = gotRemoteStream;
186
+ }
187
+
188
+ //
189
+ function gotRemoteStream(event) {
190
+ console.log('got remote stream', event);
191
+ // 会不会触发onresize
192
+ if (video.srcObject !== event.streams[0]) {
193
+ // video控件竟然支持碎片解析播放
194
+ // 绑定
195
+ video.srcObject = event.streams[0];
196
+ console.log('pc received remote stream', event);
197
+ }
198
+ }
199
+
200
+ function initVideo() {
201
+ video = document.getElementById('video');
202
+ /*
203
+ 也能部署在php下,只要广播能用
204
+ */
205
+ video.onloadedmetadata = function () {
206
+ console.log('Remote video videoWidth: ' + this.videoWidth +
207
+ 'px, videoHeight: ' + this.videoHeight + 'px');
208
+ };
209
+
210
+ video.onresize = function () {
211
+ console.log('Remote video size changed to ' +
212
+ video.videoWidth + 'x' + video.videoHeight);
213
+ // We'll use the first onresize callback as an indication that
214
+ // video has started playing out.
215
+ if (startTime) {
216
+ var elapsedTime = window.performance.now() - startTime;
217
+ console.log('Setup time: ' + elapsedTime.toFixed(3) + 'ms');
218
+ startTime = null;
219
+ }
220
+ };
221
+ video.onerror = function (err) {
222
+ console.log(err);
223
+ }
224
+ }
225
+
226
+ window.onload = function() {
227
+ initVideo()
228
+ initPC()
229
+ /*
230
+ 等待server的offer的产生,复制过来,fillRemoteAndLocal
231
+ */
232
+ };
233
+
234
+ </script>
235
+
236
+ </body>
237
+
238
+ </html>
@@ -0,0 +1,238 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+
6
+ <meta charset="utf-8">
7
+ <meta name="description" content="WebRTC code samples">
8
+ <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
9
+ <meta itemprop="description" content="Client-side WebRTC code samples">
10
+ <meta itemprop="image" content="../../../images/webrtc-icon-192x192.png">
11
+ <meta itemprop="name" content="WebRTC code samples">
12
+ <meta name="mobile-web-app-capable" content="yes">
13
+ <meta id="theme-color" name="theme-color" content="#ffffff">
14
+
15
+ <base target="_blank">
16
+
17
+ <title>手动构建WebRTC/Cliet</title>
18
+
19
+ <script src="/js/socket.io.min.js"></script>
20
+ <style>
21
+ video{
22
+ width: 400px;
23
+ height: 300px;
24
+ }
25
+ </style>
26
+ </head>
27
+
28
+ <body>
29
+
30
+ <div id="container">
31
+ <P><a href="/">CLIENT</a></P>
32
+ <div id="log"></div>
33
+ <div>
34
+ <!--reflect-->
35
+ <!--copy出去-->
36
+ <textarea id="candidate" placeholder="candidate from ice"></textarea>
37
+ </div>
38
+ <div>
39
+ <!--get-->
40
+ <!--copy进来-->
41
+ <textarea id="offer" placeholder="copy offer from server"></textarea>
42
+ <button id="set-offer" onclick="fillRemoteAndLocal()">set offer</button>
43
+ <textarea id="server-candidate" placeholder="copy candidate from server"></textarea>
44
+ <button id="" onclick="setServerCandidate()">setServerCandidate</button>
45
+ </div>
46
+ <div>
47
+ <!--gen-->
48
+ <!--copy出去-->
49
+ <textarea id="answer" placeholder="answer by gen"></textarea>
50
+ </div>
51
+ <video id="video" autoplay controls></video>
52
+ </div>
53
+
54
+ <script>
55
+
56
+ 'use strict';
57
+
58
+ //var leftVideo = document.getElementById('leftVideo');
59
+ var video, pc
60
+ var startTime;
61
+
62
+ // 对应<!--copy进来--><textarea id="server-candidate"></textarea>
63
+ // copy进来的元素,都对应一个set函数
64
+ function setServerCandidate(){
65
+ const candidate = document.getElementById('server-candidate').value
66
+ const cds = JSON.parse(candidate)
67
+ cds.forEach(element => {
68
+ /*
69
+ {
70
+ "candidate": "candidate:2316088585 1 udp 2113937151 a2ead078-c10d-4db3-a197-5d853e320c5f.local 60373 typ host generation 0 ufrag VGiA network-cost 999",
71
+ "sdpMid": "0",
72
+ "sdpMLineIndex": 0,
73
+ "usernameFragment": "VGiA"
74
+ }
75
+ Error adding candidate:InvalidStateError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': The remote description was null
76
+ remote description, 先要吸收offer?
77
+ 设置远方描述,再设置远方描述的网络候选者?
78
+ */
79
+ pc.addIceCandidate(element)
80
+ .then(() => {
81
+ console.log('addIceCandidate success', element)
82
+ })
83
+ .catch(function (err) {
84
+ console.error('Error adding candidate:' + err)
85
+ });
86
+ });
87
+ }
88
+
89
+ function setOffer(){
90
+ const desc = document.getElementById('offer').value
91
+ if( !desc ){
92
+ alert('Please enter offer')
93
+ return false;
94
+ }
95
+ // 发起pc.onicecandidate前重置
96
+ cds = []
97
+ // 会立即触发:pc.onicecandidate
98
+ pc.setRemoteDescription(JSON.parse(desc), ()=> {
99
+ // offer description
100
+ console.log('!!!!!!setRemoteDescription ok');
101
+ }, (error) => console.error('Failed to set session description: ' + error.toString()));
102
+ //console.log(desc)
103
+ return true;
104
+ }
105
+
106
+ function createAnswer() {
107
+ // answer能否夹带video/stream
108
+ /*
109
+ stream.getTracks().forEach(
110
+ function (track) {
111
+ pc.addTrack(
112
+ track,
113
+ stream
114
+ );
115
+ }
116
+ );
117
+ */
118
+ pc.createAnswer((desc) => {
119
+ document.getElementById('answer').value = JSON.stringify(desc, null, 2)
120
+ // answer with client description
121
+ pc.setLocalDescription(desc, function () {
122
+ console.log('!!!!!!setLocalDescription ok');
123
+ }, (error) => console.log('Failed to set session description: ' + error.toString())
124
+ );
125
+ // 特定类型的消息
126
+ //socket.emit('webrtc answer', desc);
127
+ },
128
+ (error) => console.log('Failed to create session description: ' + error.toString()));
129
+ }
130
+
131
+ // 先配置远端描述
132
+ function fillRemoteAndLocal() {
133
+ if( setOffer() ) {
134
+ createAnswer()
135
+ }
136
+ }
137
+
138
+ var cds = [];
139
+ function initPC() {
140
+ const configuration = {
141
+ iceServers: [
142
+ //stun协议服务器。反馈外网信息
143
+ { urls: 'stun:stun.l.google.com:19302' },
144
+ /*
145
+ {
146
+ urls: 'turn:yourturnserver.com:3478',
147
+ username: 'yourusername',
148
+ credential: 'yourpassword'
149
+ }*/
150
+ ]
151
+ };
152
+ // 获得外网信息?
153
+ pc = new RTCPeerConnection(configuration);
154
+ pc.onicecandidate = function (e) {
155
+ // 与ice通讯的结果,从ice服务器获得的自身外网情况
156
+ //console.log('onicecandidate', event);
157
+ //document.getElementById("candidate").value = event.candidate;
158
+ //socket.emit('webrtc ice-candidate', { host: hostId, candidate: event.candidate });
159
+ console.log('onicecandidate', e.candidate)
160
+ cds.push( e.candidate )
161
+ document.getElementById('candidate').value = JSON.stringify(cds, null, 2);
162
+ };
163
+ pc.oniceconnectionstatechange = function (e) {
164
+ console.log('ICE state change event: ', e);
165
+ };
166
+ /*
167
+ 增加channel
168
+ */
169
+ pc.ondatachannel = (event) => {
170
+ const dataChannelB = event.channel; // 这就是 A 端创建的通道
171
+
172
+ // 监听 B 端通道事件(接收 A 端消息用)
173
+ dataChannelB.onopen = () => {
174
+ console.log('B 端数据通道已打开');
175
+ };
176
+
177
+ dataChannelB.onmessage = (e) => {
178
+ console.log('B 收到消息:', e.data); // 输出 "Hello from A!"
179
+ };
180
+ };
181
+ //设置接入到哪个播放器
182
+ /*
183
+ 这里设置addtrack, 那一头也可以设置ontrack
184
+ */
185
+ pc.ontrack = gotRemoteStream;
186
+ }
187
+
188
+ //
189
+ function gotRemoteStream(event) {
190
+ console.log('got remote stream', event);
191
+ // 会不会触发onresize
192
+ if (video.srcObject !== event.streams[0]) {
193
+ // video控件竟然支持碎片解析播放
194
+ // 绑定
195
+ video.srcObject = event.streams[0];
196
+ console.log('pc received remote stream', event);
197
+ }
198
+ }
199
+
200
+ function initVideo() {
201
+ video = document.getElementById('video');
202
+ /*
203
+ 也能部署在php下,只要广播能用
204
+ */
205
+ video.onloadedmetadata = function () {
206
+ console.log('Remote video videoWidth: ' + this.videoWidth +
207
+ 'px, videoHeight: ' + this.videoHeight + 'px');
208
+ };
209
+
210
+ video.onresize = function () {
211
+ console.log('Remote video size changed to ' +
212
+ video.videoWidth + 'x' + video.videoHeight);
213
+ // We'll use the first onresize callback as an indication that
214
+ // video has started playing out.
215
+ if (startTime) {
216
+ var elapsedTime = window.performance.now() - startTime;
217
+ console.log('Setup time: ' + elapsedTime.toFixed(3) + 'ms');
218
+ startTime = null;
219
+ }
220
+ };
221
+ video.onerror = function (err) {
222
+ console.log(err);
223
+ }
224
+ }
225
+
226
+ window.onload = function() {
227
+ initVideo()
228
+ initPC()
229
+ /*
230
+ 等待server的offer的产生,复制过来,fillRemoteAndLocal
231
+ */
232
+ };
233
+
234
+ </script>
235
+
236
+ </body>
237
+
238
+ </html>