redirect HTTP requests to mockup web server
authorPaul Hänsch <paul@plutz.net>
Thu, 1 Nov 2018 17:13:45 +0000 (18:13 +0100)
committerPaul Hänsch <paul@plutz.net>
Thu, 1 Nov 2018 17:13:45 +0000 (18:13 +0100)
Makefile
files/etc/dnsmasq.conf
files/etc/inetd.conf [new file with mode: 0644]
files/srv/webserver.sed [new file with mode: 0755]

index 6f810da..8e8fe91 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ deb     http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi\
 deb    http://archive.raspberrypi.org/debian stretch main\n
 endef
 
-PACKAGES := apt apt-transport-https bluez bluez-firmware bluez-tools bridge-utils btrfs-tools busybox-static bzip2 ca-certificates cron deborphan dnsmasq firmware-atheros firmware-brcm80211 firmware-libertas firmware-linux-free firmware-misc-nonfree firmware-realtek gzip htop ifupdown init iptables iputils-ping irqbalance isc-dhcp-client less libraspberrypi-bin libraspberrypi0 make net-tools nmap ntpdate openssh-client openssh-server p7zip-full pi-bluetooth rpi-update rsync ssh sshfs sudo systemd traceroute unace unrar-free unzip vim wget wireless-tools wpasupplicant xz-utils zip
+PACKAGES := apt apt-transport-https bluez bluez-firmware bluez-tools bridge-utils btrfs-tools busybox-static bzip2 ca-certificates cron deborphan dnsmasq firmware-atheros firmware-brcm80211 firmware-libertas firmware-linux-free firmware-misc-nonfree firmware-realtek gzip htop ifupdown init iptables iputils-ping irqbalance isc-dhcp-client less libraspberrypi-bin libraspberrypi0 make net-tools nmap ntpdate openbsd-inetd openssh-client openssh-server p7zip-full pi-bluetooth rpi-update rsync ssh sshfs sudo systemd traceroute unace unrar-free unzip vim wget wireless-tools wpasupplicant xz-utils zip
 
 # Do not change, only override in config.mk
 WIFI-SSID = 
index dc15f81..38b9bbb 100644 (file)
@@ -3,3 +3,5 @@ bind-interfaces
 
 dhcp-authoritative
 dhcp-range=192.168.82.16,192.168.82.254,48h
+
+address=/#/192.168.82.1
diff --git a/files/etc/inetd.conf b/files/etc/inetd.conf
new file mode 100644 (file)
index 0000000..0480d69
--- /dev/null
@@ -0,0 +1 @@
+80     stream  tcp     nowait  nobody  /bin/sed        sed -nrf /srv/webserver.sed
diff --git a/files/srv/webserver.sed b/files/srv/webserver.sed
new file mode 100755 (executable)
index 0000000..f509a6c
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sed -nrf
+
+:START
+/\r?\n\r?$/bRESPONSE; N; bSTART;
+
+:RESPONSE
+
+/\nHost: oktopus\r?\n/{
+s;^.*$;;;
+iHTTP/1.1 200 OK\r\
+Content-Type: text/html; encoding=utf-8\r\
+Connection: close\r\
+\r\
+<HTML><HEAD><TITLE>Oktopus</TITLE></HEAD><BODY><H1>Oktopus</H1>Oktopus</BODY></HTML>
+p
+q
+}
+
+s;^.*$;;;
+iHTTP/1.1 307 Temporary Redirect\r\
+Location: http://oktopus\r\
+Connection: close\r\
+\r\
+p
+q