-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
session_info.go
46 lines (42 loc) · 1009 Bytes
/
session_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package configurations
import (
"context"
"fmt"
"net"
"strings"
"time"
)
type DialerContext interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
type SessionInfo struct {
SSLVersion string
Timeout time.Duration
EnableOOB bool
UnixAddress string
TransportDataUnitSize uint32
SessionDataUnitSize uint32
Protocol string
SSL bool
SSLVerify bool
Dialer DialerContext
}
func (si *SessionInfo) UpdateSSL(server *ServerAddr) error {
if server != nil {
if strings.ToLower(server.Protocol) == "tcps" {
si.SSL = true
return nil
} else if strings.ToLower(server.Protocol) == "tcp" {
si.SSL = false
return nil
}
}
if strings.ToLower(si.Protocol) == "tcp" {
si.SSL = false
} else if strings.ToLower(si.Protocol) == "tcps" {
si.SSL = true
} else {
return fmt.Errorf("unknown or missing protocol: %s", si.Protocol)
}
return nil
}