OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging, threading, time, utils | 5 import logging, threading, time |
| 6 from autotest_lib.client.bin import utils |
6 | 7 |
7 class LocalDns(object): | 8 class LocalDns(object): |
8 """a wrapper around miniFakeDns that handles managing running the server | 9 """a wrapper around miniFakeDns that handles managing running the server |
9 in a separate thread. | 10 in a separate thread. |
10 """ | 11 """ |
11 | 12 |
12 def __init__(self, fake_ip="127.0.0.1", local_port=53): | 13 def __init__(self, fake_ip="127.0.0.1", local_port=53): |
13 import miniFakeDns # So we don't need to install it in the chroot. | 14 import miniFakeDns # So we don't need to install it in the chroot. |
14 self._dns = miniFakeDns.DNSServer(fake_ip="127.0.0.1", port=local_port) | 15 self._dns = miniFakeDns.DNSServer(fake_ip="127.0.0.1", port=local_port) |
15 self._stopper = threading.Event() | 16 self._stopper = threading.Event() |
16 self._thread = threading.Thread(target=self._dns.run, | 17 self._thread = threading.Thread(target=self._dns.run, |
17 args=(self._stopper,)) | 18 args=(self._stopper,)) |
18 | 19 |
19 | 20 |
20 def run(self): | 21 def run(self): |
21 self._thread.start() | 22 self._thread.start() |
22 | 23 |
23 | 24 |
24 def stop(self): | 25 def stop(self): |
25 self._stopper.set() | 26 self._stopper.set() |
26 self._thread.join() | 27 self._thread.join() |
OLD | NEW |