Skip to content

Commit

Permalink
lots of changes:
Browse files Browse the repository at this point in the history
* moved to cmake. Seems overkill for such a small project but it does make
  life easier for developing and also for packaging (should that ever happen).
  Autotools never was an option for me.
* implemented socialist millionaire protocol
  (some problems with it though, but they seem to be libotr problems)
* put all text into /formats so messages are totally configurable.
  Also keeps the code clean.
* moved code around a bit (e.g. only one header now besides formats)
* some other things I dont recall right now ;)
  • Loading branch information
ulim committed May 30, 2008
1 parent b8f4896 commit d84a9bf
Show file tree
Hide file tree
Showing 17 changed files with 1,366 additions and 560 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,7 @@
term.h
statusbar.h
mainwindows.h
.exrc
*.swp
cscope.files
cscope.out
113 changes: 113 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,113 @@
#
# Off-the-Record Messaging (OTR) module for the irssi IRC client
# Copyright (C) 2008 Uli Meis <a.sporto+bee@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
#

PROJECT(IRSSIOTR)

SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-extensions/)
INCLUDE(cmake-extensions/cscope.cmake)

# GLIB

FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)

# LIBOTR

FIND_PACKAGE(LibOTR REQUIRED)
IF (LIBOTR_VERSION LESS "3.1.0")
MESSAGE(FATAL_ERROR "Need libotr version >= 3.1.0 (fragmentation)")
ENDIF (LIBOTR_VERSION LESS "3.1.0")

# irssi public headers

FIND_PATH(IRSSI_INCLUDE_DIR NAMES irssi/src/core/module.h)
MARK_AS_ADVANCED(IRSSI_INCLUDE_DIR)

IF(NOT IRSSI_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Couldn't find irssi headers, "
"usually installed in /usr/include/irssi")
ENDIF(NOT IRSSI_INCLUDE_DIR)

# Bad hack for irssi private headers

FIND_PACKAGE(Wget REQUIRED)

IF (NOT EXISTS "mainwindows.h")
MESSAGE(STATUS "Need to fetch and patch irssi private headers "
"mainwindows.h,statusbar.h,term.h from SVN (see irssi FS#535)")
EXECUTE_PROCESS(COMMAND "bash" "-c"
"${WGET_EXECUTABLE} '--post-data=revision=4806&root=irssi' \\
'http://svn.irssi.org/cgi-bin/viewvc.cgi/irssi/trunk/src/fe-text/mainwindows.h' \\
'http://svn.irssi.org/cgi-bin/viewvc.cgi/irssi/trunk/src/fe-text/term.h' \\
'http://svn.irssi.org/cgi-bin/viewvc.cgi/irssi/trunk/src/fe-text/statusbar.h' || exit 1
patch -p0 mainwindows.h < \"$0/privheaders.patch\" || exit 1"
${PROJECT_SOURCE_DIR} RESULT_VARIABLE IIPRIV_RET)
IF(NOT IIPRIV_RET EQUAL 0)
MESSAGE(FATAL_ERROR "Couldn't check out irssi private headers from SVN")
ENDIF(NOT IIPRIV_RET EQUAL 0)
ENDIF (NOT EXISTS "mainwindows.h")

# includes

SET(IRSSIOTR_INCLUDE_DIRS
${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${GLIB_INCLUDE_DIRS}
${LIBOTR_INCLUDE_DIRS}
${IRSSI_INCLUDE_DIR}/irssi
${IRSSI_INCLUDE_DIR}/irssi/src
${IRSSI_INCLUDE_DIR}/irssi/src/core)

include_directories(${IRSSIOTR_INCLUDE_DIRS})

# defs

ADD_DEFINITIONS(-DHAVE_CONFIG_H -Wall -g)

# generate otr-formats.{c,h}

ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/otr-formats.c
DEPENDS makeformats.py formats.txt README
COMMAND
${PROJECT_SOURCE_DIR}/makeformats.py
${PROJECT_SOURCE_DIR}/formats.txt
${PROJECT_SOURCE_DIR}/README
)

# lib

ADD_LIBRARY(otr SHARED otr.c otrutil.c otr_ops.c otr_key.c ui.c ${PROJECT_BINARY_DIR}/otr-formats.c)

TARGET_LINK_LIBRARIES(otr ${GLIB_LIBRARIES} ${LIBOTR_LIBRARIES})

# Install

EXECUTE_PROCESS(COMMAND "whoami" OUTPUT_VARIABLE WHOAMI)
IF(WHOAMI STREQUAL "root\n")
SET(IRSSIOTR_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/irssi/modules/")
MESSAGE(STATUS "Install will be into ${IRSSIOTR_INSTALL_DIR}")
ELSE(WHOAMI STREQUAL "root\n")
SET(IRSSIOTR_INSTALL_DIR "$ENV{HOME}/.irssi/modules/")
MESSAGE(STATUS "You're not root. Install will be into ${IRSSIOTR_INSTALL_DIR}")
ENDIF(WHOAMI STREQUAL "root\n")

INSTALL(TARGETS otr DESTINATION ${IRSSIOTR_INSTALL_DIR})

# cscope

FILE(GLOB CSANDHS *.c *.h)
ADD_CSCOPE_TARGET(${CSANDHS} ${IRSSIOTR_INCLUDE_DIRS})
10 changes: 10 additions & 0 deletions INSTALL
@@ -0,0 +1,10 @@
Usually the following will do:

$ cmake /path/to/src
$ make
$ make install

"make install" will install libotr.so either

1. into the system wide irssi modules folder if you're root or
2. into ~/.irssi/modules if you're not root
39 changes: 0 additions & 39 deletions Makefile

This file was deleted.

36 changes: 36 additions & 0 deletions README
@@ -0,0 +1,36 @@
Usually, you shouldn't have to do anything besides "/load otr" to have encrypted
conversations. However, some IRC servers strip off the tabs OTR uses as
announcement, there you or your buddy will have to type "?OTR?" to get going.

Initially a private key will also have to be generated...that can take two
minutes or even an hour. You can wait for OTR to trigger key generation or do
"/otr genkey nick@irc.server.com" yourself.

To make sure that you are actually talking to your buddy, you can agree on a
secret somehow and then one does "/otr auth <secret>". Shortly afterwards the
other one will be asked to do the same and you're done. Well, unfortunately the
world ain't perfect and it seems libotr isn't either (goes for me as well), so
currently only the responder will be able to authenticate this way. You'll have
to switch roles and do this twice - sry.

I also strongly recommend to do "/statusbar window add otr" so you're informed
about what's going on. Status of "manual" means manual authentication was
performed, "smp" means the above protocol was used (the thing's called
"socialist millionaire protocol").

In "~/.irssi/otr/otr.{key,fp}" you'll find the fingerprints and your private
keys(should you at any point be interested).

Commands:

/otr genkey nick@irc.server.com
Manually generate a key for the given account(also done on demand)
/otr auth <secret>
Initiate or respond to an authentication challenge
/otr authabort
Abort any ongoing authentication
/otr trust
Trust the fingerprint of the user in the current window blindly.
Better use "/otr auth"
/otr debug
Switch debug mode on/off
49 changes: 49 additions & 0 deletions cmake-extensions/FindLibOTR.cmake
@@ -0,0 +1,49 @@
#
# Uli Meis <a.sporto+bee@gmail.com>
#
# Mostly taken from cmake findcurl, version stuff from kopete
#
# - Find libotr
# Find the libotr headers and library.
#
# LIBOTR_INCLUDE_DIR
# LIBOTR_LIBRARIES
# LIBOTR_FOUND

# Look for the header file.
FIND_PATH(LIBOTR_INCLUDE_DIR NAMES libotr/version.h)
MARK_AS_ADVANCED(LIBOTR_INCLUDE_DIR)

# Look for the library.
FIND_LIBRARY(LIBOTR_LIBRARY NAMES otr)
MARK_AS_ADVANCED(LIBOTR_LIBRARY)

# Copy the results to the output variables.
IF(LIBOTR_INCLUDE_DIR AND LIBOTR_LIBRARY)
SET(LIBOTR_FOUND 1)
SET(LIBOTR_LIBRARIES ${LIBOTR_LIBRARY})
SET(LIBOTR_INCLUDE_DIRS ${LIBOTR_INCLUDE_DIR})
EXECUTE_PROCESS(COMMAND grep "OTRL_VERSION"
"${LIBOTR_INCLUDE_DIR}/libotr/version.h" OUTPUT_VARIABLE output)
STRING(REGEX MATCH "OTRL_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+"
LIBOTR_VERSION "${output}")
STRING(REGEX REPLACE "^OTRL_VERSION \"" "" LIBOTR_VERSION "${LIBOTR_VERSION}")
MESSAGE(STATUS " found libotr, version ${LIBOTR_VERSION}" )
ELSE(LIBOTR_INCLUDE_DIR AND LIBOTR_LIBRARY)
SET(LIBOTR_FOUND 0)
SET(LIBOTR_LIBRARIES)
SET(LIBOTR_INCLUDE_DIRS)
ENDIF(LIBOTR_INCLUDE_DIR AND LIBOTR_LIBRARY)

# Report the results.
IF(NOT LIBOTR_FOUND)
SET(LIBOTR_DIR_MESSAGE
"LIBOTR was not found. Make sure LIBOTR_LIBRARY and LIBOTR_INCLUDE_DIR are set.")
IF(NOT LIBOTR_FIND_QUIETLY)
MESSAGE(STATUS "${LIBOTR_DIR_MESSAGE}")
ELSE(NOT LIBOTR_FIND_QUIETLY)
IF(LIBOTR_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${LIBOTR_DIR_MESSAGE}")
ENDIF(LIBOTR_FIND_REQUIRED)
ENDIF(NOT LIBOTR_FIND_QUIETLY)
ENDIF(NOT LIBOTR_FOUND)
17 changes: 17 additions & 0 deletions cmake-extensions/cscope.cmake
@@ -0,0 +1,17 @@
#
# Uli Meis <a.sporto+bee@gmail.com>
#
# Handy macro for generating the cscope database
#

MACRO(ADD_CSCOPE_TARGET CSCOPE_SOURCES CSCOPE_INCLUDES)
ADD_CUSTOM_COMMAND(
OUTPUT cscope.out
DEPENDS ${CSCOPE_SOURCES}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND
echo '${CSCOPE_SOURCES}' | tr ' ' '\\n' >cscope.files
COMMAND
cscope -b `echo ${CSCOPE_INCLUDES} | xargs -n1 bash -c 'echo -I$$0'`)
ADD_CUSTOM_TARGET(cscope DEPENDS cscope.out)
ENDMACRO(ADD_CSCOPE_TARGET)
70 changes: 70 additions & 0 deletions formats.txt
@@ -0,0 +1,70 @@
damn {hilight Damn!}
bumsum One {hilight two}
whatever One %s hell %s
kg_failed Key generation for %s: failed: %s (%s)
kg_completed Key generation for %s: completed in %d seconds. Reloading keys
kg_aborted_dup Key generation for %s: aborted. Key generation for %s still in progress
kg_aborted_dir Key generation for %s: aborted, failed creating directory %s: %s
kg_mkdir created directory %s
kg_pipe Key generation for %s: error creating pipe: %s
kg_fork Key generation for %s: fork() error: %s
kg_initiated Key generation for %s: initiated. This might take several minutes or on some systems even an hour. If you wanna check that something is happening, see if there are two irssi processes.
fp_saved fingerprints saved
fp_save_error Error saving fingerprints: %s (%s)
ops_notify_bug BUG() in ops_notify
ops_notify title: %s prim: %s sec: %s
ops_display_bug BUG() in ops_display
ops_display msg: %s
ops_sec gone %9secure%9
ops_insec gone %9insecure%9
ops_still_reply still %9secure%9 (is reply)
ops_still_no_reply still %9secure%9 (is not reply)
ops_log log msg: %s
key_not_found no private keys found
key_loaded private keys loaded
key_load_error Error loading private keys: %s (%s)
fp_not_found no fingerprints found
fp_loaded fingerprints loaded
fp_load_error Error loading fingerprints: %s (%s)
fp_trust Trusting fingerprint from %s
send_failed send failed: msg=%s
send_change couldn't find context also OTR changed the outgoing message(BUG?)
send_fragment failed to fragment message: msg=%s
send_converted OTR converted sent message to %s
ctx_not_found couldn't find context: acc=%s nick=%s
auth_aborted_ongoing Ongoing authentication aborted
auth_aborted Authentication aborted
auth_responding Responding to authentication request...
auth_initiated Initiated authentication...
ctx_not_create couldn't create/find context: acc=%s from=%s
receive_ignore_query ignoring rest of OTR default query msg
receive_dequeued dequeued msg of length %d
receive_queued queued msg of length %d
receive_ignore ignoring protocol message of length %s, acc=%s, from=%s
receive_converted OTR converted received message
auth_have_old %s wanted to authenticate but an old authentication was still ongoing. Old authentication will be aborted, please try again.
auth_peer %s wants to authenticate. Type /otr auth <your-shared-secret> to complete.
auth_peer_reply_wrong %s replied to an auth we didn't start.
auth_peer_replied %s replied to our auth request...
auth_peer_wrong_smp3 %s sent a wrong authentication message (SMP3).
auth_successful Authentication successful!
auth_failed Authentication failed!
otr_better_two <b>%s</b> has requested an <a href=\"http://otr.cypherpunks.ca/\">Off-the-Record private conversation</a>. However, you do not have a plugin to support that.
otr_better_three See <a href=\"http://otr.cypherpunks.ca/\">http://otr.cypherpunks.ca/</a> for more information.
cmd_otr We're alive
cmd_trust failed: Can't get query details
cmd_auth Please agree on a secret and then run /otr auth <secret>
cmd_debug_on Debug mode is on
cmd_debug_off Debug mode is off
nickignore xmlconsole
st_plaintext {sb plaintext}
st_untrusted {sb {hilight encrypted}(untrusted)}
st_trust_smp {sb {hilight authenticated}(smp)}
st_trust_manual {sb {hilight authenticated}(manual)}
st_smp_wait_2 {sb {hilight awaiting auth reply...}}
st_smp_have_2 {sb {hilight finalizing auth... (won't happen with libotr 3.1(bug), ask the other guy to initiate)}}
st_smp_failed {sb {hilight auth failed}}
st_smp_finalize {sb {hilight finalizing auth...}}
st_smp_unknown {sb {hilight unknown auth state!}}
st_finished {sb finished}
st_unknown {sb {hilight state unknown (BUG!)}}

0 comments on commit d84a9bf

Please sign in to comment.