|
@@ -1,26 +1,17 @@
|
|
|
-package main
|
|
|
|
|
|
|
+package coredhcp
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"errors"
|
|
"errors"
|
|
|
"log"
|
|
"log"
|
|
|
"net"
|
|
"net"
|
|
|
- "time"
|
|
|
|
|
|
|
|
|
|
"github.com/coredhcp/coredhcp/config"
|
|
"github.com/coredhcp/coredhcp/config"
|
|
|
"github.com/coredhcp/coredhcp/handler"
|
|
"github.com/coredhcp/coredhcp/handler"
|
|
|
"github.com/coredhcp/coredhcp/plugins"
|
|
"github.com/coredhcp/coredhcp/plugins"
|
|
|
- _ "github.com/coredhcp/coredhcp/plugins/file"
|
|
|
|
|
- _ "github.com/coredhcp/coredhcp/plugins/server_id"
|
|
|
|
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
|
|
"github.com/insomniacslk/dhcp/dhcpv6"
|
|
"github.com/insomniacslk/dhcp/dhcpv6"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-// Application variables
|
|
|
|
|
-var (
|
|
|
|
|
- AppName = "CoreDHCP"
|
|
|
|
|
- AppVersion = "v0.1"
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
// Server is a CoreDHCP server structure that holds information about
|
|
// Server is a CoreDHCP server structure that holds information about
|
|
|
// DHCPv6 and DHCPv4 servers, and their respective handlers.
|
|
// DHCPv6 and DHCPv4 servers, and their respective handlers.
|
|
|
type Server struct {
|
|
type Server struct {
|
|
@@ -143,18 +134,3 @@ func (s *Server) Wait() error {
|
|
|
func NewServer(config *config.Config) *Server {
|
|
func NewServer(config *config.Config) *Server {
|
|
|
return &Server{Config: config, errors: make(chan error, 1)}
|
|
return &Server{Config: config, errors: make(chan error, 1)}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-func main() {
|
|
|
|
|
- config, err := config.Parse()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- log.Fatal(err)
|
|
|
|
|
- }
|
|
|
|
|
- server := NewServer(config)
|
|
|
|
|
- if err := server.Start(); err != nil {
|
|
|
|
|
- log.Fatal(err)
|
|
|
|
|
- }
|
|
|
|
|
- if err := server.Wait(); err != nil {
|
|
|
|
|
- log.Print(err)
|
|
|
|
|
- }
|
|
|
|
|
- time.Sleep(time.Second)
|
|
|
|
|
-}
|
|
|