mirror of
https://github.com/wneessen/logranger.git
synced 2024-10-06 00:55:57 +02:00
Winni Neessen
43b1147106
Introduced a new Connection struct and related functions in `connection.go` to facilitate network connections. Incorporated the `go-parsesyslog` package to parse incoming network data. Implemented functions in `server.go` to accept and handle incoming network connections, bolstering the application's network interaction functionality.
27 lines
630 B
Go
27 lines
630 B
Go
package logranger
|
|
|
|
import (
|
|
"bufio"
|
|
"net"
|
|
)
|
|
|
|
// Connection represents a connection to a network resource.
|
|
type Connection struct {
|
|
conn net.Conn
|
|
id string
|
|
rb *bufio.Reader
|
|
wb *bufio.Writer
|
|
}
|
|
|
|
// NewConnection creates a new Connection object with the provided net.Conn.
|
|
// The Connection object holds a reference to the provided net.Conn, along with an ID string,
|
|
// bufio.Reader, and bufio.Writer. It returns a pointer to the created Connection object.
|
|
func NewConnection(nc net.Conn) *Connection {
|
|
c := &Connection{
|
|
conn: nc,
|
|
id: "foo",
|
|
rb: bufio.NewReader(nc),
|
|
wb: bufio.NewWriter(nc),
|
|
}
|
|
return c
|
|
}
|