mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-23 00:35:39 +00:00
Fixes logger, adds some log messages.
This commit is contained in:
parent
8afa737a8d
commit
6873fd44ff
@ -48,6 +48,7 @@ func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
|||||||
logger.EnableLevel("error")
|
logger.EnableLevel("error")
|
||||||
logger.EnableLevel("warn")
|
logger.EnableLevel("warn")
|
||||||
logger.EnableLevel("info")
|
logger.EnableLevel("info")
|
||||||
|
m.logger = logger
|
||||||
m.config = config.GenerateConfig()
|
m.config = config.GenerateConfig()
|
||||||
if err := m.config.UnmarshalHJSON(configjson); err != nil {
|
if err := m.config.UnmarshalHJSON(configjson); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -87,6 +88,7 @@ func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
|||||||
// Setup the multicast module.
|
// Setup the multicast module.
|
||||||
if len(m.config.MulticastInterfaces) > 0 {
|
if len(m.config.MulticastInterfaces) > 0 {
|
||||||
var err error
|
var err error
|
||||||
|
logger.Infof("Initializing multicast %s", "")
|
||||||
options := []multicast.SetupOption{}
|
options := []multicast.SetupOption{}
|
||||||
for _, intf := range m.config.MulticastInterfaces {
|
for _, intf := range m.config.MulticastInterfaces {
|
||||||
options = append(options, multicast.MulticastInterface{
|
options = append(options, multicast.MulticastInterface{
|
||||||
@ -98,9 +100,10 @@ func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
|||||||
Password: intf.Password,
|
Password: intf.Password,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
logger.Infof("Starting multicast %s", "")
|
||||||
m.multicast, err = multicast.New(m.core, m.logger, options...)
|
m.multicast, err = multicast.New(m.core, m.logger, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.logger.Errorln("An error occurred starting multicast:", err)
|
logger.Errorln("An error occurred starting multicast:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,15 +162,20 @@ func (m *Yggdrasil) RecvBuffer(buf []byte) (int, error) {
|
|||||||
func (m *Yggdrasil) Stop() error {
|
func (m *Yggdrasil) Stop() error {
|
||||||
logger := log.New(m.log, "", 0)
|
logger := log.New(m.log, "", 0)
|
||||||
logger.EnableLevel("info")
|
logger.EnableLevel("info")
|
||||||
logger.Infof("Stop the mobile Yggdrasil instance %s", "")
|
logger.Infof("Stopping the mobile Yggdrasil instance %s", "")
|
||||||
|
if m.multicast != nil {
|
||||||
|
logger.Infof("Stopping multicast %s", "")
|
||||||
if err := m.multicast.Stop(); err != nil {
|
if err := m.multicast.Stop(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
logger.Infof("Stopping TUN device %s", "")
|
||||||
if m.tun != nil {
|
if m.tun != nil {
|
||||||
if err := m.tun.Stop(); err != nil {
|
if err := m.tun.Stop(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.Infof("Stopping Yggdrasil core %s", "")
|
||||||
m.core.Stop()
|
m.core.Stop()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user