@@ -3,18 +3,18 @@ package input
3
3
import (
4
4
"crypto/tls"
5
5
"net"
6
+ "path/filepath"
6
7
"sync"
7
8
"sync/atomic"
8
9
"time"
9
- "path/filepath"
10
10
11
- "github.com/sipcapture/heplify-server/config"
12
11
"github.com/negbie/cert"
13
12
"github.com/negbie/logp"
13
+ "github.com/sipcapture/heplify-server/config"
14
14
)
15
15
16
- func parseTLSVersion (versionText string ) uint16 {
17
- switch ( versionText ) {
16
+ func parseTLSVersion (versionText string ) uint16 {
17
+ switch versionText {
18
18
case "1.0" :
19
19
logp .Warn ("TLS1.0 is not recommended. Use 1.2 or greater where possible" )
20
20
return tls .VersionTLS10
@@ -50,7 +50,7 @@ func (h *HEPInput) serveTLS(addr string) {
50
50
cPath := config .Setting .TLSCertFolder
51
51
minTLSVersion := parseTLSVersion (config .Setting .TLSMinVersion )
52
52
// load any existing certs, otherwise generate a new one
53
- ca , err := cert .NewCertificateAuthority ( filepath .Join (cPath , "heplify-server" ) )
53
+ ca , err := cert .NewCertificateAuthority (filepath .Join (cPath , "heplify-server" ))
54
54
if err != nil {
55
55
logp .Err ("%v" , err )
56
56
return
@@ -88,30 +88,5 @@ func (h *HEPInput) serveTLS(addr string) {
88
88
}
89
89
90
90
func (h * HEPInput ) handleTLS (c net.Conn ) {
91
- defer func () {
92
- logp .Info ("closing TLS connection from %s" , c .RemoteAddr ())
93
- err := c .Close ()
94
- if err != nil {
95
- logp .Err ("%v" , err )
96
- }
97
- }()
98
-
99
- for {
100
- if atomic .LoadUint32 (& h .stopped ) == 1 {
101
- return
102
- }
103
-
104
- buf := h .buffer .Get ().([]byte )
105
- n , err := c .Read (buf )
106
- if err != nil {
107
- logp .Warn ("%v from %s" , err , c .RemoteAddr ())
108
- return
109
- } else if n > maxPktLen {
110
- logp .Warn ("received too big packet with %d bytes" , n )
111
- atomic .AddUint64 (& h .stats .ErrCount , 1 )
112
- continue
113
- }
114
- h .inputCh <- buf [:n ]
115
- atomic .AddUint64 (& h .stats .PktCount , 1 )
116
- }
91
+ h .handleStream (c , "TLS" )
117
92
}
0 commit comments