Commit Graph

207 Commits

Author SHA1 Message Date
Ivan Kozlovic
773b25af85 [FIXED] Shutdown stops http server when started manually
In case one creates a server instance with New() and then starts
the http server manually (s.StartHTTPMonitoring()), calling
s.Shutdown() would not stop the http server because Shutdown()
would return without doing anything if `running` was not true.
This boolean was set to true only in `s.Start()`.

Also added StartMonitoring() to perform the options check and
selectively start http or https server to replace individual calls.
This is useful for NATS Streaming server that will now be able
to call s.StartMonitoring() without having to duplicate code
about options checks and http server code.

This is related to PR #481
2017-05-25 17:01:35 -06:00
Ivan Kozlovic
513c0a0971 [FIXED] Specifying HTTP and HTTPs ports produces unexpected behavior
The server will now print a Fatal error if user tries to configure
both HTTP and HTTPs ports.

Resolves #495
2017-05-24 13:06:04 -06:00
Tyler Treat
fa50a2c145 [FIXED] Authorization Timeout and TLS
When TLS and authorization is enabled, the authorization timeout can
fire during the TLS handshake, causing the server to write the
authorization timeout error string into the client socket, injecting
what becomes bad data into the TLS handshake. This creates misleading
errors on the client such as tls: oversized record received with length
21024.

This moves the authorization timeout scheduling to after the TLS
handshake to avoid the race. This should be safe since TLS has its own
handshake timeout. Added a unit test that fails with the old behavior
and passes with the new. LMK if you can think of a better way to test
this.

Fixes #432
2017-05-17 14:38:02 -05:00
miraclesu
26ef3f8a70 Revise queue msg action
We think it marks a queue subscription via QRSID prefix.
2017-05-09 16:16:15 +08:00
miraclesu
b570f8de9b Add test for invalid queue sid 2017-05-09 16:16:15 +08:00
Derek Collison
76de921f65 Cleanup for Auth 2017-04-20 12:41:48 -07:00
Ivan Kozlovic
0cf8455a3a [ADDED] Support for token in configuration file
So far, it was only possible to use token from the command line.

Resolves #464
2017-03-30 11:23:07 -06:00
Ivan Kozlovic
a0245fc0c8 [FIXED] Server not sending PINGs to TSL connections (clients or routes)
- Removed unnecessary cast check to (*net.TCPConn). When the timer
fires, the connection is already established. Replaced with check
that connection has not been closed.
- Add PING test that checks that pings are sent to TLS connections.
- Changed Go version to 1.7.5 in travis.
- Removed test package from code coverage.
2017-03-24 09:49:42 -06:00
Colin Sullivan
efbd423e96 Updates based on comments. 2017-03-01 20:46:47 -07:00
Colin Sullivan
3f8a0d8b4a Use atomic.Load to access fields used in /varz and /subsz requests.
* Includes a unit test that checks all endpoints for data races.
2017-03-01 16:13:20 -07:00
Colin Sullivan
c9d90734c5 Fix staticcheck error found moving to go 1.8 2017-02-21 15:30:15 -07:00
Ivan Kozlovic
27bfed541c Fixed errors found by staticcheck
Staticcheck has probably been updated and is finding new errors.
They have been fixed.

Also, moved the run of staticcheck before running the test suite,
so if it fails, it fails sooner ;-).
2017-01-24 19:34:17 -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
Colin Sullivan
b133cda3cd Add curve preference option to configuration files.
* Add a preference to specify and order the curve preferences
* Add details tls help
* Deprecate old 1.4 cipher suite code
2016-12-27 15:41:48 -07:00
Ivan Kozlovic
d3555053d0 Change option/parameter name 2016-12-22 14:59:27 -07:00
Ivan Kozlovic
a8dfaeae3d [ADDED] Ability to configure number of connect retries for implicit routes
When a server is told to connect to a server (with auto-discovery),
it tries to connect once. There have been a report where that
connection fails, but would probably succeed if tried again (#408).
This new parameter allows to configure the number of times a failed
implicit connect should be tried.

Resolves #408
2016-12-20 18:37:23 -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
Derek Collison
970dc93b7e Add in missing file 2016-11-21 15:07:09 -08:00
Derek Collison
e57c949658 Add support for 'include' to configuration files 2016-11-21 14:58:05 -08:00
Derek Collison
61e0b758d7 Updates for Go client rename, update vendor dependencies 2016-11-20 13:15:37 -08:00
Ivan Kozlovic
645529243f Fix staticcheck reported issues
The tool is started with the "-ignore" flag to ignore warning SA2002
which corresponds to invoking t.Fatalf (and the like) in a go routine.
Calling t.Fatalf in a go routine may produce a race condition.
The rationale for ignoring this warning is that if a test executes
the t.Fatalf() line it is that we have a problem either with test
or code that should be fixed.
2016-11-15 12:54:36 -07:00
Colin Sullivan
6281894cc5 Add staticcheck static analyzer to travis.
Included are small fixes to address warnings found in test code.  No functional changes.
2016-10-27 09:51:15 -06:00
Ivan Kozlovic
8f7f6e9f8b [FIXED] Client certificate verification when verify is true.
Server was incorrectly requiring a client certificate, but not
verifying it.

Resolves #336
2016-08-25 15:33:13 -06:00
Derek Collison
c7e699ac29 Updated benchmark formatting, added 128b payload 2016-08-24 13:17:07 -07:00
Ivan Kozlovic
82dbb3a5ab [ADDED] Option to not advertise to clients cluster's IPs
By default, a server is now sending to its clients the client URLs
of all servers in the cluster. This allows clients to be able
to reconnect to any server in the cluster even if those clients
were not configured with the list of servers in the cluster.

However, there may be cases where it would make sense to disable
this feature. This now can be done with this option/command line
parameter.

Resolves #322
2016-08-12 19:24:12 -06:00
Ivan Kozlovic
c6d37ecf8f [IMPROVED] Route performance for larger messages 2016-08-01 19:01:34 -06:00
Ivan Kozlovic
61b0fec200 Updated test for corner cases
Test when client has not yet sent its CONNECT proto or the first
PING when route is added.
2016-07-26 11:57:16 -06: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
fa95bd936b spelling 2016-06-17 10:09:14 -07:00
Derek Collison
67ed61c837 fixups for PR comments 2016-06-17 09:59:39 -07:00
Derek Collison
248bd8d366 bug fix for _SYS. 2016-06-16 21:46:54 -07:00
Derek Collison
7730fac9e2 Authorization enforcement and performance tweaks 2016-06-16 17:07:25 -07:00
Derek Collison
27ac524daf version bump to next beta 2016-06-15 11:10:50 -07:00
Ivan Kozlovic
2bec28e146 Fix test
Loop should stop whenever a valid ip is found.
2016-05-23 20:05:09 -06:00
Derek Collison
82f04baa12 Allow optional reporting of authorized user under connz 2016-05-15 10:07:37 -07:00
Derek Collison
46a9e6f0bc First pass at multi-user support 2016-05-13 12:27:57 -07:00
Derek Collison
4c36522f55 new listen style 2016-05-12 17:22:09 -07:00
Derek Collison
9e73c1db76 Enable listen address parsing for client, cluster and http, enforce http hosts as separate 2016-05-12 16:47:01 -07:00
Colin Sullivan
8a07a02a97 Rename the field to 'total'. 2016-04-26 17:49:09 -06:00
Colin Sullivan
a6dfe88746 Add a live connection count to /connz monitoring. 2016-04-26 17:24:01 -06:00
Derek Collison
12fdd5dead Merge pull request #256 from nats-io/fix_data_race
Fix data race
2016-04-22 18:28:31 -07:00
Ivan Kozlovic
3691d14426 Fix missing capture of remoteID in removeClient
This needed to be captured under the client lock. Adding a test
that captured the races (when running enough times).
2016-04-22 18:06:38 -06: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
Ivan Kozlovic
3a999c1299 Add tracking of most go routines started by the server
Refactor the way client is initialized. We need to ensure that
clients are not added to the clients map and readLoop started if
the server is in the process of being shutdown otherwise there
is a chance that the server already gathered the list of connections
to close and this one would not be included, leaving a readLoop
running.
Same occurs for routes, with the complexity that the readLoop is
started well before the route connection is added to the server
routes' list. We need a temporary map that contains those connections
to be able to close them on server Shutdown.

Fixed some flapping tests.
2016-04-21 11:48:39 -06:00
Derek Collison
4f333416bb Revert race on interest graph since it could cause dropped interest propogation, fix test instead 2016-04-15 15:46:29 -07:00
Derek Collison
3e2c3714bc Fix race in interest propogation to new routes 2016-04-15 13:16:13 -07:00
Derek Collison
433d62ec0a Parse IPs and raw strings in arrays properly 2016-04-07 08:36:57 -07:00
Derek Collison
21ec036da4 Add in vendor support 2016-04-05 10:52:40 -07:00