From ff9ff71cb222561196244598e4ce9e1e420fdf32 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Fri, 24 Jan 2020 15:29:30 +0200 Subject: [PATCH 1/7] multicast fix --- lib/multicast.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/multicast.js b/lib/multicast.js index e4c5e4ad..d4023b22 100644 --- a/lib/multicast.js +++ b/lib/multicast.js @@ -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); From 9890fb88aa617c1da10c8b4ec702f8473bd75057 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Fri, 7 Jun 2019 15:58:46 +0300 Subject: [PATCH 2/7] tests for cursor and descending ordering --- test/rad/rad.js | 83 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/test/rad/rad.js b/test/rad/rad.js index d1a638d2..27f7ff8c 100644 --- a/test/rad/rad.js +++ b/test/rad/rad.js @@ -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('Radix', function(){ @@ -59,7 +59,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){ @@ -74,7 +74,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){ @@ -92,7 +92,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){ @@ -134,7 +134,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() } @@ -144,8 +144,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){ @@ -178,7 +178,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(); @@ -200,7 +200,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){ @@ -217,7 +217,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){ @@ -252,12 +252,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; @@ -273,7 +273,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){ @@ -342,9 +342,46 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam },100); }); }); - + + it('read contacts smaller than cursor', function(done){ + 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('read contacts in descending order', function(done){ + 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); + }); + }); + }); - + }); - -}()); \ No newline at end of file + +}()); From 39d467314a2c994061e2bab940b34a1d3a08cab2 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Fri, 24 Jan 2020 10:37:52 -0800 Subject: [PATCH 3/7] skip lex cursors until fixed --- test/rad/rad.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/rad/rad.js b/test/rad/rad.js index 27f7ff8c..bc2f5f5f 100644 --- a/test/rad/rad.js +++ b/test/rad/rad.js @@ -343,7 +343,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam }); }); - it('read contacts smaller than cursor', function(done){ + it.skip('read contacts smaller than cursor', function(done){ // TODO!!! var all = {}, cursor = 'm', to; names.forEach(function(v){ v = v.toLowerCase(); @@ -363,7 +363,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam }); }); - it('read contacts in descending order', function(done){ + it.skip('read contacts in descending order', function(done){ // TODO!!! var all = {}, cursor = 'm', to; names.forEach(function(v){ all[v] = true; From 66361cb6f3506817060f6ee131c90b9c719e485f Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Wed, 29 Jan 2020 20:33:27 -0800 Subject: [PATCH 4/7] Update README.md --- README.md | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index d24e168d..d7366a94 100644 --- a/README.md +++ b/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: @@ -186,28 +186,22 @@ 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. ! +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 +238,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. + [![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: From 9dbbf856d33025e94760eb251705081b1ba990b3 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Wed, 29 Jan 2020 21:42:24 -0800 Subject: [PATCH 5/7] Declare CDN --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d7366a94..433ca715 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,8 @@ var SEA = require('gun/sea'); ## Deploy + > 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/) From b3f87b180ec228b2730c91e908850cb76b2b699e Mon Sep 17 00:00:00 2001 From: Jabis Sevon Date: Fri, 31 Jan 2020 03:32:56 +0700 Subject: [PATCH 6/7] Update webrtc.js The above change corrects at least firefox RTC Peer handler where it **throws** on over 6 ice servers, and updates url: to urls: removing spec deprecation warnings Left todo: when ICE Fails it throws, and all `.on` and `.open` listeners will fail --- lib/webrtc.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/webrtc.js b/lib/webrtc.js index cc61ec60..b3539fca 100644 --- a/lib/webrtc.js +++ b/lib/webrtc.js @@ -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){ From 60c98a5ba03975dc499d4ff0b101c1c6e41205a6 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Tue, 4 Feb 2020 02:45:18 -0800 Subject: [PATCH 7/7] Update install.sh --- examples/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/install.sh b/examples/install.sh index 8e984fe5..1af60ff7 100644 --- a/examples/install.sh +++ b/examples/install.sh @@ -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 -