Compare commits

..

No commits in common. "develop" and "master" have entirely different histories.

9 changed files with 3053 additions and 21084 deletions

44
.woodpecker.yml Normal file
View File

@ -0,0 +1,44 @@
pipeline:
build:
image: git.lumeweb.com/lumeweb/ci-node
commands:
- apt-get update && apt-get install libunbound-dev
- corepack enable
- corepack prepare yarn@stable --activate
- yarn
- yarn build
package:
image: ghcr.io/goreleaser/nfpm
commands:
- nfpm pkg --packager deb
publish_focal:
image: git.lumeweb.com/lumeweb/aptly-publisher
settings:
apt_username:
from_secret: APT_USERNAME
apt_password:
from_secret: APT_PASSWORD
repo: apt.web3relay.io
folder: ubuntu
distro: focal
gpg_password:
from_secret: GPG_PASSWORD
publish_jammy:
image: git.lumeweb.com/lumeweb/aptly-publisher
settings:
apt_username:
from_secret: APT_USERNAME
apt_password:
from_secret: APT_PASSWORD
repo: apt.web3relay.io
folder: ubuntu
distro: jammy
gpg_password:
from_secret: GPG_PASSWORD
purge_cdn:
image: git.lumeweb.com/lumeweb/do-cdn-purge
settings:
DIGITALOCEAN_ACCESS_TOKEN:
from_secret: digitalocean_access_token
DIGITALOCEAN_CDN_ID:
from_secret: digitalocean_cdn_id

2
.yarnrc.yml Normal file
View File

@ -0,0 +1,2 @@
nodeLinker: node-modules

48
hsdBundlePlugin.js Normal file
View File

@ -0,0 +1,48 @@
import MagicString from "magic-string";
import astMatcher from "ast-matcher";
import path from "path";
import fs from "fs";
export default {
name: "bundle-hsd-names-db",
transform(src, id, ast) {
if (!id.includes("reserved.js")) {
return false;
}
const magicString = new MagicString(src);
astMatcher.setParser(this.parse);
if (!ast) {
try {
ast = this.parse(src);
} catch (e) {
throw e;
}
}
const findNamesDb = astMatcher("const DATA = fs.readFileSync(FILE)");
const findNamesDbMatches = findNamesDb(ast);
if (!findNamesDbMatches?.length) {
return false;
}
const dbPath = path.join(path.dirname(id), "names.db");
const dbData = fs.readFileSync(dbPath);
magicString.overwrite(
findNamesDbMatches[0].node.start,
findNamesDbMatches[0].node.end,
`const DATA = Buffer.from("${dbData.toString("base64")}","base64")`
);
return {
code: magicString.toString(),
map: magicString.generateMap({
source: src,
includeContent: true,
hires: true,
}),
};
},
};

21058
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,29 @@
{ {
"name": "@lumeweb/relay-plugin-handshake", "name": "relay-plugin-handshake",
"type": "module", "type": "module",
"packageManager": "yarn@3.3.0",
"scripts": { "scripts": {
"prepare": "presetter bootstrap", "build": "rollup -c rollup.config.js"
"build": "run build",
"semantic-release": "semantic-release"
}, },
"devDependencies": { "devDependencies": {
"@lumeweb/presetter-relay-plugin-preset": "^0.1.0-develop.8", "@rollup/plugin-commonjs": "^23.0.7",
"presetter": "^4.0.1" "@rollup/plugin-json": "^5.0.2",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-typescript": "^10.0.1",
"@types/node": "^18.15.11",
"esbuild": "^0.15.18",
"prettier": "^2.8.7",
"rollup": "^3.20.3",
"tslib": "^2.5.0",
"typescript": "^4.9.5",
"vite": "^4.2.1"
}, },
"dependencies": { "dependencies": {
"@lumeweb/interface-relay": "^0.0.2-develop.1", "@lumeweb/libhyperproxy": "git+https://git.lumeweb.com/LumeWeb/libhyperproxy.git",
"@lumeweb/libhyperproxy": "^0.0.2-develop.1" "@lumeweb/relay-plugin-rollup-preset": "git+https://git.lumeweb.com/LumeWeb/relay-plugin-rollup-preset.git",
"@lumeweb/relay-types": "git+https://git.lumeweb.com/LumeWeb/relay-types.git",
"hsd": "github:LumeWeb/hsd#spv-namestate",
"object-merger": "^1.0.3",
"random-key": "^0.3.2"
} }
} }

View File

@ -1,7 +1,5 @@
{ {
"core": {
"plugins": [ "plugins": [
"handshake" "handshake"
] ]
} }
}

View File

@ -1,14 +1,14 @@
import type { Plugin, PluginAPI } from "@lumeweb/interface-relay"; import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
// @ts-ignore // @ts-ignore
import rand from "random-key"; import rand from "random-key";
// @ts-ignore // @ts-ignore
import FullNode from "hsd/lib/node/fullnode.js"; import FullNode from "hsd/lib/node/fullnode.js";
import { MultiSocketProxy } from "@lumeweb/libhyperproxy"; import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
let server: FullNode;
let api: PluginAPI; let api: PluginAPI;
const PROTOCOL = "lumeweb.proxy.handshake"; const PROTOCOL = "lumeweb.proxy.handshake";
const DNS_PROTOCOL = "lumeweb.proxy.handshake.dns";
const plugin: Plugin = { const plugin: Plugin = {
name: "handshake", name: "handshake",
@ -27,19 +27,6 @@ const plugin: Plugin = {
muxer, muxer,
}); });
}); });
const dnsProxy = new MultiSocketProxy({
swarm: api.swarm,
protocol: DNS_PROTOCOL,
allowedPorts: [53],
server: true,
});
api.protocols.register(DNS_PROTOCOL, (peer: any, muxer: any) => {
dnsProxy.handlePeer({
peer,
muxer,
});
});
}, },
}; };

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"moduleResolution": "node",
"rootDir": "src",
"outDir": "dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}

2922
yarn.lock Normal file

File diff suppressed because it is too large Load Diff