initial commit, deployed on googleics.lerch.org
This commit is contained in:
parent
e607d26f5f
commit
744434c41a
19
.eslintrc.js
Normal file
19
.eslintrc.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es6: true,
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
'airbnb-base',
|
||||||
|
],
|
||||||
|
globals: {
|
||||||
|
Atomics: 'readonly',
|
||||||
|
SharedArrayBuffer: 'readonly',
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2018,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
},
|
||||||
|
};
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/target
|
||||||
|
/dist
|
||||||
|
**/*.rs.bk
|
||||||
|
Cargo.lock
|
||||||
|
bin/
|
||||||
|
pkg/
|
||||||
|
wasm-pack.log
|
||||||
|
worker/
|
||||||
|
node_modules/
|
||||||
|
.cargo-ok
|
7
.prettierrc
Normal file
7
.prettierrc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"semi": false,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"printWidth": 80
|
||||||
|
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Emil Lerch
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
18
README.md
Normal file
18
README.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# GoogleICS
|
||||||
|
|
||||||
|
Allows for a proxy from CloudFlare to public calendars on google in iCS format.
|
||||||
|
|
||||||
|
This will allow for requests to Google from a mobile device to not come from
|
||||||
|
a geolocatable IP address. Using CloudFlare workers for this also gets you to
|
||||||
|
use a cached edge location. Technically Google tracking would still be
|
||||||
|
available at a regional level (constrained to CloudFlare's edge locations).
|
||||||
|
However, Google would lose the ability to track to a single user.
|
||||||
|
|
||||||
|
Specifically, they will get:
|
||||||
|
|
||||||
|
* Time and IP address of CloudFlare edge location
|
||||||
|
* The following custom header: `CDN-Loop: cloudflare`
|
||||||
|
|
||||||
|
Note that CloudFlare has full knowledge of requests, etc, so this is somewhat
|
||||||
|
trading of trust from Google (AdTech company) for CloudFlare (makes money from
|
||||||
|
CDN and DDOS mitigation).
|
35
index.js
Normal file
35
index.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* Respond with whatever Google gives us
|
||||||
|
* @param {Request} request
|
||||||
|
*/
|
||||||
|
async function handleRequest(request) {
|
||||||
|
let response;
|
||||||
|
try {
|
||||||
|
const prefix = 'https://calendar.google.com/calendar/ical';
|
||||||
|
const postscript = '/public/basic.ics';
|
||||||
|
let requestPath = new URL(request.url).pathname;
|
||||||
|
if (requestPath.endsWith('/')) {
|
||||||
|
requestPath = requestPath.substring(0, requestPath.length - 1);
|
||||||
|
}
|
||||||
|
const googleCal = `${prefix}${requestPath}${postscript}`;
|
||||||
|
response = await fetch(googleCal);
|
||||||
|
} catch (err) {
|
||||||
|
// Without event.waitUntil(), our fetch() to our logging service may
|
||||||
|
// or may not complete.
|
||||||
|
// event.waitUntil(postLog(err));
|
||||||
|
const stack = JSON.stringify(err.stack) || err;
|
||||||
|
// Copy the response and initialize body to the stack trace
|
||||||
|
response = new Response(stack, response);
|
||||||
|
// Shove our rewritten URL into a header to find out what it was.
|
||||||
|
response.headers.set('X-Debug-stack', stack);
|
||||||
|
response.headers.set('X-Debug-err', err);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is "browser", but it's running in a V8 isolate, so it's really
|
||||||
|
// neither browser nor node. This is the hook into the CF Worker ecosystem,
|
||||||
|
// so we need to have this code and is safe to disable eslint for this line
|
||||||
|
addEventListener('fetch', (event) => { // eslint-disable-line no-restricted-globals
|
||||||
|
event.respondWith(handleRequest(event.request));
|
||||||
|
});
|
1666
package-lock.json
generated
Normal file
1666
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
Normal file
20
package.json
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"name": "worker",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A template for kick starting a Cloudflare Workers project",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"format": "prettier --write '**/*.{js,css,json,md}'"
|
||||||
|
},
|
||||||
|
"author": "root",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^6.8.0",
|
||||||
|
"eslint-config-airbnb-base": "^14.1.0",
|
||||||
|
"eslint-plugin-import": "^2.20.2",
|
||||||
|
"prettier": "^1.18.2"
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
6
wrangler.toml
Normal file
6
wrangler.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
name = "worker"
|
||||||
|
type = "javascript"
|
||||||
|
account_id = "fd84764d2476917a9806e45d4e1f04e9"
|
||||||
|
workers_dev = false
|
||||||
|
route = "googleics.lerch.org/*"
|
||||||
|
zone_id = "43547522ef2730b3271939345712673c"
|
Loading…
Reference in New Issue
Block a user