Commit Graph

1936 Commits

Author SHA1 Message Date
Phil Pennock
cceeb94166 WIP: add best guess prominent socket stats logging 2020-10-13 19:53:45 -04:00
Phil Pennock
331f6ca3aa WIP: theoretically, populate expvar maps 2020-10-13 19:53:35 -04:00
Phil Pennock
65be9706b3 WIP: socket stats
At this point, we're collecting for gateways, we have the general framework in
place, and we're populating unpublished expvars.
2020-10-13 18:26:28 -04:00
Matthias Hanel
60c8cbd1f2 Fixed crash on non existing directory
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-13 01:30:03 -04:00
Matthias Hanel
8d8f6480d7 Incorporating comments
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-12 19:21:32 -04:00
Matthias Hanel
bb63fd5f40 Adding list/delete/update operations for jwt stored by nats-resolver
Update already existed scoped by account, this exposes update without account.
List returns a list of all stored accounts.
Delete deletes accounts.
Fix a crash on startup with non existing directory.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-12 18:07:07 -04:00
Matthias Hanel
db44b589fc Skip revocation check if the client has no jwt and is therefore internal
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-09 14:41:32 -04:00
Ivan Kozlovic
13df1a55fd Changed warning message
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-10-09 09:36:30 -06:00
Ivan Kozlovic
df9d5f5fd9 Accepting route warns if remote server has same name
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-10-08 17:59:33 -06:00
Ivan Kozlovic
9b6385d6e7 [CHANGED] Default TLS and Auth timeout
The default TLS timeout has been bumped to 2 seconds.
The default Auth timeout is now 2 seconds, but if TLS config
is present, it is equal to TLS timeout (possibly default value) + 1s.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-10-08 16:15:30 -06:00
Matthias Hanel
387e1e1ee4 [Fixed] revocation check used current time instead of jwt issue time
Also empty revoked keys once account jwt has no revocations.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-06 21:45:34 -04:00
Matthias Hanel
4ff7b280f4 Avoid unnecessary CONNS subscription
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-05 18:25:51 -04:00
Derek Collison
9ad408e0b3 Use closed variable on consumer, don't check consumer sequences
Signed-off-by: Derek Collison <derek@nats.io>
2020-10-02 16:21:23 -07:00
Derek Collison
8a9f6eaf42 Additional fixes to interest retention based streams and offline durables with redelivery.
Signed-off-by: Derek Collison <derek@nats.io>
2020-10-02 12:58:59 -07:00
Derek Collison
a75be04b0a Various fixes for this PR.
- Fix for updating delivery subject and adjusting next delivery sequences.
- When acking explicitly but out of order, need to make sure we set floor correctly.
- Only update ack floors on an ack if the message is present.
- Fix for needAck for explicitAck out of order consumers detecting if message has been acked.
- Fix for race not locking stream when checking interest during stop.
- Fix for filestore determing if a message block still has a message. Added check to first sequence as well as cache.
- Some additions to the original test.

Signed-off-by: Derek Collison <derek@nats.io>
2020-10-01 21:24:40 -07:00
Ivan Kozlovic
7b03edb792 Bump version
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-29 19:23:12 -06:00
Matthias Hanel
08e37e0d94 Updated jwt library and check (account/token) issuer prior to jwt Validate
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-29 21:03:40 -04:00
Ivan Kozlovic
0c804f5ffb Moving TestQueueAutoUnsubscribe to norace_test.go
This test has been found to cause TestAccountNATSResolverFetch to
fail on macOS. We did not find the exact reason yet, but it seem
that with `-race`, the queue auto-unsub test (that creates 2,000
queue subs and sends 1,000 messages) cause mem to grow to 256MB
(which we know -race is memory hungry) and that may be causing
interactions with the account resolver test.

For now, moving it to norace_test.go, which consumes much less
memory (25MB) and anyway is a better place since it would stress
better the "races" of having a queue sub being unsubscribed while
messages were inflight to this queue sub.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-29 18:06:16 -06:00
Matthias Hanel
01453e03cd Add defer srv.Shutdown() where manual shutdown was done
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-29 15:54:20 -04:00
Matthias Hanel
4e055d7b72 Fixing test race condition
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-29 14:36:04 -04:00
Matthias Hanel
f3e6cd12ec Adding fetch on missing jwt of full nats based resolver
Full nats based resolver sync within a cluster.
This functionality addresses syncing between cluster.

Fixing deadlock when more than one server responds to lookup.
Fixing crash when shutdown and pack happen at the same time.
2020-09-29 14:36:04 -04:00
Ivan Kozlovic
3d00001e21 Merge pull request #1617 from nats-io/conns-event
Fix event ordering issue caused by re-locking
2020-09-29 11:53:54 -06:00
Matthias Hanel
dcb1f6ff01 Avoid blocking when holding account lock.
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-29 13:15:45 -04:00
Ivan Kozlovic
3977ea04f5 Fixed possible panic on consumer.Delete() during server Shutdown()
The panic was caused by the closing of an already closed Go channel.
The Delete() relied on the consumer's mset being nil to consider
the consumer already closed. However, the consumer's mset is set
to nil after invoking sendDeleteAdvisoryLocked() which internally
invokes sendAdvisory() which releases/reacquires the consumer lock.
This left an open door for a race to occur and Delete() to be
invoked twice on the same consumer.

Moving setting the consumer's mset to nil too early would prevent
the sendAdvisory() to actually do its job. We could pass the mset
to sendAvisory(), but a simpler approach is to simply use a "closed"
boolean on the Consumer object that is set to true at the beginning
of the Delete() function.

Resolves #1621

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-29 10:01:47 -06:00
Derek Collison
7f44d075f7 Merge pull request #1601 from ripienaar/skip_ack_on_acknxt
Do not ack to AckNxt
2020-09-28 17:19:35 -07:00
Derek Collison
9129d7b62f Set to 1 if no acks received, fixes #1619
Signed-off-by: Derek Collison <derek@nats.io>
2020-09-28 15:56:50 -07:00
Matthias Hanel
d343ba78bc Fix event ordering issue caused by re-locking
Noticed TestSystemAccountConnectionUpdatesStopAfterNoLocal failing
du to the timer still being around.
To avoid one event interfering with antoher, holding the account lock
during send seems the most appropriate solution.
sendInternalMsg essentially records the send queue and unlocks the server.
This change just merges that with the code in sendAccConnsUpdate.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-26 17:12:18 -04:00
Ivan Kozlovic
2792fd2ef1 Merge pull request #1612 from nats-io/sys-evt-cleanup
[Added] filtering by account to leafz and exposing this as per acc subject
2020-09-24 17:15:53 -06:00
Matthias Hanel
371861ec59 Holding lock when accessing leaf node account for filtering
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-24 18:57:21 -04:00
Matthias Hanel
3d2b65228a [Fixed] race condition where account conns timer was disabled too soon
The connection count sent and the connection count used to determine if
the timer should be disabled could differ.

Also fixed issues in unit test triggering this behavior.
It did not check if remote connections where set to 0 prior to doing
more tests.

Fixes #1613

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-24 18:49:32 -04:00
Matthias Hanel
d501a811b8 [Added] filtering by account to leafz and exposing this as per acc subj
On the monitoring endpoint /leafz specify ?acc=<account id>

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-24 17:23:36 -04:00
Ivan Kozlovic
63cc9a0936 Merge pull request #1611 from nats-io/sys-evt-cleanup
[Adding] Accountz monitoring endpoint and INFO monitoring req subject
2020-09-24 13:30:45 -06:00
Matthias Hanel
7a8a7a7234 Incorporating review comments 2020-09-23 18:29:44 -04:00
Ivan Kozlovic
12d84c646c Merge pull request #1535 from harrisa1/improveLogging
[CHANGED] add client provided info into server side client logs when available
2020-09-23 14:53:06 -06:00
Matthias Hanel
634ce9f7c8 [Adding] Accountz monitoring endpoint and INFO monitoring req subject
Returned imports/exports are formated like jwt exports imports, even if
they originating account is from config.

Fixes #1604

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-23 16:22:48 -04:00
Andrew Harris
40cacf5e5f updates from PR 2020-09-23 14:02:03 -04:00
Ivan Kozlovic
9b7c472c09 Merge pull request #1607 from nats-io/fix_leafnode_loop_detected
[FIXED] Prevent LeafNode loop detection on early reconnect
2020-09-22 17:27:01 -06:00
Ivan Kozlovic
2605ae71ed [FIXED] Prevent LeafNode loop detection on early reconnect
If the soliciting side detects the disconnect and attempts to
reconnect but the accepting side did not yet close the connection,
a "loop detected" error would be reported and the soliciting server
would not try to reconnect for 30 seconds.

Made a change so that the accepting server checks for existing
leafnode connection for the same server and same account, and if
it is found, close the "old" connection so it is replaced by
the "new" one.

Resolves #1606

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-22 16:58:36 -06:00
Andrew Harris
b5197cfc47 updates from PR 2020-09-22 09:05:50 -04:00
Matthias Hanel
0e982b45ea Expose SUBSZ and CONNZ monitoring endpoints for accounts
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-22 00:10:53 -04:00
Matthias Hanel
5df6cb425c Add $SYS.REQ.ACCOUNT.%s.CLAIMS.UPDATE
Old $SYS.ACCOUNT.%s.CLAIMS.UPDATE is keept for backwards compatibility.
The old name is in the same name space as events.
To be able to abuse this, an attacker needs to be in possession of the
operator key as well.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-21 14:32:17 -04:00
R.I.Pienaar
cd376aa753 Do not ack to AckNxt
This causes nil messages mid content stream and is confusing,
the test for this is amended to test the content received for
validity - where previously the test assumed any content is
good content but in fact it only received half the content.

Removing this behaviour until we can design this properly

Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-09-21 17:28:53 +02:00
Matthias Hanel
f76d6e38bd Adding new subscription for account conns (#1599)
This fits better with similar events
New subject is $SYS.ACCOUNT.%s.SERVER.CONNS
Old subject remains for backwards compatibiliby

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-18 15:52:23 -06:00
Ivan Kozlovic
04f96813a7 Validate options for user embedded NATS Server in their app
We were doing option validation from options parsing, but added
it also for Users/NKeyUsers options.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-18 13:09:52 -06:00
Ivan Kozlovic
e84f1cf52c Added test with unknown JWT allowed connection type
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-17 18:17:19 -06:00
Ivan Kozlovic
648346f857 Add some tests for config parsing
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-16 19:17:12 -06:00
Ivan Kozlovic
7ccbaca782 Added an allowed connection type filter for users
Users and NKey users will now have the option to specify a list
of allowed connection types.

This will allow for instance a certain user to be allowed to
connect as a standard NATS client, but not as Websocket, or
vice-versa.

This also fixes the websocket auth override. Indeed, with
the original behavior, the websocket users would have been bound
to $G, which would not work when there are accounts defined, since
when that is the case, no app can connect/bind to $G account.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-16 18:22:44 -06:00
Ivan Kozlovic
04ec50865d Merge pull request #1598 from nats-io/sys-evt-cleanup
Tie account in system event subject to data and clean up subject names
2020-09-16 15:29:40 -06:00
Matthias Hanel
3c149ea99b Incorporating comments and renaming claims pack as well
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-16 16:04:33 -04:00
Matthias Hanel
a4c069884f Tie account in system event subject to data and clean up subject names
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-16 13:26:06 -04:00