Commit Graph

686 Commits

Author SHA1 Message Date
Blair Bonnett
24f483f2c6 Also check CID when converting plugin_user to hub_user.
Current lookup would return the wrong user if the intended user has left
the hub and the SID has been re-used. If the CID matches then we assume
the user is still there.
2012-09-05 12:35:58 +12:00
Blair Bonnett
1520026168 User commands: handle nested substitution blocks when escaping message.
The UCMD specification doesn't mention nested blocks, and LinuxDC++ (and
therefore presumably any other client based off the DC++ core) doesn't
support them. But for future-proofing / clients that do support them,
make sure the ucmd_escape_msg() function can handle nested blocks
properly.
2012-08-18 16:38:14 +12:00
Blair Bonnett
4cb80427fe get_user_list() - use assert to check credential level. 2012-08-17 23:21:52 +12:00
Blair Bonnett
839309a4a8 Use hub_malloc(), hub_free() etc. 2012-08-17 23:05:05 +12:00
Blair Bonnett
20173e580d Revert "Check plugin API version in UCMD plugin."
This reverts commit a12e79c7ce. There is
no need to check the plugin API version within the plugin itself as
pluginloader.c does the following check (currently line 133):

(handle->plugin_api_version == PLUGIN_API_VERSION &&
 handle->plugin_funcs_size == sizeof(struct plugin_funcs))
2012-08-17 10:10:46 +12:00
Blair Bonnett
f40451a24c Update UCMD comment in user feature support flags. 2012-08-14 18:28:29 +12:00
Blair Bonnett
d34b60161b UCMD plugin: extra documentation, add commands for other plugins.
Adds entries for the !motd, !rules, and !history commands in the user
command menu.
2012-08-14 12:30:43 +12:00
Blair Bonnett
6f8bc0d270 Broadcast command: escape the message so it sends properly. 2012-08-14 12:08:31 +12:00
Blair Bonnett
a12e79c7ce Check plugin API version in UCMD plugin. 2012-08-14 11:48:08 +12:00
Blair Bonnett
a95e703b36 Documentation update for reserved SIDs. 2012-08-14 11:35:50 +12:00
Blair Bonnett
dc94754488 Add hub function for plugins to get list of currently connected users.
Can be filtered to include only users of a certain credential level, or
users of a certain credential level or greater. Results are returned as
a linked list of plugin_user objects.

Hub function to free the memory used by the list also added.

As plugins may store the list, users may disconnect before the list is
used. Hence a copy of each user is made for the list, so that if a
plugin tries to send a message to a user who has left the hub it will be
ignored, rather than the hub trying to access memory that was free()d
when the user disconnected. The lookup function to turn a plugin_user
into a hub_user for some of the other hub functions is changed
accordingly. (I think this description is possibly more confusing than
just looking at the code, but oh well...)
2012-08-09 15:23:33 +12:00
Blair Bonnett
7a440211dd Fix escaping of keyword substitutions.
Using adc_msg_escape will escape spaces etc inside keyword subsitutions
in user command messages (e.g., %[line:Enter a value] becomes
%[line:Enter\sa\svalue]) which leads to them being displayed wrong in
the client. Values outside the substitutions still need to be escaped.

This commit adds an (internal) ucmd_msg_escape() function, plus a
ucmd_msg_escape_length() helper, to the user command handler which
correctly handles keyword substitutions.
2012-08-09 00:38:36 +12:00
Blair Bonnett
2e7f0f9c12 Add plugin to send user commands.
Adds a mod_ucmd plugin which uses the previously added user command
plugin functions to send user commands when users log in. These are read
from a text file in a simple format. They can be restricted to users
with certain credentials, and can have multiple actions (e.g., send a PM
and a message in the main chat).

A sample user command file for the standard uhub commands is at
doc/ucmd.conf, and will be automatically installed if appropriate.

This currently won't send commands to existing users (e.g., if the
plugin is (re)loaded after the hub is already up and running). To
support this, a plugin function to list all current users would need to
be added.

I'm not sure how efficient this would be due to the volume of
messages needed to delete the existing commands on shutdown and send
them again on startup. As the commands are reloaded properly within the
plugin, it may be easier to require users to reconnect after the
configuration changes (and, of course, an admin could force this by
restarting the hub).
2012-08-08 19:34:19 +12:00
Blair Bonnett
30ec879cd2 Fix small memory leak in reserved SID code. 2012-08-08 17:14:24 +12:00
Blair Bonnett
c3b368a68a Add ability to reserve SIDs for certain users.
If you have a bot connected to the hub, and you want to add a user
command to interact with the bot via PM, you need to know its session ID
(SID). However, SIDs are assigned when the client first connects, prior
to the nickname being sent, and so we cannot just assign a certain SID
based on the nickname as part of the connection routine.

To overcome this, this commit adds the ability to reserve the first few
SIDs (at hub start time, when the SIDs are known) for certain nicknames.
The user manager then checks each time a user logs in to see if the
nickname matches a reserved one, and if so sets up an alias from the
reserved SID to the SID the user was given. This alias is only checked
for private messages (the ADC DMSG or EMSG commands) which are routed to
the real user. Any other commands are ignored as there should be no need
for such aliasing.

The list of nicknames to reserve SIDs for is read from a space-separated
list in the reserved_sids parameter of the config file. The reserved
users must also be registered users (i.e., given a password) -- if they
are not, the alias is not set up for them.
2012-08-06 23:58:57 +12:00
Blair Bonnett
2608f6be76 Add user command support for sending private messages.
Can send to either the currently selected user (the %[userSID] keyword
substitution) or a given SID. To make the latter useful (e.g, for
commands sent to a bot) support for static SIDs is needed.
2012-08-02 21:13:34 +12:00
Blair Bonnett
66854bc204 Add UCMD extension methods to plugin API.
The user command (UCMD) extension to the ADC protocol allows for sending
hub-specific commands to clients. These commands have a name (which
generally appears in a menu in the client) and a command string which
the client sends back to the hub when the command is selected. These
command strings can contain keyword substitutions for useful
information, such as the SID of another user that was selected in the
client.

This commit adds some support for sending user commands to the uhub
plugin API. It currently restricts the command string to containing main
chat messages (BMSG commands in ADC parlance).

A plugin_ucmd structure is added to store the details of a user command,
and four methods are added to the plugin_handle.hub structure:

* plugin->hub.ucmd_create(plugin, name, length) creates a new user
  command.
* plugin->hub.ucmd_add_chat(plugin, ucmd, message, me) adds a main chat
  message to the list of commands to be run when the user command is
  selected. The me flag allows IRC /me style messages.
* plugin->hub.ucmd_send(plugin, user, ucmd) sends the command to a user.
* plugin->hub.ucmd_free(plugin, ucmd) frees the memory taken by a user
  command.

The structure has a number of flags (categories, remove, separator,
constrained) which correspond to the flags in the UCMD specification.
The categories flag must be set prior to sending to one (or more, via
a logical OR) of the ucmd_category_* enumeration values defined in
plugin_api/types.h.

The PLUGIN_API_VERSION has been increased to 2 to mark the change.
2012-08-02 02:26:54 +12:00
Jan Vidar Krey
b0aa690cb4 Merge branch 'master' of github.com:janvidar/uhub 2012-08-07 11:56:40 +02:00
Jan Vidar Krey
fb11589bb0 Drop all ADC messages containing illegal ADC escapes. 2012-08-07 11:55:29 +02:00
Jan Vidar Krey
03c4292eea Merge pull request #8 from blairbonnett/upstart
Upstart script to run uhub as a service
2012-07-29 15:34:07 -07:00
Jan Vidar Krey
ccaf755da3 Merge branch 'master' of github.com:janvidar/uhub 2012-07-30 00:08:38 +02:00
Jan Vidar Krey
cba0121574 ADCH++ had a security bug that allowed UCMD extension to be relayed.
uhub did not have this security bug since the hub did not advertise support for the
UCMD extension, but the message was still correctly relayed as specified in the
protocol specification.

However, this commit adds support for the UCMD extension, but only to the extent
that uhub will advertise it and uhub will also drop any such CMD message
generated by a client and will (currently) never issues a CMD message by itself.
2012-07-30 00:08:12 +02:00
Blair Bonnett
166a105e33 Add upstart script to run uHub as a service.
Start and stop conditions are based off the OpenSSH upstart script which
ships with Ubuntu.
2012-07-29 16:22:38 +12:00
root
a32ea42754 - Update RH init scripts 2012-06-13 14:30:17 +04:00
Jan Vidar Krey
949b54fcdd Merge pull request #7 from yorhel/master
TLS probing fix
2012-06-03 15:45:28 -07:00
Yorhel
b9005b1724 core/probe.c: Fix TLS probe when handshake version != SSL version
GnuTLS sends a handshake with SSL 3.0 (0x0300) in the outer packet, but
mentions TLS 1.2 (0x0303) in the Client Hello. There's no real need for
uhub to validate these fields, as OpenSSL should do that itself already.
Just use the version mentioned in Client Hello for logging output.
2012-06-02 14:46:47 +02:00
Jan Vidar Krey
9651a99d46 Updated changelog. 2012-05-29 22:57:02 +02:00
Jan Vidar Krey
571abddd98 Cleaned up code generator for config file parsing. 2012-05-23 23:37:42 +02:00
Jan Vidar Krey
9ea85ad1ac Merge pull request #5 from yorhel/master
Small rewrite of convert_to_sqlite.pl
2012-05-14 14:38:22 -07:00
Jan Vidar Krey
3ae6da4a64 Print error message in case of shutting down due to errors loading plugins. 2012-05-14 23:35:53 +02:00
Jan Vidar Krey
f3754fb4e4 Fix Windows file read discrepancy. 2012-05-14 23:33:54 +02:00
Yorhel
79ca108f48 convert_to_sqlite.pl: Update to the latest SQL schema + be more Perlish
The script behaves a little different as well, but it's more simpler
this way.
2012-05-14 19:06:11 +02:00
Jan Vidar Krey
210d5d276e Fix VS2010 project file - missing .c file. 2012-05-13 23:59:27 +02:00
Jan Vidar Krey
a6d87f95ef Merge https://github.com/Tilka/uhub 2012-05-13 23:53:56 +02:00
Tilka
274f17bce0 use "I64u" instead of PRIu64 on Windows 2012-05-11 16:45:07 +02:00
Tilka
53b3087735 remove obsolete settings in uhub.conf
motd and rules are now handled by the mod_welcome plugin.
2012-05-11 03:10:05 +02:00
Tilka
8365278cbf fix uhub_itoa() and uhub_ulltoa() 2012-05-10 23:24:42 +02:00
Tilka
eb49174ab3 marked plugin callbacks that are not called yet 2012-05-10 01:37:20 +02:00
Tilka
9e52ea7eff add on_change_nick() to struct plugin_funcs
It's not called anywhere yet.
Also reorder some typedefs, rename the ip check functions and add
struct {hub,plugin}_user parameter to on_check_ip_late(). Not sure where
to insert a call to that...
2012-05-09 23:33:03 +02:00
Tilka
05fd6bb723 minimal changes 2012-05-09 23:27:06 +02:00
Boris Pek
7b77f7dc31 Updated init script in debian package. 2012-05-08 23:40:16 +03:00
Boris Pek
685e56f4c6 Updated list of man pages in debian package. 2012-05-08 23:37:37 +03:00
Boris Pek
d19e78941a Added man page for uhub-passwd. 2012-05-08 23:29:56 +03:00
Jan Vidar Krey
c5516b5729 Merge branch 'master' of https://github.com/Tilka/uhub 2012-05-06 23:15:06 +02:00
Jan Vidar Krey
3aaabbc543 Fix issue with QUI messages being allowed through the hub 2012-05-06 23:09:02 +02:00
Tilka
ccb66ced4f don't show error on SIGTERM in select() backend 2012-05-05 01:10:24 +02:00
Tilka
dce8b97bba fix dependency of 'install' target 2012-05-03 10:13:21 +02:00
Tilka
d49127b507 changed all calls to assert() to uhub_assert() 2012-05-02 21:06:46 +02:00
Jan Vidar Krey
ccded3f642 Don't strip the U4/U6 port numbers if updated after login. 2012-05-02 20:45:31 +02:00
Jan Vidar Krey
216757a1f4 Fix compile issue with double typedefs. 2012-05-02 00:29:26 +02:00