forked from quic-go/quic-go
add an Addr method to the Server
This commit is contained in:
@@ -127,6 +127,11 @@ func (s *Server) Close() error {
|
||||
return conn.Close()
|
||||
}
|
||||
|
||||
// Addr returns the server's network address
|
||||
func (s *Server) Addr() net.Addr {
|
||||
return s.addr
|
||||
}
|
||||
|
||||
func (s *Server) handlePacket(conn *net.UDPConn, remoteAddr *net.UDPAddr, packet []byte) error {
|
||||
if protocol.ByteCount(len(packet)) > protocol.MaxPacketSize {
|
||||
return qerr.PacketTooLarge
|
||||
|
||||
@@ -61,6 +61,14 @@ var _ = Describe("Server", func() {
|
||||
firstPacket = append(append(firstPacket, b.Bytes()...), 0x01)
|
||||
})
|
||||
|
||||
It("returns the address", func() {
|
||||
server.addr = &net.UDPAddr{
|
||||
IP: net.IPv4(192, 168, 13, 37),
|
||||
Port: 1234,
|
||||
}
|
||||
Expect(server.Addr().String()).To(Equal("192.168.13.37:1234"))
|
||||
})
|
||||
|
||||
It("composes version negotiation packets", func() {
|
||||
expected := append(
|
||||
[]byte{0x01 | 0x08, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||
|
||||
Reference in New Issue
Block a user