Skip to content

Commit

Permalink
Disable dhcp in single interface connected mode
Browse files Browse the repository at this point in the history
Closes #49
  • Loading branch information
davesteele committed Jul 28, 2019
1 parent f7c45cc commit 0a09509
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions comitup/cdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
pidpath = Path("/var/run/comitup-dns")

callmatrix = {
('HOTSPOT', 'pass'): (lambda: run_dns, lambda: hotspot_config),
('CONNECTING', 'start'): (lambda: run_dns, lambda: connected_config),
('HOTSPOT', 'pass', "router"):
(lambda: run_dns, lambda: hotspot_config),
('CONNECTING', 'start', "router"):
(lambda: run_dns, lambda: connected_config),
('HOTSPOT', 'pass', "single"):
(lambda: run_dns, lambda: hotspot_config),
('CONNECTING', 'start', "single"):
(lambda: run_dns, lambda: ""),
}


Expand All @@ -42,25 +48,25 @@ def run_dns(confpath):

kill_dns(pidpath, signal.SIGTERM)

dev = modemgr.get_ap_device().Interface
if os.path.exists(confpath):
dev = modemgr.get_ap_device().Interface

cmd = "dnsmasq --conf-file={0} --interface={1}".format(confpath, dev)
cmd = "dnsmasq --conf-file={0} --interface={1}".format(confpath, dev)

for _ in range(5):
cp = subprocess.run(cmd.split())
if cp.returncode == 0:
break
time.sleep(.1)
for _ in range(5):
cp = subprocess.run(cmd.split())
if cp.returncode == 0:
break
time.sleep(.1)


def state_callback(state, action):
try:
(fn_fact, svc_fact) = callmatrix[(state, action)]
(fn_fact, svc_fact) = callmatrix[(state, action, modemgr.get_mode())]
except KeyError:
return

if svc_fact():
fn_fact()(svc_fact())
fn_fact()(svc_fact())


def callback_target():
Expand Down

0 comments on commit 0a09509

Please sign in to comment.