Archived
1
0

Featureful (#31)

* Fix loading within the CLI

* Remove app

* Remove promise handle

* Add initial travis file

* Add libxkbfile dependency

* Add libxkbfile-dev

* Add build script

* Fix malformed bash statement

* Remove yarn from script

* Improve build script

* Extract upx before usage

* Only run upx if on linux

* Ensure resource directory exists

* Pack runnable binary

* Export binary with platform

* Improve build process

* Install upx before running install script

* Update typescript version before running nexe

* Add os.release() function for multi-platform support

* Update travis.yml to improve deployment

* Add on CI

* Update to v1.31.0

* Add libsecret

* Update build target

* Skip cleanup

* Fix built-in extensions

* Add basics for apps

* Create custom DNS server

* Fix forking within CLI. Fixes TS language features

* Fix filename resolve

* Fix default extensions path

* Add custom dialog

* Store workspace path

* Remove outfiles

* Cleanup

* Always authed outside of CLI

* Use location.host for client

* Remove useless app interface

* Remove debug file for building wordlist

* Use chromes tcp host

* Update patch

* Build browser app before packaging

* Replace all css containing file:// URLs, fix webviews

* Fix save

* Fix mkdir
This commit is contained in:
Kyle Carberry
2019-02-21 11:55:42 -06:00
committed by Asher
parent bdd24081ab
commit 85d2225e0c
84 changed files with 5204 additions and 264 deletions

View File

@ -0,0 +1,18 @@
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
src
# Node.js dependencies:
node_modules/

8
packages/dns/Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM node
COPY out/main.js /main.js
COPY package.json /package.json
RUN yarn
ENV NODE_ENV production
CMD ["node", "/main.js"]

5
packages/dns/app.yaml Normal file
View File

@ -0,0 +1,5 @@
runtime: nodejs10
service: cdrdns
network:
forwarded_ports:
- 53/udp

14
packages/dns/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "@coder/dns",
"main": "out/main.js",
"scripts": {
"build": "../../node_modules/.bin/webpack --config ./webpack.config.js"
},
"dependencies": {
"node-named": "^0.0.1"
},
"devDependencies": {
"ip-address": "^5.8.9",
"@types/ip-address": "^5.8.2"
}
}

109
packages/dns/src/dns.ts Normal file
View File

@ -0,0 +1,109 @@
import { field, logger } from "@coder/logger";
import * as http from "http";
//@ts-ignore
import * as named from "node-named";
import * as ip from "ip-address";
import { words, wordKeys } from "./words";
import * as dgram from "dgram";
const oldCreate = dgram.createSocket;
// tslint:disable-next-line:no-any
(<any>dgram).createSocket = (_: any, callback: any): dgram.Socket => {
return oldCreate("udp4", callback);
};
interface DnsQuery {
name(): string;
// tslint:disable-next-line:no-any
addAnswer(domain: string, target: any, ttl: number): void;
}
const dnsServer: {
listen(port: number, host: string, callback: () => void): void;
on(event: "query", callback: (query: DnsQuery) => void): void;
send(query: DnsQuery): void;
} = named.createServer();
const isDev = process.env.NODE_ENV !== "production";
const dnsPort = isDev ? 9999 : 53;
dnsServer.listen(dnsPort, "0.0.0.0", () => {
logger.info("DNS server started", field("port", dnsPort));
});
dnsServer.on("query", (query) => {
const domain = query.name();
const reqParts = domain.split(".");
if (reqParts.length < 2) {
dnsServer.send(query);
logger.info("Invalid request", field("request", domain));
return;
}
const allWords = reqParts.shift()!;
if (allWords.length > 16) {
dnsServer.send(query);
logger.info("Invalid request", field("request", domain));
return;
}
const wordParts = allWords.split(/(?=[A-Z])/);
const ipParts: string[] = [];
// Should be left with HowAreYouNow
for (let i = 0; i < wordParts.length; i++) {
const part = wordParts[i];
if (part.length > 4) {
dnsServer.send(query);
logger.info("Words too long", field("request", domain));
return;
}
const ipPart = words[part.toLowerCase()];
if (typeof ipPart === "undefined") {
dnsServer.send(query);
logger.info("Word not found in index", field("part", part), field("request", domain));
return;
}
ipParts.push(ipPart.toString());
}
const address = new ip.Address4(ipParts.join("."));
if (address.isValid()) {
logger.info("Responded with valid address query", field("address", address.address), field("request", domain));
query.addAnswer(domain, new named.ARecord(address.address), 99999);
} else {
logger.warn("Received invalid request", field("request", domain));
}
dnsServer.send(query);
});
const httpServer = http.createServer((request, response) => {
const remoteAddr = request.connection.remoteAddress;
if (!remoteAddr) {
response.writeHead(422);
response.end();
return;
}
const hostHeader = request.headers.host;
if (!hostHeader) {
response.writeHead(422);
response.end();
return;
}
const host = remoteAddr.split(".").map(p => wordKeys[Number.parseInt(p, 10)]).map(s => s.charAt(0).toUpperCase() + s.slice(1)).join("");
logger.info("Resolved host", field("remote-addr", remoteAddr), field("host", host));
response.writeHead(200);
response.write(`${host}.${hostHeader}`);
response.end();
});
const httpPort = isDev ? 3000 : 80;
httpServer.listen(httpPort, "0.0.0.0", () => {
logger.info("HTTP server started", field("port", httpPort));
});

260
packages/dns/src/words.ts Normal file
View File

@ -0,0 +1,260 @@
export const words: { readonly [key: string]: number } = {
term: 0,
salt: 1,
barn: 2,
corn: 3,
went: 4,
feel: 5,
rest: 6,
will: 7,
pale: 8,
cave: 9,
dirt: 10,
time: 11,
in: 12,
pie: 13,
star: 14,
iron: 15,
door: 16,
tone: 17,
want: 18,
task: 19,
zoo: 20,
nor: 21,
fall: 22,
tell: 23,
noon: 24,
new: 25,
per: 26,
end: 27,
arm: 28,
been: 29,
wolf: 30,
port: 31,
beat: 32,
pour: 33,
far: 34,
may: 35,
tie: 36,
moon: 37,
duck: 38,
us: 39,
led: 40,
met: 41,
bank: 42,
day: 43,
due: 44,
both: 45,
pet: 46,
gate: 47,
pain: 48,
rock: 49,
fill: 50,
open: 51,
thus: 52,
mark: 53,
our: 54,
loud: 55,
wife: 56,
say: 57,
flag: 58,
as: 59,
ride: 60,
once: 61,
sun: 62,
duty: 63,
pure: 64,
made: 65,
gulf: 66,
pig: 67,
fish: 68,
name: 69,
army: 70,
have: 71,
ill: 72,
meal: 73,
ago: 74,
late: 75,
view: 76,
atom: 77,
pen: 78,
mud: 79,
tail: 80,
sink: 81,
cow: 82,
rear: 83,
fur: 84,
go: 85,
suit: 86,
come: 87,
fear: 88,
also: 89,
sail: 90,
row: 91,
lay: 92,
noun: 93,
hat: 94,
am: 95,
mail: 96,
keep: 97,
drop: 98,
than: 99,
weak: 100,
by: 101,
who: 102,
fire: 103,
good: 104,
sick: 105,
care: 106,
pink: 107,
lady: 108,
war: 109,
sets: 110,
swam: 111,
well: 112,
shoe: 113,
bent: 114,
fuel: 115,
wet: 116,
fog: 117,
land: 118,
lead: 119,
tax: 120,
deal: 121,
verb: 122,
take: 123,
save: 124,
gift: 125,
had: 126,
gold: 127,
slow: 128,
drew: 129,
lamp: 130,
roof: 131,
hung: 132,
wild: 133,
able: 134,
girl: 135,
warn: 136,
were: 137,
know: 138,
camp: 139,
milk: 140,
neck: 141,
aid: 142,
fair: 143,
bell: 144,
dig: 145,
hope: 146,
wood: 147,
away: 148,
cook: 149,
just: 150,
form: 151,
food: 152,
hall: 153,
mind: 154,
for: 155,
card: 156,
half: 157,
sat: 158,
now: 159,
team: 160,
rush: 161,
face: 162,
wire: 163,
such: 164,
tool: 165,
make: 166,
fat: 167,
hold: 168,
inch: 169,
bill: 170,
mean: 171,
tide: 172,
burn: 173,
talk: 174,
tape: 175,
hard: 176,
mine: 177,
on: 178,
year: 179,
rich: 180,
sum: 181,
yes: 182,
baby: 183,
wide: 184,
how: 185,
clay: 186,
car: 187,
here: 188,
cent: 189,
bowl: 190,
post: 191,
said: 192,
see: 193,
raw: 194,
foot: 195,
life: 196,
bar: 197,
from: 198,
path: 199,
meat: 200,
show: 201,
sent: 202,
wait: 203,
mice: 204,
ten: 205,
pot: 206,
nice: 207,
idea: 208,
or: 209,
onto: 210,
rose: 211,
your: 212,
this: 213,
cat: 214,
bet: 215,
took: 216,
hang: 217,
very: 218,
bend: 219,
mix: 220,
base: 221,
jack: 222,
her: 223,
leg: 224,
own: 225,
book: 226,
love: 227,
dawn: 228,
deer: 229,
hit: 230,
rain: 231,
gas: 232,
eat: 233,
tube: 234,
case: 235,
pipe: 236,
get: 237,
joy: 238,
ever: 239,
nest: 240,
home: 241,
egg: 242,
pack: 243,
hand: 244,
cold: 245,
hot: 246,
frog: 247,
peep: 248,
seed: 249,
rawr: 250,
top: 251,
meow: 252,
bark: 253,
eel: 254,
swap: 255,
};
export const wordKeys = Object.keys(words);

View File

@ -0,0 +1,18 @@
const path = require("path");
const merge = require("webpack-merge");
module.exports = merge(require(path.join(__dirname, "../../scripts", "webpack.general.config.js"))(), {
devtool: "none",
mode: "production",
target: "node",
externals: {
"node-named": "commonjs node-named",
},
output: {
path: path.join(__dirname, "out"),
filename: "main.js",
},
entry: [
"./packages/dns/src/dns.ts"
],
});

88
packages/dns/yarn.lock Normal file
View File

@ -0,0 +1,88 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/ip-address@^5.8.2":
version "5.8.2"
resolved "https://registry.yarnpkg.com/@types/ip-address/-/ip-address-5.8.2.tgz#5e413c477f78b3a264745eac937538a6e6e0c1f6"
integrity sha512-LFlDGRjJDnahfPyNCZGXvlaevSmZTi/zDxjTdXeTs8TQ9pQkNZKbCWaJXW29a3bGPRsASqeO+jGgZlaTUi9jTw==
dependencies:
"@types/jsbn" "*"
"@types/jsbn@*":
version "1.2.29"
resolved "https://registry.yarnpkg.com/@types/jsbn/-/jsbn-1.2.29.tgz#28229bc0262c704a1506c3ed69a7d7e115bd7832"
integrity sha512-2dVz9LTEGWVj9Ov9zaDnpvqHFV+W4bXtU0EUEGAzWfdRNO3dlUuosdHpENI6/oQW+Kejn0hAjk6P/czs9h/hvg==
bunyan@0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/bunyan/-/bunyan-0.7.0.tgz#921065e70c936fe302a740e2c5605775beea2f42"
integrity sha1-khBl5wyTb+MCp0DixWBXdb7qL0I=
"coffee-script@>= 1.1.1":
version "1.12.7"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.7.tgz#c05dae0cb79591d05b3070a8433a98c9a89ccc53"
integrity sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw==
ip-address@^5.8.9:
version "5.8.9"
resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-5.8.9.tgz#6379277c23fc5adb20511e4d23ec2c1bde105dfd"
integrity sha512-7ay355oMN34iXhET1BmCJVsHjOTSItEEIIpOs38qUC23AIhOy+xIPnkrTuEFjeLMrTJ7m8KMXWgWfy/2Vn9sDw==
dependencies:
jsbn "1.1.0"
lodash.find "^4.6.0"
lodash.max "^4.0.1"
lodash.merge "^4.6.0"
lodash.padstart "^4.6.1"
lodash.repeat "^4.1.0"
sprintf-js "1.1.0"
ipaddr.js@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-0.1.1.tgz#28c6a7c116a021c555544f906ab1ad540b1d635a"
integrity sha1-KManwRagIcVVVE+QarGtVAsdY1o=
dependencies:
coffee-script ">= 1.1.1"
jsbn@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040"
integrity sha1-sBMHyym2GKHtJux56RH4A8TaAEA=
lodash.find@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1"
integrity sha1-ywcE1Hq3F4n/oN6Ll92Sb7iLE7E=
lodash.max@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.max/-/lodash.max-4.0.1.tgz#8735566c618b35a9f760520b487ae79658af136a"
integrity sha1-hzVWbGGLNan3YFILSHrnllivE2o=
lodash.merge@^4.6.0:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"
integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==
lodash.padstart@^4.6.1:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b"
integrity sha1-0uPuv/DZ05rVD1y9G1KnvOa7YRs=
lodash.repeat@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/lodash.repeat/-/lodash.repeat-4.1.0.tgz#fc7de8131d8c8ac07e4b49f74ffe829d1f2bec44"
integrity sha1-/H3oEx2MisB+S0n3T/6CnR8r7EQ=
node-named@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/node-named/-/node-named-0.0.1.tgz#3607b434cf237ab99440f5ff6d19c05e3a93e217"
integrity sha1-Nge0NM8jermUQPX/bRnAXjqT4hc=
dependencies:
bunyan "0.7.0"
ipaddr.js "0.1.1"
sprintf-js@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.0.tgz#cffcaf702daf65ea39bb4e0fa2b299cec1a1be46"
integrity sha1-z/yvcC2vZeo5u04PorKZzsGhvkY=