jczic / MicroDNSSrv

A micro DNS server for MicroPython to simply respond to A queries on multi-domains with or without wildcards (used on Pycom modules & ESP32)
https://microdnssrv.hc2.fr
MIT License
74 stars 21 forks source link

Confused on how to get working #5

Open GanerCodes opened 3 years ago

GanerCodes commented 3 years ago

Here is my simple setup:


import network
from microDNSSrv import MicroDNSSrv

ap = network.WLAN(network.AP_IF)
ap.ifconfig(("192.168.4.1", "255.255.255.0", "192.168.0.1", "10.0.0.1"))
ap.active(True)
ap.config(essid = "Simple Test", password = "")

while ap.active() == False: pass

print('Created AP.')
print(ap.ifconfig())

if MicroDNSSrv.Create({"*": ap.ifconfig()[1]}):
    print("yay")
else:
    print("Error to starts MicroDNSSrv...")

print()
print("=======================================================================")
print()

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 80))
s.listen(5)

with open('index.html', 'r') as f:
    pageHTML = f.read()

while True:
    conn, addr = s.accept()
    print('Got a connection from %s' % str(addr))
    request = conn.recv(1024)
    print(request)
    conn.send(pageHTML)
    conn.close()

however, if I connect to the AP on my phone there is no prompt, and going to some arbitrary website does not redirect me. What am I doing wrong?

max-win-at commented 8 months ago

I have a very similar setup and the same issue. It's been some years, did you came up with a solution you can share?

GanerCodes commented 8 months ago

I have a very similar setup and the same issue. It's been some years, did you came up with a solution you can share?

Nah unfortunately not; I just have the user navigate to 192.168.4.1 in their browser; pretty annoying ngl

max-win-at commented 8 months ago

I got it working by refactoring to this solution https://github.com/pimoroni/phew Pretty neat.