131 Commits

Author SHA1 Message Date
Mark Nadal
b03f6e0de8 put as merge 2017-01-27 22:12:50 -08:00
Mark Nadal
40c991426b launching 0.5! 2017-01-27 07:40:24 -08:00
Mark Nadal
d0bbcef285 0.5! 2017-01-27 06:27:04 -08:00
Mark Nadal
4a2a845458 launching! 2017-01-27 05:23:49 -08:00
Mark Nadal
77d71a0c94 pushing! 2017-01-27 04:58:16 -08:00
Mark Nadal
baf99d7e72 Update client.js 2017-01-11 10:47:50 -08:00
Mark Nadal
d5cf9938c1 Update file.js 2016-12-26 22:48:59 -08:00
Mark Nadal
2e826ca9d8 fix reads 2016-12-26 22:46:27 -08:00
Mark Nadal
096e224af5 Merge pull request #298 from d3x0r/patch-6
#297 passing options to websocket
2016-12-26 22:50:28 -07:00
Mark Nadal
db74549326 warning: file.js/data.json is for local development testing only. 2016-12-26 21:12:21 -08:00
d3x0r
a4425bda24 remove redundant option fetch
since options have to be fetched higher anyway... 
Or rather - this options is outside of knowing gun options
2016-12-23 00:43:05 -08:00
d3x0r
266b18109c Missed a change to get the options....
Somehow my other options test didn't work... had to add something like this.

Now I feel this is such a huge hack
2016-12-23 00:35:11 -08:00
d3x0r
8dac820902 fix default assignment 2016-12-21 12:18:39 -08:00
d3x0r
8e6d827216 fix indentation 2016-12-21 12:17:56 -08:00
d3x0r
9c41182004 Fix quotes 2016-12-21 12:17:31 -08:00
d3x0r
320183fa54 Set default options more robustly 2016-12-21 12:17:01 -08:00
d3x0r
f28b62fd4c Setup default option
if wsc doesn't previosuly exist, create a empty option block.
add option 'protocols' for wsc that can specify the optional protocols before the options.
Options will also only apply to node client websockets; (package 'ws'), browser websockets only take 1 with 1 optional parameter (being the list of protocols to connect with; so I added that optional param for compatibility.
2016-12-21 12:09:10 -08:00
d3x0r
f548db293b pull opions from 'wsc' in gun options
'ws' options are used by server
'wsc' options to be used by websock client... ?
2016-12-21 11:59:28 -08:00
d3x0r
e8f840c548 pass gun's options to websocket
I recently had to set options given to the websocket client especially 

rejectUnauthorized {Boolean} Verify or not the server certificate.

for connecting to wss which are using self signed certs...
could also pass things like 'protocol' to differentiate a Gun websocket connection from some other websocket connection....

I don't know if maybe websock options should be a object in options instead ?  To avoid namespace collision?
2016-12-21 11:21:13 -08:00
Mark Nadal
9abe3fb75f fix for d3x0r and Stefdv 2016-11-28 17:57:20 -08:00
Jesse Gibson
4848493530 Add envelope-system server sync
Using gun's new envelope system (where routing and de-duplication happen
inside gun core), server-to-server synchronization has been
implemented.
However, it comes with this warning: the chain isn't yet ready and
you'll have difficulty reading or writing data via the chain.
2016-11-25 14:42:44 -07:00
Jesse Gibson
6a63b46d2b Add max reconnect backoff
Sockets will try to reconnect upon disconnection with an exponentially
rising backoff (configurable). However, if it's unbounded, at a certain
point does it need to even try? Probably not. Instead there's now a
`max` option that defaults to a minute, and the backoff will never
exceed that time.
2016-11-18 12:49:58 -07:00
Jesse Gibson
2696b4cf88 Merge branch '0.5' into s2s-sync 2016-11-18 11:57:06 -07:00
Jesse Gibson
e402e3966e Optimistically open client sockets
Changes behavior from only opening sockets when absolutely necessary to
keeping them open for as long as possible. Key differences:
- Much higher success rate for messages sent from the connected server.
- Process no longer shuts down if nothing is done with gun, instead
  listens for incoming messages on client sockets.
Socket reconnect handle by Peer instances, meaning better handling for
deferred messages and predictable backoff.
The client.js logic has been significantly refactored. Among the
improvements, GET/PUT requests now respect the `peers` option for each
gun instance, only sending requests to the URLs listed.
2016-11-18 11:42:24 -07:00
Jesse Gibson
e8f8047cb6 Expose websocket events
The Peer "class" now extends EventEmitter. Listening to any websocket
events (e.g., "message", "close", "open", etc.) will not only subscribe
to the current websocket, but all future websockets. This provides a
much needed abstraction, since reconnection replaces the socket, which
would typically destroy your listeners.
2016-11-17 14:07:26 -07:00
Jesse Gibson
37696e1ada Prevent most broadcast storms
Better de-duplication on messages sent for GET and PUT requests,
allowing full circular connections without blowing up your computer.
Sadly, this broke some things against the previous version, so per
@amark's request I'm publishing so he can debug.
2016-11-16 16:40:14 -07:00
Jesse Gibson
f999e5f2ea Fix chain option search
If you're reading this commit history, please avert your eyes. 3
commits to fix this admittedly simple problem is more than my pride can handle.
The `gun.Back()` function was only searching for `opt`, not
`opt.file`. It would stop at the first mention of `opt` even if it
didn't have settings for `file`. Now it won't.
2016-11-15 16:20:18 -07:00
Jesse Gibson
e7162aa098 Reliably check file.js options
The FileJS module can be passed options in two ways, and this commit
ensures they're treated in the right way.
Previously, options passed as .put or .get parameters would be favored
over those used on the chain, even if `file` wasn't specified. Now, the
module will only use the method options if `file` is mentioned, falling
back to the chain options.
This was a mistake on my part with the first PR (#268), I failed to notice notice that edge case.
2016-11-15 13:10:00 -07:00
Jesse Gibson
ddf272bbb0 Allow greeting messages to be opt-out
If you use gun a bunch, you've probably noticed the messages like "Hello
wonderful person :)" and "WARNING: This file.js module...".
This PR allows you to silence them.
Use `Gun.log.off = true` to bring peace back to your workflow.
> **Note:** great when used with file watchers like nodemon."
2016-11-14 17:00:06 -07:00
Jesse Gibson
406276739a Merge pull request #268 from PsychoLlama/allow-file-json-opt-out
Allow opting out of file.json
2016-11-14 16:39:24 -07:00
Jesse Gibson
3e66aff985 Allow opting out of file.json
If the most recent gun options disable the file module, then it
won't try to read/write from the json. Previously it would. Also, now
you can override the behavior by passing `{ file: false }` as the
options in `gun.put`.
2016-11-14 16:31:45 -07:00
Jesse Gibson
ba43dcac17 Add server push
Pushes graph updates to connected clients, listening for
acknowledgements.
2016-11-14 13:40:55 -07:00
Jesse Gibson
e8194887e0 Add basic server get handling
Servers now dispatch requests to clients and listen for responses,
plugging them into gun.
2016-11-11 17:48:56 -07:00
Jesse Gibson
4cd2d434d1 Add websocket backoff/retry logic
New library handles websocket reconnection logic and queues messages
that were sent while offline.
2016-11-10 10:11:01 -07:00
Jesse Gibson
e36e78f532 Isolate websocket logic
WebSocket logic has it's own folder now, `wsp`.
2016-11-10 10:09:18 -07:00
Jesse Gibson
adbea08120 Add basic websocket logic
Servers will now try to initiate a connection using websockets if the
`peers` option is set. Currently, it'll either start throwing errors,
or generate a broadcasting storm. Still work to be done...
This marks a milestone of getting the servers to connect to each
other. Now to have those messages make sense. Committing so I
have an easy rollback point.
2016-10-26 14:52:28 -06:00
Jesse Gibson
6f8c99ccf1 Fix /gun.js route
The `wsp.server` logic was never making it to the /gun.js route. If the
browser is just sending a GET request for a the js file, it won't set
the upgrade property, and the server logic wouldn't let the request pass
if it didn't have that header.
I've simply moved the check below the file serving logic.
2016-10-18 13:54:59 -06:00
Jesse Gibson
455cec4a10 Add ability to stop broadcast
Sometimes you just wanna send data to only one client, not the whole
bunch. Now, with new advances in gun technology, you can disable the
default broadcasting behavior.
Feature implemented under the direction and guidance of @amark.
2016-10-14 14:39:59 -06:00
Allain Lalonde
81a48ff272 \r\n was incorrectly getting replaced with \r, which mangled things 2016-10-05 15:43:37 -04:00
d3x0r
a472f33e66 Check request for 'upgrade' being set
along with the path check, should check that the request is an upgrade before assuming to do anything with it really.
2016-09-30 16:54:06 -07:00
devel-pa
9098380a90 Put out of the way require polyfill. 2016-09-30 21:24:01 +02:00
devel-pa
b8025b207f Unbuilding structure. 2016-09-30 21:19:18 +02:00
Mark Nadal
347ac0ff37 Update wsp.js 2016-09-26 22:50:35 -07:00
Mark Nadal
2ce6c80521 fix crashing bug found by @d3x0r 2016-09-25 18:09:28 -07:00
Mark Nadal
cdbf06e9c4 pretty print data.json for @d3x0r 2016-09-25 13:41:14 -07:00
Mark Nadal
fa3d3eeff4 0.5 BETA TESTING 2016-09-25 13:06:29 -07:00
Mark Nadal
97449e9f28 into the meat of put 2016-08-03 16:58:15 -07:00
Mark Nadal
afc1c18304 significant internal refactor 2016-07-14 19:37:19 -07:00
Mark Nadal
7fde5eb836 fix/mask @d3x0r 's #203 2016-07-11 16:08:54 -07:00
Mark Nadal
590b52d92b fixed server-to-server for @d3x0r 2016-07-07 12:54:19 -07:00