forked from Kianmhz/GooseRelayVPN
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCode.gs
More file actions
33 lines (30 loc) · 1.07 KB
/
Code.gs
File metadata and controls
33 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// GooseRelay forwarder.
//
// Apps Script web app deployed as: Execute as: Me, Access: Anyone (or Anyone with Google account).
// All traffic is AES-GCM encrypted by the client; this script is a dumb pipe
// and never sees plaintext or holds the key.
//
// Wire: client POSTs base64(encrypted batch). We forward the bytes verbatim
// to DO_URL and return its response body verbatim.
//
// Replace DO_URL with your VPS address before deploying.
const DO_URL = 'http://YOUR.DO.IP:8443/tunnel';
function doPost(e) {
const payload = (e && e.postData && e.postData.contents) || '';
const resp = UrlFetchApp.fetch(DO_URL, {
method: 'post',
contentType: 'text/plain',
payload: payload,
muteHttpExceptions: true,
followRedirects: false,
deadline: 30, // seconds; our long-poll window is 8s so this is plenty
});
return ContentService
.createTextOutput(resp.getContentText())
.setMimeType(ContentService.MimeType.TEXT);
}
function doGet() {
return ContentService
.createTextOutput('GooseRelay forwarder OK')
.setMimeType(ContentService.MimeType.TEXT);
}