Merge branch 'master' into manhattan

This commit is contained in:
Mark Nadal 2020-02-06 14:09:37 -08:00
commit e98e51a0ea
5 changed files with 87 additions and 49 deletions

View File

@ -9,7 +9,7 @@
Currently, [Internet Archive](https://news.ycombinator.com/item?id=17685682) and HackerNoon run GUN in production. 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> <table>
<tr> <tr>
@ -186,28 +186,24 @@ rm -rf *data*
### Additional Cryptography Libraries ### Additional Cryptography Libraries
To install with npm, first install `npm install gun -S`. > These are only needed for NodeJS, they shim the native Browser WebCrypto API.
For just the networking layer, import Gun:
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 ```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 ## 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/) ### [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/) ### [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.
[![Docker Automated buil](https://img.shields.io/docker/automated/gundb/gun.svg)](https://hub.docker.com/r/gundb/gun/) [![](https://images.microbadger.com/badges/image/gundb/gun.svg)](https://microbadger.com/images/gundb/gun "Get your own image badge on microbadger.com") [![Docker Pulls](https://img.shields.io/docker/pulls/gundb/gun.svg)](https://hub.docker.com/r/gundb/gun/) [![Docker Stars](https://img.shields.io/docker/stars/gundb/gun.svg)](https://hub.docker.com/r/gundb/gun/) [![Docker Automated buil](https://img.shields.io/docker/automated/gundb/gun.svg)](https://hub.docker.com/r/gundb/gun/) [![](https://images.microbadger.com/badges/image/gundb/gun.svg)](https://microbadger.com/images/gundb/gun "Get your own image badge on microbadger.com") [![Docker Pulls](https://img.shields.io/docker/pulls/gundb/gun.svg)](https://hub.docker.com/r/gundb/gun/) [![Docker Stars](https://img.shields.io/docker/stars/gundb/gun.svg)](https://hub.docker.com/r/gundb/gun/)
Pull from the [Docker Hub](https://hub.docker.com/r/gundb/gun/) [![](https://images.microbadger.com/badges/commit/gundb/gun.svg)](https://microbadger.com/images/gundb/gun). Or: Pull from the [Docker Hub](https://hub.docker.com/r/gundb/gun/) [![](https://images.microbadger.com/badges/commit/gundb/gun.svg)](https://microbadger.com/images/gundb/gun). Or:

View File

@ -6,6 +6,7 @@
# Copy paste and run each line into your terminal. # Copy paste and run each line into your terminal.
# If you are on Windows, http://nodejs.org/download/ has # If you are on Windows, http://nodejs.org/download/ has
# an installer that will automatically do it for you. # an installer that will automatically do it for you.
# curl -o- https://raw.githubusercontent.com/amark/gun/master/examples/install.sh | bash
#debian/ubuntu #debian/ubuntu
su - su -

View File

@ -22,11 +22,10 @@ Gun.on('create', function(root){
socket.bind({port: udp.port, exclusive: true}, function(){ socket.bind({port: udp.port, exclusive: true}, function(){
socket.setBroadcast(true); socket.setBroadcast(true);
socket.setMulticastTTL(128); socket.setMulticastTTL(128);
try{ socket.addMembership(udp.address); }catch(e){}
}); });
socket.on("listening", function(){ 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 = {id: udp.address + ':' + udp.port, wire: socket};
udp.peer.say = function(raw){ udp.peer.say = function(raw){

View File

@ -21,13 +21,16 @@
opt.RTCSessionDescription = rtcsd; opt.RTCSessionDescription = rtcsd;
opt.RTCIceCandidate = rtcic; opt.RTCIceCandidate = rtcic;
opt.rtc = opt.rtc || {'iceServers': [ opt.rtc = opt.rtc || {'iceServers': [
{url: 'stun:stun.l.google.com:19302'}, {urls: 'stun:stun.l.google.com:19302'},
{url: "stun:stun.sipgate.net:3478"}, {urls: "stun:stun.sipgate.net:3478"}/*,
{url: "stun:stun.stunprotocol.org"}, {urls: "stun:stun.stunprotocol.org"},
{url: "stun:stun.sipgate.net:10000"}, {urls: "stun:stun.sipgate.net:10000"},
{url: "stun:217.10.68.152:10000"}, {urls: "stun:217.10.68.152:10000"},
{url: 'stun:stun.services.mozilla.com'} {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.dataChannel = opt.rtc.dataChannel || {ordered: false, maxRetransmits: 2};
opt.rtc.sdp = opt.rtc.sdp || {mandatory: {OfferToReceiveAudio: false, OfferToReceiveVideo: false}}; opt.rtc.sdp = opt.rtc.sdp || {mandatory: {OfferToReceiveAudio: false, OfferToReceiveVideo: false}};
opt.announce = function(to){ opt.announce = function(to){

View File

@ -367,6 +367,43 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
}); });
}); });
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);
});
});
}); });
}); });