Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (

const (
datagramChannelBufferSize = 10
datagramReadBufferSize = 64 * 1024
defaultDatagramReadBufferSize = 64 * 1024
)

// A function type which gets the TLS peer name from the connection. Can return
Expand All @@ -41,6 +41,7 @@ type Server struct {
readTimeoutMilliseconds int64
tlsPeerNameFunc TlsPeerNameFunc
datagramPool sync.Pool
datagramReadBufferSize int
}

//NewServer returns a new Server
Expand All @@ -52,6 +53,7 @@ func NewServer() *Server {
},

datagramChannelSize: datagramChannelBufferSize,
datagramReadBufferSize: defaultDatagramReadBufferSize,
}
}

Expand All @@ -70,6 +72,11 @@ func (s *Server) SetTimeout(millseconds int64) {
s.readTimeoutMilliseconds = millseconds
}

//Sets datagram read buffer size
func (s *Server) SetDatagramReadBufferSize(size int) {
s.datagramReadBufferSize = size
}

// Set the function that extracts a TLS peer name from the TLS connection
func (s *Server) SetTlsPeerNameFunc(tlsPeerNameFunc TlsPeerNameFunc) {
s.tlsPeerNameFunc = tlsPeerNameFunc
Expand Down Expand Up @@ -100,7 +107,7 @@ func (s *Server) ListenUDP(addr string) error {
if err != nil {
return err
}
connection.SetReadBuffer(datagramReadBufferSize)
connection.SetReadBuffer(s.datagramReadBufferSize)

s.connections = append(s.connections, connection)
return nil
Expand All @@ -117,7 +124,7 @@ func (s *Server) ListenUnixgram(addr string) error {
if err != nil {
return err
}
connection.SetReadBuffer(datagramReadBufferSize)
connection.SetReadBuffer(s.datagramReadBufferSize)

s.connections = append(s.connections, connection)
return nil
Expand Down