Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
milliways
mw
Commits
c218c35c
Project 'arthur/mw' was moved to 'milliways/mw'. Please update any links and bookmarks that may still have the old path.
Commit
c218c35c
authored
Oct 05, 2015
by
Justin Mitchell
Browse files
finish fixing mrod/zod, and honour onchat status
parent
33ccd70d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/client/incoming.c
View file @
c218c35c
...
...
@@ -650,9 +650,6 @@ static void display_content(ipc_message_t *msg)
asprintf
(
&
excuse
,
"%s gives the reason
\"
%s
\"
."
,
whom
,
reason
);
}
force_text
(
msg
,
excuse
,
whom
);
}
else
{
force_text
(
msg
,
"They didn't say why...
\n
"
,
whom
);
printf
(
"
\n\n
raw: %s
\n\n
"
,
msg
->
body
);
}
}
else
{
printf
(
"Unknown message type %4.4s"
,
(
char
*
)
&
msg
->
head
.
type
);
...
...
src/client/talker.c
View file @
c218c35c
...
...
@@ -1147,24 +1147,16 @@ void t_unignore(CommandList *cm, int argc, const char **argv, char *args)
void
t_zod
(
CommandList
*
cm
,
int
argc
,
const
char
**
argv
,
char
*
args
)
{
char
buff
[
MAXTEXTLENGTH
];
snprintf
(
buff
,
MAXTEXTLENGTH
-
1
,
"z"
);
if
(
args
!=
NULL
)
{
char
*
tmp
,
*
qtmp
;
tmp
=
remove_first_word
(
args
);
if
(
tmp
!=
NULL
&&
!
allspace
(
tmp
))
{
qtmp
=
quotetext
(
tmp
);
strncat
(
buff
,
"r"
,
MAXTEXTLENGTH
-
2
);
strncat
(
buff
,
qtmp
,
MAXTEXTLENGTH
-
strlen
(
buff
)
-
1
);
free
(
qtmp
);
}
else
strncat
(
buff
,
"-"
,
MAXTEXTLENGTH
-
2
);
SAFE_FREE
(
tmp
);
}
else
strncat
(
buff
,
"-"
,
MAXTEXTLENGTH
-
2
);
ipc_send_to_username
(
argv
[
1
],
IPC_KICK
,
buff
);
AUTOFREE_BUFFER
excuse
=
remove_first_word
(
args
);
ipc_message_t
*
msg
=
ipcmsg_create
(
IPC_ACTION
,
userposn
);
json_t
*
j
=
json_init
(
NULL
);
json_addstring
(
j
,
"target"
,
argv
[
1
]);
json_addstring
(
j
,
"type"
,
"zod"
);
if
(
excuse
!=
NULL
&&
!
allspace
(
excuse
))
json_addstring
(
j
,
"reason"
,
excuse
);
ipcmsg_json_encode
(
msg
,
j
);
json_decref
(
j
);
ipcmsg_transmit
(
msg
);
}
void
t_mrod
(
CommandList
*
cm
,
int
argc
,
const
char
**
argv
,
char
*
args
)
...
...
@@ -1183,46 +1175,32 @@ void t_mrod(CommandList *cm, int argc, const char **argv, char *args)
void
t_kick
(
CommandList
*
cm
,
int
argc
,
const
char
**
argv
,
char
*
args
)
{
char
buff
[
MAXTEXTLENGTH
];
snprintf
(
buff
,
MAXTEXTLENGTH
-
1
,
"k"
);
if
(
args
!=
NULL
)
{
char
*
tmp
,
*
qtmp
;
tmp
=
remove_first_word
(
args
);
if
(
tmp
!=
NULL
&&
!
allspace
(
tmp
))
{
qtmp
=
quotetext
(
tmp
);
strncat
(
buff
,
"r"
,
MAXTEXTLENGTH
-
2
);
strncat
(
buff
,
qtmp
,
MAXTEXTLENGTH
-
strlen
(
buff
)
-
1
);
free
(
qtmp
);
}
else
strncat
(
buff
,
"-"
,
MAXTEXTLENGTH
-
2
);
SAFE_FREE
(
tmp
);
}
else
strncat
(
buff
,
"-"
,
MAXTEXTLENGTH
-
2
);
ipc_send_to_username
(
argv
[
1
],
IPC_KICK
,
buff
);
AUTOFREE_BUFFER
excuse
=
remove_first_word
(
args
);
ipc_message_t
*
msg
=
ipcmsg_create
(
IPC_ACTION
,
userposn
);
json_t
*
j
=
json_init
(
NULL
);
json_addstring
(
j
,
"target"
,
argv
[
1
]);
json_addstring
(
j
,
"type"
,
"zod"
);
json_addstring
(
j
,
"admin"
,
"yes"
);
if
(
excuse
!=
NULL
&&
!
allspace
(
excuse
))
json_addstring
(
j
,
"reason"
,
excuse
);
ipcmsg_json_encode
(
msg
,
j
);
json_decref
(
j
);
ipcmsg_transmit
(
msg
);
}
void
t_remove
(
CommandList
*
cm
,
int
argc
,
const
char
**
argv
,
char
*
args
)
{
char
buff
[
MAXTEXTLENGTH
];
snprintf
(
buff
,
MAXTEXTLENGTH
-
1
,
"r"
);
if
(
args
!=
NULL
)
{
char
*
tmp
,
*
qtmp
;
tmp
=
remove_first_word
(
args
);
if
(
tmp
!=
NULL
&&
!
allspace
(
tmp
))
{
qtmp
=
quotetext
(
tmp
);
strncat
(
buff
,
"r"
,
MAXTEXTLENGTH
-
2
);
strncat
(
buff
,
qtmp
,
MAXTEXTLENGTH
-
strlen
(
buff
)
-
1
);
free
(
qtmp
);
}
else
strncat
(
buff
,
"-"
,
MAXTEXTLENGTH
-
2
);
SAFE_FREE
(
tmp
);
}
else
strncat
(
buff
,
"-"
,
MAXTEXTLENGTH
-
2
);
ipc_send_to_username
(
argv
[
1
],
IPC_KICK
,
buff
);
AUTOFREE_BUFFER
excuse
=
remove_first_word
(
args
);
ipc_message_t
*
msg
=
ipcmsg_create
(
IPC_ACTION
,
userposn
);
json_t
*
j
=
json_init
(
NULL
);
json_addstring
(
j
,
"target"
,
argv
[
1
]);
json_addstring
(
j
,
"type"
,
"mrodod"
);
json_addstring
(
j
,
"admin"
,
"yes"
);
if
(
excuse
!=
NULL
&&
!
allspace
(
excuse
))
json_addstring
(
j
,
"reason"
,
excuse
);
ipcmsg_json_encode
(
msg
,
j
);
json_decref
(
j
);
ipcmsg_transmit
(
msg
);
}
void
t_raw
(
CommandList
*
cm
,
int
argc
,
const
char
**
argv
,
char
*
args
)
...
...
src/server/actions.c
View file @
c218c35c
...
...
@@ -21,6 +21,7 @@
#include
<rooms.h>
#include
<talker_privs.h>
#include
<ipc.h>
#include
<perms.h>
#include
"servsock.h"
#include
"replay.h"
...
...
@@ -39,6 +40,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
const
char
*
command
=
json_getstring
(
j
,
"type"
);
const
char
*
victim_username
=
json_getstring
(
j
,
"target"
);
const
char
*
reason
=
json_getstring
(
j
,
"reason"
);
const
char
*
admin
=
json_getstring
(
j
,
"admin"
);
if
(
command
==
NULL
||
victim_username
==
NULL
)
{
send_error
(
conn
,
msg
,
"Invalid server command syntax"
);
...
...
@@ -70,6 +72,11 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
/* attacker was stronger, success */
if
(
prot_at
>=
prot_vi
)
success
=
1
;
/* an admin can ask to ignore protection modes */
if
(
admin
!=
NULL
&&
strcasecmp
(
admin
,
"yes"
)
==
0
&&
u_god
(
attacker
.
status
))
{
success
=
1
;
}
if
(
strcasecmp
(
command
,
"mrod"
)
==
0
)
{
// tell the world
ipc_message_t
*
event
=
ipcmsg_create
(
IPC_EVENT
,
msg
->
head
.
src
);
...
...
@@ -88,10 +95,8 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
if
(
reason
!=
NULL
)
{
asprintf
(
&
buff
,
"mr%s"
,
reason
);
json_addstring
(
ej
,
"reason"
,
reason
);
printf
(
"MROD set reason '%s'
\n
"
,
reason
);
}
else
{
asprintf
(
&
buff
,
"m-"
);
printf
(
"MROD with no reason
\n
"
);
}
ipc_message_t
*
update
=
ipcmsg_create
(
IPC_KICK
,
msg
->
head
.
src
);
ipcmsg_destination
(
update
,
toid
);
...
...
src/server/servsock.c
View file @
c218c35c
...
...
@@ -431,6 +431,9 @@ void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude
/* have we been told to exclude someone in this room */
if
(
exclude
!=
NULL
&&
strcasecmp
(
exclude
,
user
.
name
)
==
0
)
continue
;
/* person not on talker, just skip them */
if
(
!
cm_flags
(
user
.
chatmode
,
CM_ONCHAT
,
CM_MODE_ALL
))
continue
;
/* room matches, send them a copy */
if
(
user
.
room
==
msg
->
head
.
dst
)
{
msg_attach_to_pid
(
msg
,
who
.
pid
);
...
...
@@ -487,6 +490,9 @@ void msg_attach_to_all(ipc_message_t *msg)
lseek
(
users_fd
,
who
.
posn
,
SEEK_SET
);
if
(
read
(
users_fd
,
&
user
,
sizeof
(
user
))
<=
0
)
continue
;
/* person not on talker, just skip them */
if
(
!
cm_flags
(
user
.
chatmode
,
CM_ONCHAT
,
CM_MODE_ALL
))
continue
;
msg_attach_to_pid
(
msg
,
who
.
pid
);
printf
(
"Broadcast to %s in %d
\n
"
,
user
.
name
,
user
.
room
);
}
...
...
@@ -561,7 +567,7 @@ void msg_attach(ipc_message_t *msg, ipc_connection_t *conn)
**/
void
msg_apply_gag
(
struct
person
*
from
,
ipc_message_t
*
msg
,
const
char
*
field
)
{
char
*
newtext
=
NULL
;
AUTOFREE_BUFFER
newtext
=
NULL
;
json_t
*
j
=
json_init
(
msg
);
const
char
*
text
=
json_getstring
(
j
,
field
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment