mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-21 23:43:18 +01:00
transfer work from PR #837
This commit is contained in:
parent
60ee5b910b
commit
8da94c39ea
@ -9,7 +9,7 @@ import sshuttle.firewall as firewall
|
|||||||
import sshuttle.hostwatch as hostwatch
|
import sshuttle.hostwatch as hostwatch
|
||||||
import sshuttle.ssyslog as ssyslog
|
import sshuttle.ssyslog as ssyslog
|
||||||
from sshuttle.options import parser, parse_ipport
|
from sshuttle.options import parser, parse_ipport
|
||||||
from sshuttle.helpers import family_ip_tuple, log, Fatal
|
from sshuttle.helpers import family_ip_tuple, log, Fatal, start_stdout_stderr_flush_thread
|
||||||
from sshuttle.sudoers import sudoers
|
from sshuttle.sudoers import sudoers
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ CACHEFILE = os.path.expanduser('~/.sshuttle.hosts')
|
|||||||
# Have we already failed to write CACHEFILE?
|
# Have we already failed to write CACHEFILE?
|
||||||
CACHE_WRITE_FAILED = False
|
CACHE_WRITE_FAILED = False
|
||||||
|
|
||||||
|
SHOULD_WRITE_CACHE = False
|
||||||
|
|
||||||
hostnames = {}
|
hostnames = {}
|
||||||
queue = {}
|
queue = {}
|
||||||
try:
|
try:
|
||||||
@ -81,6 +83,11 @@ def read_host_cache():
|
|||||||
ip = re.sub(r'[^0-9.]', '', ip).strip()
|
ip = re.sub(r'[^0-9.]', '', ip).strip()
|
||||||
if name and ip:
|
if name and ip:
|
||||||
found_host(name, ip)
|
found_host(name, ip)
|
||||||
|
f.close()
|
||||||
|
global SHOULD_WRITE_CACHE
|
||||||
|
if SHOULD_WRITE_CACHE:
|
||||||
|
write_host_cache()
|
||||||
|
SHOULD_WRITE_CACHE = False
|
||||||
|
|
||||||
|
|
||||||
def found_host(name, ip):
|
def found_host(name, ip):
|
||||||
@ -97,12 +104,13 @@ def found_host(name, ip):
|
|||||||
if hostname != name:
|
if hostname != name:
|
||||||
found_host(hostname, ip)
|
found_host(hostname, ip)
|
||||||
|
|
||||||
|
global SHOULD_WRITE_CACHE
|
||||||
oldip = hostnames.get(name)
|
oldip = hostnames.get(name)
|
||||||
if oldip != ip:
|
if oldip != ip:
|
||||||
hostnames[name] = ip
|
hostnames[name] = ip
|
||||||
debug1('Found: %s: %s' % (name, ip))
|
debug1('Found: %s: %s' % (name, ip))
|
||||||
sys.stdout.write('%s,%s\n' % (name, ip))
|
sys.stdout.write('%s,%s\n' % (name, ip))
|
||||||
write_host_cache()
|
SHOULD_WRITE_CACHE = True
|
||||||
|
|
||||||
|
|
||||||
def _check_etc_hosts():
|
def _check_etc_hosts():
|
||||||
|
@ -2,6 +2,7 @@ import io
|
|||||||
import socket
|
import socket
|
||||||
from socket import AF_INET, AF_INET6
|
from socket import AF_INET, AF_INET6
|
||||||
import errno
|
import errno
|
||||||
|
import time
|
||||||
|
|
||||||
from unittest.mock import patch, call
|
from unittest.mock import patch, call
|
||||||
import sshuttle.helpers
|
import sshuttle.helpers
|
||||||
|
Loading…
Reference in New Issue
Block a user