Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
0bf16924
Commit
0bf16924
authored
Apr 04, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default port: 6379 normally, 6380 over ssl
parent
d0880697
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
22 deletions
+113
-22
DefaultPorts.cs
StackExchange.Redis.Tests/DefaultPorts.cs
+58
-0
Lists.cs
StackExchange.Redis.Tests/Lists.cs
+1
-5
SSL.cs
StackExchange.Redis.Tests/SSL.cs
+6
-6
StackExchange.Redis.Tests.csproj
StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
+1
-0
ConfigurationOptions.cs
...xchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
+8
-0
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+1
-0
EndPointCollection.cs
...kExchange.Redis/StackExchange/Redis/EndPointCollection.cs
+26
-1
Format.cs
StackExchange.Redis/StackExchange/Redis/Format.cs
+11
-9
ServerEndPoint.cs
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
+1
-1
No files found.
StackExchange.Redis.Tests/DefaultPorts.cs
0 → 100644
View file @
0bf16924
using
NUnit.Framework
;
using
System.Linq
;
using
System.Net
;
namespace
StackExchange.Redis.Tests
{
[
TestFixture
]
public
class
DefaultPorts
{
[
Test
]
[
TestCase
(
"foo"
,
6379
)]
[
TestCase
(
"foo:6379"
,
6379
)]
[
TestCase
(
"foo:6380"
,
6380
)]
[
TestCase
(
"foo,ssl=false"
,
6379
)]
[
TestCase
(
"foo:6379,ssl=false"
,
6379
)]
[
TestCase
(
"foo:6380,ssl=false"
,
6380
)]
[
TestCase
(
"foo,ssl=true"
,
6380
)]
[
TestCase
(
"foo:6379,ssl=true"
,
6379
)]
[
TestCase
(
"foo:6380,ssl=true"
,
6380
)]
[
TestCase
(
"foo:6381,ssl=true"
,
6381
)]
public
void
ConfigStringRoundTripWithDefaultPorts
(
string
config
,
int
expectedPort
)
{
var
options
=
ConfigurationOptions
.
Parse
(
config
);
string
backAgain
=
config
.
ToString
();
Assert
.
AreEqual
(
config
,
backAgain
);
options
.
SetDefaultPorts
();
// normally it is the multiplexer that calls this, not us
Assert
.
AreEqual
(
expectedPort
,
((
DnsEndPoint
)
options
.
EndPoints
.
Single
()).
Port
);
}
[
Test
]
[
TestCase
(
"foo"
,
0
,
false
,
6379
)]
[
TestCase
(
"foo"
,
6379
,
false
,
6379
)]
[
TestCase
(
"foo"
,
6380
,
false
,
6380
)]
[
TestCase
(
"foo"
,
0
,
true
,
6380
)]
[
TestCase
(
"foo"
,
6379
,
true
,
6379
)]
[
TestCase
(
"foo"
,
6380
,
true
,
6380
)]
[
TestCase
(
"foo"
,
6381
,
true
,
6381
)]
public
void
ConfigManualWithDefaultPorts
(
string
host
,
int
port
,
bool
useSsl
,
int
expectedPort
)
{
var
options
=
new
ConfigurationOptions
();
if
(
port
==
0
)
{
options
.
EndPoints
.
Add
(
host
);
}
else
{
options
.
EndPoints
.
Add
(
host
,
port
);
}
if
(
useSsl
)
options
.
UseSsl
=
true
;
options
.
SetDefaultPorts
();
// normally it is the multiplexer that calls this, not us
Assert
.
AreEqual
(
expectedPort
,
((
DnsEndPoint
)
options
.
EndPoints
.
Single
()).
Port
);
}
}
}
StackExchange.Redis.Tests/Lists.cs
View file @
0bf16924
using
System
;
using
System.Collections.Generic
;
using
NUnit.Framework
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
NUnit.Framework
;
namespace
StackExchange.Redis.Tests
{
...
...
StackExchange.Redis.Tests/SSL.cs
View file @
0bf16924
...
...
@@ -12,10 +12,10 @@ namespace StackExchange.Redis.Tests
public
class
SSL
:
TestBase
{
[
Test
]
[
TestCase
(
6379
,
false
,
false
)]
[
TestCase
(
6380
,
true
,
false
)]
[
TestCase
(
6380
,
true
,
true
)]
public
void
ConnectToSSLServer
(
int
port
,
bool
useSsl
,
bool
specifyHost
)
[
TestCase
(
false
,
false
)]
[
TestCase
(
true
,
false
)]
[
TestCase
(
true
,
true
)]
public
void
ConnectToSSLServer
(
bool
useSsl
,
bool
specifyHost
)
{
string
host
=
null
;
...
...
@@ -32,7 +32,7 @@ public void ConnectToSSLServer(int port, bool useSsl, bool specifyHost)
{
"cluster"
,
null
}
}
),
EndPoints
=
{
{
host
,
port
}
},
EndPoints
=
{
{
host
}
},
AllowAdmin
=
true
,
SyncTimeout
=
Debugger
.
IsAttached
?
int
.
MaxValue
:
5000
};
...
...
@@ -66,7 +66,7 @@ public void ConnectToSSLServer(int port, bool useSsl, bool specifyHost)
muxer
.
InternalError
+=
OnInternalError
;
var
db
=
muxer
.
GetDatabase
();
db
.
Ping
();
using
(
var
file
=
File
.
Create
(
"ssl
"
+
por
t
+
".zip"
))
using
(
var
file
=
File
.
Create
(
"ssl
-"
+
useSsl
+
"-"
+
specifyHos
t
+
".zip"
))
{
muxer
.
ExportConfiguration
(
file
);
}
...
...
StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
View file @
0bf16924
...
...
@@ -67,6 +67,7 @@
<Compile
Include=
"Commands.cs"
/>
<Compile
Include=
"ConnectionShutdown.cs"
/>
<Compile
Include=
"Databases.cs"
/>
<Compile
Include=
"DefaultPorts.cs"
/>
<Compile
Include=
"Expiry.cs"
/>
<Compile
Include=
"Config.cs"
/>
<Compile
Include=
"FloatingPoint.cs"
/>
...
...
StackExchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
View file @
0bf16924
...
...
@@ -231,6 +231,14 @@ public ConfigurationOptions Clone()
}
/// <summary>
/// Resolve the default port for any endpoints that did not have a port explicitly specified
/// </summary>
public
void
SetDefaultPorts
()
{
endpoints
.
SetDefaultPorts
(
UseSsl
?
6380
:
6379
);
}
/// <summary>
/// Returns the effective configuration string for this configuration
/// </summary>
...
...
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
0bf16924
...
...
@@ -695,6 +695,7 @@ static ConnectionMultiplexer CreateMultiplexer(object configuration)
throw
new
ArgumentException
(
"configuration"
);
}
if
(
config
.
EndPoints
.
Count
==
0
)
throw
new
ArgumentException
(
"No endpoints specified"
,
"configuration"
);
config
.
SetDefaultPorts
();
return
new
ConnectionMultiplexer
(
config
);
}
/// <summary>
...
...
StackExchange.Redis/StackExchange/Redis/EndPointCollection.cs
View file @
0bf16924
...
...
@@ -71,6 +71,31 @@ protected override void SetItem(int index, EndPoint item)
if
(
existingIndex
>=
0
&&
existingIndex
!=
index
)
throw
new
ArgumentException
(
"EndPoints must be unique"
,
"item"
);
base
.
SetItem
(
index
,
item
);
}
}
internal
void
SetDefaultPorts
(
int
defaultPort
)
{
for
(
int
i
=
0
;
i
<
Count
;
i
++)
{
var
endpoint
=
this
[
i
];
var
dns
=
endpoint
as
DnsEndPoint
;
if
(
dns
!=
null
)
{
if
(
dns
.
Port
==
0
)
{
this
[
i
]
=
new
DnsEndPoint
(
dns
.
Host
,
defaultPort
,
dns
.
AddressFamily
);
continue
;
}
}
var
ip
=
endpoint
as
IPEndPoint
;
if
(
ip
!=
null
)
{
if
(
ip
.
Port
==
0
)
{
this
[
i
]
=
new
IPEndPoint
(
ip
.
Address
,
defaultPort
);
continue
;
}
}
}
}
}
}
StackExchange.Redis/StackExchange/Redis/Format.cs
View file @
0bf16924
...
...
@@ -67,17 +67,19 @@ internal static string ToString(object value)
internal
static
string
ToString
(
EndPoint
endpoint
)
{
if
(
endpoint
==
null
)
return
""
;
var
dns
=
endpoint
as
DnsEndPoint
;
if
(
dns
=
=
null
)
if
(
dns
!
=
null
)
{
return
endpoint
.
ToString
();
}
else
{
// DnsEndPoint includes the family-type in
// ToString(), but we don't want that
if
(
dns
.
Port
==
0
)
return
dns
.
Host
;
return
dns
.
Host
+
":"
+
Format
.
ToString
(
dns
.
Port
);
}
var
ip
=
endpoint
as
IPEndPoint
;
if
(
ip
!=
null
)
{
if
(
ip
.
Port
==
0
)
return
ip
.
Address
.
ToString
();
return
ip
.
Address
.
ToString
()
+
":"
+
Format
.
ToString
(
ip
.
Port
);
}
return
endpoint
==
null
?
""
:
endpoint
.
ToString
();
}
internal
static
string
ToStringHostOnly
(
EndPoint
endpoint
)
{
...
...
@@ -152,7 +154,7 @@ internal static EndPoint TryParseEndPoint(string endpoint)
if
(
i
<
0
)
{
host
=
endpoint
;
port
=
6379
;
port
=
0
;
}
else
{
...
...
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
View file @
0bf16924
...
...
@@ -55,7 +55,7 @@ public ServerEndPoint(ConnectionMultiplexer multiplexer, EndPoint endpoint)
slaveReadOnly
=
true
;
isSlave
=
false
;
databases
=
0
;
writeEverySeconds
=
config
.
KeepAlive
;
writeEverySeconds
=
config
.
KeepAlive
>
0
?
config
.
KeepAlive
:
60
;
interactive
=
CreateBridge
(
ConnectionType
.
Interactive
);
serverType
=
ServerType
.
Standalone
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment