Skip to content

Commit ae202dc

Browse files
committed
feat(templates): serve USB Arsenal's gateway mode on usb0 in the OpenWrt image
USB Arsenal's tether --gateway hands the phone's USB cable to the container as usb0. Give it the same shape as the Containers interface (static 192.168.43.1/24, a /64 out of the ULA, DHCPv4, DHCPv6 and RA) and put it in the guest zone beside vaplan, so USB clients get IPv4 and IPv6 to the internet and nothing else. Signed-off-by: ravindu644 <droidcasts@protonmail.com>
1 parent 437d990 commit ae202dc

2 files changed

Lines changed: 56 additions & 10 deletions

File tree

‎templates/aarch64/OpenWrt-24.10-Minimal.Dockerfile‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ opkg install shadow-utils
3434
usermod -a -G aid_inet,aid_net_raw root || true
3535
opkg remove --force-depends shadow-utils
3636

37-
# Upstream over eth0 (Droidspaces NAT); VirtualAP adds vaplan0 LAN at start time
37+
# Upstream over eth0 (Droidspaces NAT); VirtualAP adds vaplan0 LAN at start time,
38+
# USB Arsenal's gateway mode hands the cable to the container as usb0
3839
cat > /etc/config/network <<'NETEOF'
3940
config interface 'loopback'
4041
option device 'lo'
@@ -65,6 +66,15 @@ config interface 'Containers'
6566
option ipaddr '192.168.41.1'
6667
option netmask '255.255.255.0'
6768
option ip6assign '64'
69+
70+
# USB Arsenal's gateway mode (tether --gateway) plugs the USB cable in as usb0.
71+
# Same shape as Containers: static v4 and a /64 out of the ULA.
72+
config interface 'usb'
73+
option device 'usb0'
74+
option proto 'static'
75+
option ipaddr '192.168.43.1'
76+
option netmask '255.255.255.0'
77+
option ip6assign '64'
6878
NETEOF
6979

7080
# Every server option is spelled out: odhcpd's first-boot script only fills
@@ -85,6 +95,18 @@ set dhcp.Containers.ra_slaac='1'
8595
add_list dhcp.Containers.ra_flags='managed-config'
8696
add_list dhcp.Containers.ra_flags='other-config'
8797
set dhcp.Containers.ra_default='2'
98+
set dhcp.usb=dhcp
99+
set dhcp.usb.interface='usb'
100+
set dhcp.usb.start='100'
101+
set dhcp.usb.limit='150'
102+
set dhcp.usb.leasetime='12h'
103+
set dhcp.usb.dhcpv4='server'
104+
set dhcp.usb.dhcpv6='server'
105+
set dhcp.usb.ra='server'
106+
set dhcp.usb.ra_slaac='1'
107+
add_list dhcp.usb.ra_flags='managed-config'
108+
add_list dhcp.usb.ra_flags='other-config'
109+
set dhcp.usb.ra_default='2'
88110
commit dhcp
89111
DHCPEOF
90112

@@ -118,9 +140,9 @@ ip6tables -t nat -C POSTROUTING -o eth0 -j MASQUERADE 2>/dev/null ||
118140
ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
119141
NAT6EOF
120142

121-
# fw3 zones: vaplan lives in an isolated 'guest' zone (NOT lan) so hotspot
122-
# clients reach only the internet (guest -> masqueraded wan/eth0) and never
123-
# other containers on lan. input REJECT blocks router services by default; we
143+
# fw3 zones: vaplan and usb live in an isolated 'guest' zone (NOT lan) so
144+
# hotspot and USB clients reach only the internet (guest -> masqueraded
145+
# wan/eth0) and never other containers on lan. input REJECT blocks router services by default; we
124146
# punch holes below for DHCP + DNS (needed for a lease) and LuCI (admin UI).
125147
cat > /etc/config/firewall <<'FWEOF'
126148
config defaults
@@ -138,6 +160,7 @@ config zone
138160
config zone
139161
option name 'guest'
140162
list network 'vaplan'
163+
list network 'usb'
141164
option input 'REJECT'
142165
option output 'ACCEPT'
143166
option forward 'DROP'
@@ -287,6 +310,6 @@ EOF_RUN
287310
FROM scratch AS export
288311
LABEL droidspaces.name="OpenWrt 24.10 - Minimal (iptables-legacy)" \
289312
droidspaces.distro="OpenWrt" \
290-
droidspaces.description="Minimal OpenWrt 24.10 router rootfs built for Android kernels: nftables/fw4 stripped out in favor of iptables-legacy + fw3, with full firewall (NAT, zones, masquerade) working. Tuned for VirtualAP's managed-hotspot (container) mode, and serves Droidspaces gateway-mode clients on eth1 out of the box." \
313+
droidspaces.description="Minimal OpenWrt 24.10 router rootfs built for Android kernels: nftables/fw4 stripped out in favor of iptables-legacy + fw3, with full firewall (NAT, zones, masquerade) working. Tuned for VirtualAP's managed-hotspot (container) mode, and serves Droidspaces gateway-mode clients on eth1 and USB Arsenal's gateway mode on usb0 out of the box." \
291314
droidspaces.author="Droidspaces developers"
292315
COPY --from=customizer / /

‎templates/armhf/OpenWrt-24.10-Minimal.Dockerfile‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ opkg install shadow-utils
3434
usermod -a -G aid_inet,aid_net_raw root || true
3535
opkg remove --force-depends shadow-utils
3636

37-
# Upstream over eth0 (Droidspaces NAT); VirtualAP adds vaplan0 LAN at start time
37+
# Upstream over eth0 (Droidspaces NAT); VirtualAP adds vaplan0 LAN at start time,
38+
# USB Arsenal's gateway mode hands the cable to the container as usb0
3839
cat > /etc/config/network <<'NETEOF'
3940
config interface 'loopback'
4041
option device 'lo'
@@ -65,6 +66,15 @@ config interface 'Containers'
6566
option ipaddr '192.168.41.1'
6667
option netmask '255.255.255.0'
6768
option ip6assign '64'
69+
70+
# USB Arsenal's gateway mode (tether --gateway) plugs the USB cable in as usb0.
71+
# Same shape as Containers: static v4 and a /64 out of the ULA.
72+
config interface 'usb'
73+
option device 'usb0'
74+
option proto 'static'
75+
option ipaddr '192.168.43.1'
76+
option netmask '255.255.255.0'
77+
option ip6assign '64'
6878
NETEOF
6979

7080
# Every server option is spelled out: odhcpd's first-boot script only fills
@@ -85,6 +95,18 @@ set dhcp.Containers.ra_slaac='1'
8595
add_list dhcp.Containers.ra_flags='managed-config'
8696
add_list dhcp.Containers.ra_flags='other-config'
8797
set dhcp.Containers.ra_default='2'
98+
set dhcp.usb=dhcp
99+
set dhcp.usb.interface='usb'
100+
set dhcp.usb.start='100'
101+
set dhcp.usb.limit='150'
102+
set dhcp.usb.leasetime='12h'
103+
set dhcp.usb.dhcpv4='server'
104+
set dhcp.usb.dhcpv6='server'
105+
set dhcp.usb.ra='server'
106+
set dhcp.usb.ra_slaac='1'
107+
add_list dhcp.usb.ra_flags='managed-config'
108+
add_list dhcp.usb.ra_flags='other-config'
109+
set dhcp.usb.ra_default='2'
88110
commit dhcp
89111
DHCPEOF
90112

@@ -118,9 +140,9 @@ ip6tables -t nat -C POSTROUTING -o eth0 -j MASQUERADE 2>/dev/null ||
118140
ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
119141
NAT6EOF
120142

121-
# fw3 zones: vaplan lives in an isolated 'guest' zone (NOT lan) so hotspot
122-
# clients reach only the internet (guest -> masqueraded wan/eth0) and never
123-
# other containers on lan. input REJECT blocks router services by default; we
143+
# fw3 zones: vaplan and usb live in an isolated 'guest' zone (NOT lan) so
144+
# hotspot and USB clients reach only the internet (guest -> masqueraded
145+
# wan/eth0) and never other containers on lan. input REJECT blocks router services by default; we
124146
# punch holes below for DHCP + DNS (needed for a lease) and LuCI (admin UI).
125147
cat > /etc/config/firewall <<'FWEOF'
126148
config defaults
@@ -138,6 +160,7 @@ config zone
138160
config zone
139161
option name 'guest'
140162
list network 'vaplan'
163+
list network 'usb'
141164
option input 'REJECT'
142165
option output 'ACCEPT'
143166
option forward 'DROP'
@@ -287,6 +310,6 @@ EOF_RUN
287310
FROM scratch AS export
288311
LABEL droidspaces.name="OpenWrt 24.10 - Minimal (iptables-legacy)" \
289312
droidspaces.distro="OpenWrt" \
290-
droidspaces.description="Minimal OpenWrt 24.10 router rootfs built for Android kernels: nftables/fw4 stripped out in favor of iptables-legacy + fw3, with full firewall (NAT, zones, masquerade) working. Tuned for VirtualAP's managed-hotspot (container) mode, and serves Droidspaces gateway-mode clients on eth1 out of the box." \
313+
droidspaces.description="Minimal OpenWrt 24.10 router rootfs built for Android kernels: nftables/fw4 stripped out in favor of iptables-legacy + fw3, with full firewall (NAT, zones, masquerade) working. Tuned for VirtualAP's managed-hotspot (container) mode, and serves Droidspaces gateway-mode clients on eth1 and USB Arsenal's gateway mode on usb0 out of the box." \
291314
droidspaces.author="Droidspaces developers"
292315
COPY --from=customizer / /

0 commit comments

Comments
 (0)