Commit Graph

682 Commits

Author SHA1 Message Date
Alberto Ricart
e0fe1247dd [FIX] #490 - Added server id to connz and routez 2017-10-24 19:36:10 -05:00
Ivan Kozlovic
c19527c03f Merge pull request #585 from wallyqs/process-pub-args-crlf
Remove check for '\r\n' when processing pub args
2017-10-17 08:59:43 -06:00
Ivan Kozlovic
a2d2327975 Merge pull request #580 from wallyqs/goto-parsesize
Remove for loop in parseSize to enable inlining
2017-10-17 08:57:44 -06:00
Ivan Kozlovic
d90dc55879 Update README and version number for next release 2017-09-25 13:14:48 -06:00
Ivan Kozlovic
d4695d5e99 [FIXED] Name of selected new cipher suites
Use a map by id to return name of all supported ciphers. Use that
name to display the cipher name on handshake completion.

Resolves #591
2017-09-25 10:56:36 -06:00
Ivan Kozlovic
347798428d Merge pull request #576 from orus-io/custom_auth
[ADDED] Custom Authorization through Options
2017-09-20 11:40:49 -06:00
Waldemar Quevedo
c8f151ef51 Remove check for '\r\n' when processing pub args
The parser has already dropped CRLF by when `processPub`
is called, so can skip doing the these checks there.
2017-09-11 14:21:58 -07:00
Tyler Treat
4a6fd4317a Change client Accept error log level
This is an error users should know about. Thus, the log level should be
error.

Fixes #583
2017-09-11 09:14:10 -05:00
Waldemar Quevedo
cd86c99144 Remove for loop in parseSize to enable inlining
Using a goto based loop makes it become a leaf function which can be
inlined, making us get a slight performance increase in the fast path.
See: https://github.com/golang/go/issues/14768
2017-09-08 10:17:12 -07:00
Ivan Kozlovic
0c3d4ce7fa Merge pull request #573 from nats-io/fix_sublist_insert_remove
[FIXED] Sublist Insert and Remove with wildcard characters in literals
2017-09-08 10:12:54 -06:00
Ivan Kozlovic
8b4a02dd9a Pass functions to ConfigureOptions to print version, help, tls help
This will allow NATS Streaming to provide its own version of what
should be printed when various flags are set.

Related to #578
2017-09-08 09:59:04 -06:00
Christophe de Vienne
28975f67bb Custom auth: Test both auth success & failure 2017-09-08 17:43:32 +02:00
Christophe de Vienne
b743f91107 Use GetOpts in CustomAuth tests
It increses code coverage, and makes sure GetOpts() behaves properly.
2017-09-08 11:29:26 +02:00
Christophe de Vienne
2b7cb173ff Set info.AuthRequired when CustomClientAuthentication is defined 2017-09-08 10:56:21 +02:00
Christophe de Vienne
e556854f54 Rename Custom*Auth to Custom*Authentication
Simplify and complete tests based on Ivan advice.
2017-09-08 10:54:20 +02:00
Ivan Kozlovic
6ba9269cda Added error check for fs.Parse() call
This is just for tests since from main.go, the FlagSet is set
with ExitOnError so Parse() would call os.Exit(2).
Regardless, I wanted to add error checking and a test for that.

Related to #578
2017-09-07 10:37:46 -06:00
Christophe de Vienne
e366137b6c Add a test for CustomClientAuth 2017-09-07 17:59:59 +02:00
Christophe de Vienne
b473674907 Add back custom Auth api
The removal of SetClientAuthMethod removed any possibility of providing
a custom auth backend.

This patch add it back as a Option attribute, so we can wait comfortably for #434,
which aims to provide more extensible external Auth.
2017-09-07 17:39:34 +02:00
Ivan Kozlovic
684a2e4173 Update based on code review 2017-09-07 09:06:37 -06:00
Ivan Kozlovic
379a14b8cc [FIXED] Override from command line not always working
There were some cases where override would not work. Any command
line parameter that would be set to the type default value (false
for boolean, "" for string, etc) would not be taken into account.

I moved all the flags parsing and options configuration into
a new function, which may help reduce code duplication in
NATS Streaming.

The other advantage of moving this in a function is that it
can now be unit tested.

I am also removing call to `RemoveSelfReference()` which attempted
to remove a route to self, which has been already solved at runtime
with detecting and ignoring a route to self.

This function would be invoked only when routes were defined in
the configuration file, not in the command line parameter.

Removing this call also solves an user issue (#577)

Resolves #574
Resolves #577
2017-09-06 17:31:53 -06:00
Ivan Kozlovic
8ec1f77ac8 [FIXED] Sublist Insert and Remove with wildcard characters in literals
This is similar to #561 where `*` and `>` characters appear in tokens
as literals, not wilcards.
Both Insert() and Remove() were checking that the first character
was `*` or `>` and consider it a wildcard node. This is wrong. Any
token that is more than 1 character long must be treated as a literal.
Only for token of size one should we check if the character is `*`
or `>`.
Added a test case for Insert and Remove with subject like `foo.*-`
or `foo.>-`.
2017-08-31 18:48:45 -06:00
Tyler Treat
713b1c5722 Fix permissions cache pruning
We were pruning the wrong cache.
2017-08-31 14:00:30 -05:00
Ivan Kozlovic
0cc49ece4a Improve matchLiteral further and add some more tests 2017-08-17 13:00:09 -06:00
Ivan Kozlovic
42b27d2710 Improve matchLiteral performance and simplify if conditions 2017-08-16 17:43:33 -06:00
Ivan Kozlovic
30eeac27e9 add matchLiteral benchmark 2017-08-16 16:28:24 -06:00
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
20926a6176 Added megacheck
This tool combines staticcheck, gosimple and unused.
Fixed reports from unused.
2017-08-11 17:28:18 -06:00
ingosus
5145723164 Fix subscriptions zombie at autounsubscribe on cluster 2017-07-21 12:42:41 +03:00
Ivan Kozlovic
102b9ed3d4 Release 1.0.2
Essentially patch for Windows Docker Images.
2017-07-19 13:21:27 -06:00
Ivan Kozlovic
9ff62e21a9 Fix typos 2017-07-19 11:59:05 -06:00
Ivan Kozlovic
1fa136b21a Improved Config Reload test coverage
- Move the kill of a server in a cluster test to ensure that
  list of routes to remove is not empty.
- Change write_deadline reload value to 3s to make it different
  from default value
- Add test for option that does not support hot-swapping
2017-07-19 11:59:05 -06:00
Ivan Kozlovic
c1e295957d Merge pull request #547 from nats-io/fix_duplicate_route_handling
[FIXED] Handling of duplicate routes
2017-07-19 11:58:10 -06:00
Ivan Kozlovic
2befd973cc Fixed DATA RACE and ensure route is not created/accepted on shutdown
- Created a setter for the closed flag.
- Check if route is closed under lock and set a boolean if so,
  so we don't check c.route outside of c's mutex.
- Ensure that we do not create a route on shutdown, which would
  leave a connection hanging (was seen in some config reload tests).
2017-07-19 10:42:18 -06:00
Ivan Kozlovic
69891d37ac Fix import ordering 2017-07-19 09:02:25 -06:00
Ivan Kozlovic
9cddf0fcdf [FIXED] Windows Docker Image
The use of the `svc` API prevented the NATS Server to run as
a container on both nanoserver and windowsservercore Docker images.
An attempt was made to replace svc.Debug with normal server.Start()
if detected to be interactive, however, that did not work. The
fact of detecting if interactive or not already requires connecting
to the service controller apparently.
This change looks up for an environment variable (NATS_DOCKERIZED)
and if set to "1", will not make use of the `svc` package.
This environment variable will be set in the Docker image (in
nats-docker/windows/nanoserver/Dockerfile and windowsservercore/Dockerfile).

Resolves #543
2017-07-18 19:00:17 -06:00
Ivan Kozlovic
0e2882d741 [FIXED] Handling of duplicate routes
When A connects to B and B connects to A (either based on static
configuration - explicit routes, or because of auto-discovery -
implicit routes), it is possible that each server initially
registers the route from the opposite TCP connection. It will
then result in each server dropping the connection.

We were previously setting a retry flag in the first accepted route
based on the name of servers, which means that regardless of
duplicate detection, the server with the "smaller" server name would
try to reconnect when the route connection was closed. For instance,
suppose that server B connects to server A, when B disconnects, A
would try to reconnect once to B. This became problematic in the
case of configuration reload, because removing the route from B to
A would still result in a route created from A to B.

Also, when a route attempts a reconnect, a random delay is added
to avoid repeated failure cycles that may occur in case where
A connects to B and B to A.
2017-07-18 18:25:56 -06:00
Ivan Kozlovic
009362dd65 Prepare for next release 2017-07-12 09:57:32 -06:00
Ivan Kozlovic
56649b3273 [FIXED] Possible data race in routez when route disconnects (#540)
* [FIXED] Possible data race in routez when route disconnects

Resolves #539
2017-07-11 16:11:22 -06:00
Ivan Kozlovic
edc1d74c0c Use loopback for some config reload tests 2017-07-11 11:38:32 -06:00
Ivan Kozlovic
6755617914 Bumped timeout for checkClusterFormed and use stackFatalf() 2017-07-11 10:19:34 -06:00
Tyler Treat
136355f28e Merge branch 'master' of github.com:nats-io/gnatsd into fix_symlink_garbage 2017-07-11 10:39:43 -05:00
Tyler Treat
10c70cb570 Handle symlinks better
It's hard to implement a bulletproof solution for cleaning up the
symlinks created by config reload tests on failure since, for example,
there is nothing we can do when log.Fatal is called. Instead, prevent
the existence of a symlink from failing the tests if there is one
hanging around. Generally, these symlinks will not be left unless
os.Exit was called (as is the case with log.Fatal).
2017-07-11 10:35:29 -05:00
Ivan Kozlovic
28d4420a2c Fixed some config reload cluster tests
Use checkClusterFormed() to minimize risk of test failures due
to the subscription not being registered through the cluster.
2017-07-11 09:06:00 -06:00
Tyler Treat
dea34307f1 Merge branch 'master' of github.com:nats-io/gnatsd into fix_comment 2017-07-10 19:00:49 -05:00
Ivan Kozlovic
cae6b0b23a Some fixes
Use include so that we can have logfile and remote sys log tested
on platforms other than Windows.
Added some missing defer server.Shutdown() statements.
2017-07-10 16:33:19 -06:00
Tyler Treat
317a04f106 Fix error in test comment
The test is ensuring config reload fails when trying to change cluster
host.
2017-07-10 12:32:12 -05:00
Tyler Treat
ca1b3485cb Fix "error opening file" errors in tests for Windows
This sort of just punts on the problem by not creating log files in the
tests, but it seemed like the simplest solution.
2017-07-10 12:21:01 -05: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
2ed9c64f66 Merge branch 'master' of github.com:nats-io/gnatsd into enable_config_reload 2017-06-28 14:42:11 -05:00
Tyler Treat
54e23a3989 Enable syslog when running as Windows service
This writes logs to the Windows event log.
2017-06-28 14:16:26 -05:00