Skip to content

Commit a9aa6dd

Browse files
committed
Initial attempt at captive portal with configurable port during setup and in .conf file
1 parent 38ffecc commit a9aa6dd

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

initial_setup.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
print()
1717
auto_config_delay = input("How long of a delay would you like without an active connection \nbefore auto-reconfiguration triggers (seconds)? [default: 300]: ")
1818
print()
19+
server_port_choice = input("Which port would you like to use for the Configuration Page? [default: 80]: ")
20+
print()
1921
ssl_enabled_choice = input("Would you like to enable SSL during configuration mode \n(NOTICE: you will get a certificate ID error \nwhen connecting, but traffic will be encrypted) [y/N]?: ")
2022
os.system('clear')
2123
print()
@@ -25,7 +27,7 @@
2527
if(install_ans.lower() == 'y'):
2628
setup_lib.install_prereqs()
2729
setup_lib.copy_configs()
28-
setup_lib.update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice)
30+
setup_lib.update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice, server_port_choice)
2931
else:
3032
print()
3133
print()

libs/configuration_app/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ def config_file_hash():
9191
config_hash = config_file_hash()
9292

9393
if config_hash['ssl_enabled'] == "1":
94-
app.run(host = '0.0.0.0', port = 9191, ssl_context='adhoc')
94+
app.run(host = '0.0.0.0', port = config_hash['server_port'], ssl_context='adhoc')
9595
else:
96-
app.run(host = '0.0.0.0', port = 9191)
96+
app.run(host = '0.0.0.0', port = config_hash['server_port'])

libs/reset_device/static_files/dnsmasq.conf

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ dhcp-range=10.0.0.10,10.0.0.15,12h
66
# Delays sending DHCPOFFER and proxydhcp replies for at least the specified number of seconds.
77
dhcp-mac=set:client_is_a_pi,B8:27:EB:*:*:*
88
dhcp-reply-delay=tag:client_is_a_pi,2
9+
10+
address=/raspiwifisetup.com/10.0.0.1

libs/reset_device/static_files/raspiwifi.conf

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ ssid_prefix=RaspiWiFi Setup
22
auto_config=0
33
auto_config_delay=300
44
ssl_enabled=0
5+
server_port=80

setup_lib.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def copy_configs():
2929
os.system('echo "@reboot root run-parts /etc/cron.raspiwifi/" >> /etc/crontab')
3030
os.system('mv /usr/lib/raspiwifi/reset_device/static_files/raspiwifi.conf /etc/raspiwifi')
3131

32-
def update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice):
32+
def update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay, ssl_enabled_choice, server_port_choice):
3333
if entered_ssid != "":
3434
os.system('sed -i \'s/RaspiWiFi Setup/' + entered_ssid + '/\' /etc/raspiwifi/raspiwifi.conf')
3535
if auto_config_choice.lower() == "y":
@@ -38,3 +38,5 @@ def update_main_config_file(entered_ssid, auto_config_choice, auto_config_delay,
3838
os.system('sed -i \'s/auto_config_delay=300/auto_config_delay=' + auto_config_delay + '/\' /etc/raspiwifi/raspiwifi.conf')
3939
if ssl_enabled_choice.lower() == "y":
4040
os.system('sed -i \'s/ssl_enabled=0/ssl_enabled=1/\' /etc/raspiwifi/raspiwifi.conf')
41+
if server_port_choice != "":
42+
os.system('sed -i \'s/server_port=80/server_port=' + server_port_choice + '/\' /etc/raspiwifi/raspiwifi.conf')

0 commit comments

Comments
 (0)