From acbb8d1a24506b569b44c46919a03ebfde9f8fa1 Mon Sep 17 00:00:00 2001
From: LoveIsGrief <loveisgrief@tuta.io>
Date: Mon, 25 Jan 2021 22:30:04 +0100
Subject: [PATCH] Docker: Preconfigure clients and tunnels

The follow clients and tunnels are available on all interfaces (0.0.0.0) of the container:

 - routerconsole
 - SAM
 - I2P HTTP Proxy
 - Irc2P
---
 Dockerfile              |   1 +
 docker/clients.config   |  61 +++++++++++++++
 docker/i2ptunnel.config | 161 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 223 insertions(+)
 create mode 100644 docker/clients.config
 create mode 100644 docker/i2ptunnel.config

diff --git a/Dockerfile b/Dockerfile
index 8d5597cf49..8f591f87fe 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -31,6 +31,7 @@ ENV PATH=${I2P_PREFIX}/bin:$PATH
 
 # "install" i2p by copying over installed files
 COPY --from=builder /opt/i2p ${I2P_PREFIX}
+COPY docker/* /opt/i2p/
 
 # Setup user and fix permissions in
 RUN adduser --system --uid ${I2P_UID} --home /user ${I2P_USER} \
diff --git a/docker/clients.config b/docker/clients.config
new file mode 100644
index 0000000000..190dc9c698
--- /dev/null
+++ b/docker/clients.config
@@ -0,0 +1,61 @@
+# NOTE: This I2P config file must use UTF-8 encoding
+#
+# If you have a 'split' directory installation, with configuration
+# files in ~/.i2p (Linux), %LOCALAPPDATA%\I2P (Windows),
+# or /Users/(user)/Library/Application Support/i2p (Mac), be sure to
+# edit the file in the configuration directory, NOT the install directory.
+# When running as a Linux daemon, the configuration directory is /var/lib/i2p
+# and the install directory is /usr/share/i2p .
+# When running as a Windows service, the configuration directory is \ProgramData\i2p
+# and the install directory is \Program Files\i2p .
+#
+# On first run, this file will be split into individual config files
+# in clients.config.d/ in the configuration directory.
+# Look in that directory for the file to edit.
+#
+
+# fire up the web console
+## There are several choices, here are some examples:
+## non-SSL, bind to local IPv4 only
+#clientApp.0.args=7657 127.0.0.1 ./webapps/
+## non-SSL, bind to local IPv6 only
+#clientApp.0.args=7657 ::1 ./webapps/
+## non-SSL, bind to all IPv4 addresses
+#clientApp.0.args=7657 0.0.0.0 ./webapps/
+## non-SSL, bind to all IPv6 addresses
+#clientApp.0.args=7657 :: ./webapps/
+## For SSL only, change clientApp.4.args below to https://
+## SSL only
+#clientApp.0.args=-s 7657 ::1,127.0.0.1 ./webapps/
+## non-SSL and SSL
+#clientApp.0.args=7657 ::1,127.0.0.1 -s 7667 ::1,127.0.0.1 ./webapps/
+## non-SSL only, both IPv6 and IPv4 local interfaces
+clientApp.0.args=7657 0.0.0.0 ./webapps/
+clientApp.0.main=net.i2p.router.web.RouterConsoleRunner
+clientApp.0.name=webConsole
+clientApp.0.onBoot=true
+
+# start up the SAM bridge so other client apps can connect
+clientApp.1.main=net.i2p.sam.SAMBridge
+clientApp.1.name=SAMBridge
+clientApp.1.args=sam.keys 0.0.0.0 7656 i2cp.tcp.host=localhost i2cp.tcp.port=7654
+clientApp.1.startOnLoad=false
+
+# poke the i2ptunnels defined in i2ptunnel.config
+clientApp.2.main=net.i2p.i2ptunnel.TunnelControllerGroup
+clientApp.2.name=Tunnels
+clientApp.2.args=i2ptunnel.config
+
+# run our own eepsite with a seperate jetty instance
+clientApp.3.main=org.mortbay.jetty.Server
+clientApp.3.name=eepsite
+clientApp.3.args=eepsite/jetty.xml
+clientApp.3.delay=30
+clientApp.3.startOnLoad=false
+
+# load a browser pointing at the web console whenever we start up
+clientApp.4.main=net.i2p.apps.systray.UrlLauncher
+clientApp.4.name=consoleBrowser
+clientApp.4.args=http://localhost:7657/
+clientApp.4.delay=5
+clientApp.4.startOnLoad=false
diff --git a/docker/i2ptunnel.config b/docker/i2ptunnel.config
new file mode 100644
index 0000000000..8ff8eb3547
--- /dev/null
+++ b/docker/i2ptunnel.config
@@ -0,0 +1,161 @@
+# NOTE: This I2P config file must use UTF-8 encoding
+#
+# If you have a 'split' directory installation, with configuration
+# files in ~/.i2p (Linux), %LOCALAPPDATA%\I2P (Windows),
+# or /Users/(user)/Library/Application Support/i2p (Mac), be sure to
+# edit the file in the configuration directory, NOT the install directory.
+# When running as a Linux daemon, the configuration directory is /var/lib/i2p
+# and the install directory is /usr/share/i2p .
+# When running as a Windows service, the configuration directory is \ProgramData\i2p
+# and the install directory is \Program Files\i2p .
+#
+# On first run, this file will be split into individual config files
+# in i2ptunnel.config.d/ in the configuration directory.
+# Look in that directory for the file to edit.
+#
+
+# eepproxy
+tunnel.0.name=I2P HTTP Proxy
+tunnel.0.description=HTTP proxy for browsing eepsites and the web
+tunnel.0.type=httpclient
+tunnel.0.sharedClient=true
+tunnel.0.interface=0.0.0.0
+tunnel.0.listenPort=4444
+tunnel.0.proxyList=false.i2p
+tunnel.0.i2cpHost=127.0.0.1
+tunnel.0.i2cpPort=7654
+tunnel.0.option.inbound.nickname=shared clients
+tunnel.0.option.outbound.nickname=shared clients
+tunnel.0.option.i2cp.leaseSetEncType=4,0
+tunnel.0.option.i2cp.reduceIdleTime=900000
+tunnel.0.option.i2cp.reduceOnIdle=true
+tunnel.0.option.i2cp.reduceQuantity=1
+tunnel.0.option.i2p.streaming.connectDelay=1000
+tunnel.0.option.i2ptunnel.httpclient.SSLOutproxies=false.i2p
+tunnel.0.option.inbound.length=3
+tunnel.0.option.inbound.lengthVariance=0
+tunnel.0.option.outbound.length=3
+tunnel.0.option.outbound.lengthVariance=0
+tunnel.0.option.outbound.priority=10
+tunnel.0.startOnLoad=true
+
+# irc
+tunnel.1.name=Irc2P
+tunnel.1.description=IRC tunnel to access the Irc2P network
+tunnel.1.type=ircclient
+tunnel.1.sharedClient=false
+tunnel.1.interface=0.0.0.0
+tunnel.1.listenPort=6668
+tunnel.1.targetDestination=irc.postman.i2p:6667,irc.echelon.i2p:6667
+tunnel.1.i2cpHost=127.0.0.1
+tunnel.1.i2cpPort=7654
+tunnel.1.option.inbound.nickname=Irc2P
+tunnel.1.option.outbound.nickname=Irc2P
+tunnel.1.option.i2cp.closeIdleTime=1200000
+tunnel.1.option.i2cp.closeOnIdle=true
+tunnel.1.option.i2cp.delayOpen=true
+tunnel.1.option.i2cp.destination.sigType=7
+tunnel.1.option.i2cp.leaseSetEncType=4,0
+tunnel.1.option.i2cp.newDestOnResume=false
+tunnel.1.option.i2cp.reduceIdleTime=600000
+tunnel.1.option.i2cp.reduceOnIdle=true
+tunnel.1.option.i2cp.reduceQuantity=1
+tunnel.1.option.i2p.streaming.connectDelay=1000
+tunnel.1.option.i2p.streaming.maxWindowSize=16
+tunnel.1.option.inbound.length=3
+tunnel.1.option.inbound.lengthVariance=0
+tunnel.1.option.outbound.length=3
+tunnel.1.option.outbound.lengthVariance=0
+tunnel.1.option.outbound.priority=15
+tunnel.1.startOnLoad=true
+
+# local eepserver
+tunnel.3.name=I2P webserver
+tunnel.3.description=My eepsite
+tunnel.3.type=httpserver
+tunnel.3.targetHost=127.0.0.1
+tunnel.3.targetPort=7658
+tunnel.3.spoofedHost=mysite.i2p
+tunnel.3.privKeyFile=eepsite/eepPriv.dat
+tunnel.3.i2cpHost=127.0.0.1
+tunnel.3.i2cpPort=7654
+tunnel.3.option.inbound.nickname=eepsite
+tunnel.3.option.outbound.nickname=eepsite
+tunnel.3.option.i2cp.destination.sigType=7
+tunnel.3.option.i2cp.leaseSetEncType=4,0
+tunnel.3.option.inbound.length=3
+tunnel.3.option.inbound.lengthVariance=0
+tunnel.3.option.outbound.length=3
+tunnel.3.option.outbound.lengthVariance=0
+# uncomment for HTTPS to port 7668
+#tunnel.3.option.targetForPort.443=127.0.0.1:7668
+tunnel.3.startOnLoad=false
+
+# postman's SMTP server - see hq.postman.i2p
+tunnel.4.description=smtp server
+tunnel.4.i2cpHost=127.0.0.1
+tunnel.4.i2cpPort=7654
+tunnel.4.interface=127.0.0.1
+tunnel.4.listenPort=7659
+tunnel.4.name=smtp.postman.i2p
+tunnel.4.option.inbound.nickname=shared clients
+tunnel.4.option.outbound.nickname=shared clients
+tunnel.4.option.i2cp.leaseSetEncType=4,0
+tunnel.4.option.i2cp.reduceIdleTime=900000
+tunnel.4.option.i2cp.reduceOnIdle=true
+tunnel.4.option.i2cp.reduceQuantity=1
+tunnel.4.option.inbound.length=3
+tunnel.4.option.inbound.lengthVariance=0
+tunnel.4.option.outbound.length=3
+tunnel.4.option.outbound.lengthVariance=0
+tunnel.4.startOnLoad=true
+tunnel.4.targetDestination=smtp.postman.i2p:25
+tunnel.4.type=client
+tunnel.4.sharedClient=true
+
+# postman's POP3 server - see hq.postman.i2p
+tunnel.2.name=pop3.postman.i2p
+tunnel.2.description=pop3 server
+tunnel.2.i2cpHost=127.0.0.1
+tunnel.2.i2cpPort=7654
+tunnel.2.interface=127.0.0.1
+tunnel.2.listenPort=7660
+tunnel.2.option.inbound.nickname=shared clients
+tunnel.2.option.outbound.nickname=shared clients
+tunnel.2.option.i2cp.leaseSetEncType=4,0
+tunnel.2.option.i2cp.reduceIdleTime=900000
+tunnel.2.option.i2cp.reduceOnIdle=true
+tunnel.2.option.i2cp.reduceQuantity=1
+tunnel.2.option.i2p.streaming.connectDelay=1000
+tunnel.2.option.inbound.length=3
+tunnel.2.option.inbound.lengthVariance=0
+tunnel.2.option.outbound.length=3
+tunnel.2.option.outbound.lengthVariance=0
+tunnel.2.startOnLoad=true
+tunnel.2.targetDestination=pop.postman.i2p:110
+tunnel.2.type=client
+tunnel.2.sharedClient=true
+
+# HTTPS (CONNECT) outproxy
+tunnel.5.name=I2P HTTPS Proxy
+tunnel.5.description=HTTPS proxy for browsing eepsites and the web
+tunnel.5.type=connectclient
+tunnel.5.sharedClient=true
+tunnel.5.interface=127.0.0.1
+tunnel.5.listenPort=4445
+tunnel.5.proxyList=outproxy-tor.meeh.i2p
+tunnel.5.i2cpHost=127.0.0.1
+tunnel.5.i2cpPort=7654
+tunnel.5.option.inbound.nickname=shared clients
+tunnel.5.option.outbound.nickname=shared clients
+tunnel.5.option.i2cp.leaseSetEncType=4,0
+tunnel.5.option.i2cp.reduceIdleTime=900000
+tunnel.5.option.i2cp.reduceOnIdle=true
+tunnel.5.option.i2cp.reduceQuantity=1
+tunnel.5.option.i2p.streaming.connectDelay=1000
+tunnel.5.option.inbound.length=3
+tunnel.5.option.inbound.lengthVariance=0
+tunnel.5.option.outbound.length=3
+tunnel.5.option.outbound.lengthVariance=0
+tunnel.5.startOnLoad=true
+
-- 
GitLab