Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftr: add TLS support #685

Merged
merged 25 commits into from
Aug 14, 2020
Prev Previous commit
Next Next commit
fix
  • Loading branch information
aliiohs committed Aug 10, 2020
commit 07bf1c4cd5274d909ba64ada7718145ba3bb77a7
19 changes: 18 additions & 1 deletion protocol/dubbo/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package dubbo

import (
"crypto/tls"
"fmt"
"math/rand"
"net"
Expand Down Expand Up @@ -116,7 +117,23 @@ func (c *gettyRPCClient) newSession(session getty.Session) error {
if conf.GettySessionParam.CompressEncoding {
session.SetCompressType(getty.CompressZip)
}

if c.pool.sslEnabled {
if _, ok = session.Conn().(*tls.Conn); !ok {
panic(fmt.Sprintf("%s, session.conn{%#v} is not tls connection\n", session.Stat(), session.Conn()))
}
session.SetName(conf.GettySessionParam.SessionName)
session.SetMaxMsgLen(conf.GettySessionParam.MaxMsgLen)
session.SetPkgHandler(NewRpcClientPackageHandler(c.pool.rpcClient))
session.SetEventListener(NewRpcClientHandler(c))
session.SetWQLen(conf.GettySessionParam.PkgWQSize)
session.SetReadTimeout(conf.GettySessionParam.tcpReadTimeout)
session.SetWriteTimeout(conf.GettySessionParam.tcpWriteTimeout)
session.SetCronPeriod((int)(conf.heartbeatPeriod.Nanoseconds() / 1e6))
session.SetWaitTime(conf.GettySessionParam.waitTimeout)
logger.Debugf("client new session:%s\n", session.Stat())
session.SetTaskPool(clientGrpool)
return nil
}
if tcpConn, ok = session.Conn().(*net.TCPConn); !ok {
panic(fmt.Sprintf("%s, session.conn{%#v} is not tcp connection\n", session.Stat(), session.Conn()))
}
Expand Down
16 changes: 15 additions & 1 deletion protocol/dubbo/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package dubbo

import (
"crypto/tls"
"fmt"
"net"
)
Expand Down Expand Up @@ -127,7 +128,20 @@ func (s *Server) newSession(session getty.Session) error {
if conf.GettySessionParam.CompressEncoding {
session.SetCompressType(getty.CompressZip)
}

if _, ok = session.Conn().(*tls.Conn); ok {
session.SetName(conf.GettySessionParam.SessionName)
session.SetMaxMsgLen(conf.GettySessionParam.MaxMsgLen)
session.SetPkgHandler(rpcServerPkgHandler)
session.SetEventListener(s.rpcHandler)
session.SetWQLen(conf.GettySessionParam.PkgWQSize)
session.SetReadTimeout(conf.GettySessionParam.tcpReadTimeout)
session.SetWriteTimeout(conf.GettySessionParam.tcpWriteTimeout)
session.SetCronPeriod((int)(conf.sessionTimeout.Nanoseconds() / 1e6))
session.SetWaitTime(conf.GettySessionParam.waitTimeout)
logger.Debugf("app accepts new session:%s\n", session.Stat())
session.SetTaskPool(srvGrpool)
return nil
}
if tcpConn, ok = session.Conn().(*net.TCPConn); !ok {
panic(fmt.Sprintf("%s, session.conn{%#v} is not tcp connection\n", session.Stat(), session.Conn()))
}
Expand Down