First git commit.

This commit is contained in:
Jan Vidar Krey
2009-02-19 17:14:09 +01:00
commit ac56e7a5b9
72 changed files with 16652 additions and 0 deletions

256
doc/Doxyfile Normal file
View File

@@ -0,0 +1,256 @@
# Doxyfile 1.5.5-KDevelop
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = uHub
PROJECT_NUMBER = 0.2.0-alpha
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = YES
INLINE_INHERITED_MEMB = YES
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = YES
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = YES
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = .
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = autotest/*
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = YES
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = YES
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NONE
TREEVIEW_WIDTH = 250
FORMULA_FONTSIZE = 10
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = uhub.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
DOT_FONTNAME = FreeSans
DOT_FONTPATH =
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = YES
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO

91
doc/architecture.txt Normal file
View File

@@ -0,0 +1,91 @@
= Architecture of uHub =
uHub is single threaded and handles network and timer events using the
libevent library.
For each state there is a read event (and sometimes a write event) and timeout
event in case an expected read (or write) event does not occur.
== Protocol overview ==
uHub use "speak" the ADC protocol, which works in short as follows:
(C = client, S = server aka uHub).
C: HSUP ADBASE
Client connects to hub and supplies a list of supported features to the hub.
S: ISUP ADBASE { }
Server responds with a list of supported features.
S: ISID xxxx
Server assigns a session-ID to the client (4 bytes, BASE32 encoded).
C: BINF xxxx (...)
Client sends information about itself, such as nick name, etc.
The hub will relay this information to all users, including the client.
S: BINF xxx1 NInick1 (...)
S: BINF xxx2 NInick2
S: (...)
S: BINF xxxx (client's own nick)
Client gets list of other clients, which ends with the client's own user info.
At this point the client is successfully logged into the hub.
== The hub architecture ==
Accepting new users
--------------------- -----------------
| Accept connection | <---------- | libevent loop |
--------------------- -----------------
|
V
--------------------- ------------
| Setup login timer | --+----> | Timeout? | <----+
--------------------- | ------------ |
| | | |
V | V |
--------------------- | --------------- |
| Receive 'HSUP' | --+----> | DISCONNECT! | |
--------------------- --------------- |
| ^ |
V | |
--------------------- | |
| Send 'ISUP', and | | |
| assign Session ID | | |
--------------------- | |
| | |
V | |
--------------------- | |
| Receive 'BINF' |-----------------+------------
+--| Validate message | ^
| --------------------- |
| | |
| V |
| --------------------- ---------------------
| | Send password | ------> | Reveive and check |
| | request, if needed| | password. |
| --------------------- ---------------------
| |
| |
| ------------------------ |
+->| Send welcome message |<--------------+
------------------------
|
V
------------------------
| Send user list to |
| newly accepted user. |
------------------------
|
V
------------------------
| User is logged in. |
| Announce to all. |
------------------------

76
doc/extensions.txt Normal file
View File

@@ -0,0 +1,76 @@
ADC protocol extensions supported:
STATUS: **** Not yet implemented.
the 'AUT0' extension (network connection auto detection extension).
Rationale: Detect if client is capable of initiating active connections.
After logging in:
Client -> 'HCHK 12345 ABCD'.
Server sends a UDP packet containing token to the client's IP address at the given port as shown in the INF message.
Server -> 'ICHK ABCD'
The server should send it from a UDP socket bound to the same port as the TCP server, which means the server will
have to listen to both TCP and UDP.
If client receives the packet, it knows it can receive UDP connections, and will advertise it in the INF message as
a supported feature.
If the client does not receive any UDP packets within a few seconds, it MAY try to reconfigure the router using
UPnP/ZeroConf, and issue a HCHK command to the server again.
If the client still doesn't receive any UDP packets, hole punching can be tried.
The server will send a UDP packet to the hub (using the port of the TCP server), and reissue the HCHK command.
The UDP packet SHOULD be echoed by the hub.
This UDP packet should contain simply 'HECH {cid} {token}' (Hub echo).
The hub should send a packet containing the token back:
'IECH {token} {host:port}', aswell as the same message via TCP.
If the client receives the message via UDP, it should now be able to determine the type of NAT.
If the client receives the message via TCP only it knows it has a firewall blocking icomming communication.
If the client does not receive the message, it should assume a firewall is blocking all UDP communication,
and resume in passive mode.
Requirements:
'AUT0' in the extensions message (SUP) for client and hub.
Server will also listen to UDP messages on the same port as the TCP port.
The server MUST now respond to the 'HCHK' command via TCP
The server MUST now respond to the 'HECH' command via UDP.
The client will always initiate communication.
-------------------------------------------------------------------------------
Syntax: HCHK {port} {token}
- port is a 16-bit port number where the client is listening for packets.
- token is 4 bytes base32 encoded data specified by the client.
Example:
Client: 'HCHK 1511 BACD' (tcp)
Server: 'ICHK BACD' (udp)
-------------------------------------------------------------------------------
Syntax: HECH {cid} {token}
- cid is the client ID.
- token is 4 bytes base32 encoded data specified by the client.
Example:
Client: 'HECH 3NGFVJUDBRHX2CYRJGQ5HACRDM5CTNLGZ36M64I BACD' (udp)
Server: 'IECH BACD 192.168.0.1:1512' (udp)
Server: 'IECH BACD 192.168.0.1:1512' (tcp)
Security considerations:
The hub must verify that IP address where the HECH command originated from
matches the IP address where the user with the given CID is connected from.
If the CID and IP does not match, or the CID is not used the hub MUST ignore
the request.

66
doc/uhub.conf Normal file
View File

@@ -0,0 +1,66 @@
# uhub.conf - A example configuration file.
# You should normally place this file in /etc/uhub/uhub.conf
# And change the file_acl and file_motd below.
#
# This file is read only to the uhub deamon, and if you
# make changes to it while uhub is running you can send a
# HUP signal to it, to reparse configuration (only on UNIX).
# Bind to this port and address
# server_bind_addr=any means listen to "::" if IPv6 is supported
# by the host OS, otherwise 0.0.0.0.
server_port=1511
server_bind_addr=any
# The maximum amount of users allowed on the hub.
max_users=500
# If 1, will show a "This hub is running uhub/version".
show_banner=1
# Allow only registered users on the hub if set to 1.
registered_users_only=0
# A server name and description.
hub_name=my hub
hub_description=Powered by uHub
# Set this to 0, and the hub will disconnect everyone
hub_enabled=1
# Access control list (user database)
file_acl=/etc/uhub/users.conf
# This file can contain a message of the day. A welcome
# message send to any client when connecting.
# If the file does not exist, is empty, or cannot be opened
# the motd will not be sent to the clients.
# Normally this message is sent to clients when connecting.
file_motd=/etc/uhub/motd.txt
# Configure status message as sent to clients in different circumstances.
msg_hub_full = Hub is full
msg_hub_disabled = Hub is disabled
msg_hub_registered_users_only = Hub is for registered users only
msg_inf_error_nick_missing = No nickname given
msg_inf_error_nick_multiple = Multiple nicknames given
msg_inf_error_nick_invalid = Nickname is invalid
msg_inf_error_nick_long = Nickname too long
msg_inf_error_nick_short = Nickname too short
msg_inf_error_nick_spaces = Nickname cannot start with spaces
msg_inf_error_nick_bad_chars = Nickname contains invalid characters
msg_inf_error_nick_not_utf8 = Nickname is not valid utf8
msg_inf_error_nick_taken = Nickname is already in use
msg_inf_error_nick_restricted = Nickname cannot be used on this hub
msg_inf_error_cid_invalid = CID is not valid
msg_inf_error_cid_missing = CID is not specified
msg_inf_error_cid_taken = CID is taken
msg_inf_error_pid_missing = PID is not specified
msg_inf_error_pid_invalid = PID is invalid
msg_ban_permanently = Banned permanently
msg_ban_temporarily = Banned temporarily
msg_auth_invalid_password = Password is wrong
msg_auth_user_not_found = User not found in password database
msg_error_no_memory = No memory

59
doc/uhub.dot Normal file
View File

@@ -0,0 +1,59 @@
/**
* Overview of uHub
*/
digraph G
{
"main()" -> "event_dispatch()"
"event_dispatch()" -> "net_on_accept()"
"event_dispatch()" -> "net_on_read()"
"event_dispatch()" -> "net_on_write()"
"event_dispatch()" -> "event_queue_process()"
/* net events */
"net_on_write()" -> "net_send()"
"net_on_write()" -> "user_disconnect()"
"net_on_accept()" -> "user_create()"
"net_on_read()" -> "net_recv()"
"net_on_read()" -> "user_disconnect()"
"net_recv()" -> "hub_handle_message()"
/* adc message handling */
"hub_handle_message()" -> "hub_handle_password()"
"hub_handle_message()" -> "hub_handle_support()"
"hub_handle_password()" -> "user_disconnect()"
"hub_handle_support()" -> "user_disconnect()"
"hub_handle_password()" -> "route_to_user()"
"hub_handle_support()" -> "route_to_user()"
"hub_handle_message()" -> "hub_handle_info()"
"hub_handle_message()" -> "route_message()"
"hub_handle_info()" -> "route_to_user()"
"hub_handle_info()" -> "route_to_all()"
/* message routing, depending on message type */
"route_message()" -> "route_to_user()"
"route_message()" -> "route_to_all()" -> "route_to_user()"
"route_message()" -> "route_to_subscribers()" -> "route_to_user()"
"route_to_user()" -> "net_send()"
"route_to_user()" -> "queue_command()"
"route_to_user()" -> "user_disconnect()"
/* Message dispatcher */
"event_queue_process()" -> "hub_event_dispatcher()"
"hub_event_dispatcher()" -> "EVENT_USER_JOIN"
"hub_event_dispatcher()" -> "EVENT_USER_QUIT"
"EVENT_USER_QUIT" -> "route_to_all()"
"EVENT_USER_QUIT" -> "user_destroy()"
"EVENT_USER_JOIN" -> "route_to_all()"
/* user_disconnect() -- critical part */
"user_disconnect()" -> "user_set_state(state_cleanup)" -> "post: EVENT_USER_QUIT"
"user_disconnect()" -> "user_destroy()"
}

51
doc/users.conf Normal file
View File

@@ -0,0 +1,51 @@
# uHub access control lists.
#
# Syntax: <command> [data]
#
# commands:
# 'user_reg' - registered user with no particular privileges (data=nick:password)
# 'user_op' - operator, can kick or ban people (data=nick:password)
# 'user_admin' - administrator, can do everything operators can, and reconfigure the hub (data=nick:password)
# 'deny_nick' - nick name that is not accepted (example; Administrator)
# 'deny_ip' - Unacceptable IP (masks can be specified as CIDR: 0.0.0.0/32 will block all IPv4)
# 'ban_nick' - banned user by nick
# 'ban_cid' - banned user by cid
# Administrator
user_admin Dj_Offset:uhub
user_op janvidar:password
# We don't want users with these names
deny_nick Hub-Security
deny_nick Administrator
deny_nick root
deny_nick admin
deny_nick username
deny_nick user
deny_nick guest
deny_nick operator
# Banned users
# ban_nick H4X0R
# ban_cid FOIL5EK2UDZYAXT7UIUFEKL4SEBEAJE3INJDKAY
# ban by ip
#
# to ban by CIDR
# deny_ip 10.21.44.0/24
#
# to ban by IP-range.
# deny_ip 10.21.44.7-10.21.44.9
#
# to ban a single IP address
# deny_ip 10.21.44.7
# (which is equivalent to using):
# deny_ip 10.21.44.7/32
# Will not work, yet
# nat_ip 10.0.0.0/8
# nat_ip 127.0.0.0/8
# If you have made changes to this file, you must send a HANGUP signal
# to uHub so that it will re-read the configuration files.
# For example by invoking: 'killall -HUP uhub'