Compare commits
No commits in common. "develop" and "master" have entirely different histories.
|
@ -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
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
nodeLinker: node-modules
|
|
@ -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,
|
||||
}),
|
||||
};
|
||||
},
|
||||
};
|
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
|
@ -1,17 +1,29 @@
|
|||
{
|
||||
"name": "@lumeweb/relay-plugin-handshake",
|
||||
"name": "relay-plugin-handshake",
|
||||
"type": "module",
|
||||
"packageManager": "yarn@3.3.0",
|
||||
"scripts": {
|
||||
"prepare": "presetter bootstrap",
|
||||
"build": "run build",
|
||||
"semantic-release": "semantic-release"
|
||||
"build": "rollup -c rollup.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/presetter-relay-plugin-preset": "^0.1.0-develop.8",
|
||||
"presetter": "^4.0.1"
|
||||
"@rollup/plugin-commonjs": "^23.0.7",
|
||||
"@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": {
|
||||
"@lumeweb/interface-relay": "^0.0.2-develop.1",
|
||||
"@lumeweb/libhyperproxy": "^0.0.2-develop.1"
|
||||
"@lumeweb/libhyperproxy": "git+https://git.lumeweb.com/LumeWeb/libhyperproxy.git",
|
||||
"@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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"core": {
|
||||
"plugins": [
|
||||
"handshake"
|
||||
"handshake"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
17
src/index.ts
17
src/index.ts
|
@ -1,14 +1,14 @@
|
|||
import type { Plugin, PluginAPI } from "@lumeweb/interface-relay";
|
||||
import type { Plugin, PluginAPI } from "@lumeweb/relay-types";
|
||||
// @ts-ignore
|
||||
import rand from "random-key";
|
||||
// @ts-ignore
|
||||
import FullNode from "hsd/lib/node/fullnode.js";
|
||||
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
||||
|
||||
let server: FullNode;
|
||||
let api: PluginAPI;
|
||||
|
||||
const PROTOCOL = "lumeweb.proxy.handshake";
|
||||
const DNS_PROTOCOL = "lumeweb.proxy.handshake.dns";
|
||||
|
||||
const plugin: Plugin = {
|
||||
name: "handshake",
|
||||
|
@ -27,19 +27,6 @@ const plugin: Plugin = {
|
|||
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,
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue