-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go-tlsdialer: initial repository setup
To disable SSL by default we want to transfer OpenSslDialer and any other ssl logic to the new go-tlsdialer repository. go-tlsdialer serves as an interlayer between go-tarantool and go-openssl. All ssl logic from go-tarantool is moved to the go-tlsdialer. go-tlsdialer still uses tarantool connection, but also types and methods from go-openssl. This way we are removing the direct go-openssl dependency from go-tarantool, without creating a tarantool dependency in go-openssl. Moved all ssl code from go-tarantool, some test helpers. Part of tarantool/go-tarantool#301
- Loading branch information
Showing
24 changed files
with
1,929 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package tlsdialer | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"net" | ||
|
||
"github.com/tarantool/go-tarantool/v2" | ||
) | ||
|
||
type tntConn struct { | ||
net net.Conn | ||
reader io.Reader | ||
writer writeFlusher | ||
} | ||
|
||
// writeFlusher is the interface that groups the basic Write and Flush methods. | ||
type writeFlusher interface { | ||
io.Writer | ||
Flush() error | ||
} | ||
|
||
// Addr makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) Addr() net.Addr { | ||
return c.net.RemoteAddr() | ||
} | ||
|
||
// Read makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) Read(p []byte) (int, error) { | ||
return c.reader.Read(p) | ||
} | ||
|
||
// Write makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) Write(p []byte) (int, error) { | ||
if l, err := c.writer.Write(p); err != nil { | ||
return l, err | ||
} else if l != len(p) { | ||
return l, errors.New("wrong length written") | ||
} else { | ||
return l, nil | ||
} | ||
} | ||
|
||
// Flush makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) Flush() error { | ||
return c.writer.Flush() | ||
} | ||
|
||
// Close makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) Close() error { | ||
return c.net.Close() | ||
} | ||
|
||
// Greeting makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) Greeting() tarantool.Greeting { | ||
return tarantool.Greeting{} | ||
} | ||
|
||
// ProtocolInfo makes tntConn satisfy the Conn interface. | ||
func (c *tntConn) ProtocolInfo() tarantool.ProtocolInfo { | ||
return tarantool.ProtocolInfo{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package tlsdialer | ||
|
||
import ( | ||
"net" | ||
"time" | ||
) | ||
|
||
type deadlineIO struct { | ||
to time.Duration | ||
c net.Conn | ||
} | ||
|
||
func (d *deadlineIO) Write(b []byte) (n int, err error) { | ||
if d.to > 0 { | ||
if err := d.c.SetWriteDeadline(time.Now().Add(d.to)); err != nil { | ||
return 0, err | ||
} | ||
} | ||
n, err = d.c.Write(b) | ||
return | ||
} | ||
|
||
func (d *deadlineIO) Read(b []byte) (n int, err error) { | ||
if d.to > 0 { | ||
if err := d.c.SetReadDeadline(time.Now().Add(d.to)); err != nil { | ||
return 0, err | ||
} | ||
} | ||
n, err = d.c.Read(b) | ||
return | ||
} |
Oops, something went wrong.