Stop is run when the device is removed from the instance.
()
| 457 | |
| 458 | // Stop is run when the device is removed from the instance. |
| 459 | func (d *proxy) Stop() (*deviceConfig.RunConfig, error) { |
| 460 | // Stop any background NAT address monitor before clearing the firewall entries. |
| 461 | d.stopNATMonitor() |
| 462 | |
| 463 | // Remove possible firewall entries. |
| 464 | err := d.state.Firewall.InstanceClearProxyNAT(d.inst.Project().Name, d.inst.Name(), d.name) |
| 465 | if err != nil { |
| 466 | logger.Errorf("Failed to remove proxy NAT filters: %v", err) |
| 467 | } |
| 468 | |
| 469 | devFileName := fmt.Sprintf("proxy.%s", linux.PathNameEncode(d.name)) |
| 470 | devPath := filepath.Join(d.inst.DevicesPath(), devFileName) |
| 471 | |
| 472 | if !util.PathExists(devPath) { |
| 473 | // There's no proxy process if NAT is enabled |
| 474 | return nil, nil |
| 475 | } |
| 476 | |
| 477 | err = d.killProxyProc(devPath) |
| 478 | if err != nil { |
| 479 | return nil, err |
| 480 | } |
| 481 | |
| 482 | // Unload apparmor profile. |
| 483 | err = apparmor.ForkproxyUnload(d.state.OS, d.inst, d) |
| 484 | if err != nil { |
| 485 | return nil, err |
| 486 | } |
| 487 | |
| 488 | return nil, nil |
| 489 | } |
| 490 | |
| 491 | func (d *proxy) setupNAT() error { |
| 492 | listenAddr, err := network.ProxyParseAddr(d.config["listen"]) |
nothing calls this directly
no test coverage detected