Skip to content

Commit

Permalink
Made eepSite keypair generation optional via NOI2P makefile setting
Browse files Browse the repository at this point in the history
Gentoo ebuild now supports USE=i2p flag, and "gen-i2p-hostname" is
not installed if the flag is not set.

"cable-info" applet now displays an error only when no addresses
have been configured (i.e., Tor-only configuration is fine). The
applet also displays the addresses in a more user-friendly fashion.
  • Loading branch information
Maxim Kammerer committed Dec 6, 2012
1 parent ba4fd96 commit 90a97a9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 59 deletions.
53 changes: 23 additions & 30 deletions bin/cable-id
Expand Up @@ -13,48 +13,41 @@ torhost=${CABLE_TOR}/hidden_service/hostname
i2phost=${CABLE_I2P}/eepsite/hostname
username=${CABLE_CERTS}/certs/username


if [ ! -e ${torhost} ]; then
error "Tor host identity not initialized yet"
fi

if [ ! -e ${i2phost} ]; then
error "I2P host identity not initialized yet"
fi

if [ ! -e ${username} ]; then
error "cable identity not initialized yet"
fi


torhost=`cat ${torhost} | tr -cd '[:alnum:].-' | tr '[:upper:]' '[:lower:]'`
i2phost=`cat ${i2phost} | tr -cd '[:alnum:].-' | tr '[:upper:]' '[:lower:]'`
username=`cat ${username} | tr -cd a-z2-7`

[ ${#torhost} != 0 ] || error "bad Tor hostname"
[ ${#i2phost} != 0 ] || error "bad I2P hostname"
[ ${#username} = 32 ] || error "bad username"
undefined="undefined"


case "$1" in
user)
echo "${username}"
if [ ! -e ${username} ]; then
echo "${undefined}"
else
username=`cat ${username} | tr -cd a-z2-7`
[ ${#username} = 32 ] || error "bad username"
echo "${username}"
fi
;;

tor)
echo "${torhost}"
if [ ! -e ${torhost} ]; then
echo "${undefined}"
else
torhost=`cat ${torhost} | tr -cd '[:alnum:].-' | tr '[:upper:]' '[:lower:]'`
[ ${#torhost} != 0 ] || error "bad Tor hostname"
echo "${torhost}"
fi
;;

i2p)
echo "${i2phost}"
;;

test)
echo http://"${torhost}"/"${username}"/request/ver
echo http://"${i2phost}"/"${username}"/request/ver
if [ ! -e ${i2phost} ]; then
echo "${undefined}"
else
i2phost=`cat ${i2phost} | tr -cd '[:alnum:].-' | tr '[:upper:]' '[:lower:]'`
[ ${#i2phost} != 0 ] || error "bad I2P hostname"
echo "${i2phost}"
fi
;;

*)
error "param: user|tor|i2p|test"
error "param: user|tor|i2p"
;;
esac
36 changes: 23 additions & 13 deletions bin/cable-info
@@ -1,38 +1,48 @@
#!/bin/sh -e

cableid=cable-id
undefined="undefined"
title="Cables Communication Identity"

if username=`${cableid} user 2>/dev/null`; then
torhost=`${cableid} tor | sed 's/\.onion$//'`
i2phost=`${cableid} i2p | sed 's/\.b32\.i2p$//'`
else
username=`${cableid} user`
torhost=`${cableid} tor | sed 's/\.onion$//'`
i2phost=`${cableid} i2p | sed 's/\.b32\.i2p$//'`


if [ "${username}" = "${undefined}" -o "${torhost}${i2phost}" = "${undefined}${undefined}" ]; then
message="<big><b>${title}</b></big>
Cables communication addresses have not been configured.
This is typically a result of disabled persistence: booting from an ISO image in a virtual machine, booting from an actual CD, or write-protecting the boot media.
When using cables in Liberté Linux, this is typically a result of disabled persistence: booting from an ISO image in a virtual machine, booting from an actual CD, or write-protecting the boot media.
In order to enable persistence, install Liberté Linux to a writable media, such as a USB stick or an SD card."

exec zenity --error --title="${title}" --text="${message}"
fi


splitre='s@\([[:alnum:]]\{4\}\)\([[:alnum:]]\{4\}\)\?@<span foreground="red">\1</span><span foreground="blue">\2</span>@g'

username=`echo "${username}" | sed "${splitre}"`
torhost=`echo "${torhost}" | sed "${splitre}"`.onion
i2phost=`echo "${i2phost}" | sed "${splitre}"`.b32.i2p
addrs=

message="<big><b>${title}</b></big>
if [ "${torhost}" != "${undefined}" ]; then
torhost=`echo "${torhost}" | sed "${splitre}"`.onion
addrs="${addrs}&#10;<big><tt>${username}</tt>@<tt>${torhost}</tt></big>"
fi
if [ "${i2phost}" != "${undefined}" ]; then
i2phost=`echo "${i2phost}" | sed "${splitre}"`.b32.i2p
addrs="${addrs}&#10;<big><tt>${username}</tt>@<tt>${i2phost}</tt></big>"
fi

You can use the following addresses for cables communication via Claws-Mail:

<b>Username</b>: <big><tt>${username}</tt></big>
message="<big><b>${title}</b></big>
<b>Tor hostname</b>: <big><tt>@${torhost}</tt></big>
<b>I2P hostname</b>: <big><tt>@${i2phost}</tt></big>
You can use the following addresses for cables communication via Claws-Mail:
${addrs}
Your address is the username concatenated with one of the hostnames (including ‘<tt>@</tt>’). Always check the username of incoming messages — its authenticity is guaranteed by the cables communication protocol. When manually reading addresses, keep in mind that only digits <tt>2</tt>–<tt>7</tt> are used, the rest are letters.
Always check the username of incoming messages — its authenticity is guaranteed by the cables communication protocol. When manually reading addresses, keep in mind that only digits <tt>2</tt>–<tt>7</tt> are used, the rest are letters.
You can set either address in Claws-Mail account settings. Upon startup, Claws-Mail will reset the account to Tor-based address if the configured address is not one of the above."

Expand Down
11 changes: 9 additions & 2 deletions makefile
@@ -1,6 +1,6 @@
# Single-source file programs to build
progs = cable/daemon cable/mhdrop cable/hex2base32 \
cable/eeppriv.jar
$(if $(NOI2P),,cable/eeppriv.jar)
objextra_daemon = obj/server.o obj/service.o obj/process.o obj/util.o
ldextra_daemon = -lrt -lmicrohttpd
cpextra_EepPriv = /opt/i2p/lib/i2p.jar
Expand All @@ -22,6 +22,9 @@ etcdir=$(DESTDIR)$(ETCPREFIX)
CC = gcc
JAVAC = javac

# Disable I2P eepSite keypair generation functionality? (non-empty to disable)
NOI2P =

# Modifications to compiler flags
CFLAGS := -std=c99 -Wall -pedantic -MMD -D_FILE_OFFSET_BITS=64 -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -DNDEBUG $(CFLAGS)
JFLAGS := -target 1.5 -deprecation -Werror -g:none $(JFLAGS)
Expand Down Expand Up @@ -60,14 +63,18 @@ install: all
install -t $(instdir)/bin bin/*
install -t $(instdir)/libexec/cable cable/*
install -m 644 -t $(instdir)/share/applications $(wildcard share/*.desktop)
-chmod a-x $(instdir)/libexec/cable/eeppriv.jar
sed -i 's&/usr/libexec/cable\>&$(PREFIX)/libexec/cable&g' \
$(addprefix $(etcdir)/cable/,profile cabled) \
$(instdir)/bin/cable-send
sed -i 's&/etc/cable\>&$(ETCPREFIX)/cable&g' \
$(etcdir)/cable/profile \
$(addprefix $(instdir)/libexec/cable/,cabled send) \
$(addprefix $(instdir)/bin/,cable-id cable-ping cable-send gen-cable-username gen-tor-hostname gen-i2p-hostname)
ifeq ($(strip $(NOI2P)),)
chmod a-x $(instdir)/libexec/cable/eeppriv.jar
else
rm $(instdir)/bin/gen-i2p-hostname
endif


# File-specific dependencies
Expand Down
45 changes: 31 additions & 14 deletions pkg/cables-x.y.ebuild
Expand Up @@ -18,20 +18,22 @@ I2P_MY_P=i2pupdate_${I2P_PV}

# GitHub URI can refer to a tagged download or the master branch
SRC_URI="https://github.com/mkdesu/cables/tarball/v${PV} -> ${P}.tar.gz
http://mirror.i2p2.de/${I2P_MY_P}.zip
http://launchpad.net/i2p/trunk/${I2P_PV}/+download/${I2P_MY_P}.zip"
i2p? (
http://mirror.i2p2.de/${I2P_MY_P}.zip
http://launchpad.net/i2p/trunk/${I2P_PV}/+download/${I2P_MY_P}.zip
)"

SLOT="0"
KEYWORDS="x86 amd64"
IUSE="i2p"

IUSE=""
DEPEND="app-arch/unzip
>=virtual/jdk-1.5"
i2p? ( >=virtual/jdk-1.5 )"
RDEPEND="net-libs/libmicrohttpd
mail-filter/procmail
net-misc/curl
dev-libs/openssl
>=virtual/jre-1.5
i2p? ( >=virtual/jre-1.5 )
gnome-extra/zenity"

pkg_setup() {
Expand All @@ -41,9 +43,19 @@ pkg_setup() {

src_unpack() {
unpack ${P}.tar.gz
mv ${MY_P_PF}-* ${P} || die "failed to recognize archive top directory"
mv ${MY_P_PF}-* ${P} || die "failed to recognize archive top directory"

unzip -j -d ${P}/lib ${DISTDIR}/${I2P_MY_P}.zip lib/i2p.jar || die "failed to extract i2p.jar"
if use i2p; then
unzip -j -d ${P}/lib ${DISTDIR}/${I2P_MY_P}.zip lib/i2p.jar || die "failed to extract i2p.jar"
fi
}

src_prepare() {
if ! use i2p; then
export MAKEOPTS+=" NOI2P=1"
fi

default
}

src_install() {
Expand All @@ -60,16 +72,21 @@ pkg_postinst() {
elog " gen-cable-username"
elog " gen-tor-hostname"
elog " copy CABLE_TOR/hidden_service to /var/lib/tor (readable only by 'tor')"
elog " gen-i2p-hostname"
elog " copy CABLE_I2P/eepsite to /var/lib/i2p (readable only by 'i2p')"
elog "Configure Tor and I2P to forward HTTP connections to cables daemon:"
if use i2p; then
elog " gen-i2p-hostname"
elog " copy CABLE_I2P/eepsite to /var/lib/i2p (readable only by 'i2p')"
fi
elog "Configure Tor to forward HTTP connections to cables daemon:"
elog " /etc/tor/torrc"
elog " HiddenServiceDir /var/lib/tor/hidden_service/"
elog " HiddenServicePort 80 127.0.0.1:9080"
elog " /var/lib/i2p/i2ptunnel.config"
elog " tunnel.X.privKeyFile=eepsite/eepPriv.dat"
elog " tunnel.X.targetHost=127.0.0.1"
elog " tunnel.X.targetPort=9080"
if use i2p; then
elog "Configure I2P similarly:"
elog " /var/lib/i2p/i2ptunnel.config"
elog " tunnel.X.privKeyFile=eepsite/eepPriv.dat"
elog " tunnel.X.targetHost=127.0.0.1"
elog " tunnel.X.targetPort=9080"
fi
elog "Finally, the user should configure the email client to run cable-send"
elog "as a pipe for sending messages from addresses shown by cable-info."
elog "See comments in /usr/bin/cable-send for suggested /etc/sudoers entry."
Expand Down

0 comments on commit 90a97a9

Please sign in to comment.