23 lines
506 B
Go
23 lines
506 B
Go
package networking
|
|
|
|
import (
|
|
"crypto/tls"
|
|
)
|
|
|
|
|
|
type ClientTLSConfigProvider interface {
|
|
GetClientTLSConfig() *tls.Config
|
|
}
|
|
|
|
type Client[T any] struct {
|
|
Connection Connection[T]
|
|
}
|
|
|
|
func NewClient[T any](clientTLSConfigProvider ClientTLSConfigProvider) (Client[T],error) {
|
|
dialConn, err := tls.Dial("tcp", "localhost:8080", clientTLSConfigProvider.GetClientTLSConfig())
|
|
if err != nil {
|
|
return Client[T]{},err
|
|
}
|
|
conn := NewConnection[T](dialConn)
|
|
return Client[T]{Connection: conn},nil
|
|
}
|