Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wei.xuan
getty
Commits
94d35a38
Commit
94d35a38
authored
Jul 27, 2020
by
aliiohs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tls support
parent
b89c0bb5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
5 deletions
+13
-5
client.go
client.go
+1
-1
go.mod
go.mod
+2
-2
options.go
options.go
+9
-0
server.go
server.go
+1
-2
No files found.
client.go
View file @
94d35a38
...
...
@@ -153,7 +153,7 @@ func (c *client) dialTCP() Session {
if
c
.
IsClosed
()
{
return
nil
}
if
c
.
sslConfig
!=
nil
{
if
c
.
ssl
Enabled
&&
c
.
ssl
Config
!=
nil
{
d
:=
&
net
.
Dialer
{
Timeout
:
connectTimeout
}
conn
,
err
=
tls
.
DialWithDialer
(
d
,
"tcp"
,
c
.
addr
,
c
.
sslConfig
)
}
else
{
...
...
go.mod
View file @
94d35a38
module github.com/dubbogo/getty
go 1.14
require (
github.com/dubbogo/gost v1.9.0
github.com/golang/snappy v0.0.1
...
...
@@ -8,5 +10,3 @@ require (
github.com/stretchr/testify v1.5.1
go.uber.org/zap v1.15.0
)
go 1.13
options.go
View file @
94d35a38
...
...
@@ -17,6 +17,8 @@
package
getty
import
"crypto/tls"
/////////////////////////////////////////
// Server Options
/////////////////////////////////////////
...
...
@@ -25,6 +27,9 @@ type ServerOption func(*ServerOptions)
type
ServerOptions
struct
{
addr
string
//tls
sslEnabled
bool
sslConfig
*
tls
.
Config
// websocket
path
string
...
...
@@ -79,6 +84,10 @@ type ClientOptions struct {
number
int
reconnectInterval
int
// reConnect Interval
//tls
sslEnabled
bool
sslConfig
*
tls
.
Config
// the cert file of wss server which may contain server domain, server ip, the starting effective date, effective
// duration, the hash alg, the len of the private key.
// wss client will use it.
...
...
server.go
View file @
94d35a38
...
...
@@ -56,7 +56,6 @@ type server struct {
lock
sync
.
Mutex
// for server
endPointType
EndPointType
server
*
http
.
Server
// for ws or wss server
sslConfig
*
tls
.
Config
sync
.
Once
done
chan
struct
{}
wg
sync
.
WaitGroup
...
...
@@ -175,7 +174,7 @@ func (s *server) listenTCP() error {
return
perrors
.
Wrapf
(
err
,
"gxnet.ListenOnTCPRandomPort(addr:%s)"
,
s
.
addr
)
}
}
else
{
if
s
.
sslConfig
!=
nil
{
if
s
.
ssl
Enabled
&&
s
.
ssl
Config
!=
nil
{
streamListener
,
err
=
tls
.
Listen
(
"tcp"
,
s
.
addr
,
s
.
sslConfig
)
}
else
{
streamListener
,
err
=
net
.
Listen
(
"tcp"
,
s
.
addr
)
...
...
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