Commit Graph

47 Commits

Author SHA1 Message Date
Ivan Kozlovic
515779ae0b [FIXED] Use of * and > in subjects as literals
The issue was that a subject such as `foo.bar,*,>` would be
inserted to the cache as is, but when trying to remove from the
cache, calling matchLiteral() with the above subject in the cache
against the same subject would return false. This is because
matchLiteral would treat those characters as wildcards token.

Note that the sublist itself splits subjects on the `.` separator
and seem not bothered by such subject (would have `foo` and `bar,*,>`
tokens). Also, note that IsValidSubject() and IsValidLiteralSubject()
properly checked that the characters `*` and `>` are treated
as wildcards only if they are tokens on their own.

Resolves #558
2017-08-16 12:12:18 -06:00
Ivan Kozlovic
70b3b18535 Fix some tests
Fixing various tests that were failing locally when running in
parallel mode (without -p=1).
In reload_test.go, lots of nats.Conn.Close() were missing which
would require too much memory when running with `-race` mode.
2017-07-05 18:57:15 -06:00
Tyler Treat
6e3f58f48c Fix tests and cleanup log output 2017-06-14 10:38:21 -05:00
Peter Miron
d1f38f38a2 changes to support random ports for clusters and profiler. 2017-06-10 10:35:01 -04:00
Tyler Treat
d2fd0b7190 Reduce AuthTimeout in test 2017-06-05 09:51:05 -05:00
Tyler Treat
0bda6da60e [FIXED] Intermittent failing test
Added the sleep back in to TestAuthorizationTimeout which got removed in #493.
This was causing the test to fail intermittently, though it would
usually pass on Travis CI or with the -race flag since these slowed it
down enough.
2017-06-01 16:38:02 -05: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
Derek Collison
45d523e800 Fixups for auth always being checked now 2017-04-20 13:26:59 -07:00
Derek Collison
76de921f65 Cleanup for Auth 2017-04-20 12:41:48 -07:00
Ivan Kozlovic
7c59ce3dba [ADDED] Reject clients connecting to route's listen port
This happens sometimes, and the latest occurence was today:
https://github.com/nats-io/java-nats/issues/96

When it happens, there is no error but subscribers would not receive
anything, etc...

This PR uses the fact that clients set the field Lang in the CONNECT
protocol that ROUTEs do not. I have checked that all Apcera supported
clients do set Lang in the CONNECT protocol.
If we plan to add Lang for routes, we need to find another field or
use a new one, in which case that would work only for new clients
(that would need to be updated).

With this change, when the server accepts a connection on the route
port and detects that this protocol field is present, it now closes
the client connection.

The nice thing is that newer clients, when incorrectly connecting
to the route port, get from the route's INFO the list of client URLs,
which means that on the initial connect error, they are able to
subsequently connect to the proper client port, so it is transparent
to the user (which may or may not be a good thing). However, it is not
guaranteed because if the client is not setting NoRandomize to true,
the client URL is added but the array shuffled, so it is possible that
the client library does not find the correct port in the connect loop.
2017-01-24 19:46:46 -07:00
Christophe de Vienne
872c9e0c39 Test GetTLSConnectionState
Run GetTLSConnectionState on a non-tls connection (in a dedicated test)
and a tls connection.
Because initializing the TLS connection in the tests is non-trivial,

I hijacked the TestTLSCloseClientConnection test.
2016-12-21 10:42:50 +01:00
Derek Collison
61e0b758d7 Updates for Go client rename, update vendor dependencies 2016-11-20 13:15:37 -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
Ivan Kozlovic
d46a17d228 Fix test
Use RunServer() so that it ensures that server is ready to accept
connections.
2016-05-23 20:15:26 -06:00
Ivan Kozlovic
188f7bf84c Fix possible blocking on socket write or connection close (when using TLS)
Ensure that all socket writes are protected with deadlines.
For connection Close(), also use deadlines since in case of TLS,
the Close() will send an alert (do a write) if the handshake was
completed. If the peer is not reading, this would cause the Close()
to hang.
2016-05-23 19:57:54 -06:00
Derek Collison
b3388db53f Enable dynamic write buffers for client connections 2016-04-15 18:16:13 -07:00
Derek Collison
df02bc0bcf Removed sublist, hash and hashmap, no longer needed. 2016-04-02 12:52:48 -07:00
Derek Collison
3dd490a449 Go Report Card fixes 2016-03-20 16:06:28 -10: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
Ivan Kozlovic
97da466312 Fix races, add a test and adjust others.
* There was a race during unsubscribe()
* 'go test -race' reports a race in TestSetLogger test. This one could be ignored since we normally invoke SetLogger only on server startup. That being said, Travis failed when I tried to submit a PR for the fix of the unsubscribe race. So proposing to fix the logger too.
2015-11-18 20:39:56 -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
Máximo Cuadros Ortiz
65ae9c16f2 extendable auth methods 2014-11-27 00:26:13 +01:00
Julian Friedman and Zach Robinson
6ed7227371 No longer add subscriptions to router clients with no existing connection.
race condition:
 - a client is closed at the same time as an incoming SUB message occurs.
 - the subscription is added to the srv.sl even though the socket is
   closed.
 - the connection cleanup has already run, so the bad state is never
   corrected
 - now messages may be forwarded to a client without a connection
 - messages will not be forwarded to a router that needs it now, because
   processMsg assumes the router already received it
2014-09-18 22:36:13 -07:00
Ken Robertson
8ccf0a8bb8 Fix gofmt issues 2014-08-12 23:06:01 -07:00
w00228948
31bc0bdb8c Use authTimeout in setAuthTimer 2014-08-12 17:55:59 +00:00
Derek Collison
0e47153275 Move to %q to properly print out 2014-01-09 00:04:35 -05:00
Derek Collison
c36036541b Fix for MatchLiteral bug, report #18 2014-01-07 18:35:18 -08:00
Derek Collison
ddb54bb154 Need to flush the clients 2013-12-12 14:56:24 -08:00
Derek Collison
4e1502cc4c README license, copyright cleanup, etc 2013-09-30 10:16:43 -07:00
Derek Collison
cf0f30200f log file support, data race fixes 2013-08-02 16:52:54 -07:00
Derek Collison
72b68bf363 Added sub and unsub broadcast to routes 2013-07-27 22:05:15 -07:00
Derek Collison
5189dba7b6 Cluster startup 2013-07-27 16:29:25 -07:00
Derek Collison
411ad06d17 Added more tests for auto-unsubscribe 2013-06-25 18:25:40 -05:00
Derek Collison
ef2902eef2 Fix data races 2013-06-11 22:32:17 -07:00
Derek Collison
71cb11db92 Make timing work with GOMAXPROCS>1 2013-02-22 17:31:37 -08:00
Derek Collison
ac50411dfd Added no body test 2012-12-19 17:47:58 -08:00
Derek Collison
69bc1a2e25 Test server's client map 2012-12-18 17:27:03 -08:00
Derek Collison
fb79a982ef Added ability to run server as a Go routine 2012-12-18 16:56:49 -08:00
Derek Collison
0c5fa45bdd Added options for auth, user, and pass. 2012-12-03 11:38:59 -08:00
Derek Collison
3a5765b6af Added new fields to connect options 2012-11-30 08:53:43 -08:00
Derek Collison
56cfcac374 Enable verbose mode 2012-11-29 16:52:10 -08:00
Derek Collison
f6a039bd6a Added PING to provide flush semantics 2012-11-20 13:52:27 -08:00
Derek Collison
0e2ae6c9d3 Fixed bad comments 2012-11-13 19:25:51 -08:00
Derek Collison
3ea6f64c73 more default options, fixed tests 2012-11-13 11:39:31 -08:00
Derek Collison
6630efb298 first pass server 2012-11-12 14:26:38 -08:00