mirror of
https://github.com/amark/gun.git
synced 2025-06-06 22:26:48 +00:00
Merge branch 'master' into manhattan
This commit is contained in:
commit
e98e51a0ea
32
README.md
32
README.md
@ -9,7 +9,7 @@
|
||||
|
||||
Currently, [Internet Archive](https://news.ycombinator.com/item?id=17685682) and HackerNoon run GUN in production.
|
||||
|
||||
Decentralized alternatives to [Reddit](https://notabug.io/t/whatever/comments/36588a16b9008da4e3f15663c2225e949eca4a15/gpu-bot-test), [YouTube](https://d.tube/), [Wikipedia](https://news.ycombinator.com/item?id=17685682), etc. are already pushing terabytes of daily P2P traffic on GUN. We are a [friendly community](https://gitter.im/amark/gun) creating a free fun future for freedom:
|
||||
Decentralized alternatives to [Reddit](https://notabug.io/t/whatever/comments/36588a16b9008da4e3f15663c2225e949eca4a15/gpu-bot-test), [YouTube](https://d.tube/), [Wikipedia](https://news.ycombinator.com/item?id=17685682), etc. have already pushed terabytes of daily P2P traffic on GUN. We are a [friendly community](https://gitter.im/amark/gun) creating a free fun future for freedom:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@ -186,28 +186,24 @@ rm -rf *data*
|
||||
|
||||
### Additional Cryptography Libraries
|
||||
|
||||
To install with npm, first install `npm install gun -S`.
|
||||
For just the networking layer, import Gun:
|
||||
> These are only needed for NodeJS, they shim the native Browser WebCrypto API.
|
||||
|
||||
If you want to use [SEA](https://gun.eco/docs/SEA) for `User` auth and security, you will need to install:
|
||||
|
||||
`npm install text-encoding isomorphic-webcrypto --save`
|
||||
|
||||
Then you can require [SEA](https://gun.eco/docs/SEA) without an error:
|
||||
|
||||
```javascript
|
||||
var Gun = require('gun/gun');
|
||||
var GUN = require('gun/gun');
|
||||
var SEA = require('gun/sea');
|
||||
```
|
||||
|
||||
If you also need to install SEA for user auth and crypto, also install some of its dependencies like this:
|
||||
|
||||
`npm install text-encoding @peculiar/webcrypto --save`
|
||||
|
||||
You will need to require it too (it will be automatically added to the Gun object):
|
||||
|
||||
```javascript
|
||||
var Gun = require('gun/gun');
|
||||
var Sea = require('gun/sea');
|
||||
```
|
||||
|
||||
|
||||
## Deploy
|
||||
|
||||
To quickly spin up a Gun test server for your development team, utilize either [Heroku](http://heroku.com) or [Docker](http://docker.com) or any variant thereof [Dokku](http://dokku.viewdocs.io/dokku/), [Flynn.io](http://flynn.io), [now.sh](https://zeit.co/now), etc. !
|
||||
> Note: The default examples that get auto-deployed on `npm start` CDN-ify all GUN files, modules, & storage.
|
||||
|
||||
To quickly spin up a GUN relay peer for your development team, utilize either [Heroku](http://heroku.com), [Docker](http://docker.com), any variant thereof [Dokku](http://dokku.viewdocs.io/dokku/), [Flynn.io](http://flynn.io), [now.sh](https://zeit.co/now), etc. ! Or use all of them so your relays are decentralized too!
|
||||
|
||||
### [Heroku](https://www.heroku.com/)
|
||||
|
||||
@ -244,6 +240,8 @@ Then visit the deployed app by following the 'view app' button, in your browser.
|
||||
|
||||
### [Docker](https://www.docker.com/)
|
||||
|
||||
> Warning: Docker image is community contributed and may be old with missing security updates, please check version numbers to compare.
|
||||
|
||||
[](https://hub.docker.com/r/gundb/gun/) [](https://microbadger.com/images/gundb/gun "Get your own image badge on microbadger.com") [](https://hub.docker.com/r/gundb/gun/) [](https://hub.docker.com/r/gundb/gun/)
|
||||
|
||||
Pull from the [Docker Hub](https://hub.docker.com/r/gundb/gun/) [](https://microbadger.com/images/gundb/gun). Or:
|
||||
|
@ -6,6 +6,7 @@
|
||||
# Copy paste and run each line into your terminal.
|
||||
# If you are on Windows, http://nodejs.org/download/ has
|
||||
# an installer that will automatically do it for you.
|
||||
# curl -o- https://raw.githubusercontent.com/amark/gun/master/examples/install.sh | bash
|
||||
|
||||
#debian/ubuntu
|
||||
su -
|
||||
|
@ -22,11 +22,10 @@ Gun.on('create', function(root){
|
||||
socket.bind({port: udp.port, exclusive: true}, function(){
|
||||
socket.setBroadcast(true);
|
||||
socket.setMulticastTTL(128);
|
||||
try{ socket.addMembership(udp.address); }catch(e){}
|
||||
});
|
||||
|
||||
socket.on("listening", function(){
|
||||
try { socket.addMembership(udp.address) }catch(e){ return }
|
||||
try { socket.addMembership(udp.address) }catch(e){ console.error(e); return; }
|
||||
udp.peer = {id: udp.address + ':' + udp.port, wire: socket};
|
||||
|
||||
udp.peer.say = function(raw){
|
||||
@ -60,7 +59,7 @@ Gun.on('create', function(root){
|
||||
|
||||
var url = 'http://' + info.address + ':' + (port || (opt.web && opt.web.address()||{}).port) + '/gun';
|
||||
if(root.opt.peers[url]){ return }
|
||||
|
||||
|
||||
//console.log('discovered', url, message, info);
|
||||
root.$.opt(url);
|
||||
|
||||
|
@ -21,13 +21,16 @@
|
||||
opt.RTCSessionDescription = rtcsd;
|
||||
opt.RTCIceCandidate = rtcic;
|
||||
opt.rtc = opt.rtc || {'iceServers': [
|
||||
{url: 'stun:stun.l.google.com:19302'},
|
||||
{url: "stun:stun.sipgate.net:3478"},
|
||||
{url: "stun:stun.stunprotocol.org"},
|
||||
{url: "stun:stun.sipgate.net:10000"},
|
||||
{url: "stun:217.10.68.152:10000"},
|
||||
{url: 'stun:stun.services.mozilla.com'}
|
||||
{urls: 'stun:stun.l.google.com:19302'},
|
||||
{urls: "stun:stun.sipgate.net:3478"}/*,
|
||||
{urls: "stun:stun.stunprotocol.org"},
|
||||
{urls: "stun:stun.sipgate.net:10000"},
|
||||
{urls: "stun:217.10.68.152:10000"},
|
||||
{urls: 'stun:stun.services.mozilla.com'}*/
|
||||
]};
|
||||
// TODO: Select the most appropriate stuns.
|
||||
// FIXME: Find the wire throwing ICE Failed
|
||||
// The above change corrects at least firefox RTC Peer handler where it **throws** on over 6 ice servers, and updates url: to urls: removing deprecation warning
|
||||
opt.rtc.dataChannel = opt.rtc.dataChannel || {ordered: false, maxRetransmits: 2};
|
||||
opt.rtc.sdp = opt.rtc.sdp || {mandatory: {OfferToReceiveAudio: false, OfferToReceiveVideo: false}};
|
||||
opt.announce = function(to){
|
||||
|
@ -19,16 +19,16 @@ var Gun;
|
||||
require('../../lib/store');
|
||||
require('../../lib/rfs');
|
||||
}
|
||||
|
||||
|
||||
try{ var expect = global.expect = require("../expect") }catch(e){}
|
||||
|
||||
|
||||
}(this));
|
||||
|
||||
|
||||
;(function(){
|
||||
Gun = root.Gun
|
||||
|
||||
if(Gun.window && !Gun.window.RindexedDB){ return }
|
||||
|
||||
|
||||
var opt = {};
|
||||
opt.file = 'radatatest';
|
||||
var Radisk = (Gun.window && Gun.window.Radisk) || require('../../lib/radisk');
|
||||
@ -36,11 +36,11 @@ opt.store = ((Gun.window && Gun.window.RindexedDB) || require('../../lib/rfs'))(
|
||||
opt.chunk = 1000;
|
||||
var Radix = Radisk.Radix;
|
||||
var rad = Radisk(opt), esc = String.fromCharCode(27);
|
||||
|
||||
|
||||
describe('RAD', function(){
|
||||
|
||||
|
||||
var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammamaria","Andy","Anselme","Ardeen","Armand","Ashelman","Aube","Averyl","Baker","Barger","Baten","Bee","Benia","Bernat","Bevers","Bittner","Bobbe","Bonny","Boyce","Breech","Brittaney","Bryn","Burkitt","Cadmann","Campagna","Carlee","Carver","Cavallaro","Chainey","Chaunce","Ching","Cianca","Claudina","Clyve","Colon","Cooke","Corrina","Crawley","Cullie","Dacy","Daniela","Daryn","Deedee","Denie","Devland","Dimitri","Dolphin","Dorinda","Dream","Dunham","Eachelle","Edina","Eisenstark","Elish","Elvis","Eng","Erland","Ethan","Evelyn","Fairman","Faus","Fenner","Fillander","Flip","Foskett","Fredette","Fullerton","Gamali","Gaspar","Gemina","Germana","Gilberto","Giuditta","Goer","Gotcher","Greenstein","Grosvenor","Guthrey","Haldane","Hankins","Harriette","Hayman","Heise","Hepsiba","Hewie","Hiroshi","Holtorf","Howlond","Hurless","Ieso","Ingold","Isidora","Jacoba","Janelle","Jaye","Jennee","Jillana","Johnson","Josy","Justinian","Kannan","Kast","Keeley","Kennett","Kho","Kiran","Knowles","Koser","Kroll","LaMori","Lanctot","Lasky","Laverna","Leff","Leonanie","Lewert","Lilybel","Lissak","Longerich","Lou","Ludeman","Lyman","Madai","Maia","Malvina","Marcy","Maris","Martens","Mathilda","Maye","McLain","Melamie","Meras","Micco","Millburn","Mittel","Montfort","Moth","Mutz","Nananne","Nazler","Nesta","Nicolina","Noellyn","Nuli","Ody","Olympie","Orlena","Other","Pain","Parry","Paynter","Pentheas","Pettifer","Phyllida","Plath","Posehn","Proulx","Quinlan","Raimes","Ras","Redmer","Renelle","Ricard","Rior","Rocky","Ron","Rosetta","Rubia","Ruttger","Salbu","Sandy","Saw","Scholz","Secor","September","Shanleigh","Shenan","Sholes","Sig","Sisely","Soble","Spanos","Stanwinn","Stevie","Stu","Suzanne","Tacy","Tanney","Tekla","Thackeray","Thomasin","Tilla","Tomas","Tracay","Tristis","Ty","Urana","Valdis","Vasta","Vezza","Vitoria","Wait","Warring","Weissmann","Whetstone","Williamson","Wittenburg","Wymore","Yoho","Zamir","Zimmermann"];
|
||||
|
||||
|
||||
//console.log("HYPER TEST");var z = 10000; while(--z){ names.push(Gun.text.random(7)) }this.timeout(9000);
|
||||
|
||||
describe.only('Radix', function(){
|
||||
@ -73,7 +73,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
expect(Gun.obj.empty(all)).to.be.ok();
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
it('radix write read again', function(done){
|
||||
var all = {};
|
||||
names.forEach(function(v,i){
|
||||
@ -88,7 +88,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
expect(Gun.obj.empty(all)).to.be.ok();
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
it('radix read start end', function(done){
|
||||
var all = {}, start = 'Warring'.toLowerCase(), end = 'Zamir'.toLowerCase();
|
||||
names.forEach(function(v,i){
|
||||
@ -106,7 +106,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
expect(Gun.obj.empty(all)).to.be.ok();
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
it('radix read start- end+', function(done){
|
||||
var all = {}, start = 'Warrinf'.toLowerCase(), end = 'Zamis'.toLowerCase();
|
||||
names.forEach(function(v,i){
|
||||
@ -158,7 +158,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
});
|
||||
|
||||
describe('Radisk', function(){
|
||||
|
||||
|
||||
/*it('parse', function(done){
|
||||
this.timeout(60000);
|
||||
if(Gun.window){ return done() }
|
||||
@ -168,8 +168,8 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
}, raw);
|
||||
return;
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
|
||||
it('write contacts', function(done){
|
||||
var all = {}, to, start;
|
||||
names.forEach(function(v,i){
|
||||
@ -202,7 +202,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
}, opt);
|
||||
});
|
||||
console.log("UNDO THIS RETURN!!!");return;*/
|
||||
|
||||
|
||||
it('read contacts start end', function(done){
|
||||
var opt = {};
|
||||
opt.start = 'Warring'.toLowerCase();
|
||||
@ -224,7 +224,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
done();
|
||||
}, opt);
|
||||
});
|
||||
|
||||
|
||||
it('read contacts', function(done){
|
||||
var all = {}, find = 'a';
|
||||
names.forEach(function(v){
|
||||
@ -241,7 +241,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('read again', function(done){
|
||||
var all = {}, find = 'm';
|
||||
names.forEach(function(v){
|
||||
@ -276,12 +276,12 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
var ntmp = names;
|
||||
describe('RAD + GUN', function(){
|
||||
var ochunk = 1000;
|
||||
var gun = Gun({chunk: ochunk});
|
||||
|
||||
|
||||
it('write same', function(done){
|
||||
var all = {}, to, start, tmp;
|
||||
var names = [], c = 285;
|
||||
@ -297,7 +297,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('write contacts', function(done){
|
||||
var all = {}, to, start, tmp;
|
||||
names.forEach(function(v,i){
|
||||
@ -366,9 +366,46 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
},100);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it.skip('read contacts smaller than cursor', function(done){ // TODO!!!
|
||||
var all = {}, cursor = 'm', to;
|
||||
names.forEach(function(v){
|
||||
v = v.toLowerCase();
|
||||
if(v < cursor){ all[v] = true }
|
||||
});
|
||||
gun.get('names').get({'.': {'<': cursor}, '%': 1000 * 100}).once().map().once(function(data, key){
|
||||
expect(data.name).to.be.ok();
|
||||
expect(data.age).to.be.ok();
|
||||
//if(!all.hasOwnProperty(key)){console.error(key);}
|
||||
expect(all.hasOwnProperty(key)).to.be.ok();
|
||||
delete all[key];
|
||||
clearTimeout(to);
|
||||
to = setTimeout(function(){
|
||||
expect(Gun.obj.empty(all)).to.be.ok();
|
||||
done();
|
||||
},100);
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('read contacts in descending order', function(done){ // TODO!!!
|
||||
var all = {}, cursor = 'm', to;
|
||||
names.forEach(function(v){
|
||||
all[v] = true;
|
||||
});
|
||||
gun.get('names').get({'.': {'-': true}, '%': 1000 * 100}).once().map().once(function(data, key){
|
||||
expect(data.name).to.be.ok();
|
||||
expect(data.age).to.be.ok();
|
||||
delete all[key];
|
||||
clearTimeout(to);
|
||||
to = setTimeout(function(){
|
||||
expect(Gun.obj.empty(all)).to.be.ok();
|
||||
done();
|
||||
},100);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
}());
|
||||
|
Loading…
x
Reference in New Issue
Block a user