Commit Graph

81 Commits

Author SHA1 Message Date
Matthias Hanel
a8e6af30a3 On client connect, send first ping after ping interval.
On connect message resend reset timer with setFirstPingTimer, so RTT can
be obtained quicker.

Disable short first ping in default server options for client_test.
In log_test prevent immediate scheduling by setting ping interval.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-03-02 20:10:15 -05:00
Derek Collison
ebd4deb8b9 Stager first ping from server and suppress pings if a ping was received.
Signed-off-by: Derek Collison <derek@nats.io>
2019-06-29 15:43:15 -07:00
Ivan Kozlovic
ed1901c792 Update go.mod to satisfy v2 requirements
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-06-03 19:45:47 -06:00
Derek Collison
acfe372d63 Changes for rename from gnatsd -> nats-server
Signed-off-by: Derek Collison <derek@nats.io>
2019-05-06 15:04:24 -07:00
Derek Collison
bacb73a403 First pass at leaf nodes. Basic functionality working, including gateways.
What is not completed:
1. TLS
2. config to bind local account.
3. Info updates for solicitor to track topology changes like a client.
4. CONNECT sent after INFO for nonce authroization.
5. Authorization
6. Services and Streams tests.
7. config file parsing.

Signed-off-by: Derek Collison <derek@nats.io>
2019-03-25 08:54:47 -07:00
Derek Collison
e9c1d26f0b quick enablement of logging and tracing
Signed-off-by: Derek Collison <derek@nats.io>
2018-12-09 18:07:56 -08:00
Derek Collison
f4f3d3baf1 Updates for operator based configurations.
Added update to parse and load operator JWTs.
Changed to add in signing keys from operator JWT to list of trusted keys.
Added URL account resolver.
Added account claim updates by system messages.

Signed-off-by: Derek Collison <derek@nats.io>
2018-12-02 20:34:33 -08:00
Ivan Kozlovic
10fd3ca0c6 Gateways [WIP]
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-11-27 19:00:03 -07:00
Derek Collison
a2e310ffc1 Vendor jwt, fixes for nkey, jwt changes
Signed-off-by: Derek Collison <derek@nats.io>
2018-11-21 19:22:04 -08: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
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
3b953ce838 Allow localhost to not be defined, only need 127.0.0.1
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 16:10:19 -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
df574ce951 varz cluster empty when not defined
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Derek Collison
50a99241ea Slow consumer updates and latency improvements.
Use pending bytes as slow consumer trigger, so reintroduce max_pending.
Improve latency with inplace flush calls when appropriate. Utilize simple
time budget for readLoop routine.

Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Ivan Kozlovic
fb972bd0fc Remove ssl_required references 2018-03-23 13:40:10 -06:00
Derek Collison
00901acc78 Update license to Apache 2 2018-03-15 22:31:07 -07:00
Ivan Kozlovic
72bbd2b982 Restore DefaultTestOptions port to 4222
This is used by RunDefaultServer() and some external projects tests
may rely on the fact that this runs on the default port.

Our tests that want to use ephemeral ports to avoid port conflicts
should be updated to not use these default options and/or RunDefaultServer().
2018-03-07 12:12:19 -07:00
Ivan Kozlovic
0ac50bda76 Try reduce port conflicts in tests 2018-03-06 08:49:45 -07:00
Ivan Kozlovic
20926a6176 Added megacheck
This tool combines staticcheck, gosimple and unused.
Fixed reports from unused.
2017-08-11 17:28:18 -06:00
Derek Collison
76de921f65 Cleanup for Auth 2017-04-20 12:41:48 -07:00
Colin Sullivan
31dc3a7e11 Increase the client dial timeout.
* Windows and stressed machines require more time to connect; this was causing flappers.
2017-01-06 15:35:41 -07:00
Ivan Kozlovic
5f471b6e7f Replace GetListenEndpoint() with ReadyForConnections()
The RunServer() function (and the various variants)
call Server.Start() in a go-routine, but do not return until
it has verified that the server is ready to accept connections.
To do so, it use GetListenEndpoint() to get a suitable connect
address (replacing "0.0.0.0" or "::" with localhost - important
on Windows). It then creates a raw TCP connection to ensure the
server is started, repeating the process in case of failure up
to 10 seconds.

This PR replaces this with a function that checks that client
listener, and route listener if configured, are set. This removes
the need to get a connect address and create test tcp connections.

The reason for this change is that NATS Streaming when starting
the NATS Server (unless configured to connect to a remote one)
calls RunServerWithAuth(), which when getting "localhost" from
GetListenEndpoint(), would fail trying to resolve it. This happened
for the NATS Streaming Docker image built with Go 1.7+.
2016-12-09 14:03:45 -07:00
Derek Collison
8fbacaaea1 Cleanup for cluster opts 2016-12-02 14:29:22 -08:00
Ivan Kozlovic
fda5bd7ac7 [ADDED] Server sends INFO with cluster URLs to clients with support
Clients that will be at the ClientProtoInfo protocol level (or above)
will now receive an asynchronous INFO protocol when the server
they connect to adds a *new* route. This means that when the cluster
adds a new server, all clients in the cluster should now be notified
of this new addition.
2016-07-26 10:55:55 -06:00
Derek Collison
e3b5713ab9 Check for control line violations and memory attacks 2016-07-11 12:03:49 -07:00
Derek Collison
46a9e6f0bc First pass at multi-user support 2016-05-13 12:27:57 -07:00
Ivan Kozlovic
ad1198db85 Add code coverage
-Test coverage was no longer triggered due to the check for BUILD_GOOS
 environment variable that was removed. Removed the check.
-Re-run test package with server code coverage.
-Remove unused functions in test.go.
-Add test for a function in test.go.
-Add missing parse +OK test.
2016-04-22 13:03:04 -06:00
Derek Collison
3e2c3714bc Fix race in interest propogation to new routes 2016-04-15 13:16:13 -07:00
Derek Collison
a4c46694ff gosimple fixes 2016-03-31 07:33:36 -07:00
Colin Sullivan
2baac47820 Address issues found by golint.
* No functional changes
* Did not address the ALL_CAPS issues
* Did not modify public APIs and field names.
2016-03-15 15:21:13 -06:00
Derek Collison
7237972420 support for bcrypt in cluster auth 2016-02-23 12:47:46 -08:00
Derek Collison
a8f622269b For possible slow travis tests 2016-02-06 07:35:09 -08:00
Ivan Kozlovic
eb0eabff04 Replace all changes with simple 25ms delay after connection close. 2016-02-03 18:58:42 -07:00
Ivan Kozlovic
437458e13e Fix completeConnection + fix monitor test.
Don't check what is sent back. The point is that the client should be fully initialized at this point.
We can't ensure using metrics that the "check" connection is gone since in some tests, the server is started and clients auto-reconnect to it.
For tests that depend on the number of clients connected (such as the monitor one), have specific code for those tests.
2016-02-03 18:08:52 -07:00
Ivan Kozlovic
0a4da78f38 Fix code that checks that server is started + route test
- The raw connection used to check that the server is started now consumes the INFO and sends PING and consumes PONG before returning.
- The route test needs to make sure that the client connection has client id 2. Using PING/PONG before creating route connection to make sure of that.
2016-02-03 15:01:00 -07:00
Derek Collison
e9b5839bf0 Merge branch 'discovery' 2015-12-16 14:18:34 -08:00
Derek Collison
8393c3c994 Basic INFO for cluster auto-discovery, Addresses #126 2015-12-16 12:36:24 -08:00
Ivan Kozlovic
d133e68338 Adapt tests for Travis GCE.
* Add server.GetListenEndpoint() to return options' host and port when server is ready to accept client connections. The server can be asked to pick a random port. This function returns a string of the form "host:port" with the port selected by the net.Listen() call.
* Replace the use of server.Addr() with above function to connect to the starting server (using net.Dial) to check for success. The original issue was that, when no hostname is specified in the configuration, the server uses 0.0.0.0 for the listen address. However, server.Addr() would return "[::]", even on a machine with IPv6 disabled, which would cause the net.Dial call to fail with "network unreachable".
2015-12-10 13:06:18 -07:00
Ivan Kozlovic
9b25a379b8 Increase TLS timeout in config files
We would get failures on Travis, I would think because of small TLS timeout. Increase (or set) the TLS timeout to 2 seconds in most configuration files. Update tests that relied on the original value.
2015-12-08 15:20:20 -07:00
Derek Collison
749d4f89cc First pass at client TLS support 2015-10-22 03:30:27 +02:00
Derek Collison
fe3b8f2aa1 BufSize option, bump for go1.5.1, bump version 2015-09-18 07:41:33 -07:00
Derek Collison
45564dbde2 race fixes, go1.5 on travis 2015-09-17 19:02:00 -07:00
Derek Collison
075529e2fe Properly handle and enforce max payload 2015-08-05 22:05:58 -07:00
Derek Collison
96bab33075 fixed import paths 2015-06-19 12:08:11 -07:00
Derek Collison
d9c7392c4d race fixes, tests 2015-06-16 12:48:50 -07:00
Máximo Cuadros Ortiz
65ae9c16f2 extendable auth methods 2014-11-27 00:26:13 +01:00
Derek Collison
65ff554574 Better split buffer testing for CONNECT, fixes issue #63. 2014-11-16 08:58:36 -08:00
Derek Collison
9dc875b88e pedantic about over zealous GC for sockets 2014-09-18 21:25:13 -07:00
Alex Toombs
20b08f5a33 Allow nats to choose a random port when given port -1.
* In order to allow nats to resolve a randomly-chosen port, we want to
  sometimes give net.Listen a port of 0. However, a port of 0 in the
  config resolve to a constant port. In order to avoid behavioral
  changes, we define '-1' to be the default "choose random port"
  number.
* Resolve ports can be retrievd using the server's Addr() method.
2014-06-05 19:48:42 -07:00