mirror of
https://github.com/luscis/openlan.git
synced 2025-10-05 08:36:59 +08:00
fix: restart openvpn without vrf master.
This commit is contained in:
@@ -64,7 +64,7 @@ type Router interface {
|
||||
}
|
||||
|
||||
type VPNer interface {
|
||||
RestartVpn()
|
||||
RestartVPN()
|
||||
}
|
||||
|
||||
type Qoser interface {
|
||||
|
@@ -116,7 +116,7 @@ func (h Network) RestartVPN(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
worker.RestartVpn()
|
||||
worker.RestartVPN()
|
||||
|
||||
ResponseJson(w, true)
|
||||
}
|
||||
|
@@ -428,25 +428,8 @@ func (w *WorkerImpl) UndoZTrust() {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WorkerImpl) Start(v api.Switcher) {
|
||||
cfg, vpn := w.GetCfgs()
|
||||
|
||||
w.out.Info("WorkerImpl.Start")
|
||||
|
||||
w.loadVRF()
|
||||
w.loadRoutes()
|
||||
|
||||
w.acl.Start()
|
||||
w.toACL(cfg.Bridge.Name)
|
||||
|
||||
for _, output := range cfg.Outputs {
|
||||
output.GenName()
|
||||
w.addOutput(cfg.Bridge.Name, output)
|
||||
}
|
||||
|
||||
if !(w.vpn == nil) {
|
||||
w.vpn.Start()
|
||||
if !(w.vrf == nil) {
|
||||
func (w *WorkerImpl) letVPN2VRF() {
|
||||
_, vpn := w.GetCfgs()
|
||||
promise := libol.NewPromise()
|
||||
promise.Go(func() error {
|
||||
link, err := nl.LinkByName(vpn.Device)
|
||||
@@ -475,8 +458,29 @@ func (w *WorkerImpl) Start(v api.Switcher) {
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (w *WorkerImpl) Start(v api.Switcher) {
|
||||
cfg, vpn := w.GetCfgs()
|
||||
|
||||
w.out.Info("WorkerImpl.Start")
|
||||
|
||||
w.loadVRF()
|
||||
w.loadRoutes()
|
||||
|
||||
w.acl.Start()
|
||||
w.toACL(cfg.Bridge.Name)
|
||||
|
||||
for _, output := range cfg.Outputs {
|
||||
output.GenName()
|
||||
w.addOutput(cfg.Bridge.Name, output)
|
||||
}
|
||||
|
||||
if !(w.vpn == nil) {
|
||||
w.vpn.Start()
|
||||
if !(w.vrf == nil) {
|
||||
w.letVPN2VRF()
|
||||
}
|
||||
w.fire.Mangle.In.AddRule(cn.IPRule{
|
||||
Input: vpn.Device,
|
||||
Jump: w.qos.ChainIn(),
|
||||
@@ -559,9 +563,12 @@ func (w *WorkerImpl) unloadRoutes() {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WorkerImpl) RestartVpn() {
|
||||
func (w *WorkerImpl) RestartVPN() {
|
||||
if w.vpn != nil {
|
||||
w.vpn.Restart()
|
||||
if !(w.vrf == nil) {
|
||||
w.letVPN2VRF()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user