Skip to content

Commit 90ad1e2

Browse files
authored
Merge pull request #826 from gotd/feat-tgtest-allow-private-key
feat(tgtest): export NewPrivateKey
2 parents a375981 + 97f30b8 commit 90ad1e2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tgtest/server.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tgtest
22

33
import (
44
"context"
5+
"crypto/rsa"
56
"io"
67
"net"
78
"time"
@@ -49,6 +50,13 @@ type Server struct {
4950
log *zap.Logger // immutable
5051
}
5152

53+
// NewPrivateKey creates new private key from RSA private key.
54+
func NewPrivateKey(k *rsa.PrivateKey) exchange.PrivateKey {
55+
return exchange.PrivateKey{
56+
RSA: k,
57+
}
58+
}
59+
5260
// NewServer creates new Server.
5361
func NewServer(key exchange.PrivateKey, handler Handler, opts ServerOptions) *Server {
5462
opts.setDefaults()

transport/protocol.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func (p Protocol) Codec() Codec {
5454
return p.codec()
5555
}
5656

57+
// CodecNoHeader is Codec without header.
58+
func (p Protocol) CodecNoHeader() Codec {
59+
return codec.NoHeader{Codec: p.codec()}
60+
}
61+
5762
// Handshake inits given net.Conn as MTProto connection.
5863
func (p Protocol) Handshake(conn net.Conn) (Conn, error) {
5964
connCodec := p.codec()

0 commit comments

Comments
 (0)