Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Something i don't understand with m_privmsg (messages.c)  (Read 4971 times)

0 Members and 1 Guest are viewing this topic.

debhian

  • Anope User
  • Offline Offline
  • Posts: 4
Something i don't understand with m_privmsg (messages.c)
« on: July 21, 2010, 11:59:32 PM »

Hi,

I made an unrealircd module wich send PRIVMSG messages to some users.
It works.

But anope have a problem with the messages. When i send for exemple :
:debhian2!user@HOST PRIVMSG #welcome :test

Anope receives the message within m_privmsg (messages.c:105)
The problem is const char *source wich is filled with "debhian2!user@HOST".

The function u = finduser(source); returns NULL because isn't a valid nick, and an error is sent to the staff chan.
[00:44:01] <Global> test: user record for debhian2!user@HOST not found


Why anope receives badly the messages ? I don't think they are malformed !
Exept the anope error log, every messages are accepted by server and client both.


Thanks


Part of messages.c
Code: [Select]
int m_privmsg(const char *source, const std::string &receiver, const char *msg)
{
char *target;
time_t starttime, stoptime; /* When processing started and finished */

BotInfo *bi;
ChannelInfo *ci;
User *u;

if (!source || !*source || receiver.empty() || !msg) {
return MOD_CONT;
}

u = finduser(source);

if (!u) {
Alog() << msg << ": user record for " << source << " not found";
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: Something i don't understand with m_privmsg (messages.c)
« Reply #1 on: July 22, 2010, 08:14:41 AM »

I suggest you check the IRCd Servert-to-Server Protocol documentation..

UnrealIRCd channel PRIVMSGs look like this:
Code: [Select]
:Viper PRIVMSG #opers :Channel message goes here...or like this when tokens are being used..
Code: [Select]
:Viper ! #opers :Channel message goes here...
So anope moans about receiving it badly because you send it badly. :)
Client-to-Server protocols are not the same as Server-to-Server protocols.. unreal doesn't have to do anything with your message other then pass it along, so there s not much "accepting" that can go wrong.. chances are the client accepts it because it is in a valid server-to-client format so it only goes wrong once it gets to a server that does care about server-to-server standards..  ::)
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

debhian

  • Anope User
  • Offline Offline
  • Posts: 4
Re: Something i don't understand with m_privmsg (messages.c)
« Reply #2 on: July 22, 2010, 11:52:27 AM »

I understand what are you saying, and the RFC goes to the same way:

Quote
   The extended prefix (["!" user "@" host ]) MUST NOT be used in server
   to server communications and is only intended for server to client
   messages in order to provide clients with more useful information
   about who a message is from without the need for additional queries.

But my module send messages to a client, it's a server->client message. If i send only the nickname without username@host, the client lose informations because he receive only the nickname.

Perhaps anope should not reveive my messages ? Perhaps it's unrealircd wich have a misunderstanding with sendto_one C function ?
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: Something i don't understand with m_privmsg (messages.c)
« Reply #3 on: July 22, 2010, 12:28:18 PM »

From what I see in your original post, this is a message to a channel, so hardly one-on-one... every client in the channel will receive that message, and if there s a services client in it, anope will too.

And from a quick look at the unreal code sendto_one() wants a nick, not a nick + host..

Anyways, why on earth would you think that the nick!username@host would be send with every message???
That would be a major overhead... hell, when using tokens unreal even replaces "PRIVMSG" to save on bandwidth.. if a client wants to know the host of a user, that client has to send such a request to the server.
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

debhian

  • Anope User
  • Offline Offline
  • Posts: 4
Re: Something i don't understand with m_privmsg (messages.c)
« Reply #4 on: July 22, 2010, 01:09:30 PM »

It's a major overhead but it's exactly what i receive from unrealIRCD (and others).

And it's a server to client message, i'm sure, if there is 5 clients in the chan, i send 5 PRIVMSG messages to the 5 clients.

So maybe it's an unrealircd problem, or i don't use the correct function, but theoretically my raws are good !
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: Something i don't understand with m_privmsg (messages.c)
« Reply #5 on: July 22, 2010, 01:43:39 PM »

My mistake.. I was getting s2c and s2s mixed up again...

I don't think it s an unrealircd problem... I think it s how you use the functions...
Code: [Select]
sendto_one(aClient target, ":%s PRIVMSG %s :%s", sender_nick, channel, text);So I guess you ll have to check what you are using as target...
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

debhian

  • Anope User
  • Offline Offline
  • Posts: 4
Re: Something i don't understand with m_privmsg (messages.c)
« Reply #6 on: July 23, 2010, 03:09:32 PM »

Resolved !

The module needs to ignore linked servers (like anope) to work, because it's a LOCAL modification of PRIVMSGs and anope don't need to know the modifications.

My bad, sorry !
Logged
Pages: [1]   Go Up