Skip to content

Commit b0cda15

Browse files
committed
1 parent b06ca39 commit b0cda15

31 files changed

+706
-60
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<a href="https://localmesh.org">
22
<img src="https://img.shields.io/badge/Sponsored%20by-localmesh.org-green">
3+
<img src="https://img.shields.io/badge/matrix-%23orbitdns%3Amatrix.org-blue">
34
</a>
45

56
# OrbitDNS

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99
"bin": {
1010
"orbitdns": "src/cli/cli.js"
1111
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/vaultec81/orbitdns.git"
15+
},
1216
"license": "MIT",
17+
"bugs": {
18+
"url": "https://github.com/vaultec81/orbitdns/issues"
19+
},
20+
"homepage": "https://github.com/vaultec81/orbitdns#readme",
1321
"dependencies": {
1422
"@hapi/hapi": "^18.4.0",
23+
"base64url": "^3.0.1",
1524
"bip39": "^3.0.2",
1625
"buffer-json": "^2.0.0",
1726
"datastore-fs": "^0.9.1",
@@ -23,6 +32,7 @@
2332
"orbit-db": "^0.21.4",
2433
"orbit-db-access-controllers": "^0.2.3",
2534
"orbit-db-identity-provider": "^0.1.7",
26-
"p-map-series": "^2.1.0"
35+
"p-map-series": "^2.1.0",
36+
"orbitdns-http-client": "^1.0.0"
2737
}
2838
}

src/cli/commands/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict'
2+
3+
module.exports = {
4+
command: 'config <command>',
5+
6+
description: 'Manage configuration',
7+
8+
builder (yargs) {
9+
return yargs.commandDir('config');
10+
},
11+
12+
handler (argv) {
13+
}
14+
}

src/cli/commands/daemon.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Yargs = require('yargs')
2+
const fs = require('fs');
23

34
module.exports = {
45
command: "daemon",
@@ -22,6 +23,7 @@ module.exports = {
2223
await daemon.start();
2324
daemon._httpApi._apiServers.forEach(apiServer => {
2425
print(`API listening on ${apiServer.info.ma.toString()}`)
26+
2527
})
2628
} catch (err) {
2729
console.log(err)

src/cli/commands/domain/list.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ module.exports = {
88
},
99

1010
handler(argv) {
11-
console.log(argv)
11+
argv.resolve((async () => {
12+
//console.log(argv)
13+
const orbitdns = await argv.getOrbitDNS()
14+
console.log(orbitdns)
15+
})())
1216
}
1317
}

src/cli/commands/key.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const Yargs = require('yargs')
2+
3+
module.exports = {
4+
command: "key <command>",
5+
describe: "Key management.",
6+
7+
builder(yargs) {
8+
return yargs.commandDir('key');
9+
},
10+
11+
handler(argv) {
12+
}
13+
}

src/cli/commands/root.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
module.exports = {
4-
command: 'net <command>',
4+
command: 'root <command>',
55

66
description: 'Interact with root TLD management',
77

src/cli/daemon.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const OrbitDNS = require('../core')
22
const HttpApi = require('../http')
33
const Resolver = require('../core/resolver')
4+
const fs = require('fs')
5+
const path = require('path')
46

57
class Daemon {
68
constructor(options) {
@@ -25,6 +27,14 @@ class Daemon {
2527
if (this._httpApi._apiServers.length) {
2628
//await promisify(ipfs._repo.apiAddr.set)(this._httpApi._apiServers[0].info.ma)
2729
}
30+
this._httpApi._apiServers.forEach(apiServer => {
31+
var str = apiServer.info.ma.toString();
32+
if(str.includes("0.0.0.0")) {
33+
str = str.replace("0.0.0.0", "127.0.0.1")
34+
}
35+
console.log(str)
36+
//fs.writeFileSync(path.join(this._options.directory, "apiaddr"), apiServer.info.ma.toString())
37+
})
2838
console.log(Resolver)
2939
this.resolver = new Resolver(this._orbitdns);
3040
this.resolver.start();
@@ -37,6 +47,7 @@ class Daemon {
3747

3848

3949
])
50+
4051
return this;
4152
}
4253
}

src/cli/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const parser = yargs
1212
})
1313
.epilog(utils.ipfsPathHelp)
1414
.middleware(argv => Object.assign(argv, {
15-
getIpfs: utils.singleton(cb => utils.getIPFS(argv, cb)),
15+
getOrbitDNS: utils.singleton(cb => utils.getOrbitDNS(argv, cb)),
1616
print: utils.print,
1717
isDaemonOn: utils.isDaemonOn,
1818
getRepoPath: utils.getRepoPath

src/cli/utils.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
const fs = require('fs')
22
const os = require('os')
3+
const multiaddr = require('multiaddr')
4+
const path = require('path')
35
const promisify = require('promisify-es6')
4-
5-
6+
const debug = require('debug')
7+
const log = debug('cli')
8+
log.error = debug('cli:error')
9+
const Core = require("../core/core")
610

711
exports.getRepoPath = () => {
812
return process.env.ORBITDNS_PATH || os.homedir() + '/.orbitdns'
913
}
1014

1115
exports.isDaemonOn = isDaemonOn
1216
function isDaemonOn() {
17+
console.log(path.join(exports.getRepoPath(), 'apiaddr'))
1318
try {
14-
fs.readFileSync(path.join(exports.getRepoPath(), 'api'))
19+
fs.readFileSync(path.join(exports.getRepoPath(), 'apiaddr'))
1520
log('daemon is on')
1621
return true
1722
} catch (err) {
@@ -25,20 +30,21 @@ function getAPICtl(apiAddr) {
2530
throw new Error('daemon is not on')
2631
}
2732
if (!apiAddr) {
28-
const apiPath = path.join(exports.getRepoPath(), 'api')
33+
const apiPath = path.join(exports.getRepoPath(), 'apiaddr')
2934
apiAddr = multiaddr(fs.readFileSync(apiPath).toString()).toString()
3035
}
3136
// Required inline to reduce startup time
32-
//const APIctl = require('ipfs-http-client')
33-
return APIctl(apiAddr)
37+
const APIctl = require('orbitdns-http-client')
38+
return new APIctl(apiAddr)
3439
}
35-
exports.getIPFS = async (argv) => {
40+
exports.getOrbitDNS = async (argv, callback) => {
41+
console.log(isDaemonOn())
42+
console.log(argv.api)
3643
if (argv.api || isDaemonOn()) {
3744
return callback(null, getAPICtl(argv.api), promisify((cb) => cb()))
3845
}
39-
4046
// Required inline to reduce startup time
41-
const core = require('../core/')
47+
const Core = require('../core/')
4248
const node = new Core({
4349
directory: exports.getRepoPath()
4450
})

src/core/AccessController.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ class orbitDNSAC extends EventEmitter {
158158

159159
// Return true if entry is allowed to be added to the database
160160
async canAppend (entry, identityProvider) {
161+
if(entry.payload.op === "DEL") {
162+
return false; //Block deletion of records temporarily until a proper system for record deletion is created.
163+
}
164+
if(entry)
161165
console.log(entry.payload.value)
162166
for(var address in this._orbitdb.stores) {
163167
var split = address.split("/");

0 commit comments

Comments
 (0)