Skip to content

Commit

Permalink
feat: export set channel buffer size (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
niltonkummer authored Mar 30, 2020
1 parent f64d9a0 commit 6f9fc1a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Server struct {
connections []net.PacketConn
wait sync.WaitGroup
doneTcp chan bool
datagramChannelSize int
datagramChannel chan DatagramMessage
format format.Format
handler Handler
Expand All @@ -48,7 +49,10 @@ func NewServer() *Server {
New: func() interface{} {
return make([]byte, 65536)
},
}}
},

datagramChannelSize: datagramChannelBufferSize,
}
}

//Sets the syslog format (RFC3164 or RFC5424 or RFC6587)
Expand All @@ -71,6 +75,10 @@ func (s *Server) SetTlsPeerNameFunc(tlsPeerNameFunc TlsPeerNameFunc) {
s.tlsPeerNameFunc = tlsPeerNameFunc
}

func (s *Server) SetDatagramChannelSize(size int) {
s.datagramChannelSize = size
}

// Default TLS peer name function - returns the CN of the certificate
func defaultTlsPeerName(tlsConn *tls.Conn) (tlsPeer string, ok bool) {
state := tlsConn.ConnectionState()
Expand Down Expand Up @@ -353,7 +361,7 @@ func (s *Server) goReceiveDatagrams(packetconn net.PacketConn) {
}

func (s *Server) goParseDatagrams() {
s.datagramChannel = make(chan DatagramMessage, datagramChannelBufferSize)
s.datagramChannel = make(chan DatagramMessage, s.datagramChannelSize)

s.wait.Add(1)
go func() {
Expand Down

0 comments on commit 6f9fc1a

Please sign in to comment.