Commit Graph

143 Commits

Author SHA1 Message Date
Ivan Kozlovic
7449e9ac53 Replace megacheck with staticcheck
Fixed issues reported by staticcheck

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-01-09 14:14:47 -07:00
Ivan Kozlovic
4b70cdfc89 Fix Gateways with Service Imports
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-12-11 00:27:40 -08:00
Ivan Kozlovic
efd891d2ae Fix performance degradation introduced by GW code
This impacted even non gateway traffic

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-12-08 17:44:32 -07:00
Ivan Kozlovic
c57ff0e26c Fixed possible deadlock when updating route permissions
This bug is only in master, not in any public release.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-12-07 09:15:05 -07:00
Derek Collison
08ca7b5f2a ServiceImports and queue groups
Signed-off-by: Derek Collison <derek@nats.io>
2018-12-06 17:52:17 -08:00
Ivan Kozlovic
111e050d32 Allow service import to work with Gateways
This is not complete solution and is a bit hacky but is a start
to be able to have service import work at least in some basic
cases.

Also fixed a bug where replySub would not be removed from
connection's list of subs after delivery.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-12-05 20:35:43 -07:00
Derek Collison
a95fa1a8e9 race on global account
Signed-off-by: Derek Collison <derek@nats.io>
2018-12-05 14:59:38 -08:00
Derek Collison
2d54fc3ee7 Account lookup failures, account and client limits, options reload.
Changed account lookup and validation failures to be more understandable by users.
Changed limits to be -1 for unlimited to match jwt pkg.

The limits changed exposed problems with options holding real objects causing issues with reload tests under race mode.
Longer term this code should be reworked such that options only hold config data, not real structs, etc.

Signed-off-by: Derek Collison <derek@nats.io>
2018-12-05 14:25:40 -08:00
Ivan Kozlovic
a23ef5b740 Switch to send-all-subs when number of RS- gets too big
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-12-03 13:15:11 -07:00
Derek Collison
744795ead5 Allow servers to send system events.
Specifically this is to support distributed tracking of number of account connections across clusters.
Gateways may not work yet based on attempts to only generate payloads when we know there is outside interest.

Signed-off-by: Derek Collison <derek@nats.io>
2018-12-01 13:54:25 -08:00
Derek Collison
574fd62e01 Allow servers to send and receive messages directly
Signed-off-by: Derek Collison <derek@nats.io>
2018-11-29 12:15:08 -08:00
Ivan Kozlovic
d78b1ae464 Fixed issue with gateways
- If/when splitting buffer to pass to queueOutbound(), it has to
  be include full protocol.
- Fix counting of total queue subs
- Fix tests
- Send RS- if no plain sub interest even if there is queue sub
  interest.
- Removed a one-liner function

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-28 13:15:47 -07:00
Ivan Kozlovic
bbacc58f7a Updates based on comments
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-27 20:19:02 -07:00
Ivan Kozlovic
52c724a83c Updates based on comments
- Solve RS+ with wildcards
- Solve issue with messages not send to remote gateways queue subs
  if there was a qsub on local server.
- Made rcache a perAccountCache since it is now used by routes and
  gateways
- Order outbound gateways only on RTT updates
- Print a server's gateway name on startup
- Augment/add some tests
- Update TLS handling: when connecting, use hostname for ServerName
  if url is not IP, otherwise use a hostname that we saved when
  parsing/adding URLs for the remote gateway.
- Send big buffer in chunks if needed.
- Add caching for qsubs match

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-27 19:39:41 -07:00
Ivan Kozlovic
10fd3ca0c6 Gateways [WIP]
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-27 19:00:03 -07:00
Ivan Kozlovic
eb17950971 Introduce some delay before closing clients in LameDuck mode.
This will allow to signal multiple servers at once to go in
that mode and not have their client reconnect to one of the
servers in the group.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-08 18:34:15 -07:00
Ivan Kozlovic
0c11279946 Fixed data race with client trace flag
This was introduced with ec3115ad21

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-07 16:33:30 -07:00
Derek Collison
1ce1a434b0 Fix for #792
Allow deny clauses for subscriptions to still allow wildcard subscriptions but do not deliver the messages themselves.

Signed-off-by: Derek Collison <derek@nats.io>
2018-11-06 15:00:21 -08:00
Derek Collison
57904107b2 Added L1 cache to routes
Signed-off-by: Derek Collison <derek@nats.io>
2018-11-01 13:31:12 -07:00
Derek Collison
ea5a6d9589 Updates for comments, some golint fixes
Signed-off-by: Derek Collison <derek@nats.io>
2018-10-31 20:28:44 -07:00
Derek Collison
4058948185 Updates based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2018-10-29 13:51:21 -07:00
Derek Collison
47963303f8 First pass at new cluster design
Signed-off-by: Derek Collison <derek@nats.io>
2018-10-24 21:29:29 -07:00
Derek Collison
14cdda8cd4 Updates from comments
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-30 09:36:32 -07:00
Derek Collison
c4bcbf6275 Map anonymous reply subjects
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-29 13:04:19 +02:00
Derek Collison
f6cb706c68 First pass req/reply across accounts
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-29 13:04:19 +02:00
Derek Collison
1cbfbfa071 Basic account support
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-29 13:04:19 +02:00
Ivan Kozlovic
4cd3453392 Set buf size limit to 50% of max_pending
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-09-27 09:43:56 -06:00
Ivan Kozlovic
e7f5cc82f0 Updates
- Use stack buffers
- Ensure that buffer size is no greater than 90% of max_pending
- Added test with low max_pending

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-09-26 12:19:14 -06:00
Ivan Kozlovic
178aab096d Updates based on comments
- Removed un-needed lock/unlock
- Buffer SUBs/UNSUBs protocols and ensure flushing when buffer
  gets to a certain size (otherwise route would get disconnected
  with high number of subscriptions)

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-09-24 16:06:34 -06:00
Ivan Kozlovic
178766d6c9 [ADDED] Support for route permissions config reload
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-09-18 18:28:40 -06:00
Derek Collison
f85f002a28 Update tls and remove pre 1.9 files
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-06 19:00:44 -07:00
Derek Collison
f032dc4529 Simplify, don't need connect processing
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-05 17:03:45 -07:00
Derek Collison
2ee868ba18 Propogate route imports and exports to other connected servers
Signed-off-by: Derek Collison <derek@nats.io>
2018-09-05 16:15:31 -07:00
Ivan Kozlovic
7e39d0935d Fixed crash related to route permissions after allow/deny feature
This is an issue in master only, not in any public release.
The issue is that permissions should be assigned as-is for the
route perms because Publish/Subscribe could be nil, so trying
to dereference Publish.Allow/Deny or Subscribe.Allow/Deny could
crash. The code checking for permissions correctly check if
Publish/Subscribe is nil or not.

This was introduced with PR #725

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-27 14:43:32 -06:00
Derek Collison
5955f22d65 Add in route permission support
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-23 14:42:43 -07:00
Derek Collison
65188f9768 Added parser for new style authorizations
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-22 20:41:48 -07:00
Ivan Kozlovic
b1bb181f3d Ensure URLs are compared using reflect.DeepEqual
I don't think it is a good thing to compare the pointers and we
should use the DeepEqual instead.
When comparing a solicited route's URL to the URL that was created
during the parsing of the configuration, the pointers maybe the
same and so u1 == u2 would work. However, there are cases where
the URL is built on the fly based on the received route INFO protocol
so I think it is safer to use a function that does a reflect.DeepEqual
instead.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-16 09:48:32 -06:00
Ivan Kozlovic
d98d51c8cc [FIXED] Possible cluster Authorization Error during config reload
When changing something in the cluster, such as Timeout and doing
a config reload, the route could be closed with an `Authorization
Error` report. Moreover, the route would not try to reconnect,
even if specified as an explicit route.

There were 2 issues:
- When checking if a solicited route is still valid, we need to
  check the Routes' URL against the URL that we try to connect
  to but not compare the pointers, but either do a reflect
  deep equal, or compare their String representation (this is
  what I do in the PR).
- We should check route authorization only if this is an accepted
  route, not an explicit one. The reason is that we a server
  explicitly connect to another server, it does not get the remote
  server's username and password. So the check would always fail.

Note: It is possible that a config reload even without any change
in the cluster triggers the code checking if routes are properly
authorized, and that happens if there is TLS specified. When
the reload code checks if config has changed, the TLSConfig
between the old and new seem to indicate a change, eventhough there
is apparently none. Another reload does not detect a change. I
suspect some internal state in TLSConfig that causes the
reflect.DeepEqual() to report a difference.

Note2: This commit also contains fixes to regex that staticcheck
would otherwise complain about (they did not have any special
character), and I have removed printing the usage on startup when
getting an error. The usage is still correctly printed if passing
a parameter that is unknown.

Resolves #719

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-15 18:20:29 -06:00
Derek Collison
061788ab9b Add no echo feature
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 18:34:27 -07:00
Derek Collison
ec8e2636de Track closed connections and reason for closing
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-25 17:56:07 -07:00
Ivan Kozlovic
dd59bdf285 Merge pull request #688 from nats-io/route_permissions_v2
[ADDED] Route permissions
2018-06-21 21:13:02 -06:00
Ivan Kozlovic
d435fb9aa3 Remove some debug statements
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-21 20:23:39 -06:00
Derek Collison
b7ece91825 Avoid race by using conditional deep copy
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-21 18:22:06 -07:00
Ivan Kozlovic
bf3bc81722 Add route permissions
The `client.perms` struct is left unchanged. We simply map Import
and Export semantics to existing Publish and Subscribe ones.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-21 17:04:10 -06:00
Derek Collison
17fecd4c9b Support CID in client INFO, allow filtering /connz by CID
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-21 15:23:15 -07:00
Derek Collison
37352edff0 Fixes #681
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-19 16:42:39 -07:00
Derek Collison
cc07d500dd new subs collector
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Derek Collison
50bb4b9a1b delivery last activity update 2018-06-04 17:45:05 -07:00
Derek Collison
26dafe464b Don't send route unsub with max
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Derek Collison
049db6e854 Support for queue subscriber retries over routes
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00