Skip to content

Commit

Permalink
Merge pull request #127 from telekom-mms/feature/add-combined-daemon-…
Browse files Browse the repository at this point in the history
…config

Add combined Daemon configuration
  • Loading branch information
hwipl authored Dec 16, 2024
2 parents 9045012 + 027f412 commit f7afed8
Show file tree
Hide file tree
Showing 45 changed files with 2,307 additions and 1,721 deletions.
63 changes: 0 additions & 63 deletions internal/api/config.go

This file was deleted.

40 changes: 0 additions & 40 deletions internal/api/config_test.go

This file was deleted.

5 changes: 3 additions & 2 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

log "github.com/sirupsen/logrus"
"github.com/telekom-mms/oc-daemon/internal/daemoncfg"
)

const (
Expand All @@ -20,7 +21,7 @@ const (

// Server is a Daemon API server.
type Server struct {
config *Config
config *daemoncfg.SocketServer
listen net.Listener
requests chan *Request
shutdown chan struct{}
Expand Down Expand Up @@ -239,7 +240,7 @@ func (s *Server) Requests() chan *Request {
}

// NewServer returns a new API server.
func NewServer(config *Config) *Server {
func NewServer(config *daemoncfg.SocketServer) *Server {
return &Server{
config: config,
requests: make(chan *Request),
Expand Down
16 changes: 9 additions & 7 deletions internal/api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"net"
"reflect"
"testing"

"github.com/telekom-mms/oc-daemon/internal/daemoncfg"
)

// TestServerHandleRequest tests handleRequest of Server.
func TestServerHandleRequest(t *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
server := NewServer(config)

// connection closed
Expand Down Expand Up @@ -77,7 +79,7 @@ func TestServerHandleRequest(t *testing.T) {

// TestServerSetSocketOwner tests setSocketOwner of Server.
func TestServerSetSocketOwner(_ *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
server := NewServer(config)

// no changes
Expand All @@ -95,7 +97,7 @@ func TestServerSetSocketOwner(_ *testing.T) {

// TestServerSetSocketGroup tests setSocketGroup of Server.
func TestServerSetSocketGroup(_ *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
server := NewServer(config)

// no changes
Expand All @@ -113,7 +115,7 @@ func TestServerSetSocketGroup(_ *testing.T) {

// TestServerSetSocketPermissions tests setSocketPermissions of Server.
func TestServerSetSocketPermissions(_ *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
server := NewServer(config)

// socket file does not exist
Expand All @@ -131,7 +133,7 @@ func TestServerSetSocketPermissions(_ *testing.T) {

// TestServerStartStop tests Start and Stop of Server.
func TestServerStartStop(t *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
config.SocketFile = "test.sock"
server := NewServer(config)
if err := server.Start(); err != nil {
Expand All @@ -143,7 +145,7 @@ func TestServerStartStop(t *testing.T) {

// TestServerRequests tests Requests of Server.
func TestServerRequests(t *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
config.SocketFile = "test.sock"
server := NewServer(config)
if server.Requests() != server.requests {
Expand All @@ -153,7 +155,7 @@ func TestServerRequests(t *testing.T) {

// TestNewServer tests NewServer.
func TestNewServer(t *testing.T) {
config := NewConfig()
config := daemoncfg.NewSocketServer()
server := NewServer(config)

if server == nil ||
Expand Down
62 changes: 0 additions & 62 deletions internal/cpd/config.go

This file was deleted.

44 changes: 0 additions & 44 deletions internal/cpd/config_test.go

This file was deleted.

5 changes: 3 additions & 2 deletions internal/cpd/cpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

log "github.com/sirupsen/logrus"
"github.com/telekom-mms/oc-daemon/internal/daemoncfg"
)

// Report is a captive portal detection report.
Expand All @@ -17,7 +18,7 @@ type Report struct {

// CPD is a captive portal detection instance.
type CPD struct {
config *Config
config *daemoncfg.CPD
reports chan *Report
probes chan struct{}
done chan struct{}
Expand Down Expand Up @@ -211,7 +212,7 @@ func (c *CPD) Results() chan *Report {
}

// NewCPD returns a new CPD.
func NewCPD(config *Config) *CPD {
func NewCPD(config *daemoncfg.CPD) *CPD {
return &CPD{
config: config,
reports: make(chan *Report),
Expand Down
Loading

0 comments on commit f7afed8

Please sign in to comment.