mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-13 18:31:18 +01:00
logger and first client
This commit is contained in:
parent
6743054451
commit
8653c32367
@ -61,27 +61,24 @@ type Client struct {
|
||||
ctxCancelLock *sync.Mutex
|
||||
deviceName string
|
||||
routeListener routemanager.RouteListener
|
||||
logger CustomLogger
|
||||
onHostDnsFn func([]string)
|
||||
}
|
||||
|
||||
// NewClient instantiate a new Client
|
||||
func NewClient(cfgFile, deviceName string, iFaceDiscover IFaceDiscover, routeListener RouteListener, logger CustomLogger) *Client {
|
||||
func NewClient(cfgFile, deviceName string, iFaceDiscover IFaceDiscover, routeListener RouteListener) *Client {
|
||||
return &Client{
|
||||
cfgFile: cfgFile,
|
||||
deviceName: deviceName,
|
||||
iFaceDiscover: iFaceDiscover,
|
||||
recorder: peer.NewRecorder(""),
|
||||
ctxCancelLock: &sync.Mutex{},
|
||||
logger: logger,
|
||||
routeListener: routeListener,
|
||||
}
|
||||
}
|
||||
|
||||
// Run start the internal client. It is a blocker function
|
||||
// func (c *Client) Run(fd int32, dns *DNSList, dnsReadyListener DnsReadyListener) error {
|
||||
func (c *Client) Run(fd int32, dns *DNSList, dnsReadyListener DnsReadyListener) error {
|
||||
c.logger.Info("Starting NetBird client")
|
||||
log.Infof("Starting NetBird client")
|
||||
cfg, err := internal.UpdateOrCreateConfig(internal.ConfigInput{
|
||||
ConfigPath: c.cfgFile,
|
||||
})
|
||||
@ -100,12 +97,12 @@ func (c *Client) Run(fd int32, dns *DNSList, dnsReadyListener DnsReadyListener)
|
||||
|
||||
auth := NewAuthWithConfig(ctx, cfg)
|
||||
// err = auth.login(urlOpener)
|
||||
auth.loginWithSetupKeyAndSaveConfig("E9EEBA50-76A1-4C72-A939-C10655C1CC09", "iPhone")
|
||||
auth.loginWithSetupKeyAndSaveConfig("C3803F45-435B-4333-96EB-50F9EC723355", "iPhone")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.logger.Info("Auth successful")
|
||||
log.Infof("Auth successful")
|
||||
// todo do not throw error in case of cancelled context
|
||||
ctx = internal.CtxInitState(ctx)
|
||||
c.onHostDnsFn = func([]string) {}
|
||||
|
31
client/ios/netbird/logger.go
Normal file
31
client/ios/netbird/logger.go
Normal file
@ -0,0 +1,31 @@
|
||||
package netbird
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/netbirdio/netbird/util"
|
||||
)
|
||||
|
||||
var logFile *os.File
|
||||
|
||||
// InitializeLog initializes the log file.
|
||||
func InitializeLog(logLevel string, filePath string) error {
|
||||
var err error
|
||||
err = util.InitLog(logLevel, filePath)
|
||||
return err
|
||||
}
|
||||
|
||||
// // CloseLog closes the log file.
|
||||
// func CloseLog() {
|
||||
// if logFile != nil {
|
||||
// logFile.Close()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Log writes a message to the log file.
|
||||
// func Log(message string) {
|
||||
// if logFile != nil {
|
||||
// ts := time.Now().Format(time.RFC3339)
|
||||
// fmt.Fprintf(logFile, "%s: %s\n", ts, message)
|
||||
// }
|
||||
// }
|
Loading…
Reference in New Issue
Block a user