Moved function for Leasefile name generation to shared lib for web_client

This commit is contained in:
MaMe82 2018-08-06 16:37:58 +02:00
parent d6d8ce789f
commit 8b790c2bdc
6 changed files with 16 additions and 22 deletions

View File

@ -51,17 +51,17 @@ LOGGING:
Events:
- remove debug out
- proper unregister of event listeners from web app
- Done: proper unregister of event listeners from web app
OTHER:
- extend installer to movee HIDScripts to a fixed absolute path
- proper error extraction from gRPC calls
- Done: extend installer to move HIDScripts to a fixed absolute path
- Not possible (status isn't working here) proper error extraction from gRPC calls
- set date from Browser
TO FIX:
- remove dependencies of CLI client on service package
- debug out of HIDScript puts way to much CPU load on journaling daemon (floods logs)
- allow gRPC server to abort Running HID scripts on context.Done() -> possible, testing needed
- Done: allow gRPC server to abort Running HID scripts on context.Done() -> possible, testing needed
- jobs aren't deleted from global job list, unless result is fetched with waitResult. This affects interrupted
jobs (f.e. timeout) and jobs run as background job --> cancelled jobs need a way to communicate back to the controller,
that they could be deleted (Solution: goroutine listening for context.Done() per job in controller)

View File

@ -10,7 +10,7 @@ import (
//"github.com/mame82/P4wnP1_go/service"
"strings"
"strconv"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_go/common_web"
)
//Empty settings used to store cobra flags
@ -234,7 +234,7 @@ func createDHCPServerSettings(iface string, ip4 string, mask4 string, disabled b
Enabled: !disabled,
DhcpServerSettings: &pb.DHCPServerSettings{
ListenInterface:iface,
LeaseFile: common.NameLeaseFileDHCPSrv(iface),
LeaseFile: common_web.NameLeaseFileDHCPSrv(iface),
CallbackScript: "",
ListenPort: 0, //Disable DNS
DoNotBindInterface: false, //only listen on given interface

View File

@ -32,7 +32,7 @@ func ClientConnectServer(rpcHost string, rpcPort string) (
client = pb.NewP4WNP1Client(connection)
// Contact the server
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
ctx, cancel = context.WithTimeout(context.Background(), time.Second*3)
//defer cancel()
err = nil

View File

@ -1,11 +0,0 @@
package common
import "fmt"
// File holds functions used by CLI client and P4wnP1 systemd service. Not to cross import the whole CLI/service
// package, is preferred over placing these functions in a contextual logic place.
func NameLeaseFileDHCPSrv(nameIface string) (lf string) {
return fmt.Sprintf("/tmp/dnsmasq_%s.leases", nameIface)
}

5
common_web/net.go Normal file
View File

@ -0,0 +1,5 @@
package common_web
func NameLeaseFileDHCPSrv(nameIface string) (lf string) {
return "/tmp/dnsmasq_" + nameIface + ".leases"
}

View File

@ -11,7 +11,7 @@ import (
"strconv"
"syscall"
"strings"
"github.com/mame82/P4wnP1_go/common"
"github.com/mame82/P4wnP1_go/common_web"
)
/*
@ -30,7 +30,7 @@ func pidFileDHCPClient(nameIface string) string {
}
func leaseFileDHCPSrv(s *pb.DHCPServerSettings) (lf string) {
return common.NameLeaseFileDHCPSrv(s.ListenInterface) //default lease file
return common_web.NameLeaseFileDHCPSrv(s.ListenInterface) //default lease file
}
@ -214,7 +214,7 @@ func StopDHCPServer(nameIface string) (err error) {
os.Remove(pidFileDHCPSrv(nameIface))
//Deleting leaseFile
os.Remove(common.NameLeaseFileDHCPSrv(nameIface))
os.Remove(common_web.NameLeaseFileDHCPSrv(nameIface))
return nil
}